rubygems-update 1.3.5 → 1.3.6

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.

Potentially problematic release.


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

Files changed (146) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +8 -1
  3. data/ChangeLog +164 -0
  4. data/History.txt +52 -1
  5. data/Manifest.txt +8 -8
  6. data/README +3 -2
  7. data/Rakefile +49 -5
  8. data/bin/gem +2 -2
  9. data/bin/update_rubygems +9 -11
  10. data/cruise_config.rb +4 -3
  11. data/hide_lib_for_update/note.txt +5 -0
  12. data/lib/rbconfig/datadir.rb +10 -14
  13. data/lib/rubygems.rb +117 -140
  14. data/lib/rubygems/builder.rb +4 -2
  15. data/lib/rubygems/command.rb +51 -48
  16. data/lib/rubygems/command_manager.rb +2 -0
  17. data/lib/rubygems/commands/dependency_command.rb +10 -5
  18. data/lib/rubygems/commands/environment_command.rb +1 -1
  19. data/lib/rubygems/commands/fetch_command.rb +6 -5
  20. data/lib/rubygems/commands/install_command.rb +1 -0
  21. data/lib/rubygems/commands/mirror_command.rb +8 -8
  22. data/lib/rubygems/commands/owner_command.rb +75 -0
  23. data/lib/rubygems/commands/pristine_command.rb +1 -1
  24. data/lib/rubygems/commands/push_command.rb +45 -0
  25. data/lib/rubygems/commands/query_command.rb +4 -1
  26. data/lib/rubygems/commands/rdoc_command.rb +24 -9
  27. data/lib/rubygems/commands/server_command.rb +6 -0
  28. data/lib/rubygems/commands/setup_command.rb +14 -4
  29. data/lib/rubygems/commands/unpack_command.rb +2 -2
  30. data/lib/rubygems/commands/update_command.rb +2 -2
  31. data/lib/rubygems/commands/which_command.rb +7 -9
  32. data/lib/rubygems/config_file.rb +100 -26
  33. data/lib/rubygems/defaults.rb +1 -1
  34. data/lib/rubygems/dependency.rb +133 -75
  35. data/lib/rubygems/dependency_installer.rb +28 -10
  36. data/lib/rubygems/dependency_list.rb +41 -12
  37. data/lib/rubygems/doc_manager.rb +7 -0
  38. data/lib/rubygems/format.rb +16 -20
  39. data/lib/rubygems/gem_openssl.rb +1 -1
  40. data/lib/rubygems/gem_path_searcher.rb +10 -12
  41. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  42. data/lib/rubygems/indexer.rb +2 -2
  43. data/lib/rubygems/install_update_options.rb +1 -9
  44. data/lib/rubygems/installer.rb +35 -76
  45. data/lib/rubygems/local_remote_options.rb +1 -2
  46. data/lib/rubygems/package.rb +0 -1
  47. data/lib/rubygems/package/tar_input.rb +3 -1
  48. data/lib/rubygems/package_task.rb +16 -11
  49. data/lib/rubygems/remote_fetcher.rb +22 -8
  50. data/lib/rubygems/requirement.rb +78 -100
  51. data/lib/rubygems/server.rb +41 -10
  52. data/lib/rubygems/source_index.rb +5 -5
  53. data/lib/rubygems/spec_fetcher.rb +2 -2
  54. data/lib/rubygems/specification.rb +66 -16
  55. data/lib/rubygems/test_utilities.rb +33 -4
  56. data/lib/rubygems/uninstaller.rb +3 -3
  57. data/lib/rubygems/user_interaction.rb +45 -0
  58. data/lib/rubygems/validator.rb +6 -7
  59. data/lib/rubygems/version.rb +206 -149
  60. data/lib/rubygems/version_option.rb +16 -0
  61. data/test/fake_certlib/openssl.rb +1 -1
  62. data/test/functional.rb +0 -7
  63. data/test/gem_installer_test_case.rb +4 -4
  64. data/test/gem_package_tar_test_case.rb +1 -1
  65. data/test/gemutilities.rb +35 -31
  66. data/test/insure_session.rb +0 -8
  67. data/test/mockgemui.rb +0 -8
  68. data/test/simple_gem.rb +2 -8
  69. data/test/test_config.rb +3 -10
  70. data/test/test_gem.rb +9 -14
  71. data/test/test_gem_builder.rb +1 -7
  72. data/test/test_gem_command.rb +1 -8
  73. data/test/test_gem_command_manager.rb +1 -7
  74. data/test/test_gem_commands_build_command.rb +4 -4
  75. data/test/test_gem_commands_cert_command.rb +1 -2
  76. data/test/test_gem_commands_check_command.rb +1 -7
  77. data/test/test_gem_commands_contents_command.rb +1 -1
  78. data/test/test_gem_commands_dependency_command.rb +17 -31
  79. data/test/test_gem_commands_environment_command.rb +1 -1
  80. data/test/test_gem_commands_fetch_command.rb +14 -12
  81. data/test/test_gem_commands_generate_index_command.rb +1 -1
  82. data/test/test_gem_commands_install_command.rb +22 -20
  83. data/test/test_gem_commands_list_command.rb +1 -1
  84. data/test/test_gem_commands_lock_command.rb +1 -1
  85. data/test/test_gem_commands_mirror_command.rb +5 -5
  86. data/test/test_gem_commands_outdated_command.rb +3 -5
  87. data/test/test_gem_commands_owner_command.rb +105 -0
  88. data/test/test_gem_commands_pristine_command.rb +2 -2
  89. data/test/test_gem_commands_push_command.rb +61 -0
  90. data/test/test_gem_commands_query_command.rb +23 -56
  91. data/test/test_gem_commands_server_command.rb +1 -1
  92. data/test/test_gem_commands_sources_command.rb +1 -70
  93. data/test/test_gem_commands_specification_command.rb +3 -4
  94. data/test/test_gem_commands_stale_command.rb +1 -1
  95. data/test/test_gem_commands_uninstall_command.rb +3 -4
  96. data/test/test_gem_commands_unpack_command.rb +1 -1
  97. data/test/test_gem_commands_update_command.rb +13 -13
  98. data/test/test_gem_commands_which_command.rb +66 -0
  99. data/test/test_gem_config_file.rb +13 -7
  100. data/test/test_gem_dependency.rb +82 -134
  101. data/test/test_gem_dependency_installer.rb +55 -30
  102. data/test/test_gem_dependency_list.rb +28 -7
  103. data/test/test_gem_doc_manager.rb +1 -7
  104. data/test/test_gem_ext_configure_builder.rb +2 -2
  105. data/test/test_gem_ext_ext_conf_builder.rb +1 -1
  106. data/test/test_gem_ext_rake_builder.rb +1 -1
  107. data/test/test_gem_format.rb +14 -11
  108. data/test/test_gem_gem_path_searcher.rb +12 -1
  109. data/test/test_gem_gem_runner.rb +1 -1
  110. data/test/test_gem_gemcutter_utilities.rb +103 -0
  111. data/test/test_gem_indexer.rb +44 -51
  112. data/test/test_gem_install_update_options.rb +1 -7
  113. data/test/test_gem_installer.rb +22 -82
  114. data/test/test_gem_local_remote_options.rb +1 -1
  115. data/test/test_gem_package_tar_header.rb +1 -8
  116. data/test/test_gem_package_tar_input.rb +1 -8
  117. data/test/test_gem_package_tar_output.rb +1 -8
  118. data/test/test_gem_package_tar_reader.rb +1 -8
  119. data/test/test_gem_package_tar_reader_entry.rb +1 -8
  120. data/test/test_gem_package_tar_writer.rb +1 -8
  121. data/test/test_gem_package_task.rb +1 -25
  122. data/test/test_gem_platform.rb +4 -4
  123. data/test/test_gem_remote_fetcher.rb +31 -21
  124. data/test/test_gem_requirement.rb +210 -140
  125. data/test/test_gem_server.rb +36 -1
  126. data/test/test_gem_source_index.rb +7 -13
  127. data/test/test_gem_spec_fetcher.rb +17 -47
  128. data/test/test_gem_specification.rb +7 -20
  129. data/test/test_gem_stream_ui.rb +21 -1
  130. data/test/test_gem_uninstaller.rb +1 -2
  131. data/test/test_gem_validator.rb +2 -8
  132. data/test/test_gem_version.rb +110 -254
  133. data/test/test_gem_version_option.rb +1 -1
  134. data/test/test_kernel.rb +1 -7
  135. data/util/CL2notes +1 -1
  136. data/util/gem_prelude.rb.template +64 -41
  137. metadata +33 -71
  138. metadata.gz.sig +0 -0
  139. data/lib/rubygems/digest/digest_adapter.rb +0 -49
  140. data/lib/rubygems/digest/md5.rb +0 -23
  141. data/lib/rubygems/digest/sha1.rb +0 -22
  142. data/lib/rubygems/digest/sha2.rb +0 -22
  143. data/lib/rubygems/timer.rb +0 -28
  144. data/test/test_gem_digest.rb +0 -46
  145. data/test/test_gem_source_info_cache.rb +0 -447
  146. data/test/test_gem_source_info_cache_entry.rb +0 -78
