rubygems-update 1.3.1 → 1.3.2

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 (128) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +24 -0
  3. data/.document +4 -3
  4. data/ChangeLog +382 -1
  5. data/Manifest.txt +214 -0
  6. data/README +1 -49
  7. data/Rakefile +124 -191
  8. data/bin/gem +1 -4
  9. data/cruise_config.rb +22 -0
  10. data/doc/release_notes/rel_1_3_1.rdoc +3 -3
  11. data/doc/release_notes/rel_1_3_2.rdoc +119 -0
  12. data/lib/gauntlet_rubygems.rb +50 -0
  13. data/lib/rubygems.rb +250 -25
  14. data/lib/rubygems/builder.rb +62 -60
  15. data/lib/rubygems/command.rb +421 -319
  16. data/lib/rubygems/command_manager.rb +153 -125
  17. data/lib/rubygems/commands/check_command.rb +12 -7
  18. data/lib/rubygems/commands/cleanup_command.rb +11 -2
  19. data/lib/rubygems/commands/contents_command.rb +42 -18
  20. data/lib/rubygems/commands/generate_index_command.rb +91 -15
  21. data/lib/rubygems/commands/install_command.rb +33 -47
  22. data/lib/rubygems/commands/query_command.rb +36 -20
  23. data/lib/rubygems/commands/rdoc_command.rb +62 -68
  24. data/lib/rubygems/commands/search_command.rb +26 -32
  25. data/lib/rubygems/commands/setup_command.rb +353 -0
  26. data/lib/rubygems/commands/sources_command.rb +5 -0
  27. data/lib/rubygems/commands/specification_command.rb +23 -3
  28. data/lib/rubygems/commands/uninstall_command.rb +71 -61
  29. data/lib/rubygems/commands/unpack_command.rb +14 -12
  30. data/lib/rubygems/commands/update_command.rb +26 -5
  31. data/lib/rubygems/defaults.rb +16 -3
  32. data/lib/rubygems/dependency.rb +38 -7
  33. data/lib/rubygems/dependency_installer.rb +7 -4
  34. data/lib/rubygems/digest/digest_adapter.rb +42 -33
  35. data/lib/rubygems/digest/sha1.rb +6 -1
  36. data/lib/rubygems/digest/sha2.rb +5 -0
  37. data/lib/rubygems/doc_manager.rb +31 -11
  38. data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
  39. data/lib/rubygems/ext/rake_builder.rb +6 -2
  40. data/lib/rubygems/format.rb +63 -63
  41. data/lib/rubygems/gem_openssl.rb +14 -2
  42. data/lib/rubygems/gem_path_searcher.rb +7 -3
  43. data/lib/rubygems/gem_runner.rb +59 -39
  44. data/lib/rubygems/indexer.rb +450 -109
  45. data/lib/rubygems/install_update_options.rb +13 -1
  46. data/lib/rubygems/installer.rb +25 -22
  47. data/lib/rubygems/local_remote_options.rb +5 -3
  48. data/lib/rubygems/old_format.rb +124 -120
  49. data/lib/rubygems/package/tar_header.rb +25 -3
  50. data/lib/rubygems/package/tar_input.rb +5 -5
  51. data/lib/rubygems/package/tar_output.rb +2 -0
  52. data/lib/rubygems/package/tar_reader.rb +19 -0
  53. data/lib/rubygems/package/tar_reader/entry.rb +43 -0
  54. data/lib/rubygems/package/tar_writer.rb +65 -3
  55. data/lib/rubygems/package_task.rb +117 -0
  56. data/lib/rubygems/platform.rb +12 -8
  57. data/lib/rubygems/remote_fetcher.rb +43 -24
  58. data/lib/rubygems/require_paths_builder.rb +14 -12
  59. data/lib/rubygems/requirement.rb +15 -6
  60. data/lib/rubygems/rubygems_version.rb +14 -1
  61. data/lib/rubygems/source_index.rb +38 -16
  62. data/lib/rubygems/source_info_cache_entry.rb +2 -2
  63. data/lib/rubygems/spec_fetcher.rb +43 -20
  64. data/lib/rubygems/specification.rb +1122 -947
  65. data/lib/rubygems/text.rb +30 -0
  66. data/lib/rubygems/timer.rb +14 -11
  67. data/lib/rubygems/uninstaller.rb +25 -5
  68. data/lib/rubygems/user_interaction.rb +294 -264
  69. data/lib/rubygems/validator.rb +70 -36
  70. data/lib/rubygems/version.rb +97 -33
  71. data/lib/rubygems/version_option.rb +1 -0
  72. data/setup.rb +11 -306
  73. data/test/foo/discover.rb +0 -0
  74. data/test/gem_installer_test_case.rb +22 -11
  75. data/test/gem_package_tar_test_case.rb +0 -14
  76. data/test/gemutilities.rb +89 -8
  77. data/test/mockgemui.rb +2 -1
  78. data/test/rubygems_plugin.rb +16 -0
  79. data/test/test_gem.rb +107 -36
  80. data/test/test_gem_command.rb +3 -13
  81. data/test/test_gem_command_manager.rb +1 -14
  82. data/test/test_gem_commands_cert_command.rb +1 -1
  83. data/test/test_gem_commands_contents_command.rb +63 -0
  84. data/test/test_gem_commands_environment_command.rb +1 -1
  85. data/test/test_gem_commands_generate_index_command.rb +104 -1
  86. data/test/test_gem_commands_install_command.rb +95 -0
  87. data/test/test_gem_commands_pristine_command.rb +3 -3
  88. data/test/test_gem_commands_query_command.rb +46 -0
  89. data/test/test_gem_commands_sources_command.rb +9 -5
  90. data/test/test_gem_commands_specification_command.rb +31 -0
  91. data/test/test_gem_commands_uninstall_command.rb +3 -2
  92. data/test/test_gem_commands_unpack_command.rb +3 -2
  93. data/test/test_gem_commands_update_command.rb +12 -7
  94. data/test/test_gem_dependency.rb +62 -11
  95. data/test/test_gem_dependency_installer.rb +18 -5
  96. data/test/test_gem_dependency_list.rb +6 -6
  97. data/test/test_gem_doc_manager.rb +7 -1
  98. data/test/test_gem_ext_configure_builder.rb +8 -10
  99. data/test/test_gem_ext_ext_conf_builder.rb +14 -8
  100. data/test/test_gem_gem_path_searcher.rb +1 -1
  101. data/test/test_gem_gem_runner.rb +11 -0
  102. data/test/test_gem_indexer.rb +398 -21
  103. data/test/test_gem_install_update_options.rb +20 -6
  104. data/test/test_gem_installer.rb +22 -14
  105. data/test/test_gem_local_remote_options.rb +2 -1
  106. data/test/test_gem_package_tar_header.rb +3 -3
  107. data/test/test_gem_package_tar_input.rb +3 -3
  108. data/test/test_gem_package_tar_output.rb +2 -2
  109. data/test/test_gem_package_task.rb +70 -0
  110. data/test/test_gem_platform.rb +12 -6
  111. data/test/test_gem_remote_fetcher.rb +23 -1
  112. data/test/test_gem_source_index.rb +32 -21
  113. data/test/test_gem_spec_fetcher.rb +77 -5
  114. data/test/test_gem_specification.rb +274 -1
  115. data/test/test_gem_uninstaller.rb +34 -4
  116. data/test/test_gem_version.rb +94 -4
  117. data/test/test_gem_version_option.rb +13 -0
  118. data/test/test_kernel.rb +4 -4
  119. data/util/CL2notes +56 -0
  120. data/util/gem_prelude.rb.template +251 -0
  121. metadata +30 -20
  122. metadata.gz.sig +3 -4
  123. data/TODO +0 -1
  124. data/scripts/buildtests.rb +0 -31
  125. data/scripts/gemdoc.rb +0 -67
  126. data/scripts/runtest.rb +0 -40
  127. data/scripts/specdoc.rb +0 -171
  128. data/scripts/upload_gemdoc.rb +0 -140
