rubygems-update 2.0.17 → 2.1.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -0
  4. data/.autotest +1 -1
  5. data/History.txt +82 -153
  6. data/Manifest.txt +35 -9
  7. data/Rakefile +35 -36
  8. data/lib/rubygems.rb +106 -18
  9. data/lib/rubygems/available_set.rb +68 -0
  10. data/lib/rubygems/basic_specification.rb +139 -0
  11. data/lib/rubygems/command_manager.rb +37 -40
  12. data/lib/rubygems/commands/cert_command.rb +78 -29
  13. data/lib/rubygems/commands/cleanup_command.rb +2 -2
  14. data/lib/rubygems/commands/contents_command.rb +101 -58
  15. data/lib/rubygems/commands/dependency_command.rb +94 -53
  16. data/lib/rubygems/commands/environment_command.rb +70 -53
  17. data/lib/rubygems/commands/fetch_command.rb +1 -2
  18. data/lib/rubygems/commands/help_command.rb +85 -55
  19. data/lib/rubygems/commands/install_command.rb +84 -42
  20. data/lib/rubygems/commands/outdated_command.rb +2 -12
  21. data/lib/rubygems/commands/owner_command.rb +6 -0
  22. data/lib/rubygems/commands/pristine_command.rb +26 -16
  23. data/lib/rubygems/commands/sources_command.rb +85 -70
  24. data/lib/rubygems/commands/uninstall_command.rb +32 -2
  25. data/lib/rubygems/commands/update_command.rb +111 -75
  26. data/lib/rubygems/config_file.rb +15 -3
  27. data/lib/rubygems/core_ext/kernel_require.rb +9 -31
  28. data/lib/rubygems/defaults.rb +8 -0
  29. data/lib/rubygems/dependency.rb +4 -2
  30. data/lib/rubygems/dependency_installer.rb +180 -170
  31. data/lib/rubygems/dependency_resolver.rb +191 -526
  32. data/lib/rubygems/dependency_resolver/activation_request.rb +109 -0
  33. data/lib/rubygems/dependency_resolver/api_set.rb +65 -0
  34. data/lib/rubygems/dependency_resolver/api_specification.rb +36 -0
  35. data/lib/rubygems/dependency_resolver/composed_set.rb +18 -0
  36. data/lib/rubygems/dependency_resolver/current_set.rb +16 -0
  37. data/lib/rubygems/dependency_resolver/dependency_conflict.rb +85 -0
  38. data/lib/rubygems/dependency_resolver/dependency_request.rb +51 -0
  39. data/lib/rubygems/dependency_resolver/index_set.rb +59 -0
  40. data/lib/rubygems/dependency_resolver/index_specification.rb +53 -0
  41. data/lib/rubygems/dependency_resolver/installed_specification.rb +38 -0
  42. data/lib/rubygems/dependency_resolver/installer_set.rb +130 -0
  43. data/lib/rubygems/exceptions.rb +88 -1
  44. data/lib/rubygems/ext/builder.rb +1 -1
  45. data/lib/rubygems/gem_runner.rb +17 -9
  46. data/lib/rubygems/gemcutter_utilities.rb +72 -42
  47. data/lib/rubygems/install_default_message.rb +12 -0
  48. data/lib/rubygems/install_update_options.rb +3 -0
  49. data/lib/rubygems/installer.rb +55 -30
  50. data/lib/rubygems/name_tuple.rb +18 -7
  51. data/lib/rubygems/package.rb +50 -25
  52. data/lib/rubygems/package/tar_test_case.rb +9 -9
  53. data/lib/rubygems/package/tar_writer.rb +35 -12
  54. data/lib/rubygems/package_task.rb +2 -5
  55. data/lib/rubygems/path_support.rb +10 -0
  56. data/lib/rubygems/platform.rb +9 -3
  57. data/lib/rubygems/psych_additions.rb +1 -1
  58. data/lib/rubygems/remote_fetcher.rb +9 -276
  59. data/lib/rubygems/request.rb +267 -0
  60. data/lib/rubygems/request_set.rb +123 -125
  61. data/lib/rubygems/request_set/gem_dependency_api.rb +39 -0
  62. data/lib/rubygems/security.rb +32 -23
  63. data/lib/rubygems/security/policy.rb +35 -9
  64. data/lib/rubygems/security/signer.rb +2 -2
  65. data/lib/rubygems/server.rb +8 -16
  66. data/lib/rubygems/source.rb +25 -14
  67. data/lib/rubygems/source/installed.rb +28 -0
  68. data/lib/rubygems/source/local.rb +122 -0
  69. data/lib/rubygems/source/specific_file.rb +28 -0
  70. data/lib/rubygems/source_local.rb +2 -89
  71. data/lib/rubygems/source_specific_file.rb +2 -26
  72. data/lib/rubygems/spec_fetcher.rb +11 -11
  73. data/lib/rubygems/specification.rb +186 -198
  74. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
  75. data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
  76. data/lib/rubygems/ssl_certs/{GeoTrustGlobalCA.pem → GeoTrust_Global_CA.pem} +20 -20
  77. data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
  78. data/lib/rubygems/stub_specification.rb +119 -0
  79. data/lib/rubygems/test_case.rb +117 -49
  80. data/lib/rubygems/uninstaller.rb +14 -9
  81. data/lib/rubygems/uri_formatter.rb +39 -0
  82. data/lib/rubygems/util/list.rb +44 -0
  83. data/lib/rubygems/version.rb +15 -5
  84. data/lib/rubygems/version_option.rb +8 -2
  85. data/test/rubygems/ca_cert.pem +23 -0
  86. data/test/rubygems/client.pem +49 -0
  87. data/test/rubygems/encrypted_private_key.pem +30 -0
  88. data/test/rubygems/invalid_client.pem +49 -0
  89. data/test/rubygems/specifications/bar-0.0.2.gemspec +9 -0
  90. data/test/rubygems/specifications/foo-0.0.1.gemspec +0 -0
  91. data/test/rubygems/test_gem.rb +76 -454
  92. data/test/rubygems/test_gem_command_manager.rb +23 -21
  93. data/test/rubygems/test_gem_commands_cert_command.rb +154 -14
  94. data/test/rubygems/test_gem_commands_cleanup_command.rb +15 -0
  95. data/test/rubygems/test_gem_commands_contents_command.rb +32 -4
  96. data/test/rubygems/test_gem_commands_environment_command.rb +9 -1
  97. data/test/rubygems/test_gem_commands_fetch_command.rb +2 -28
  98. data/test/rubygems/test_gem_commands_help_command.rb +6 -3
  99. data/test/rubygems/test_gem_commands_install_command.rb +2 -65
  100. data/test/rubygems/test_gem_commands_owner_command.rb +49 -0
  101. data/test/rubygems/test_gem_commands_pristine_command.rb +30 -0
  102. data/test/rubygems/test_gem_commands_sources_command.rb +1 -1
  103. data/test/rubygems/test_gem_commands_uninstall_command.rb +33 -0
  104. data/test/rubygems/test_gem_commands_update_command.rb +2 -1
  105. data/test/rubygems/test_gem_config_file.rb +12 -0
  106. data/test/rubygems/test_gem_dependency_installer.rb +58 -65
  107. data/test/rubygems/test_gem_dependency_resolver.rb +6 -3
  108. data/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb +36 -0
  109. data/test/rubygems/test_gem_ext_builder.rb +2 -4
  110. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +7 -2
  111. data/test/rubygems/test_gem_gem_runner.rb +17 -13
  112. data/test/rubygems/test_gem_gemcutter_utilities.rb +6 -19
  113. data/test/rubygems/test_gem_impossible_dependencies_error.rb +41 -0
  114. data/test/rubygems/test_gem_install_update_options.rb +4 -1
  115. data/test/rubygems/test_gem_installer.rb +31 -2
  116. data/test/rubygems/test_gem_name_tuple.rb +22 -0
  117. data/test/rubygems/test_gem_package.rb +122 -11
  118. data/test/rubygems/test_gem_package_old.rb +8 -0
  119. data/test/rubygems/test_gem_package_tar_reader.rb +9 -8
  120. data/test/rubygems/test_gem_package_tar_reader_entry.rb +1 -1
  121. data/test/rubygems/test_gem_package_tar_writer.rb +78 -56
  122. data/test/rubygems/test_gem_package_task.rb +2 -23
  123. data/test/rubygems/test_gem_path_support.rb +17 -0
  124. data/test/rubygems/test_gem_platform.rb +18 -0
  125. data/test/rubygems/test_gem_remote_fetcher.rb +106 -385
  126. data/test/rubygems/test_gem_request.rb +239 -0
  127. data/test/rubygems/test_gem_requirement.rb +9 -11
  128. data/test/rubygems/test_gem_security.rb +58 -2
  129. data/test/rubygems/test_gem_security_policy.rb +42 -1
  130. data/test/rubygems/test_gem_security_signer.rb +13 -1
  131. data/test/rubygems/test_gem_security_trust_dir.rb +5 -1
  132. data/test/rubygems/test_gem_server.rb +1 -105
  133. data/test/rubygems/test_gem_source.rb +4 -14
  134. data/test/rubygems/test_gem_source_local.rb +4 -4
  135. data/test/rubygems/test_gem_source_specific_file.rb +1 -1
  136. data/test/rubygems/test_gem_spec_fetcher.rb +0 -12
  137. data/test/rubygems/test_gem_specification.rb +452 -28
  138. data/test/rubygems/test_gem_stub_specification.rb +30 -0
  139. data/test/rubygems/test_gem_uninstaller.rb +14 -0
  140. data/test/rubygems/test_gem_uri_formatter.rb +20 -0
  141. data/test/rubygems/test_gem_version.rb +23 -13
  142. data/test/rubygems/test_gem_version_option.rb +63 -1
  143. data/test/rubygems/test_require.rb +0 -12
  144. data/util/create_encrypted_key.rb +16 -0
  145. metadata +161 -23
  146. metadata.gz.sig +0 -0
  147. data/CVE-2013-4287.txt +0 -36
  148. data/CVE-2013-4363.txt +0 -45
  149. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  150. data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  151. data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  152. data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  153. data/test/rubygems/test_bundled_ca.rb +0 -59
  154. data/util/update_bundled_ca_certificates.rb +0 -103