@@ -45,7 +45,7 @@ class Gem::Commands::QueryCommand < Gem::Command
45
45
  options[:all] = value
46
46
  end
47
47
 
48
- add_option( '--prerelease',
48
+ add_option( '--[no-]prerelease',
49
49
  'Display prerelease versions') do |value, options|
50
50
  options[:prerelease] = value
51
51
  end
@@ -111,6 +111,9 @@ class Gem::Commands::QueryCommand < Gem::Command
111
111
  begin
112
112
  fetcher = Gem::SpecFetcher.fetcher
113
113
  spec_tuples = fetcher.find_matching dep, all, false, prerelease
114
+
115
+ spec_tuples += fetcher.find_matching dep, false, false, true if
116
+ prerelease and all
114
117
  rescue Gem::RemoteFetcher::FetchError => e
115
118
  if prerelease then
116
119
  raise Gem::OperationNotSupportedError,
@@ -8,7 +8,7 @@ class Gem::Commands::RdocCommand < Gem::Command
8
8
  def initialize
9
9
  super 'rdoc', 'Generates RDoc for pre-installed gems',
10
10
  :version => Gem::Requirement.default,
11
- :include_rdoc => true, :include_ri => true
11
+ :include_rdoc => true, :include_ri => true, :overwrite => false
12
12
 
13
13
  add_option('--all',
14
14
  'Generate RDoc/RI documentation for all',
@@ -17,15 +17,20 @@ class Gem::Commands::RdocCommand < Gem::Command
17
17
  end
18
18
 
19
19
  add_option('--[no-]rdoc',
20
- 'Include RDoc generated documents') do |value, options|
20
+ 'Generate RDoc HTML') do |value, options|
21
21
  options[:include_rdoc] = value
22
22
  end
23
23
 
24
24
  add_option('--[no-]ri',
25
- 'Include RI generated documents') do |value, options|
25
+ 'Generate RI data') do |value, options|
26
26
  options[:include_ri] = value
