Class: William::Runner

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

Instance Method Summary collapse

Constructor Details

#initialize(file_path, debug = false) ⇒ Runner

Returns a new instance of Runner.



3
4
5
6
# File 'lib/william/runner.rb', line 3

def initialize(file_path, debug=false)
  @debug = debug
  @file_path = file_path
end

Instance Method Details

#create_class(class_name, superclass, &block) ⇒ Object



23
24
25
26
# File 'lib/william/runner.rb', line 23

def create_class(class_name, superclass, &block)
  klass = Class.new superclass, &block
  Object.const_set class_name, klass
end

#run(args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/william/runner.rb', line 8

def run(args)
  file_content = File.open(@file_path).read

  create_class "MyCommands", Commands do
    self.class_eval file_content
  end

  $remotes.each do |remote|
    args.each do |arg|
      commander = MyCommands.new(remote, @debug)
      commander.send arg.to_sym
    end
  end
end