@@ -42,85 +42,106 @@ class Gem::Commands::DependencyCommand < Gem::Command
42
42
  "#{program_name} GEMNAME"
43
43
  end
44
44
 
45
- def execute
46
- if options[:reverse_dependencies] and remote? and not local? then
47
- alert_error 'Only reverse dependencies for local gems are supported.'
48
- terminate_interaction 1
49
- end
45
+ def fetch_remote_specs dependency # :nodoc:
46
+ fetcher = Gem::SpecFetcher.fetcher
47
+
48
+ ss, = fetcher.spec_for_dependency dependency
49
+
50
+ ss.map { |spec, _| spec }
51
+ end
52
+
53
+ def fetch_specs dependency # :nodoc:
54
+ specs = []
55
+
56
+ specs.concat dependency.matching_specs if local?
57
+ specs.concat fetch_remote_specs dependency if remote?
58
+
59
+ ensure_specs specs
60
+
61
+ specs.uniq.sort
62
+ end
50
63
 
51
- options[:args] << '' if options[:args].empty?
64
+ def gem_dependency args, version, prerelease # :nodoc:
65
+ args << '' if args.empty?
52
66
 
53
- pattern = if options[:args].length == 1 and
54
- options[:args].first =~ /\A\/(.*)\/(i)?\z/m then
67
+ pattern = if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
55
68
  flags = $2 ? Regexp::IGNORECASE : nil
