gemrage 0.1.1 → 0.1.2

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.
Files changed (151) hide show
  1. data/Gemfile +2 -0
  2. data/Gemfile.lock +5 -0
  3. data/VERSION +1 -1
  4. data/gemrage.gemspec +148 -3
  5. data/lib/rubygems/commands/scan_command.rb +77 -4
  6. data/vendor/ruby/1.8/bin/rvm-install +19 -0
  7. data/vendor/ruby/1.8/cache/macaddr-1.0.0.gem +0 -0
  8. data/vendor/ruby/1.8/cache/rvm-1.0.14.gem +0 -0
  9. data/vendor/ruby/1.8/gems/macaddr-1.0.0/README +33 -0
  10. data/vendor/ruby/1.8/gems/macaddr-1.0.0/gemspec.rb +27 -0
  11. data/vendor/ruby/1.8/gems/macaddr-1.0.0/install.rb +210 -0
  12. data/vendor/ruby/1.8/gems/macaddr-1.0.0/lib/macaddr.rb +69 -0
  13. data/vendor/ruby/1.8/gems/rvm-1.0.14/LICENCE +18 -0
  14. data/vendor/ruby/1.8/gems/rvm-1.0.14/README +127 -0
  15. data/vendor/ruby/1.8/gems/rvm-1.0.14/bin/rvm-install +5 -0
  16. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm +76 -0
  17. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-auto-ruby +24 -0
  18. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-prompt +204 -0
  19. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-shell +35 -0
  20. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-update-head +35 -0
  21. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-update-latest +27 -0
  22. data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvmsudo +24 -0
  23. data/vendor/ruby/1.8/gems/rvm-1.0.14/config/db +71 -0
  24. data/vendor/ruby/1.8/gems/rvm-1.0.14/config/known +55 -0
  25. data/vendor/ruby/1.8/gems/rvm-1.0.14/config/md5 +87 -0
  26. data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/gemset_snapshot +25 -0
  27. data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/install-system-wide +191 -0
  28. data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/r +44 -0
  29. data/vendor/ruby/1.8/gems/rvm-1.0.14/examples/rvmrc +47 -0
  30. data/vendor/ruby/1.8/gems/rvm-1.0.14/gemsets/default.gems +1 -0
  31. data/vendor/ruby/1.8/gems/rvm-1.0.14/gemsets/global.gems +1 -0
  32. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/alias +46 -0
  33. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/benchmark +17 -0
  34. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/cleanup +23 -0
  35. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/debug +8 -0
  36. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/disk-usage +15 -0
  37. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/docs +22 -0
  38. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/exec +33 -0
  39. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/fetch +5 -0
  40. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gem +0 -0
  41. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gemdir +0 -0
  42. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gemset +0 -0
  43. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/implode +0 -0
  44. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/info +64 -0
  45. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/install +0 -0
  46. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/list +0 -0
  47. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/migrate +15 -0
  48. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/monitor +0 -0
  49. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/notes +0 -0
  50. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/package +0 -0
  51. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rake +14 -0
  52. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/remove +0 -0
  53. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/repair +23 -0
  54. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/reset +0 -0
  55. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/ruby +84 -0
  56. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rubygems +11 -0
  57. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rvmrc +34 -0
  58. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/snapshot +15 -0
  59. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/specs +0 -0
  60. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/srcdir +0 -0
  61. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/tests +0 -0
  62. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/tools +22 -0
  63. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/uninstall +0 -0
  64. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/update +0 -0
  65. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/upgrade +18 -0
  66. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/use +0 -0
  67. data/vendor/ruby/1.8/gems/rvm-1.0.14/help/wrapper +41 -0
  68. data/vendor/ruby/1.8/gems/rvm-1.0.14/install +631 -0
  69. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/VERSION.yml +4 -0
  70. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/capistrano.rb +45 -0
  71. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/alias.rb +69 -0
  72. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/cleanup.rb +54 -0
  73. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/configuration.rb +60 -0
  74. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb +52 -0
  75. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/gemset.rb +222 -0
  76. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/info.rb +13 -0
  77. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/list.rb +124 -0
  78. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/rubies.rb +50 -0
  79. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/sets.rb +123 -0
  80. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/tools.rb +68 -0
  81. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/utility.rb +173 -0
  82. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/wrapper.rb +23 -0
  83. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment.rb +64 -0
  84. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/errors.rb +31 -0
  85. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb +51 -0
  86. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/abstract_wrapper.rb +145 -0
  87. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/calculate_rvm_path.sh +26 -0
  88. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/result.rb +42 -0
  89. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/shell_wrapper.sh +10 -0
  90. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/single_shot_wrapper.rb +56 -0
  91. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/utility.rb +37 -0
  92. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell.rb +25 -0
  93. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/version.rb +19 -0
  94. data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm.rb +156 -0
  95. data/vendor/ruby/1.8/gems/rvm-1.0.14/man/man1/rvm.1 +385 -0
  96. data/vendor/ruby/1.8/gems/rvm-1.0.14/man/man1/rvm.1.gz +0 -0
  97. data/vendor/ruby/1.8/gems/rvm-1.0.14/rvm.gemspec +184 -0
  98. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/alias +225 -0
  99. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/aliases +4 -0
  100. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array +32 -0
  101. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/base +49 -0
  102. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cd +87 -0
  103. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cleanup +58 -0
  104. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cli +781 -0
  105. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/color +49 -0
  106. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/completion +151 -0
  107. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/db +87 -0
  108. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/default +64 -0
  109. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/disk-usage +60 -0
  110. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/docs +115 -0
  111. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/env +46 -0
  112. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/environment-convertor +74 -0
  113. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/fetch +229 -0
  114. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/gemsets +950 -0
  115. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash +37 -0
  116. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/help +46 -0
  117. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hook +23 -0
  118. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/info +214 -0
  119. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/initialize +29 -0
  120. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/install +631 -0
  121. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/irbrc +9 -0
  122. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/irbrc.rb +63 -0
  123. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/list +315 -0
  124. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/log +38 -0
  125. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/maglev +193 -0
  126. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/manage +2094 -0
  127. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/match +6 -0
  128. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/md5 +22 -0
  129. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/migrate +175 -0
  130. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/monitor +105 -0
  131. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/notes +121 -0
  132. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/override_gem +14 -0
  133. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/package +301 -0
  134. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/patches +64 -0
  135. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/patchsets +87 -0
  136. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/repair +199 -0
  137. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rubygems +157 -0
  138. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rvm +120 -0
  139. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rvm-install +631 -0
  140. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/selector +818 -0
  141. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/set +301 -0
  142. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/snapshot +262 -0
  143. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/tools +58 -0
  144. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/update +631 -0
  145. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/upgrade +144 -0
  146. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/utility +1557 -0
  147. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/version +17 -0
  148. data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/wrapper +210 -0
  149. data/vendor/ruby/1.8/specifications/macaddr-1.0.0.gemspec +27 -0
  150. data/vendor/ruby/1.8/specifications/rvm-1.0.14.gemspec +42 -0
  151. metadata +149 -4
