module Gync

Public Instance Methods

config_file() click to toggle source
# File lib/gync.rb, line 39
def config_file
  ENV['GYNC_CONFIG'] || File.join(home_dir, '.gync.yml')
end
home_dir() click to toggle source
# File lib/gync.rb, line 35
def home_dir
  ENV['HOME']
end
opts_for(command) click to toggle source
# File lib/gync.rb, line 43
def opts_for(command)
  opts = YAML.load_file(config_file)
  # validate
  result = opts[command] || raise("There is no `#{command}` section #{config_file}")
  result['local']        || raise("There is no `#{command}.local` section #{config_file}")
  result['remote']       || raise("There is no `#{command}.remote` section #{config_file}")
  OpenStruct.new(result)
end
print_help() click to toggle source
run(args) click to toggle source
# File lib/gync.rb, line 22
def run(args)
  @opts = opts_for args.first
  git = Gync::Git.new(@opts.local, @opts.remote)
  git.pull
  system Shellwords.shelljoin args
  git.push
rescue Exception => err
  log = Logger.new '/tmp/gync.log'
  log.error err
  STDERR.puts err
  exit 1
end