56
69
  Regexp.new $1, flags
57
70
  else
58
- /\A#{Regexp.union(*options[:args])}/
71
+ /\A#{Regexp.union(*args)}/
59
72
  end
60
73
 
61
- # TODO: deprecate for real damnit
62
74
  dependency = Gem::Deprecate.skip_during {
63
- Gem::Dependency.new pattern, options[:version]
75
+ Gem::Dependency.new pattern, version
64
76
  }
65
- dependency.prerelease = options[:prerelease]
66
77
 
67
- specs = []
78
+ dependency.prerelease = prerelease
68
79
 
69
- specs.concat dependency.matching_specs if local?
80
+ dependency
81
+ end
70
82
 
71
- if remote? and not options[:reverse_dependencies] then
72
- fetcher = Gem::SpecFetcher.fetcher
83
+ def display_pipe specs # :nodoc:
84
+ specs.each do |spec|
85
+ unless spec.dependencies.empty? then
86
+ spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
87
+ say "#{dep.name} --version '#{dep.requirement}'"
88
+ end
89
+ end
90
+ end
91
+ end
73
92
 
74
- ss, _ = fetcher.spec_for_dependency dependency
93
+ def display_readable specs, reverse # :nodoc:
94
+ response = ''
75
95
 
76
- ss.each { |s,o| specs << s }
96
+ specs.each do |spec|
97
+ response << print_dependencies(spec)
98
+ unless reverse[spec.full_name].empty? then
99
+ response << " Used by\n"
100
+ reverse[spec.full_name].each do |sp, dep|
101
+ response << " #{sp} (#{dep})\n"
102
+ end
103
+ end
104
+ response << "\n"
77
105
  end