27
27
  end
28
28
 
29
+ add_option('--[no-]overwrite',
30
+ 'Overwrite installed documents') do |value, options|
31
+ options[:overwrite] = value
32
+ end
33
+
29
34
  add_version_option
30
35
  end
31
36
 
@@ -34,7 +39,14 @@ class Gem::Commands::RdocCommand < Gem::Command
34
39
  end
35
40
 
36
41
  def defaults_str # :nodoc:
37
- "--version '#{Gem::Requirement.default}' --rdoc --ri"
42
+ "--version '#{Gem::Requirement.default}' --rdoc --ri --no-overwrite"
43
+ end
44
+
45
+ def description # :nodoc:
46
+ <<-DESC
47
+ The rdoc command builds RDoc and RI documentation for installed gems. Use
48
+ --overwrite to force rebuilding of documentation.
49
+ DESC
38
50
  end
39
51
 
40
52
  def usage # :nodoc:
@@ -53,24 +65,27 @@ class Gem::Commands::RdocCommand < Gem::Command
53
65
  end
54
66
 
55
67
  if specs.empty?
56
- fail "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
68
+ raise "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
57
69
  end
58
70
 
59
71
  if options[:include_ri]
60
- specs.each do |spec|
61
- Gem::DocManager.new(spec).generate_ri
72
+ specs.sort.each do |spec|
73
+ doc = Gem::DocManager.new(spec)
74
+ doc.generate_ri if options[:overwrite] || !doc.ri_installed?
62
75
  end
63
76
 
64
77
  Gem::DocManager.update_ri_cache
65
78
  end
66
79
 
67
80
  if options[:include_rdoc]
68
- specs.each do |spec|
69
- Gem::DocManager.new(spec).generate_rdoc
81
+ specs.sort.each do |spec|
82
+ doc = Gem::DocManager.new(spec)
83
+ doc.generate_rdoc if options[:overwrite] || !doc.rdoc_installed?
70
84
  end
71
85
  end
72
86
 
73
87
  true
74
88
  end
89
+
75
90
  end
76
91
 
@@ -36,6 +36,12 @@ class Gem::Commands::ServerCommand < Gem::Command
36
36
  add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
37
37
  options[:daemon] = daemon
38
38
  end
