Class: C11n::Executable::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/c11n/executable/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



7
8
9
# File 'lib/c11n/executable/runner.rb', line 7

def initialize(options = {})
  @options = options
end

Instance Method Details

#config_hashObject



28
29
30
31
32
# File 'lib/c11n/executable/runner.rb', line 28

def config_hash
  if @options[:config_file_path]
    @config_hash ||= YAML.load(File.open(@options[:config_file_path]).read)
  end
end

#load_config_fileObject



34
35
36
# File 'lib/c11n/executable/runner.rb', line 34

def load_config_file
  C11n::Configuration.instance.load_from_hash(config_hash) if config_hash
end

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/c11n/executable/runner.rb', line 11

def run
  load_config_file

  case task
  when 'push'
    synchronizer.upload
  when 'pull'
    synchronizer.download
  when 'setup'
    synchronizer.setup
  end
end

#synchronizerObject



38
39
40
# File 'lib/c11n/executable/runner.rb', line 38

def synchronizer
  C11n::Synchronizer.new(configuration: C11n::Configuration.instance)
end

#taskObject



24
25
26
# File 'lib/c11n/executable/runner.rb', line 24

def task
  @options[:task]
end