78
106
 
79
- if specs.empty? then
80
- patterns = options[:args].join ','
81
- say "No gems found matching #{patterns} (#{options[:version]})" if
82
- Gem.configuration.verbose
107
+ say response
108
+ end
83
109
 
84
- terminate_interaction 1
85
- end
110
+ def execute
111
+ ensure_local_only_reverse_dependencies
86
112
 
87
- specs = specs.uniq.sort
113
+ dependency =
114
+ gem_dependency options[:args], options[:version], options[:prerelease]
88
115
 
89
- reverse = Hash.new { |h, k| h[k] = [] }
116
+ specs = fetch_specs dependency
90
117
 
91
- if options[:reverse_dependencies] then
92
- specs.each do |spec|
93
- reverse[spec.full_name] = find_reverse_dependencies spec
94
- end
95
- end
118
+ reverse = reverse_dependencies specs
96
119
 
97
120
  if options[:pipe_format] then
98
- specs.each do |spec|
99
- unless spec.dependencies.empty?
100
- spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
101
- say "#{dep.name} --version '#{dep.requirement}'"
102
- end
103
- end
104
- end
121
+ display_pipe specs
105
122
  else
106
- response = ''
107
-
108
- specs.each do |spec|
109
- response << print_dependencies(spec)
110
- unless reverse[spec.full_name].empty? then
111
- response << " Used by\n"
112
- reverse[spec.full_name].each do |sp, dep|
113
- response << " #{sp} (#{dep})\n"
114
- end
115
- end
116
- response << "\n"
117
- end
123
+ display_readable specs, reverse
124
+ end
125
+ end
118
126
 
119
- say response
127
+ def ensure_local_only_reverse_dependencies # :nodoc:
128
+ if options[:reverse_dependencies] and remote? and not local? then
129
+ alert_error 'Only reverse dependencies for local gems are supported.'
130
+ terminate_interaction 1
120
131
  end
121
132
  end
122
133
 
123
- def print_dependencies(spec, level = 0)
134
+ def ensure_specs specs # :nodoc:
135
+ return unless specs.empty?
136
+
137
+ patterns = options[:args].join ','
138
+ say "No gems found matching #{patterns} (#{options[:version]})" if
139
+ Gem.configuration.verbose
140
+
141
+ terminate_interaction 1
142
+ end
143
+
144
+ def print_dependencies(spec, level = 0) # :nodoc:
124
145
  response = ''
125
146
  response << ' ' * level + "Gem #{spec.full_name}\n"
126
147
  unless spec.dependencies.empty? then
@@ -131,10 +152,30 @@ class Gem::Commands::DependencyCommand < Gem::Command
131
152
  response
132
153
  end
133
154
 
155
+ def remote_specs dependency # :nodoc:
156
+ fetcher = Gem::SpecFetcher.fetcher
157
+
158
+ ss, _ = fetcher.spec_for_dependency dependency
159
+
160
+ ss.map { |s,o| s }
161
+ end
162
+
163
+ def reverse_dependencies specs # :nodoc:
164
+ reverse = Hash.new { |h, k| h[k] = [] }
165
+
166
+ return reverse unless options[:reverse_dependencies]
167
+
168
+ specs.each do |spec|
169
+ reverse[spec.full_name] = find_reverse_dependencies spec
170
+ end
171
+
172
+ reverse
173
+ end
174
+
134
175
  ##
135
176
  # Returns an Array of [specification, dep] that are satisfied by +spec+.
136
177
 
137
- def find_reverse_dependencies(spec)
178
+ def find_reverse_dependencies spec # :nodoc:
138
179
  result = []
139
180
 
140
181
  Gem::Specification.each do |sp|