@@ -8,139 +8,167 @@ require 'timeout'
8
8
  require 'rubygems/command'
9
9
  require 'rubygems/user_interaction'
10
10
 
11
- module Gem
12
-
13
- ####################################################################
14
- # The command manager registers and installs all the individual
15
- # sub-commands supported by the gem command.
16
- class CommandManager
17
- include UserInteraction
18
-
19
- # Return the authoritative instance of the command manager.
20
- def self.instance
21
- @command_manager ||= CommandManager.new
22
- end
23
-
24
- # Register all the subcommands supported by the gem command.
25
- def initialize
26
- @commands = {}
27
- register_command :build
28
- register_command :cert
29
- register_command :check
30
- register_command :cleanup
31
- register_command :contents
32
- register_command :dependency
33
- register_command :environment
34
- register_command :fetch
35
- register_command :generate_index
36
- register_command :help
37
- register_command :install
38
- register_command :list
39
- register_command :lock
40
- register_command :mirror
41
- register_command :outdated
42
- register_command :pristine
43
- register_command :query
44
- register_command :rdoc
45
- register_command :search
46
- register_command :server
47
- register_command :sources
48
- register_command :specification
49
- register_command :stale
50
- register_command :uninstall
51
- register_command :unpack
52
- register_command :update
53
- register_command :which
54
- end
55
-
56
- # Register the command object.
57
- def register_command(command_obj)
58
- @commands[command_obj] = false
59
- end
60
-
61
- # Return the registered command from the command name.
62
- def [](command_name)
63
- command_name = command_name.intern
64
- return nil if @commands[command_name].nil?
65
- @commands[command_name] ||= load_and_instantiate(command_name)
66
- end
67
-
68
- # Return a list of all command names (as strings).
69
- def command_names
70
- @commands.keys.collect {|key| key.to_s}.sort
71
- end
72
-
73
- # Run the config specified by +args+.
74
- def run(args)
75
- process_args(args)
76
- rescue StandardError, Timeout::Error => ex
77
- alert_error "While executing gem ... (#{ex.class})\n #{ex.to_s}"
78
- ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
79
- Gem.configuration.backtrace
11
+ ##
12
+ # The command manager registers and installs all the individual sub-commands
13
+ # supported by the gem command.
14
+ #
15
+ # Extra commands can be provided by writing a rubygems_plugin.rb
16
+ # file in an installed gem. You should register your command against the
17
+ # Gem::CommandManager instance, like this:
18
+ #
19
+ # # file rubygems_plugin.rb
20
+ # require 'rubygems/command_manager'
21
+ #
22
+ # class Gem::Commands::EditCommand < Gem::Command
23
+ # # ...
24
+ # end
25
+ #
26
+ # Gem::CommandManager.instance.register_command :edit
27
+ #
28
+ # See Gem::Command for instructions on writing gem commands.
29
+
30
+ class Gem::CommandManager
31
+
32
+ include Gem::UserInteraction
33
+
34
+ ##
35
+ # Return the authoritative instance of the command manager.
36
+
37
+ def self.instance
38
+ @command_manager ||= new
39
+ end
40
+
41
+ ##
42
+ # Register all the subcommands supported by the gem command.
43
+
44
+ def initialize
45
+ @commands = {}
46
+ register_command :build
47
+ register_command :cert
48
+ register_command :check
49
+ register_command :cleanup
50
+ register_command :contents
51
+ register_command :dependency
52
+ register_command :environment
53
+ register_command :fetch
54
+ register_command :generate_index
55
+ register_command :help
56
+ register_command :install
57
+ register_command :list
58
+ register_command :lock
59
+ register_command :mirror
60
+ register_command :outdated
61
+ register_command :pristine
62
+ register_command :query
63
+ register_command :rdoc
64
+ register_command :search
65
+ register_command :server
66
+ register_command :sources
67
+ register_command :specification
68
+ register_command :stale
69
+ register_command :uninstall
70
+ register_command :unpack
71
+ register_command :update
72
+ register_command :which
73
+ end
74
+
75
+ ##
76
+ # Register the command object.
77
+
78
+ def register_command(command_obj)
79
+ @commands[command_obj] = false
80
+ end
81
+
82
+ ##
83
+ # Return the registered command from the command name.
84
+
85
+ def [](command_name)
86
+ command_name = command_name.intern
87
+ return nil if @commands[command_name].nil?
88
+ @commands[command_name] ||= load_and_instantiate(command_name)
89
+ end
90
+
91
+ ##
92
+ # Return a sorted list of all command names (as strings).
93
+
94
+ def command_names
95
+ @commands.keys.collect {|key| key.to_s}.sort
96
+ end
97
+
98
+ ##
99
+ # Run the config specified by +args+.
100
+
101
+ def run(args)
102
+ process_args(args)
103
+ rescue StandardError, Timeout::Error => ex
104
+ alert_error "While executing gem ... (#{ex.class})\n #{ex.to_s}"
105
+ ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
106
+ Gem.configuration.backtrace
107
+ terminate_interaction(1)
108
+ rescue Interrupt
109
+ alert_error "Interrupted"
110
+ terminate_interaction(1)
111
+ end
112
+
113
+ def process_args(args)
114
+ args = args.to_str.split(/\s+/) if args.respond_to?(:to_str)
115
+ if args.size == 0
116
+ say Gem::Command::HELP
80
117
  terminate_interaction(1)
