fdietz-ruby-config 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -6
- data/ReleaseNotes.md +4 -0
- data/VERSION +1 -1
- data/bin/ruby-config +1 -1
- data/lib/ruby_config/{runner.rb → main.rb} +32 -21
- data/lib/ruby_config/options_parser.rb +101 -57
- data/lib/ruby_config/profile_config.rb +1 -1
- data/lib/ruby_config.rb +2 -6
- data/test/unit/profile_config_test.rb +1 -1
- metadata +3 -4
data/README.md
CHANGED
@@ -22,19 +22,19 @@ Install the gem:
|
|
22
22
|
|
23
23
|
Ensure that your bash profile script is configured correctly:
|
24
24
|
|
25
|
-
#bash: ruby-config
|
25
|
+
#bash: ruby-config setup
|
26
26
|
|
27
27
|
Note, that the setup routine will show the changes it will make beforehand and will prompt you
|
28
28
|
before actually applying the changes. You can manually apply the changes if you decide.
|
29
29
|
|
30
30
|
List all available runtimes:
|
31
31
|
|
32
|
-
#bash: ruby-config
|
32
|
+
#bash: ruby-config available
|
33
33
|
|
34
34
|
|
35
35
|
List all currently installed runtimes:
|
36
36
|
|
37
|
-
#bash: ruby-config
|
37
|
+
#bash: ruby-config list
|
38
38
|
|
39
39
|
Installed Ruby Versions:
|
40
40
|
1) Default Leopard Ruby 1.8.6 [ruby-leopard-1.8.6]
|
@@ -48,15 +48,15 @@ The wildcard for the 5. item indicates that this is the currently used runtime.
|
|
48
48
|
|
49
49
|
Install new Runtime by handle name:
|
50
50
|
|
51
|
-
#bash: ruby-config
|
51
|
+
#bash: ruby-config install jruby-1.3.1
|
52
52
|
|
53
53
|
Alternatively, you can use the index of the available runtimes listing:
|
54
54
|
|
55
|
-
#bash: ruby-config
|
55
|
+
#bash: ruby-config install 3
|
56
56
|
|
57
57
|
Switch to an already installed runtime:
|
58
58
|
|
59
|
-
#bash: ruby-config
|
59
|
+
#bash: ruby-config switch jruby-1.3.1
|
60
60
|
|
61
61
|
Alternatively, you can use the index again.. Now check the ruby-version:
|
62
62
|
|
data/ReleaseNotes.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# Ruby-Config Release Notes
|
2
2
|
|
3
|
+
## ruby-config 0.7
|
4
|
+
* Use command-style interface instead of options
|
5
|
+
|
3
6
|
## ruby-config 0.6
|
4
7
|
* Set GEM_HOME correctly when installing new gems
|
5
8
|
* Ensure that ruby-config gem is installed on each runtime gem path
|
9
|
+
* Added tests for Ruby compile from source runtimes
|
6
10
|
|
7
11
|
## ruby-config 0.5
|
8
12
|
* Added support for Ruby 1.8.6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/bin/ruby-config
CHANGED
@@ -7,7 +7,7 @@ require 'ruby_config/switcher'
|
|
7
7
|
|
8
8
|
module RubyConfig
|
9
9
|
|
10
|
-
class
|
10
|
+
class Main
|
11
11
|
|
12
12
|
RUBY_CONFIG_PATH = File.join(ENV['HOME'], ".ruby-config")
|
13
13
|
|
@@ -19,31 +19,42 @@ module RubyConfig
|
|
19
19
|
@config = RubyConfig::Config.new(RUBY_CONFIG_PATH)
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def main(argv)
|
23
|
+
arguments = argv
|
23
24
|
options_parser = RubyConfig::OptionsParser.new
|
24
|
-
|
25
|
+
|
25
26
|
begin
|
26
|
-
options = options_parser.
|
27
|
-
|
28
|
-
if options.
|
29
|
-
list_available
|
30
|
-
elsif options.list_installed
|
31
|
-
list_installed
|
32
|
-
elsif options.install
|
33
|
-
install_runtime(options.runtime)
|
34
|
-
elsif options.uninstall
|
35
|
-
uninstall(options.runtime)
|
36
|
-
elsif options.use
|
37
|
-
use_runtime(options.runtime)
|
38
|
-
elsif options.help
|
27
|
+
options = options_parser.parse_options!(arguments)
|
28
|
+
|
29
|
+
if options.help
|
39
30
|
help(options_parser)
|
40
|
-
|
41
|
-
setup
|
31
|
+
exit
|
42
32
|
end
|
43
33
|
rescue OptionParser::ParseError => e
|
44
34
|
puts e
|
45
35
|
options_parser.print_help
|
36
|
+
exit
|
46
37
|
end
|
38
|
+
|
39
|
+
commands = options_parser.parse_commands!(arguments)
|
40
|
+
|
41
|
+
if commands.list
|
42
|
+
list_installed
|
43
|
+
elsif commands.available
|
44
|
+
list_available
|
45
|
+
elsif commands.install
|
46
|
+
install(commands.handle)
|
47
|
+
elsif commands.uninstall
|
48
|
+
uninstall(commands.handle)
|
49
|
+
elsif commands.switch
|
50
|
+
switch(commands.handle)
|
51
|
+
elsif commands.setup
|
52
|
+
setup
|
53
|
+
else
|
54
|
+
puts "Unknown Command: #{arguments}"
|
55
|
+
options_parser.print_help
|
56
|
+
end
|
57
|
+
|
47
58
|
end
|
48
59
|
|
49
60
|
private
|
@@ -102,7 +113,7 @@ module RubyConfig
|
|
102
113
|
options_parser.print_help
|
103
114
|
end
|
104
115
|
|
105
|
-
def
|
116
|
+
def install(handle)
|
106
117
|
unless @registry.exists?(handle)
|
107
118
|
puts "Unknown ruby runtime: #{handle}"
|
108
119
|
return
|
@@ -122,7 +133,7 @@ module RubyConfig
|
|
122
133
|
|
123
134
|
end
|
124
135
|
|
125
|
-
def
|
136
|
+
def switch(handle)
|
126
137
|
unless @registry.exists?(handle)
|
127
138
|
puts "Unknown ruby runtime: #{handle}"
|
128
139
|
return
|
@@ -150,7 +161,7 @@ module RubyConfig
|
|
150
161
|
def print_info_header
|
151
162
|
puts "ruby-config (http://github/fdietz/ruby-config)"
|
152
163
|
puts "Author: Frederik Dietz <fdietz@gmail.com>"
|
153
|
-
puts "Version: #{RubyConfig
|
164
|
+
puts "Version: #{RubyConfig::VERSION}"
|
154
165
|
puts
|
155
166
|
end
|
156
167
|
|
@@ -1,76 +1,120 @@
|
|
1
1
|
module RubyConfig
|
2
2
|
class OptionsParser
|
3
|
+
|
4
|
+
COMMANDS = {
|
5
|
+
'list' => 'List installed Ruby runtimes',
|
6
|
+
'available' => 'List available Ruby runtimes',
|
7
|
+
'switch' => 'Switch to specific Ruby runtime',
|
8
|
+
'install' => 'Install specific Ruby runtime',
|
9
|
+
'uninstall' => 'Uninstall specific Ruby runtime',
|
10
|
+
'setup' => 'Setup your bash environment'
|
11
|
+
}
|
12
|
+
|
13
|
+
OPTIONS = {
|
14
|
+
'-v, --version' => "Display version",
|
15
|
+
'-h, --help' => "Display this screen"
|
16
|
+
}
|
3
17
|
|
18
|
+
EXAMPLES = [
|
19
|
+
'ruby-config list ',
|
20
|
+
'ruby-config install jruby-1.3.1',
|
21
|
+
'ruby-config switch jruby-1.3.1',
|
22
|
+
'ruby-config -v'
|
23
|
+
]
|
24
|
+
|
4
25
|
def initialize
|
5
26
|
create_options
|
6
27
|
end
|
7
28
|
|
8
29
|
def print_help
|
9
|
-
puts
|
10
|
-
|
11
|
-
|
12
|
-
def create_options
|
13
|
-
@options = OpenStruct.new
|
14
|
-
@options.verbose = false
|
15
|
-
@options.list_available = false
|
16
|
-
@options.list_installed = false
|
17
|
-
@options.use = false
|
18
|
-
@options.runtime = nil
|
19
|
-
@options.install = false
|
20
|
-
@options.uninstall = false
|
21
|
-
@options.help = false
|
22
|
-
@options.setup = false
|
30
|
+
puts "Usage: ruby-config [command] [options]"
|
31
|
+
puts
|
32
|
+
puts " Available Commands:"
|
23
33
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
@options.install = true
|
43
|
-
@options.runtime = runtime
|
44
|
-
abort("No Runtime specified") unless runtime
|
45
|
-
end
|
46
|
-
|
47
|
-
opts.on('--uninstall [HANDLE]', 'Uninstall specific Ruby runtime') do |runtime|
|
48
|
-
@options.uninstall = true
|
49
|
-
@options.runtime = runtime
|
50
|
-
abort("No Runtime specified") unless runtime
|
51
|
-
end
|
34
|
+
COMMANDS.each do |key, value|
|
35
|
+
puts " #{key} #{indent} #{value}"
|
36
|
+
end
|
37
|
+
|
38
|
+
puts
|
39
|
+
puts " Available Options:"
|
40
|
+
OPTIONS.each do |key, value|
|
41
|
+
puts " #{key} #{indent} #{value}"
|
42
|
+
end
|
43
|
+
|
44
|
+
puts
|
45
|
+
puts " Examples:"
|
46
|
+
EXAMPLES.each do |value|
|
47
|
+
puts " #{value}"
|
48
|
+
end
|
49
|
+
|
50
|
+
puts
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
53
|
+
def parse_commands!(arguments)
|
54
|
+
args = find_commands(arguments)
|
55
|
+
|
56
|
+
@commands = OpenStruct.new
|
57
|
+
@commands.list = false
|
58
|
+
@commands.available = false
|
59
|
+
@commands.switch = false
|
60
|
+
@commands.install = false
|
61
|
+
@commands.uninstall = false
|
62
|
+
@commands.setup = false
|
63
|
+
|
64
|
+
case args.first
|
65
|
+
when 'list'
|
66
|
+
@commands.list = true
|
67
|
+
when 'available'
|
68
|
+
@commands.available = true
|
69
|
+
when 'setup'
|
70
|
+
@commands.setup = true
|
71
|
+
when 'install'
|
72
|
+
@commands.install = true
|
73
|
+
@commands.handle = args[1]
|
74
|
+
abort("No Runtime specified") unless @commands.handle
|
75
|
+
when 'uninstall'
|
76
|
+
@commands.uninstall = true
|
77
|
+
@commands.handle = args[1]
|
78
|
+
abort("No Runtime specified") unless @commands.handle
|
79
|
+
when 'switch'
|
80
|
+
@commands.switch = true
|
81
|
+
@commands.handle = args[1]
|
82
|
+
abort("No Runtime specified") unless @commands.handle
|
65
83
|
end
|
66
84
|
|
85
|
+
@commands
|
67
86
|
end
|
68
|
-
|
69
|
-
def
|
70
|
-
@optparse.parse!
|
87
|
+
|
88
|
+
def parse_options!(arguments)
|
89
|
+
@optparse.parse!(arguments)
|
71
90
|
@options
|
72
91
|
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def create_options
|
96
|
+
@options = OpenStruct.new
|
97
|
+
@options.help = false
|
98
|
+
|
99
|
+
@optparse = OptionParser.new do |opts|
|
100
|
+
opts.on('-v', '--version', 'Display version' ) do
|
101
|
+
puts "ruby-config version: #{RubyConfig::VERSION}"
|
102
|
+
exit
|
103
|
+
end
|
104
|
+
opts.on('-h', '--help', 'Display this screen' ) do
|
105
|
+
@options.help = true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
73
109
|
|
110
|
+
def find_commands(args)
|
111
|
+
args.reject { |a| a =~ /^(-|--)/ }
|
112
|
+
end
|
113
|
+
|
114
|
+
def indent
|
115
|
+
"\t\t\t\t"
|
116
|
+
end
|
117
|
+
|
74
118
|
end
|
75
119
|
|
76
120
|
end
|
data/lib/ruby_config.rb
CHANGED
@@ -8,13 +8,9 @@ require 'optparse'
|
|
8
8
|
require 'yaml'
|
9
9
|
require 'highline/import'
|
10
10
|
|
11
|
-
require 'ruby_config/
|
12
|
-
#require 'ruby_config/registry'
|
11
|
+
require 'ruby_config/main'
|
13
12
|
|
14
13
|
module RubyConfig
|
15
|
-
|
16
|
-
version_path = File.join(File.dirname(__FILE__), '..', 'VERSION')
|
17
|
-
File.open(version_path, "r") { |file| file.read }
|
18
|
-
end
|
14
|
+
VERSION = File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), "r") { |file| file.read }
|
19
15
|
end
|
20
16
|
|
@@ -68,7 +68,7 @@ class ProfileConfigTest < Test::Unit::TestCase
|
|
68
68
|
|
69
69
|
test "should contain the ruby-config header" do
|
70
70
|
result = @config.send(:content_for_existing_script)
|
71
|
-
assert result.include?("# ruby-config v#{RubyConfig
|
71
|
+
assert result.include?("# ruby-config v#{RubyConfig::VERSION}")
|
72
72
|
end
|
73
73
|
|
74
74
|
test "should contain bash script header" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fdietz-ruby-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederik Dietz
|
@@ -29,11 +29,11 @@ files:
|
|
29
29
|
- lib/ruby_config.rb
|
30
30
|
- lib/ruby_config/config.rb
|
31
31
|
- lib/ruby_config/installer.rb
|
32
|
+
- lib/ruby_config/main.rb
|
32
33
|
- lib/ruby_config/options_parser.rb
|
33
34
|
- lib/ruby_config/profile_config.rb
|
34
35
|
- lib/ruby_config/registry.rb
|
35
36
|
- lib/ruby_config/rubygems.rb
|
36
|
-
- lib/ruby_config/runner.rb
|
37
37
|
- lib/ruby_config/runtime_base.rb
|
38
38
|
- lib/ruby_config/runtimes/jruby_runtime.rb
|
39
39
|
- lib/ruby_config/runtimes/leopard_runtime.rb
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- lib/ruby_config/switcher.rb
|
46
46
|
has_rdoc: true
|
47
47
|
homepage: http://github.com/fdietz/ruby-config
|
48
|
-
licenses:
|
49
48
|
post_install_message:
|
50
49
|
rdoc_options:
|
51
50
|
- --charset=UTF-8
|
@@ -66,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
65
|
requirements: []
|
67
66
|
|
68
67
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.2.0
|
70
69
|
signing_key:
|
71
70
|
specification_version: 2
|
72
71
|
summary: Install and Switch between various Ruby Runtimes easily
|