class Syncbox::Syncbox

Public Class Methods

new() click to toggle source

read config path from command line, and load configs init a store instance

# File lib/syncbox.rb, line 17
def initialize      
  config_file = option_parser[:config]
  @local_directory = read_config(config_file, "local_directory")
  config_s3 = read_config(config_file, "s3")
  @store = Store.new("S3", config_s3)
end
start() click to toggle source
# File lib/syncbox.rb, line 9
def self.start      
  syncbox = Syncbox.new
  syncbox.start
end

Public Instance Methods

start() click to toggle source

Init a Syncer object, and start sync

# File lib/syncbox.rb, line 26
def start
  syncer = Syncer.new(@local_directory, @store)
  syncer.sync
end

Private Instance Methods

option_parser() click to toggle source
# File lib/syncbox.rb, line 37
def option_parser   
  options = {}
  option_parser = OptionParser.new do |opts|
    opts.banner = 'This is help messages.'
    opts.on('-c file', '--config file', 'Pass-in config file path') do |value|
      options[:config] = value
    end
  end.parse!
  options
end
read_config(config_file, store) click to toggle source
# File lib/syncbox.rb, line 32
def read_config(config_file, store)
  config = YAML.load_file(config_file)
  config[store]      
end