Class: RubyConfig::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_config/main.rb

Constant Summary collapse

RUBY_CONFIG_PATH =
File.join(ENV['HOME'], ".ruby-config")

Instance Method Summary collapse

Constructor Details

#initializeMain

Returns a new instance of Main.



14
15
16
17
18
19
20
# File 'lib/ruby_config/main.rb', line 14

def initialize
  @rubygems = RubyConfig::Rubygems.new(RUBY_CONFIG_PATH)
  @registry = RubyConfig::Registry.new(RUBY_CONFIG_PATH)      
  @installer = RubyConfig::Installer.new(RUBY_CONFIG_PATH)
  @switcher = RubyConfig::Switcher.new(RUBY_CONFIG_PATH)
  @config = RubyConfig::Config.new(RUBY_CONFIG_PATH)
end

Instance Method Details

#main(argv) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ruby_config/main.rb', line 22

def main(argv)
  arguments = argv
  options_parser = RubyConfig::OptionsParser.new
        
  begin
    options = options_parser.parse_options!(arguments)
    
    if options.help
      help(options_parser)
      exit
    end
  rescue OptionParser::ParseError => e
    puts e
    options_parser.print_help
    exit
  end
  
  commands = options_parser.parse_commands!(arguments)
  
  if commands.list
    list_installed
  elsif commands.available
    list_available
  elsif commands.install
    install(commands.handle)
  elsif commands.uninstall
    uninstall(commands.handle)
  elsif commands.switch
    switch(commands.handle)
  elsif commands.setup
    setup
  else
    puts "Unknown Command: #{arguments}"
    options_parser.print_help
  end
  
end