39
+
40
+ add_option '-b', '--bind=HOST,HOST',
41
+ 'addresses to bind', Array do |address, options|
42
+ options[:addresses] ||= []
43
+ options[:addresses].push(*address)
44
+ end
39
45
  end
40
46
 
41
47
  def defaults_str # :nodoc:
@@ -2,7 +2,6 @@ require 'rubygems/command'
2
2
  require 'fileutils'
3
3
  require 'rbconfig'
4
4
  require 'tmpdir'
5
- require 'pathname'
6
5
 
7
6
  ##
8
7
  # Installs RubyGems itself. This command is ordinarily only available from a
@@ -57,10 +56,10 @@ class Gem::Commands::SetupCommand < Gem::Command
57
56
  end
58
57
 
59
58
  def check_ruby_version
60
- required_version = Gem::Version.new '1.8.3'
59
+ required_version = Gem::Requirement.new '>= 1.8.6'
61
60
 
62
- unless Gem.ruby_version > required_version then
63
- alert_error "Ruby version > #{required_version} required, is #{Gem.ruby_version}"
61
+ unless required_version.satisfied_by? Gem.ruby_version then
62
+ alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
64
63
  terminate_interaction 1
65
64
  end
66
65
  end
@@ -117,6 +116,8 @@ By default, this RubyGems will install gem as:
117
116
 
118
117
  say "RubyGems #{Gem::VERSION} installed"
119
118
 
119
+ uninstall_old_gemcutter
120
+
120
121
  install_rdoc
121
122
 
122
123
  say
@@ -359,5 +360,14 @@ abort "#{deprecation_message}"
359
360
  r.document args
360
361
  end
361
362
 
363
+ def uninstall_old_gemcutter
364
+ require 'rubygems/uninstaller'
365
+
366
+ ui = Gem::Uninstaller.new('gemcutter', :all => true, :ignore => true,
367
+ :version => '< 0.4')
368
+ ui.uninstall
369
+ rescue Gem::InstallError
370
+ end
371
+
362
372
  end
363
373
 
@@ -41,7 +41,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
41
41
  path = get_path name, options[:version]
42
42
 
43
43
  if path then
44
- basename = File.basename(path).sub(/\.gem$/, '')
44
+ basename = File.basename(path, '.gem')
45
45
  target_dir = File.expand_path File.join(options[:target], basename)
46
46
  FileUtils.mkdir_p target_dir
47
47
  Gem::Installer.new(path, :unpack => true).unpack target_dir
@@ -79,7 +79,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
79
79
  # We expect to find (basename).gem in the 'cache' directory.
80
80
  # Furthermore, the name match must be exact (ignoring case).
81
81
  if gemname =~ /^#{selected.name}$/i
82
- filename = selected.full_name + '.gem'
82
+ filename = selected.file_name
83
83
  path = nil
84
84
 
85
85
  Gem.path.find do |gem_dir|
@@ -28,8 +28,8 @@ class Gem::Commands::UpdateCommand < Gem::Command
28
28
  end
29
29
 
30
30
  add_local_remote_options
31
-
32
31
  add_platform_option
32
+ add_prerelease_option "as update targets"
33
33
  end
34
34
 
35
35
  def arguments # :nodoc:
@@ -51,7 +51,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
51
51
  say "Updating RubyGems"
52
52
 
53
53
  unless options[:args].empty? then
54
- fail "No gem names are allowed with the --system option"
54
+ raise "No gem names are allowed with the --system option"
55
55
  end
56
56
 
57
57
  rubygems_update = Gem::Specification.new
@@ -27,13 +27,11 @@ class Gem::Commands::WhichCommand < Gem::Command
27
27
  "--no-gems-first --no-all"
28
28
  end
29
29
 
30
- def usage # :nodoc:
31
- "#{program_name} FILE [FILE ...]"
32
- end
33
-
34
30
  def execute
35
31
  searcher = Gem::GemPathSearcher.new
36
32
 
33
+ found = false
34
+
37
35
  options[:args].each do |arg|
38
36
  dirs = $LOAD_PATH
39
37
  spec = searcher.find arg
@@ -44,19 +42,19 @@ class Gem::Commands::WhichCommand < Gem::Command
44
42
  else
45
43
  dirs = $LOAD_PATH + gem_paths(spec)
46
44
  end
47
-
48
- say "(checking gem #{spec.full_name} for #{arg})" if
49
- Gem.configuration.verbose and $stdout.tty?
50
45
  end
51
46
 
52
47
  paths = find_paths arg, dirs