@@ -69,66 +69,83 @@ lib/rubygems/defaults/operating_system.rb
69
69
  def execute
70
70
  out = ''
71
71
  arg = options[:args][0]
72
- case arg
73
- when /^packageversion/ then
74
- out << Gem::RubyGemsPackageVersion
75
- when /^version/ then
76
- out << Gem::VERSION
77
- when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
78
- out << Gem.dir
79
- when /^gempath/, /^path/, /^GEM_PATH/ then
80
- out << Gem.path.join(File::PATH_SEPARATOR)
81
- when /^remotesources/ then
82
- out << Gem.sources.to_a.join("\n")
83
- when /^platform/ then
84
- out << Gem.platforms.join(File::PATH_SEPARATOR)
85
- when nil then
86
- out = "RubyGems Environment:\n"
87
-
88
- out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n"
89
-
90
- out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
91
- out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
92
- out << ") [#{RUBY_PLATFORM}]\n"
93
-
94
- out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n"
95
-
96
- out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
97
-
98
- out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
99
-
100
- out << " - EXECUTABLE DIRECTORY: #{Gem.bindir}\n"
101
-
102
- out << " - RUBYGEMS PLATFORMS:\n"
103
- Gem.platforms.each do |platform|
104
- out << " - #{platform}\n"
72
+ out <<
73
+ case arg
74
+ when /^packageversion/ then
75
+ Gem::RubyGemsPackageVersion
76
+ when /^version/ then
77
+ Gem::VERSION
78
+ when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
79
+ Gem.dir
80
+ when /^gempath/, /^path/, /^GEM_PATH/ then
81
+ Gem.path.join(File::PATH_SEPARATOR)
82
+ when /^remotesources/ then
83
+ Gem.sources.to_a.join("\n")
84
+ when /^platform/ then
85
+ Gem.platforms.join(File::PATH_SEPARATOR)
86
+ when nil then
87
+ show_environment
88
+ else
89
+ raise Gem::CommandLineError, "Unknown environment option [#{arg}]"
105
90
  end
91
+ say out
92
+ true
93
+ end
106
94
 
107
- out << " - GEM PATHS:\n"
108
- out << " - #{Gem.dir}\n"
95
+ def add_path out, path
96
+ path.each do |component|
97
+ out << " - #{component}\n"
98
+ end
99
+ end
109
100
 
110
- path = Gem.path.dup
111
- path.delete Gem.dir
112
- path.each do |p|
113
- out << " - #{p}\n"
114
- end
101
+ def show_environment # :nodoc:
102
+ out = "RubyGems Environment:\n"
115
103
 
116
- out << " - GEM CONFIGURATION:\n"
117
- Gem.configuration.each do |name, value|
118
- value = value.gsub(/./, '*') if name == 'gemcutter_key'
119
- out << " - #{name.inspect} => #{value.inspect}\n"
120
- end
104
+ out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n"
121
105
 
122
- out << " - REMOTE SOURCES:\n"
123
- Gem.sources.each do |s|
124
- out << " - #{s}\n"
125
- end
106
+ out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
107
+ out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
108
+ out << ") [#{RUBY_PLATFORM}]\n"
109
+
110
+ out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n"
111
+
112
+ out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
113
+
114
+ out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
115
+
116
+ out << " - EXECUTABLE DIRECTORY: #{Gem.bindir}\n"
126
117
 
127
- else
128
- raise Gem::CommandLineError, "Unknown environment option [#{arg}]"
118
+ out << " - SPEC CACHE DIRECTORY: #{Gem.spec_cache_dir}\n"
119
+
120
+ out << " - RUBYGEMS PLATFORMS:\n"
121
+ Gem.platforms.each do |platform|
122
+ out << " - #{platform}\n"
129
123
  end
130
- say out
131
- true
124
+
125
+ out << " - GEM PATHS:\n"
126
+ out << " - #{Gem.dir}\n"
127
+
128
+ gem_path = Gem.path.dup
129
+ gem_path.delete Gem.dir
130
+ add_path out, gem_path
131
+
132
+ out << " - GEM CONFIGURATION:\n"
133
+ Gem.configuration.each do |name, value|
134
+ value = value.gsub(/./, '*') if name == 'gemcutter_key'
135
+ out << " - #{name.inspect} => #{value.inspect}\n"
136
+ end
137
+
138
+ out << " - REMOTE SOURCES:\n"
139
+ Gem.sources.each do |s|
140
+ out << " - #{s}\n"
141
+ end
142
+
143
+ out << " - SHELL PATH:\n"
144
+
145
+ shell_path = ENV['PATH'].split(File::PATH_SEPARATOR)
146
+ add_path out, shell_path
147
+
148
+ out
132
149
  end