81
- rescue Interrupt
82
- alert_error "Interrupted"
118
+ end
119
+ case args[0]
120
+ when '-h', '--help'
121
+ say Gem::Command::HELP
122
+ terminate_interaction(0)
123
+ when '-v', '--version'
124
+ say Gem::RubyGemsVersion
125
+ terminate_interaction(0)
126
+ when /^-/
127
+ alert_error "Invalid option: #{args[0]}. See 'gem --help'."
83
128
  terminate_interaction(1)
129
+ else
130
+ cmd_name = args.shift.downcase
131
+ cmd = find_command(cmd_name)
132
+ cmd.invoke(*args)
84
133
  end
134
+ end
85
135
 
86
- def process_args(args)
87
- args = args.to_str.split(/\s+/) if args.respond_to?(:to_str)
88
- if args.size == 0
89
- say Gem::Command::HELP
90
- terminate_interaction(1)
91
- end
92
- case args[0]
93
- when '-h', '--help'
94
- say Gem::Command::HELP
95
- terminate_interaction(0)
96
- when '-v', '--version'
97
- say Gem::RubyGemsVersion
98
- terminate_interaction(0)
99
- when /^-/
100
- alert_error "Invalid option: #{args[0]}. See 'gem --help'."
101
- terminate_interaction(1)
102
- else
103
- cmd_name = args.shift.downcase
104
- cmd = find_command(cmd_name)
105
- cmd.invoke(*args)
106
- end
136
+ def find_command(cmd_name)
137
+ possibilities = find_command_possibilities cmd_name
138
+ if possibilities.size > 1 then
139
+ raise "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
140
+ elsif possibilities.size < 1 then
141
+ raise "Unknown command #{cmd_name}"
107
142
  end