53
48
 
54
49
  if paths.empty? then
55
- say "Can't find ruby library file or shared library #{arg}"
50
+ alert_error "Can't find ruby library file or shared library #{arg}"
56
51
  else
57
52
  say paths
53
+ found = true
58
54
  end
59
55
  end
56
+
57
+ terminate_interaction 1 unless found
60
58
  end
61
59
 
62
60
  def find_paths(package_name, dirs)
@@ -80,7 +78,7 @@ class Gem::Commands::WhichCommand < Gem::Command
80
78
  end
81
79
 
82
80
  def usage # :nodoc:
83
- "#{program_name} FILE [...]"
81
+ "#{program_name} FILE [FILE ...]"
84
82
  end
85
83
 
86
84
  end
@@ -4,10 +4,26 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- require 'yaml'
8
-
9
- # Store the gem command options specified in the configuration file. The
10
- # config file object acts much like a hash.
7
+ ##
8
+ # Gem::ConfigFile RubyGems options and gem command options from ~/.gemrc.
9
+ #
10
+ # ~/.gemrc is a YAML file that uses strings to match gem command arguments and
11
+ # symbols to match RubyGems options.
12
+ #
13
+ # Gem command arguments use a String key that matches the command name and
14
+ # allow you to specify default arguments:
15
+ #
16
+ # install: --no-rdoc --no-ri
17
+ # update: --no-rdoc --no-ri
18
+ #
19
+ # You can use <tt>gem:</tt> to set default arguments for all commands.
20
+ #
21
+ # RubyGems options use symbol keys. Valid options are:
22
+ #
23
+ # +:backtrace+:: See #backtrace
24
+ # +:benchmark+:: See #benchmark
25
+ # +:sources+:: Sets Gem::sources
26
+ # +:verbose+:: See #verbose
11
27
 
12
28
  class Gem::ConfigFile
13
29
 
@@ -52,49 +68,74 @@ class Gem::ConfigFile
52
68
 
53
69
  SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
54
70
 
71
+ ##
55
72
  # List of arguments supplied to the config file object.
73
+
56
74
  attr_reader :args
57
75
 
58
- # Where to look for gems
76
+ ##
77
+ # Where to look for gems (deprecated)
78
+
59
79
  attr_accessor :path
60
80
 
81
+ ##
82
+ # Where to install gems (deprecated)
83
+
61
84
  attr_accessor :home
62
85
 
86
+ ##
63
87
  # True if we print backtraces on errors.
88
+
64
89
  attr_writer :backtrace
65
90
 
91
+ ##
66
92
  # True if we are benchmarking this run.
93
+
67
94
  attr_accessor :benchmark
68
95
 
69
- # Bulk threshold value. If the number of missing gems are above
70
- # this threshold value, then a bulk download technique is used.
96
+ ##
97
+ # Bulk threshold value. If the number of missing gems are above this
98
+ # threshold value, then a bulk download technique is used. (deprecated)
99
+
71
100
  attr_accessor :bulk_threshold
72
101
 
102
+ ##
73
103
  # Verbose level of output:
74
104
  # * false -- No output
75
105
  # * true -- Normal output
76
106
  # * :loud -- Extra output
107
+
77
108
  attr_accessor :verbose
78
109
 
110
+ ##
79
111
  # True if we want to update the SourceInfoCache every time, false otherwise
112
+
80
113
  attr_accessor :update_sources
81
114
 
115
+ ##
116
+ # API key for RubyGems.org
117
+
118
+ attr_reader :rubygems_api_key
119
+
120
+ ##
82
121
  # Create the config file object. +args+ is the list of arguments
83
122
  # from the command line.
84
123
  #
85
124
  # The following command line options are handled early here rather
86
125
  # than later at the time most command options are processed.
87
126
  #
88
- # * --config-file and --config-file==NAME -- Obviously these need
89
- # to be handled by the ConfigFile object to ensure we get the
90
- # right config file.
91
- #
92
- # * --backtrace -- Backtrace needs to be turned on early so that
93
- # errors before normal option parsing can be properly handled.
127
+ # <tt>--config-file</tt>, <tt>--config-file==NAME</tt>::
128
+ # Obviously these need to be handled by the ConfigFile object to ensure we
129
+ # get the right config file.
94
130
  #
95
- # * --debug -- Enable Ruby level debug messages. Handled early
96
- # for the same reason as --backtrace.
131
+ # <tt>--backtrace</tt>::
132
+ # Backtrace needs to be turned on early so that errors before normal
133
+ # option parsing can be properly handled.
97
134
  #