@@ -0,0 +1,69 @@
1
+ module RVM
2
+ class Environment
3
+
4
+ # Returns a hash of aliases.
5
+ def alias_list
6
+ lines = normalize_array(rvm(:alias, :list).stdout)
7
+ lines.inject({}) do |acc, current|
8
+ alias_name, ruby_string = current.to_s.split(" => ")
9
+ unless alias_name.empty? || ruby_string.empty?
10
+ acc[alias_name] = ruby_string
11
+ end
12
+ acc
13
+ end
14
+ end
15
+
16
+ # Shows the full ruby string that a given alias points to.
17
+ def alias_show(name)
18
+ normalize rvm(:alias, :show, name.to_s).stdout
19
+ end
20
+
21
+ # Deletes an alias and returns the exit status.
22
+ def alias_delete(name)
23
+ rvm(:alias, :delete, name.to_s).successful?
24
+ end
25
+
26
+ # Creates an alias with the given name.
27
+ def alias_create(name, ruby_string)
28
+ rvm(:alias, :create, name.to_s, ruby_string.to_s).successful?
29
+ end
30
+
31
+ # Returns an aliases proxy which can be used in a more Ruby-like manner.
32
+ def aliases
33
+ @aliases ||= AliasWrapper.new(self)
34
+ end
35
+
36
+ # Provides a Ruby-like wrapper to the alias functionality.
37
+ class AliasWrapper
38
+
39
+ def initialize(parent)
40
+ @parent = parent
41
+ end
42
+
43
+ # Shows the value of a given alias.
44
+ def show(name)
45
+ @parent.alias_show name
46
+ end
47
+ alias [] show
48
+
49
+ # Deletes the given alias.
50
+ def delete(name)
51
+ @parent.alias_delete name
52
+ end
53
+
54
+ # Creates an alias with a given name and ruby string.
55
+ def create(name, ruby_string)
56
+ @parent.alias_create name, ruby_string
57
+ end
58
+ alias []= create
59
+
60
+ # Returns a hash of all aliases.
61
+ def list
62
+ @parent.alias_list
63
+ end
64
+ alias all list
65
+
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,54 @@
1
+ module RVM
2
+ class Environment
3
+
4
+ # Batch define common operations.
5
+ %w(all archives repos sources logs).each do |cleanup_type|
6
+ define_method(:"cleanup_#{cleanup_type}") do
7
+ rvm(:cleanup, cleanup_type).successful?
8
+ end
9
+ end
10
+
11
+ # Returns the ruby-like interface defined by CleanupWrapper
12
+ def cleanup
13
+ @cleanup_wrapper ||= CleanupWrapper.new(self)
14
+ end
15
+
16
+ # Implements a Ruby-like interface to cleanup, making it nicer to deal with.
17
+ class CleanupWrapper
18
+
19
+ def initialize(parent)
20
+ @parent = parent
21
+ end
22
+
23
+ # Cleans up archives, repos, sources and logs
24
+ def all
25
+ @parent.cleanup_all
26
+ end
27
+ alias everything all
28
+
29
+ # Cleans up everything in the archives folder
30
+ def archives
31
+ @parent.cleanup_archives
32
+ end
33
+
34
+ # Cleans up everything in the repos path
35
+ def repos
36
+ @parent.cleanup_repos
37
+ end
38
+ alias repositories repos
39
+
40
+ # Cleans up everything in the source folder
41
+ def sources
42
+ @parent.cleanup_sources
43
+ end
44
+ alias src sources
45
+
46
+ # Cleans up all of the logs
47
+ def logs
48
+ @parent.cleanup_logs
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,60 @@
1
+ module RVM
2
+ class Environment
3
+
4
+ # Define the config accessor, which basically uses config_value_for and
5
+ # the linke to set the env variable.
6
+ def self.define_config_accessor(*args)
7
+ singleton = (class << self; self; end)
8
+ args.each do |arg|
9
+ singleton.send(:define_method, arg) { RVM::Environment.config_value_for(arg) }
10
+ singleton.send(:define_method, :"#{arg}=") { |v| RVM::Environment.merge_config! arg => v }
11
+ end
12
+ end
13
+
14
+ define_config_accessor :rvm_path, :rvm_config_path, :rvm_bin_path
15
+
16
+ # Mixin for a set of configs.
17
+ module ConfigMixin
18
+
19
+ # Returns the current config for this scope
20
+ def config
21
+ @config ||= {}
22
+ end
23
+
24
+ # Merge a set of items into the config.
25
+ def merge_config!(r)
26
+ r.each_pair { |k, v| config[k.to_s] = v }
27
+ end
28
+
29
+ # Reset this local config to be empty.
30
+ def clear_config!
31
+ @config = {}
32
+ end
33
+ end
34
+
35
+ include ConfigMixin
36
+ extend ConfigMixin
37
+
38
+ # Gets the default option or the current
39
+ # environment variable for a given env var.
40
+ def self.config_value_for(value)
41
+ value = value.to_s
42
+ config[value] || ENV[value]
43
+ end
44
+
45
+ # Returns the value for a configuration option (mapping to an
46
+ # environment variable). If check_live is true (which it is
47
+ # by default), it will also check the environment for a value.
48
+ def config_value_for(key, default = nil, check_live = true)
49
+ key = key.to_s
50
+ value = check_live ? self[key.to_s] : nil
51
+ value || config[key] || self.class.config_value_for(key) || default
52
+ end
53
+
54
+ # Returns a hash of all of the user defined configuration.
55
+ def defined_config
56
+ self.class.config.merge(self.config)
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,52 @@
1
+ module RVM
2
+ class Environment
3
+
4
+ # Returns the contents of the env file.
5
+ def env_contents
6
+ rvm(:env, environment_name).stdout
7
+ end
8
+
9
+ # Returns the path to the env file
10
+ def env_path
11
+ rvm(:env, environment_name, :path => true).stdout.strip
12
+ end
13
+
14
+ # Returns a ruby-like wrapper for the env functions
15
+ def env
16
+ @env_wrapper ||= EnvWrapper.new(self)
17
+ end
18
+
19
+ # Returns the path for the given command
20
+ def path_for(command)
21
+ run(:command, "-v", command).stdout.strip
22
+ end
23
+ alias which path_for
24
+
25
+ # Simple ruby like wrapper for envs.
26
+ class EnvWrapper
27
+
28
+ def initialize(parent)
29
+ @parent = parent
30
+ end
31
+
32
+ # Contents of the env file.
33
+ def contents
34
+ @parent.env_contents
35
+ end
36
+ alias read contents
37
+ alias to_s contents
38
+
39
+ # The path of the env file.
40
+ def path
41
+ @parent.env_path
42
+ end
43
+
44
+ # Opens a file on the env file.
45
+ def to_file
46
+ File.open(path)
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,222 @@
1
+ module RVM
2
+ class Environment
3
+
4
+ # Loads a gemset into the current environment.
5
+ # If an argument is given, it will load it from
6
+ # file_prefix.gems
7
+ def gemset_import(file_prefix = nil)
8
+ args = [file_prefix].compact
9
+ rvm(:gemset, :import, *args).successful?
10
+ end
11
+ alias gemset_load gemset_import
12
+
13
+ # Exports a gemset.
14
+ def gemset_export(gemset_or_file = nil)
15
+ args = [gemset_or_file].compact
16
+ rvm(:gemset, :export, *args).successful?
17
+ end
18
+ alias gemset_dump gemset_export
19
+
20
+ def gemset_list
21
+ normalize_array rvm(:gemset, :list).stdout
22
+ end
23
+
24
+ # Creates a new gemset with the given name.
25
+ def gemset_create(*names)
26
+ names = names.flatten
27
+ rvm(:gemset, :create, *names).successful?
28
+ end
29
+
30
+ # Copies the gems between two different gemsets.
31
+ def gemset_copy(from, to)
32
+ rvm(:gemset, :copy, from, to).successful?
33
+ end
34
+
35
+ # Deletes the gemset with a given name.
36
+ def gemset_delete(name)
37
+ run("echo 'yes' | rvm", :gemset, :delete, name.to_s).successful?
38
+ end
39
+
40
+ # Removes all gem-related stuff from the current gemset.
41
+ def gemset_empty
42
+ run("echo 'yes' | rvm", :gemset, :empty).successful?
43
+ end
44
+
45
+ # Resets the current gemset to a pristine state.
46
+ def gemset_pristine
47
+ rvm(:gemset, :pristine).successful?
48
+ end
49
+
50
+ # Updates all gems in the current gemset.
51
+ def gemset_update
52
+ rvm(@environment_name, :gemset, :update).successful?
53
+ end
54
+
55
+ # Prunes the gem cache for the current ruby.
56
+ def gemset_prune
57
+ rvm(:gemset, :prune).successful?
58
+ end
59
+
60
+ # Initializes gemsets for a given ruby.
61
+ def gemset_intial
62
+ rvm(:gemset, :initial).successful?
63
+ end
64
+
65
+ # Enable or disable the rvm gem global cache.
66
+ def gemset_globalcache(enable = true)
67
+ case enable
68
+ when "enabled", :enabled
69
+ run(:__rvm_using_gemset_globalcache).successful?
70
+ when true, "enable", :enable
71
+ rvm(:gemset, :globalcache, :enable).successful?
72
+ when false, "disable", :disable
73
+ rvm(:gemset, :globalcache, :disable).successful?
74
+ else
75
+ false
76
+ end
77
+ end
78
+
79
+ # Changes the current environments gemset. If :replace_env is passed
80
+ # and the ruby is compatible, it will attempt to replace the current
81
+ # processes gem home and path with the one requested.
82
+ def gemset_use(gemset, options = {})
83
+ replace_env = options.delete(:replace_env)
84
+ result = rvm(:gemset, :use, gemset, options)
85
+ if result.successful?
86
+ gemset_name = result[:rvm_gemset_name]
87
+ @environment_name = self.class.environment_with_gemset(@environment_name, gemset_name)
88
+ @expanded_name = nil
89
+ self.class.reset_current!
90
+ use_env_from_result! result if replace_env
91
+ true
92
+ end
93
+ end
94
+
95
+ # Like gemset_use, but replaces the env by default.
96
+ def gemset_use!(name, options = {})
97
+ gemset_use name, {:replace_env => true}.merge(options)
98
+ end
99
+
100
+ %w(gemdir gempath gemhome home path version name string dir).each do |action|
101
+ define_method(:"gemset_#{action}") do
102
+ normalize rvm(:gemset, action).stdout
103
+ end
104
+ end
105
+
106
+ # Returns the Ruby-like wrapper for gemset operations.
107
+ def gemset
108
+ @gemset_wrapper ||= GemsetWrapper.new(self)
109
+ end
110
+
111
+ # Wraps the gemset functionality.
112
+ class GemsetWrapper
113
+ extend Forwardable
114
+
115
+ def initialize(parent)
116
+ @parent = parent
117
+ end
118
+
119
+ # Import a gemset file.
120
+ def import(prefix)
121
+ @parent.gemset_export prefix.to_s.gsub(/\.gems$/, '')
122
+ end
123
+ alias load import
124
+
125
+ # Export a given gemset or, if the name ends with .gems, the current gemset.
126
+ def export(path_or_name)
127
+ @parent.gemset_export path_or_name.to_s
128
+ end
129
+ alias dump export
130
+ alias save export
131
+
132
+ # Returns a list of all gemsets belonging to the current ruby.
133
+ def list
134
+ @parent.gemset_list
135
+ end
136
+ alias all list
137
+
138
+ # Creates gemsets with the given names.
139
+ def create(*names)
140
+ @parent.gemset_create(*names.flatten)
141
+ end
142
+
143
+ # Delete a given gemset.
144
+ def delete(name)
145
+ @parent.gemset_delete(name)
146
+ end
147
+
148
+ # Empty the current gemset.
149
+ def empty
150
+ @parent.gemset_empty
151
+ end
152
+
153
+ # Restores the current gemset to a pristine state.
154
+ def pristine
155
+ @parent.gemset_pristine
156
+ end
157
+
158
+ # Updates all gems in the current gemset.
159
+ def update
160
+ @parent.gemset_update
161
+ end
162
+
163
+ # Prune the current gemset.
164
+ def prune
165
+ @parent.gemset_prune
166
+ end
167
+
168
+ # Use a given gemset in this environment
169
+ def use(name)
170
+ @parent.gemset_use(name)
171
+ end
172
+
173
+ # Use the given gemset, replacing the current
174
+ # gem environment if possible.
175
+ def use!(name)
176
+ @parent.gemset_use(name, :replace_env => true)
177
+ end
178
+
179
+ # Shortcut to deal with the gemset global cache.
180
+ def globalcache
181
+ @globalcache ||= GlobalCacheHelper.new(@parent)
182
+ end
183
+
184
+ # Copy gems from one gemset to another.
185
+ def copy(from, to)
186
+ @parent.gemset_copy(from, to)
187
+ end
188
+
189
+ %w(gemdir gempath gemhome home path version name string dir).each do |action|
190
+ define_method(action) do
191
+ @parent.send(:"gemset_#{action}")
192
+ end
193
+ end
194
+
195
+ # A Ruby-like wrapper to manipulate the rvm gem global cache.
196
+ class GlobalCacheHelper
197
+
198
+ def initialize(parent)
199
+ @parent = parent
200
+ end
201
+
202
+ # Enable the globalcache
203
+ def enable!
204
+ @parent.gemset_globalcache :enable
205
+ end
206
+
207
+ # Disable the globalcache
208
+ def disable!
209
+ @parent.gemset_globalcache :disable
210
+ end
211
+
212
+ # Returns whether or not the globalcache is enabled.
213
+ def enabled?
214
+ @parent.gemset_globalcache :enabled
215
+ end
216
+
217
+ end
218
+
219
+ end
220
+
221
+ end
222
+ end
@@ -0,0 +1,13 @@
1
+ require 'yaml'
2
+
3
+ module RVM
4
+ class Environment
5
+
6
+ def info(*ruby_strings)
7
+ ruby_string = normalize_ruby_string(ruby_strings)
8
+ res = rvm(:info, ruby_string)
9
+ res.successful? ? YAML.load(res.stdout) : {}
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,124 @@
1
+ module RVM
2
+ class Environment
3
+
4
+ # Returns a raw array list of ruby + gemset combinations.
5
+ def list_gemsets
6
+ normalize_listing_output rvm(:list, :gemsets, :strings).stdout
7
+ end
8
+
9
+ # Returns a raw array list of installed ruby strings, including aliases.
10
+ def list_strings
11
+ normalize_listing_output rvm(:list, :strings).stdout.tr(' ', "\n")
12
+ end
13
+
14
+ # Lists the default ruby (minus gemset)
15
+ def list_default
16
+ normalize rvm(:list, :default, :string).stdout
17
+ end
18
+
19
+ # Lists all known ruby strings (raw, filtered output)
20
+ def list_known
21
+ normalize_listing_output rvm(:list, :known).stdout
22
+ end
23
+
24
+ # Lists all known ruby strings
25
+ def list_known_strings
26
+ normalize_listing_output rvm(:list, :known_strings).stdout
27
+ end
28
+
29
+ # Lists all known svn tags.
30
+ def list_ruby_svn_tags
31
+ normalize_listing_output rvm(:list, :ruby_svn_tags).stdout
32
+ end
33
+
34
+ # Returns an interface to a more Ruby-like interface for list.
35
+ def list
36
+ @list_helper ||= ListWrapper.new(self)
37
+ end
38
+
39
+ # Provides a ruby-like interface to make listing rubies easier.
40
+ class ListWrapper
41
+
42
+ def initialize(parent)
43
+ @parent = parent
44
+ end
45
+
46
+ # Returns an array of ruby + gemset combinations.
47
+ def gemsets
48
+ @parent.list_gemsets
49
+ end
50
+
51
+ # Returns an array of installed rubies.
52
+ def rubies
53
+ @parent.list_strings
54
+ end
55
+ alias installed rubies
56
+ alias strings rubies
57
+
58
+ # Shows the current default. If :gemset is passed in and is
59
+ # true, it will include the gemset in the output.
60
+ def default(options = {})
61
+ options[:gemset] ? @parent.show_alias(:default) : @parent.list_default
62
+ end
63
+
64
+ # A raw list of known rubies.
65
+ def raw_known
66
+ @parent.list_known
67
+ end
68
+
69
+ def known_strings
70
+ @parent.list_known_strings
71
+ end
72
+
73
+ # A list of known ruby strings, minus svn tags.
74
+ def expanded_known
75
+ raw_known.map do |raw|
76
+ expand_variants(raw)
77
+ end.flatten.uniq.sort
78
+ end
79
+
80
+ # Raw list of svn tagged version
81
+ def raw_ruby_svn_tags
82
+ @parent.list_ruby_svn_tags
83
+ end
84
+
85
+ # Normalized list of ruby svn tags.
86
+ def ruby_svn_tags
87
+ raw_ruby_svn_tags.map { |t| expand_variants(t) }.flatten.uniq.sort
88
+ end
89
+ alias from_svn ruby_svn_tags
90
+
91
+ # Most installable ruby strings.
92
+ def installable
93
+ (expanded_known + ruby_svn_tags).uniq.sort
94
+ end
95
+
96
+ protected
97
+
98
+ # Expands strings to include optional parts (surrounded in brackets),
99
+ # given a useable string.
100
+ def expand_variants(s)
101
+ if s =~ /(\([^\)]+\))/
102
+ part = $1
103
+ expand_variants(s.sub(part, "")) + expand_variants(s.sub(part, part[1..-2]))
104
+ else
105
+ [s]
106
+ end
107
+ end
108
+
109
+ end
110
+
111
+ protected
112
+
113
+ # Takes a list of rubies / items, 1 per line and strips comments and blank lines.
114
+ def normalize_listing_output(results)
115
+ lines = []
116
+ results.each_line do |line|
117
+ line = line.gsub(/#.*/, '').strip
118
+ lines << line unless line.empty?
119
+ end
120
+ lines.sort
121
+ end
122
+
123
+ end
124
+ end
@@ -0,0 +1,50 @@
1
+ module RVM
2
+ class Environment
3
+
4
+ # Installs the given ruby
5
+ def install(rubies, opts = {})
6
+ rvm(:install, normalize_ruby_string(rubies), opts).successful?
7
+ end
8
+
9
+ # Uninstalls a ruby (remove but keeps src etc)
10
+ def uninstall(rubies, opts = {})
11
+ rvm(:uninstall, normalize_ruby_string(rubies), opts).successful?
12
+ end
13
+
14
+ # Removes a given ruby from being managed by rvm.
15
+ def remove(rubies, opts = {})
16
+ rvm(:remove, normalize_ruby_string(rubies), opts).successful?
17
+ end
18
+
19
+ # Changes the ruby string for the current environment.
20
+ def use(ruby_string, opts = {})
21
+ ruby_string = ruby_string.to_s
22
+ result = rvm(:use, ruby_string)
23
+ if result.successful?
24
+ @environment_name = ruby_string
25
+ @expanded_name = nil
26
+ use_env_from_result! result if opts[:replace_env]
27
+ end
28
+ end
29
+
30
+ # Like use but with :replace_env defaulting to true.
31
+ def use!(ruby_string, opts = {})
32
+ use ruby_string, opts.merge(:replace_env => true)
33
+ end
34
+
35
+ # Will get the ruby from the given path. If there
36
+ # is a compatible ruby found, it will then attempt
37
+ # to use the associated gemset.
38
+ # e.g. RVM::Environment.current.use_from_path! Dir.pwd
39
+ def use_from_path!(path)
40
+ use! tools.path_identifier(path)
41
+ end
42
+
43
+ protected
44
+
45
+ def normalize_ruby_string(rubies)
46
+ Array(rubies).join(",")
47
+ end
48
+
49
+ end
50
+ end