108
143
 
109
- def find_command(cmd_name)
110
- possibilities = find_command_possibilities(cmd_name)
111
- if possibilities.size > 1
112
- raise "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
113
- end
114
- if possibilities.size < 1
115
- raise "Unknown command #{cmd_name}"
116
- end
144
+ self[possibilities.first]
145
+ end
117
146
 
118
- self[possibilities.first]
119
- end
147
+ def find_command_possibilities(cmd_name)
148
+ len = cmd_name.length
120
149
 
121
- def find_command_possibilities(cmd_name)
122
- len = cmd_name.length
123
- self.command_names.select { |n| cmd_name == n[0,len] }
124
- end
125
-
126
- private
127
-
128
- def load_and_instantiate(command_name)
129
- command_name = command_name.to_s
130
- retried = false
131
-
132
- begin
133
- const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase }
134
- Gem::Commands.const_get("#{const_name}Command").new
135
- rescue NameError
136
- if retried then
137
- raise
138
- else
139
- retried = true
140
- require "rubygems/commands/#{command_name}_command"
141
- retry
142
- end
150
+ command_names.select { |n| cmd_name == n[0, len] }
151
+ end
152
+
153
+ private
154
+
155
+ def load_and_instantiate(command_name)
156
+ command_name = command_name.to_s
157
+ retried = false
158
+
159
+ begin
160
+ const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase }
161
+ Gem::Commands.const_get("#{const_name}Command").new
162
+ rescue NameError
163
+ if retried then
164
+ raise
165
+ else
166
+ retried = true
167
+ require "rubygems/commands/#{command_name}_command"
168
+ retry
143
169
  end