135
+ # <tt>--debug</tt>::
136
+ # Enable Ruby level debug messages. Handled early for the same reason as
137
+ # --backtrace.
138
+
98
139
  def initialize(arg_list)
99
140
  @config_file_name = nil
100
141
  need_config_file_name = false
@@ -131,21 +172,53 @@ class Gem::ConfigFile
131
172
  @hash = @hash.merge user_config
132
173
 
133
174
  # HACK these override command-line args, which is bad
134
- @backtrace = @hash[:backtrace] if @hash.key? :backtrace
135
- @benchmark = @hash[:benchmark] if @hash.key? :benchmark
136
- @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
137
- Gem.sources = @hash[:sources] if @hash.key? :sources
138
- @verbose = @hash[:verbose] if @hash.key? :verbose
139
- @update_sources = @hash[:update_sources] if @hash.key? :update_sources
140
- @path = @hash[:gempath] if @hash.key? :gempath
141
- @home = @hash[:gemhome] if @hash.key? :gemhome
175
+ @backtrace = @hash[:backtrace] if @hash.key? :backtrace
176
+ @benchmark = @hash[:benchmark] if @hash.key? :benchmark
177
+ @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
178
+ @home = @hash[:gemhome] if @hash.key? :gemhome
179
+ @path = @hash[:gempath] if @hash.key? :gempath
180
+ @update_sources = @hash[:update_sources] if @hash.key? :update_sources
181
+ @verbose = @hash[:verbose] if @hash.key? :verbose
182
+
183
+ load_rubygems_api_key
142
184
 
185
+ Gem.sources = @hash[:sources] if @hash.key? :sources
143
186
  handle_arguments arg_list
144
187
  end
145
188
 
189
+ ##
190
+ # Location of RubyGems.org credentials
191
+
192
+ def credentials_path
193
+ File.join(Gem.user_home, '.gem', 'credentials')
194
+ end
195
+
196
+ def load_rubygems_api_key
197
+ api_key_hash = File.exists?(credentials_path) ? load_file(credentials_path) : @hash
198
+
199
+ @rubygems_api_key = api_key_hash[:rubygems_api_key] if api_key_hash.key? :rubygems_api_key
200
+ end
201
+
202
+ def rubygems_api_key=(api_key)
203
+ config = load_file(credentials_path).merge(:rubygems_api_key => api_key)
204
+
205
+ dirname = File.dirname(credentials_path)
206
+ Dir.mkdir(dirname) unless File.exists?(dirname)
207
+
208
+ require 'yaml'
209
+
210
+ File.open(credentials_path, 'w') do |f|
211
+ f.write config.to_yaml
212
+ end
213
+
214
+ @rubygems_api_key = api_key
215
+ end
216
+
146
217
  def load_file(filename)
218
+ return {} unless filename and File.exists?(filename)
147
219
  begin
148
- YAML.load(File.read(filename)) if filename and File.exist?(filename)
220
+ require 'yaml'
221
+ YAML.load(File.read(filename))
149
222
  rescue ArgumentError
150
223
  warn "Failed to load #{config_file_name}"
151
224
  rescue Errno::EACCES
@@ -239,8 +312,9 @@ class Gem::ConfigFile
239
312
 
240
313
  # Writes out this config file, replacing its source.
241
314
  def write
242
- File.open config_file_name, 'w' do |fp|
243
- fp.write self.to_yaml
315
+ require 'yaml'
316
+ open config_file_name, 'w' do |io|
317
+ io.write to_yaml
244
318
  end
245
319
  end
246
320
 
@@ -9,7 +9,7 @@ module Gem
9
9
  # An Array of the default sources that come with RubyGems
10
10
 
11
11
  def self.default_sources