133
150
 
134
151
  end
@@ -43,13 +43,12 @@ class Gem::Commands::FetchCommand < Gem::Command
43
43
  dep.prerelease = options[:prerelease]
44
44
 
45
45
  specs_and_sources, errors = Gem::SpecFetcher.fetcher.spec_for_dependency dep
46
-
47
46
  if platform then
48
47
  filtered = specs_and_sources.select { |s,| s.platform == platform }
49
48
  specs_and_sources = filtered unless filtered.empty?
50
49
  end
51
50
 
52
- spec, source = specs_and_sources.max_by { |s,| s.version }
51
+ spec, source = specs_and_sources.sort_by { |s,| s.version }.first
53
52
 
54
53
  if spec.nil? then
55
54
  show_lookup_failure gem_name, version, errors, options[:domain]
@@ -46,6 +46,10 @@ Some examples of 'gem' usage.
46
46
  * Update all gems on your system:
47
47
 
48
48
  gem update
49
+
50
+ * Update your local version of RubyGems
51
+
52
+ gem update --system
49
53
  EOF
50
54
 
51
55
  PLATFORMS = <<-'EOF'
@@ -55,8 +59,9 @@ your current platform by running `gem environment`.
55
59
 
56
60
  RubyGems matches platforms as follows:
57
61
 
58
- * The CPU must match exactly, unless one of the platforms has
59
- "universal" as the CPU.
62
+ * The CPU must match exactly unless one of the platforms has
63
+ "universal" as the CPU or the local CPU starts with "arm" and the gem's
64
+ CPU is exactly "arm" (for gems that support generic ARM architecture).
60
65
  * The OS must match exactly.
61
66
  * The versions must match exactly unless one of the versions is nil.
62
67
 
@@ -66,11 +71,20 @@ you pass must match "#{cpu}-#{os}" or "#{cpu}-#{os}-#{version}". On mswin
66
71
  platforms, the version is the compiler version, not the OS version. (Ruby
67
72
  compiled with VC6 uses "60" as the compiler version, VC8 uses "80".)
68
73
 
74
+ For the ARM architecture, gems with a platform of "arm-linux" should run on a
75
+ reasonable set of ARM CPUs and not depend on instructions present on a limited
76
+ subset of the architecture. For example, the binary should run on platforms
77
+ armv5, armv6hf, armv6l, armv7, etc. If you use the "arm-linux" platform
78
+ please test your gem on a variety of ARM hardware before release to ensure it
79
+ functions correctly.
80
+
69
81
  Example platforms:
70
82
 
71
83
  x86-freebsd # Any FreeBSD version on an x86 CPU
72
84
  universal-darwin-8 # Darwin 8 only gems that run on any CPU
73
85
  x86-mswin32-80 # Windows gems compiled with VC8
86
+ armv7-linux # Gem complied for an ARMv7 CPU running linux
87
+ arm-linux # Gem compiled for any ARM CPU running linux
74
88
 
75
89
  When building platform gems, set the platform in the gem specification to
76
90
  Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's
@@ -80,6 +94,8 @@ platform.
80
94
 
81
95
  def initialize
82
96
  super 'help', "Provide help on the 'gem' command"
97
+
98
+ @command_manager = Gem::CommandManager.instance
83
99
  end
84
100
 
85
101
  def arguments # :nodoc:
@@ -96,46 +112,10 @@ platform.
96
112
  end
97
113
 
98
114
  def execute
99
- command_manager = Gem::CommandManager.instance
100
115
  arg = options[:args][0]
101
116
 
102
117
  if begins? "commands", arg then