144
170
  end
145
171
  end
146
- end
172
+
173
+ end
174
+
@@ -21,6 +21,10 @@ class Gem::Commands::CheckCommand < Gem::Command
21
21
  options[:alien] = true
22
22
  end
23
23
 
24
+ add_option('-v', '--verbose', "Spew more words") do |value, options|
25
+ options[:verbose] = true
26
+ end
27
+
24
28
  add_option('-t', '--test', "Run unit tests for gem") do |value, options|
25
29
  options[:test] = true
26
30
  end
@@ -38,16 +42,17 @@ class Gem::Commands::CheckCommand < Gem::Command
38
42
 
39
43
  if options[:alien]
40
44
  say "Performing the 'alien' operation"
41
- Gem::Validator.new.alien.each do |key, val|
42
- if(val.size > 0)
45
+ say
46
+ gems = get_all_gem_names rescue []
47
+ Gem::Validator.new.alien(gems).sort.each do |key, val|
48
+ unless val.empty? then
43
49
  say "#{key} has #{val.size} problems"
44
50
  val.each do |error_entry|
45
- say "\t#{error_entry.path}:"
46
- say "\t#{error_entry.problem}"
47
- say
51
+ say " #{error_entry.path}:"
52
+ say " #{error_entry.problem}"
48
53
  end
49
- else
50
- say "#{key} is error-free"
54
+ else
55
+ say "#{key} is error-free" if options[:verbose]
51
56
  end
52
57
  say
53
58
  end
@@ -1,6 +1,7 @@
1
1
  require 'rubygems/command'
2
2
  require 'rubygems/source_index'
3
3
  require 'rubygems/dependency_list'
4
+ require 'rubygems/uninstaller'
4
5
 
5
6
  class Gem::Commands::CleanupCommand < Gem::Command
6
7
 
@@ -22,6 +23,13 @@ class Gem::Commands::CleanupCommand < Gem::Command
22
23
  "--no-dryrun"
23
24
  end
24
25
 
26
+ def description # :nodoc:
27
+ <<-EOF
28
+ The cleanup command removes old gems from GEM_HOME. If an older version is
29
+ installed elsewhere in GEM_PATH the cleanup command won't touch it.
30
+ EOF
31
+ end
32
+
25
33
  def usage # :nodoc:
26
34
  "#{program_name} [GEMNAME ...]"
27
35
  end
@@ -41,7 +49,8 @@ class Gem::Commands::CleanupCommand < Gem::Command
41
49
 
42
50
  unless options[:args].empty? then
43
51
  options[:args].each do |gem_name|
44
- specs = Gem.cache.search(/^#{gem_name}$/i)
52
+ dep = Gem::Dependency.new gem_name, Gem::Requirement.default
53
+ specs = Gem.source_index.search dep
45
54
  specs.each do |spec|
46
55
  gems_to_cleanup << spec
47
56
  end
@@ -56,7 +65,6 @@ class Gem::Commands::CleanupCommand < Gem::Command
56
65
  primary_gems[spec.name].version != spec.version
57
66
  }
58
67
 
59
- uninstall_command = Gem::CommandManager.instance['uninstall']
60
68
  deplist = Gem::DependencyList.new
61
69
  gems_to_cleanup.uniq.each do |spec| deplist.add spec end
62
70
 
@@ -77,6 +85,7 @@ class Gem::Commands::CleanupCommand < Gem::Command
77
85
  begin