12
- %w[http://gems.rubyforge.org/]
12
+ %w[http://rubygems.org/]
13
13
  end
14
14
 
15
15
  ##
@@ -1,14 +1,22 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
1
+ require "rubygems/requirement"
6
2
 
7
3
  ##
8
- # The Dependency class holds a Gem name and a Gem::Requirement
4
+ # The Dependency class holds a Gem name and a Gem::Requirement.
9
5
 
10
6
  class Gem::Dependency
11
7
 
8
+ # :stopdoc:
9
+ @warned_version_requirement = false
10
+
11
+ def self.warned_version_requirement
12
+ @warned_version_requirement
13
+ end
14
+
15
+ def self.warned_version_requirement= value
16
+ @warned_version_requirement = value
17
+ end
18
+ # :startdoc:
19
+
12
20
  ##
13
21
  # Valid dependency types.
14
22
  #--
@@ -16,9 +24,9 @@ class Gem::Dependency
16
24
  # Gem::Specification::CURRENT_SPECIFICATION_VERSION as well.
17
25
 
18
26
  TYPES = [
19
- :development,
20
- :runtime,
21
- ]
27
+ :development,
28
+ :runtime,
29
+ ]
22
30
 
23
31
  ##
24
32
  # Dependency name or regular expression.
@@ -26,122 +34,172 @@ class Gem::Dependency
26
34
  attr_accessor :name
27
35
 
28
36
  ##
29
- # Dependency type.
37
+ # Allows you to force this dependency to be a prerelease.
30
38
 
31
- attr_reader :type
39
+ attr_writer :prerelease
32
40
 
33
41
  ##
34
- # Dependent versions.
35
-
36
- attr_writer :version_requirements
37
-
38
- ##
39
- # Orders dependencies by name only.
42
+ # Dependency type.
40
43
 
41
- def <=>(other)
42
- [@name] <=> [other.name]
43
- end
44
+ attr_reader :type
44
45
 
45
46
  ##
46
- # Constructs a dependency with +name+ and +requirements+.
47
+ # Constructs a dependency with +name+ and +requirements+. The last
48
+ # argument can optionally be the dependency type, which defaults to
49
+ # <tt>:runtime</tt>.
47
50
 
48
- def initialize(name, version_requirements, type=:runtime)
49
- @name = name
51
+ def initialize name, *requirements
52
+ type = Symbol === requirements.last ? requirements.pop : :runtime
53
+ requirements = requirements.first if 1 == requirements.length # unpack
50
54
 
51
55
  unless TYPES.include? type
52
- raise ArgumentError, "Valid types are #{TYPES.inspect}, not #{@type.inspect}"
56
+ raise ArgumentError, "Valid types are #{TYPES.inspect}, "
57
+ + "not #{@type.inspect}"
53
58
  end
54
59
 
55
- @type = type
60
+ @name = name
61
+ @requirement = Gem::Requirement.create requirements
62
+ @type = type
63
+ @prerelease = false
56
64
 
57
- @version_requirements = Gem::Requirement.create version_requirements
58
- @version_requirement = nil # Avoid warnings.
59
- end
65
+ # This is for Marshal backwards compatability. See the comments in
66
+ # +requirement+ for the dirty details.
60
67
 
61
- def version_requirements
62
- normalize if defined? @version_requirement and @version_requirement
63
- @version_requirements
68
+ @version_requirements = @requirement
64
69
  end
65
70
 
66
- def requirement_list
67
- version_requirements.as_list
68
- end
71
+ ##
72
+ # What does this dependency require?
69
73
 
70
- alias requirements_list requirement_list
74
+ ##
75
+ # A dependency's hash is the XOR of the hashes of +name+, +type+,
76
+ # and +requirement+.
71
77
 
72
- def normalize
73
- ver = @version_requirement.instance_variable_get :@version
74
- @version_requirements = Gem::Requirement.new([ver])
75
- @version_requirement = nil
78
+ def hash # :nodoc:
79
+ name.hash ^ type.hash ^ requirement.hash
76
80
  end
77
81
 
78
- def to_s # :nodoc:
79
- "#{name} (#{version_requirements}, #{@type || :runtime})"
82
+ def inspect # :nodoc:
83
+ "<%s type=%p name=%p requirements=%p>" %
84
+ [self.class, @type, @name, requirement.to_s]
85
+ end
86
+
87
+ ##
88
+ # Does this dependency require a prerelease?
89
+
90
+ def prerelease?
91
+ @prerelease || requirement.prerelease?
80
92
  end
81
93
 
82
94
  def pretty_print(q) # :nodoc:
83
95
  q.group 1, 'Gem::Dependency.new(', ')' do
84
- q.pp @name
96
+ q.pp name
85
97
  q.text ','
86
98
  q.breakable
87
99
 
88
- q.pp @version_requirements
100
+ q.pp requirement
89
101
 
90
102
  q.text ','
91
103
  q.breakable
92
104
 
93
- q.pp @type
105
+ q.pp type
94
106
  end
95
107
  end
96
108
 
97
- def ==(other) # :nodoc:
98
- self.class === other &&
99
- self.name == other.name &&
100
- self.type == other.type &&
101
- self.version_requirements == other.version_requirements
109
+ def requirement
110
+ return @requirement if defined?(@requirement) and @requirement
111
+
112
+ # @version_requirements and @version_requirement are legacy ivar
113
+ # names, and supported here because older gems need to keep
114
+ # working and Dependency doesn't implement marshal_dump and
115
+ # marshal_load. In a happier world, this would be an
116
+ # attr_accessor. The horrifying instance_variable_get you see
117
+ # below is also the legacy of some old restructurings.
118
+ #
119
+ # Note also that because of backwards compatibility (loading new
120
+ # gems in an old RubyGems installation), we can't add explicit
121
+ # marshaling to this class until we want to make a big
122
+ # break. Maybe 2.0.
123
+ #
124
+ # Children, define explicit marshal and unmarshal behavior for
125
+ # public classes. Marshal formats are part of your public API.
126
+
127
+ if defined?(@version_requirement) && @version_requirement
128
+ version = @version_requirement.instance_variable_get :@version
129
+ @version_requirement = nil
130
+ @version_requirements = Gem::Requirement.new version
131
+ end
132
+
133
+ @requirement = @version_requirements if defined?(@version_requirements)
102
134
  end
103
135
 
104
136
  ##
105
- # Uses this dependency as a pattern to compare to +other+. This dependency
106
- # will match if the name matches the other's name, and other has only an
107
- # equal version requirement that satisfies this dependency.
137
+ # Rails subclasses Gem::Dependency and uses this method, so we'll hack
138
+ # around it.
108
139
 
109
- def =~(other)
110
- other = if self.class === other then
111
- other
112
- else
113
- return false unless other.respond_to? :name and
114
- other.respond_to? :version
140
+ alias __requirement requirement # :nodoc:
115
141
 
116
- Gem::Dependency.new other.name, other.version
117
- end
142
+ def requirements_list
143
+ requirement.as_list
144
+ end
118
145
 
119
- pattern = @name
120
- pattern = /\A#{Regexp.escape @name}\Z/ unless Regexp === pattern
146
+ def to_s # :nodoc:
147
+ "#{name} (#{requirement}, #{type})"
148
+ end
121
149
 
122
- return false unless pattern =~ other.name
150
+ def version_requirements # :nodoc:
151
+ unless Gem::Dependency.warned_version_requirement then
152
+ warn "#{Gem.location_of_caller.join ':'}:Warning: " \
153
+ "Gem::Dependency#version_requirements is deprecated " \
154
+ "and will be removed on or after August 2010. " \
155
+ "Use #requirement"
123
156
 
124
- reqs = other.version_requirements.requirements
157
+ Gem::Dependency.warned_version_requirement = true
158
+ end
125
159
 
126
- return false unless reqs.length == 1
127
- return false unless reqs.first.first == '='
160
+ __requirement
161
+ end
128
162
 
129
- version = reqs.first.last
163
+ alias_method :version_requirement, :version_requirements
130
164
 
131
- version_requirements.satisfied_by? version
165
+ def == other # :nodoc:
166
+ Gem::Dependency === other &&
167
+ self.name == other.name &&
168
+ self.type == other.type &&
169
+ self.requirement == other.requirement
132
170
  end
133
171
 
134
172
  ##
135
- # A dependency's hash is the sum of the hash of the #name, #type and
136
- # #version_requirements
173
+ # Dependencies are ordered by name.
137
174
 
138
- def hash
139
- name.hash + type.hash + version_requirements.hash
175
+ def <=> other
176
+ [@name] <=> [other.name]
140
177
  end
141
178
 
142
- def inspect # :nodoc:
143
- "<%s type=%p name=%p requirements=%p>" % [self.class, @type, @name,
144
- version_requirements.to_s]
179
+ ##
180
+ # Uses this dependency as a pattern to compare to +other+. This
181
+ # dependency will match if the name matches the other's name, and
182
+ # other has only an equal version requirement that satisfies this
183
+ # dependency.
184
+
185
+ def =~ other
186
+ unless Gem::Dependency === other
187
+ other = Gem::Dependency.new other.name, other.version rescue return false
188
+ end
189
+
190
+ pattern = name
191
+ pattern = /\A#{Regexp.escape pattern}\Z/ unless Regexp === pattern
192
+
193
+ return false unless pattern =~ other.name
194
+
195
+ reqs = other.requirement.requirements
196
+
197
+ return false unless reqs.length == 1
198
+ return false unless reqs.first.first == '='
199
+
200
+ version = reqs.first.last
201
+
202
+ requirement.satisfied_by? version
145
203
  end
146
204
 
147
205
  end