Class: Gemi::Runner
- Inherits:
-
Object
- Object
- Gemi::Runner
- Defined in:
- lib/gemi/runner.rb
Defined Under Namespace
Classes: ConfNotFound
Instance Method Summary collapse
- #execute(cmd) ⇒ Object
- #execute_commands(conf) ⇒ Object
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
- #load_conf ⇒ Object
- #main ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Runner
Returns a new instance of Runner.
6 7 8 |
# File 'lib/gemi/runner.rb', line 6 def initialize(argv) @argv = argv.dup end |
Instance Method Details
#execute(cmd) ⇒ Object
57 58 59 60 |
# File 'lib/gemi/runner.rb', line 57 def execute(cmd) puts cmd system cmd end |
#execute_commands(conf) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/gemi/runner.rb', line 49 def execute_commands(conf) conf.rubys.each do |ruby| puts "------- installing for #{ruby[:name]} ..." cmd = Command.new(@opt.type, @opt.gem_names, @opt.yamls).build(ruby) execute(cmd) end end |
#load_conf ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gemi/runner.rb', line 30 def load_conf conf_exist = File.exist?(@opt.confpath) yaml_given = !@opt.yamls.empty? if conf_exist Conf.new(@opt.confpath) else if yaml_given Conf.new(nil) elsif @opt.confpath == GEMIRC create_conf return else raise ConfNotFound, "config file not found in #{@opt.confpath}" return end end end |
#main ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gemi/runner.rb', line 18 def main @opt = Options.parse(@argv) if @opt.empty? usage return end conf = load_conf execute_commands(conf) end |
#run ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/gemi/runner.rb', line 10 def run begin main rescue => e $stderr.puts "Error: #{e.}" end end |