103
- out = []
104
- out << "GEM commands are:"
105
- out << nil
106
-
107
- margin_width = 4
108
-
109
- desc_width = command_manager.command_names.map { |n| n.size }.max + 4
110
-
111
- summary_width = 80 - margin_width - desc_width
112
- wrap_indent = ' ' * (margin_width + desc_width)
113
- format = "#{' ' * margin_width}%-#{desc_width}s%s"
114
-
115
- command_manager.command_names.each do |cmd_name|
116
- command = command_manager[cmd_name]
117
-
118
- summary =
119
- if command then
120
- command.summary
121
- else
122
- "[No command found for #{cmd_name}, bug?]"
123
- end
124
-
125
- summary = wrap(summary, summary_width).split "\n"
126
- out << sprintf(format, cmd_name, summary.shift)
127
- until summary.empty? do
128
- out << "#{wrap_indent}#{summary.shift}"
129
- end
130
- end
131
-
132
- out << nil
133
- out << "For help on a particular command, use 'gem help COMMAND'."
134
- out << nil
135
- out << "Commands may be abbreviated, so long as they are unambiguous."
136
- out << "e.g. 'gem i rake' is short for 'gem install rake'."
137
-
138
- say out.join("\n")
118
+ show_commands
139
119
 
140
120
  elsif begins? "options", arg then
141
121
  say Gem::Command::HELP
@@ -147,29 +127,79 @@ platform.
147
127
  say PLATFORMS
148
128
 
149
129
  elsif options[:help] then
150
- command = command_manager[options[:help]]
151
- if command
152
- # help with provided command
153
- command.invoke("--help")
154
- else
155
- alert_error "Unknown command #{options[:help]}. Try 'gem help commands'"
156
- end
130
+ show_help
157
131
 
158
132
  elsif arg then
159
- possibilities = command_manager.find_command_possibilities(arg.downcase)
160
- if possibilities.size == 1
161
- command = command_manager[possibilities.first]
162
- command.invoke("--help")
163
- elsif possibilities.size > 1
164
- alert_warning "Ambiguous command #{arg} (#{possibilities.join(', ')})"
165
- else
166
- alert_warning "Unknown command #{arg}. Try gem help commands"
167
- end
133
+ show_command_help arg
168
134
 
169
135
  else
170
136
  say Gem::Command::HELP
171
137
  end
172
138
  end
173
139
 
140
+ def show_commands # :nodoc:
141
+ out = []
142
+ out << "GEM commands are:"
143
+ out << nil
144
+
145
+ margin_width = 4
146
+
147
+ desc_width = @command_manager.command_names.map { |n| n.size }.max + 4
148
+
149
+ summary_width = 80 - margin_width - desc_width
150
+ wrap_indent = ' ' * (margin_width + desc_width)
151
+ format = "#{' ' * margin_width}%-#{desc_width}s%s"
152
+
153
+ @command_manager.command_names.each do |cmd_name|
154
+ command = @command_manager[cmd_name]
155
+
156
+ summary =
157
+ if command then
158
+ command.summary
159
+ else
160
+ "[No command found for #{cmd_name}]"
161
+ end
162
+
163
+ summary = wrap(summary, summary_width).split "\n"
164
+ out << sprintf(format, cmd_name, summary.shift)
165
+ until summary.empty? do
166
+ out << "#{wrap_indent}#{summary.shift}"
167
+ end
168
+ end
169
+
170
+ out << nil
171
+ out << "For help on a particular command, use 'gem help COMMAND'."
172
+ out << nil
173
+ out << "Commands may be abbreviated, so long as they are unambiguous."
174
+ out << "e.g. 'gem i rake' is short for 'gem install rake'."
175
+
176
+ say out.join("\n")
177
+ end
178
+
179
+ def show_command_help command_name # :nodoc:
180
+ command_name = command_name.downcase
181
+
182
+ possibilities = @command_manager.find_command_possibilities command_name
183
+
184
+ if possibilities.size == 1 then
185
+ command = @command_manager[possibilities.first]
186
+ command.invoke("--help")
187
+ elsif possibilities.size > 1 then
188
+ alert_warning "Ambiguous command #{command_name} (#{possibilities.join(', ')})"
189
+ else
190
+ alert_warning "Unknown command #{command_name}. Try: gem help commands"
191
+ end
192
+ end
193
+
194
+ def show_help # :nodoc:
195
+ command = @command_manager[options[:help]]
196
+ if command then
197
+ # help with provided command
198
+ command.invoke("--help")
199
+ else
200
+ alert_error "Unknown command #{options[:help]}. Try 'gem help commands'"
201
+ end
202
+ end
203
+
174
204
  end
175
205