78
86
  uninstaller.uninstall
79
87
  rescue Gem::DependencyRemovalException,
88
+ Gem::InstallError,
80
89
  Gem::GemNotInHomeException => e
81
90
  say "Unable to uninstall #{spec.full_name}:"
82
91
  say "\t#{e.class}: #{e.message}"
@@ -11,6 +11,11 @@ class Gem::Commands::ContentsCommand < Gem::Command
11
11
 
12
12
  add_version_option
13
13
 
14
+ add_option( '--all',
15
+ "Contents for all gems") do |all, options|
16
+ options[:all] = all
17
+ end
18
+
14
19
  add_option('-s', '--spec-dir a,b,c', Array,
15
20
  "Search for gems under specific paths") do |spec_dirs, options|
16
21
  options[:specdirs] = spec_dirs
@@ -20,6 +25,11 @@ class Gem::Commands::ContentsCommand < Gem::Command
20
25
  "Only return files in the Gem's lib_dirs") do |lib_only, options|
21
26
  options[:lib_only] = lib_only
22
27
  end
28
+
29
+ add_option( '--[no-]prefix',
30
+ "Don't include installed path prefix") do |prefix, options|
31
+ options[:prefix] = prefix
32
+ end
23
33
  end
24
34
 
25
35
  def arguments # :nodoc:
@@ -27,46 +37,60 @@ class Gem::Commands::ContentsCommand < Gem::Command
27
37
  end
28
38
 
29
39
  def defaults_str # :nodoc:
30
- "--no-lib-only"
40
+ "--no-lib-only --prefix"
31
41
  end
32
42
 
33
43
  def usage # :nodoc:
34
- "#{program_name} GEMNAME"
44
+ "#{program_name} GEMNAME [GEMNAME ...]"
35
45
  end
36
46
 
37
47
  def execute
38
48
  version = options[:version] || Gem::Requirement.default
39
- gem = get_one_gem_name
40
49
 
41
- s = options[:specdirs].map do |i|
50
+ spec_dirs = options[:specdirs].map do |i|
42
51
  [i, File.join(i, "specifications")]
43
52
  end.flatten
44
53
 
45
- path_kind = if s.empty? then
46
- s = Gem::SourceIndex.installed_spec_directories
54
+ path_kind = if spec_dirs.empty? then
55
+ spec_dirs = Gem::SourceIndex.installed_spec_directories
47
56
  "default gem paths"
48
57
  else
49
58
  "specified path"
50
59
  end
51
60
 
52
- si = Gem::SourceIndex.from_gems_in(*s)
61
+ si = Gem::SourceIndex.from_gems_in(*spec_dirs)
53
62
 
54
- gem_spec = si.find_name(gem, version).last
63
+ gem_names = if options[:all] then
64
+ si.map { |_, spec| spec.name }
65
+ else
66
+ get_all_gem_names
67
+ end
55
68
 
56
- unless gem_spec then
57
- say "Unable to find gem '#{gem}' in #{path_kind}"
69
+ gem_names.each do |name|
70
+ gem_spec = si.find_name(name, version).last
58
71
 
59
- if Gem.configuration.verbose then
60
- say "\nDirectories searched:"
61
- s.each { |dir| say dir }
72
+ unless gem_spec then
73
+ say "Unable to find gem '#{name}' in #{path_kind}"
74
+
75
+ if Gem.configuration.verbose then
76
+ say "\nDirectories searched:"
77
+ spec_dirs.each { |dir| say dir }
78
+ end
79
+
80
+ terminate_interaction 1 if gem_names.length == 1
62
81
  end
63
82
 
64
- terminate_interaction
65
- end
83
+ files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
66
84
 
67
- files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
68
- files.each do |f|
69
- say File.join(gem_spec.full_gem_path, f)
85
+ files.each do |f|
86
+ path = if options[:prefix] then
87
+ File.join gem_spec.full_gem_path, f
88
+ else
89
+ f
90
+ end
91
+
92
+ say path
93
+ end
70
94
  end
71
95
  end
72
96