rubygems-update 1.0.1 → 1.1.0

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 (172) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +248 -0
  3. data/README +2 -0
  4. data/Rakefile +47 -23
  5. data/bin/gem +9 -4
  6. data/bin/update_rubygems +15 -1
  7. data/examples/application/bin/myapp +0 -0
  8. data/lib/rubygems.rb +506 -373
  9. data/lib/rubygems/builder.rb +14 -7
  10. data/lib/rubygems/command.rb +9 -9
  11. data/lib/rubygems/command_manager.rb +1 -0
  12. data/lib/rubygems/commands/cleanup_command.rb +67 -69
  13. data/lib/rubygems/commands/environment_command.rb +16 -10
  14. data/lib/rubygems/commands/fetch_command.rb +7 -9
  15. data/lib/rubygems/commands/install_command.rb +9 -3
  16. data/lib/rubygems/commands/list_command.rb +2 -4
  17. data/lib/rubygems/commands/mirror_command.rb +1 -1
  18. data/lib/rubygems/commands/query_command.rb +52 -5
  19. data/lib/rubygems/commands/sources_command.rb +19 -10
  20. data/lib/rubygems/commands/specification_command.rb +10 -6
  21. data/lib/rubygems/commands/uninstall_command.rb +23 -6
  22. data/lib/rubygems/commands/unpack_command.rb +15 -3
  23. data/lib/rubygems/commands/update_command.rb +27 -25
  24. data/lib/rubygems/custom_require.rb +1 -1
  25. data/lib/rubygems/defaults.rb +8 -1
  26. data/lib/rubygems/dependency_installer.rb +72 -104
  27. data/lib/rubygems/digest/digest_adapter.rb +0 -0
  28. data/lib/rubygems/digest/md5.rb +0 -0
  29. data/lib/rubygems/digest/sha1.rb +0 -0
  30. data/lib/rubygems/digest/sha2.rb +0 -0
  31. data/lib/rubygems/exceptions.rb +22 -1
  32. data/lib/rubygems/format.rb +16 -10
  33. data/lib/rubygems/indexer.rb +46 -33
  34. data/lib/rubygems/indexer/abstract_index_builder.rb +10 -2
  35. data/lib/rubygems/indexer/latest_index_builder.rb +35 -0
  36. data/lib/rubygems/indexer/master_index_builder.rb +9 -8
  37. data/lib/rubygems/indexer/quick_index_builder.rb +5 -3
  38. data/lib/rubygems/install_update_options.rb +7 -1
  39. data/lib/rubygems/installer.rb +8 -5
  40. data/lib/rubygems/package.rb +17 -774
  41. data/lib/rubygems/package/f_sync_dir.rb +24 -0
  42. data/lib/rubygems/package/tar_header.rb +245 -0
  43. data/lib/rubygems/package/tar_input.rb +219 -0
  44. data/lib/rubygems/package/tar_output.rb +143 -0
  45. data/lib/rubygems/package/tar_reader.rb +86 -0
  46. data/lib/rubygems/package/tar_reader/entry.rb +99 -0
  47. data/lib/rubygems/package/tar_writer.rb +180 -0
  48. data/lib/rubygems/remote_fetcher.rb +131 -16
  49. data/lib/rubygems/requirement.rb +2 -0
  50. data/lib/rubygems/rubygems_version.rb +1 -1
  51. data/lib/rubygems/security.rb +1 -0
  52. data/lib/rubygems/server.rb +85 -104
  53. data/lib/rubygems/source_index.rb +412 -329
  54. data/lib/rubygems/source_info_cache.rb +232 -99
  55. data/lib/rubygems/source_info_cache_entry.rb +14 -4
  56. data/lib/rubygems/specification.rb +9 -10
  57. data/lib/rubygems/timer.rb +0 -0
  58. data/lib/rubygems/uninstaller.rb +56 -32
  59. data/lib/rubygems/user_interaction.rb +4 -10
  60. data/lib/rubygems/validator.rb +0 -0
  61. data/scripts/gemdoc.rb +0 -0
  62. data/scripts/specdoc.rb +0 -0
  63. data/setup.rb +56 -19
  64. data/test/gem_installer_test_case.rb +86 -0
  65. data/test/gem_installer_test_case.rbc +0 -0
  66. data/test/gem_package_tar_test_case.rb +146 -0
  67. data/test/gem_package_tar_test_case.rbc +0 -0
  68. data/test/gemutilities.rb +123 -38
  69. data/test/gemutilities.rbc +0 -0
  70. data/test/mockgemui.rb +5 -13
  71. data/test/mockgemui.rbc +0 -0
  72. data/test/private_key.pem +27 -0
  73. data/test/public_cert.pem +20 -0
  74. data/test/simple_gem.rbc +0 -0
  75. data/test/test_config.rbc +0 -0
  76. data/test/test_gem.rb +46 -4
  77. data/test/test_gem.rbc +0 -0
  78. data/test/test_gem_builder.rbc +0 -0
  79. data/test/test_gem_command.rbc +0 -0
  80. data/test/test_gem_command_manager.rb +4 -2
  81. data/test/test_gem_command_manager.rbc +0 -0
  82. data/test/test_gem_commands_build_command.rbc +0 -0
  83. data/test/test_gem_commands_cert_command.rb +5 -1
  84. data/test/test_gem_commands_cert_command.rbc +0 -0
  85. data/test/test_gem_commands_check_command.rbc +0 -0
  86. data/test/test_gem_commands_contents_command.rbc +0 -0
  87. data/test/test_gem_commands_dependency_command.rbc +0 -0
  88. data/test/test_gem_commands_environment_command.rb +17 -1
  89. data/test/test_gem_commands_environment_command.rbc +0 -0
  90. data/test/test_gem_commands_fetch_command.rb +6 -5
  91. data/test/test_gem_commands_fetch_command.rbc +0 -0
  92. data/test/test_gem_commands_generate_index_command.rbc +0 -0
  93. data/test/test_gem_commands_install_command.rb +36 -28
  94. data/test/test_gem_commands_install_command.rbc +0 -0
  95. data/test/test_gem_commands_mirror_command.rbc +0 -0
  96. data/test/test_gem_commands_pristine_command.rbc +0 -0
  97. data/test/test_gem_commands_query_command.rb +143 -19
  98. data/test/test_gem_commands_query_command.rbc +0 -0
  99. data/test/test_gem_commands_server_command.rb +1 -1
  100. data/test/test_gem_commands_server_command.rbc +0 -0
  101. data/test/test_gem_commands_sources_command.rb +67 -9
  102. data/test/test_gem_commands_sources_command.rbc +0 -0
  103. data/test/test_gem_commands_specification_command.rb +3 -2
  104. data/test/test_gem_commands_specification_command.rbc +0 -0
  105. data/test/test_gem_commands_unpack_command.rb +46 -4
  106. data/test/test_gem_commands_unpack_command.rbc +0 -0
  107. data/test/test_gem_commands_update_command.rb +174 -0
  108. data/test/test_gem_commands_update_command.rbc +0 -0
  109. data/test/test_gem_config_file.rbc +0 -0
  110. data/test/test_gem_dependency.rbc +0 -0
  111. data/test/test_gem_dependency_installer.rb +172 -187
  112. data/test/test_gem_dependency_installer.rbc +0 -0
  113. data/test/test_gem_dependency_list.rbc +0 -0
  114. data/test/test_gem_digest.rb +0 -0
  115. data/test/test_gem_digest.rbc +0 -0
  116. data/test/test_gem_doc_manager.rbc +0 -0
  117. data/test/test_gem_ext_configure_builder.rb +9 -6
  118. data/test/test_gem_ext_configure_builder.rbc +0 -0
  119. data/test/test_gem_ext_ext_conf_builder.rbc +0 -0
  120. data/test/test_gem_ext_rake_builder.rbc +0 -0
  121. data/test/test_gem_format.rb +1 -1
  122. data/test/test_gem_format.rbc +0 -0
  123. data/test/test_gem_gem_path_searcher.rbc +0 -0
  124. data/test/test_gem_gem_runner.rbc +0 -0
  125. data/test/test_gem_indexer.rb +7 -2
  126. data/test/test_gem_indexer.rbc +0 -0
  127. data/test/test_gem_install_update_options.rbc +0 -0
  128. data/test/test_gem_installer.rb +5 -84
  129. data/test/test_gem_installer.rbc +0 -0
  130. data/test/test_gem_local_remote_options.rbc +0 -0
  131. data/test/test_gem_outdated_command.rbc +0 -0
  132. data/test/test_gem_package_tar_header.rb +137 -0
  133. data/test/test_gem_package_tar_header.rbc +0 -0
  134. data/test/test_gem_package_tar_input.rb +119 -0
  135. data/test/test_gem_package_tar_input.rbc +0 -0
  136. data/test/test_gem_package_tar_output.rb +104 -0
  137. data/test/test_gem_package_tar_output.rbc +0 -0
  138. data/test/test_gem_package_tar_reader.rb +53 -0
  139. data/test/test_gem_package_tar_reader.rbc +0 -0
  140. data/test/test_gem_package_tar_reader_entry.rb +116 -0
  141. data/test/test_gem_package_tar_reader_entry.rbc +0 -0
  142. data/test/test_gem_package_tar_writer.rb +151 -0
  143. data/test/test_gem_package_tar_writer.rbc +0 -0
  144. data/test/test_gem_platform.rbc +0 -0
  145. data/test/test_gem_remote_fetcher.rb +189 -17
  146. data/test/test_gem_remote_fetcher.rbc +0 -0
  147. data/test/test_gem_requirement.rbc +0 -0
  148. data/test/test_gem_server.rb +13 -12
  149. data/test/test_gem_server.rbc +0 -0
  150. data/test/test_gem_source_index.rb +305 -56
  151. data/test/test_gem_source_index.rbc +0 -0
  152. data/test/test_gem_source_info_cache.rb +179 -53
  153. data/test/test_gem_source_info_cache.rbc +0 -0
  154. data/test/test_gem_source_info_cache_entry.rb +41 -10
  155. data/test/test_gem_source_info_cache_entry.rbc +0 -0
  156. data/test/test_gem_specification.rb +7 -7
  157. data/test/test_gem_specification.rbc +0 -0
  158. data/test/test_gem_stream_ui.rbc +0 -0
  159. data/test/test_gem_uninstaller.rb +43 -0
  160. data/test/test_gem_uninstaller.rbc +0 -0
  161. data/test/test_gem_validator.rbc +0 -0
  162. data/test/test_gem_version.rb +1 -1
  163. data/test/test_gem_version.rbc +0 -0
  164. data/test/test_gem_version_option.rbc +0 -0
  165. data/test/test_kernel.rb +1 -0
  166. data/test/test_kernel.rbc +0 -0
  167. metadata +85 -8
  168. metadata.gz.sig +0 -0
  169. data/lib/rubygems/gem_open_uri.rb +0 -7
  170. data/lib/rubygems/open-uri.rb +0 -773
  171. data/test/test_open_uri.rb +0 -13
  172. data/test/test_package.rb +0 -608
File without changes
File without changes
File without changes
File without changes
@@ -11,8 +11,15 @@ class Gem::DependencyError < Gem::Exception; end
11
11
 
12
12
  class Gem::DependencyRemovalException < Gem::Exception; end
13
13
 
14
+ ##
15
+ # Raised when attempting to uninstall a gem that isn't in GEM_HOME.
16
+
17
+ class Gem::GemNotInHomeException < Gem::Exception
18
+ attr_accessor :spec
19
+ end
20
+
14
21
  class Gem::DocumentError < Gem::Exception; end
15
-
22
+
16
23
  ##
17
24
  # Potentially raised when a specification is validated.
18
25
  class Gem::EndOfYAMLException < Gem::Exception; end
@@ -61,3 +68,17 @@ class Gem::RemoteSourceException < Gem::Exception; end
61
68
 
62
69
  class Gem::VerificationError < Gem::Exception; end
63
70
 
71
+ ##
72
+ # Raised to indicate that a system exit should occur with the specified
73
+ # exit_code
74
+
75
+ class Gem::SystemExitException < SystemExit
76
+ attr_accessor :exit_code
77
+
78
+ def initialize(exit_code)
79
+ @exit_code = exit_code
80
+
81
+ super "Exiting RubyGems with exit_code #{exit_code}"
82
+ end
83
+
84
+ end
@@ -43,15 +43,12 @@ module Gem
43
43
 
44
44
  # check for old version gem
45
45
  if File.read(file_path, 20).include?("MD5SUM =")
46
- #alert_warning "Gem #{file_path} is in old format."
47
46
  require 'rubygems/old_format'
47
+
48
48
  format = OldFormat.from_file_by_path(file_path)
49
49
  else
50
- begin
51
- f = File.open(file_path, 'rb')
52
- format = from_io(f, file_path, security_policy)
53
- ensure
54
- f.close unless f.closed?
50
+ open file_path, Gem.binary_mode do |io|
51
+ format = from_io io, file_path, security_policy
55
52
  end
56
53
  end
57
54
 
@@ -65,15 +62,24 @@ module Gem
65
62
  # io:: [IO] Stream from which to read the gem
66
63
  #
67
64
  def self.from_io(io, gem_path="(io)", security_policy = nil)
68
- format = self.new(gem_path)
69
- Package.open_from_io(io, 'r', security_policy) do |pkg|
65
+ format = new gem_path
66
+
67
+ Package.open io, 'r', security_policy do |pkg|
70
68
  format.spec = pkg.metadata
71
69
  format.file_entries = []
70
+
72
71
  pkg.each do |entry|
73
- format.file_entries << [{"size" => entry.size, "mode" => entry.mode,
74
- "path" => entry.full_name}, entry.read]
72
+ size = entry.header.size
73
+ mode = entry.header.mode
74
+
75
+ format.file_entries << [{
76
+ "size" => size, "mode" => mode, "path" => entry.full_name,
77
+ },
78
+ entry.read
79
+ ]
75
80
  end
76
81
  end
82
+
77
83
  format
78
84
  end
79
85
 
@@ -11,6 +11,7 @@ end
11
11
 
12
12
  ##
13
13
  # Top level class for building the gem repository index.
14
+
14
15
  class Gem::Indexer
15
16
 
16
17
  include Gem::UserInteraction
@@ -25,7 +26,9 @@ class Gem::Indexer
25
26
 
26
27
  attr_reader :directory
27
28
 
29
+ ##
28
30
  # Create an indexer that will index the gems in +directory+.
31
+
29
32
  def initialize(directory)
30
33
  unless ''.respond_to? :to_xs then
31
34
  fail "Gem::Indexer requires that the XML Builder library be installed:" \
@@ -39,52 +42,60 @@ class Gem::Indexer
39
42
 
40
43
  @master_index = Gem::Indexer::MasterIndexBuilder.new "yaml", @directory
41
44
  @marshal_index = Gem::Indexer::MarshalIndexBuilder.new marshal_name, @directory
42
- @quick_index = Gem::Indexer::QuickIndexBuilder.new "index", @directory
45
+ @quick_index = Gem::Indexer::QuickIndexBuilder.new 'index', @directory
46
+
47
+ quick_dir = File.join @directory, 'quick'
48
+ @latest_index = Gem::Indexer::LatestIndexBuilder.new 'latest_index', quick_dir
43
49
  end
44
50
 
51
+ ##
45
52
  # Build the index.
53
+
46
54
  def build_index
47
55
  @master_index.build do
48
56
  @quick_index.build do
49
57
  @marshal_index.build do
50
- progress = ui.progress_reporter gem_file_list.size,
58
+ @latest_index.build do
59
+ progress = ui.progress_reporter gem_file_list.size,
51
60
  "Generating index for #{gem_file_list.size} gems in #{@dest_directory}",
52
61
  "Loaded all gems"
53
62
 
54
- gem_file_list.each do |gemfile|
55
- if File.size(gemfile.to_s) == 0 then
56
- alert_warning "Skipping zero-length gem: #{gemfile}"
57
- next
58
- end
59
-
60
- begin
61
- spec = Gem::Format.from_file_by_path(gemfile).spec
62
-
63
- unless gemfile =~ /\/#{Regexp.escape spec.original_name}.*\.gem\z/i then
64
- alert_warning "Skipping misnamed gem: #{gemfile} => #{spec.full_name} (#{spec.original_name})"
63
+ gem_file_list.each do |gemfile|
64
+ if File.size(gemfile.to_s) == 0 then
65
+ alert_warning "Skipping zero-length gem: #{gemfile}"
65
66
  next
66
67
  end
67
68
 
68
- abbreviate spec
69
- sanitize spec
69
+ begin
70
+ spec = Gem::Format.from_file_by_path(gemfile).spec
70
71
 
71
- @master_index.add spec
72
- @quick_index.add spec
73
- @marshal_index.add spec
72
+ unless gemfile =~ /\/#{Regexp.escape spec.original_name}.*\.gem\z/i then
73
+ alert_warning "Skipping misnamed gem: #{gemfile} => #{spec.full_name} (#{spec.original_name})"
74
+ next
75
+ end
74
76
 
75
- progress.updated spec.original_name
77
+ abbreviate spec
78
+ sanitize spec
76
79
 
77
- rescue SignalException => e
78
- alert_error "Recieved signal, exiting"
79
- raise
80
- rescue Exception => e
81
- alert_error "Unable to process #{gemfile}\n#{e.message} (#{e.class})\n\t#{e.backtrace.join "\n\t"}"
82
- end
83
- end
80
+ @master_index.add spec
81
+ @quick_index.add spec
82
+ @marshal_index.add spec
83
+ @latest_index.add spec
84
+
85
+ progress.updated spec.original_name
84
86
 
85
- progress.done
87
+ rescue SignalException => e
88
+ alert_error "Recieved signal, exiting"
89
+ raise
90
+ rescue Exception => e
91
+ alert_error "Unable to process #{gemfile}\n#{e.message} (#{e.class})\n\t#{e.backtrace.join "\n\t"}"
92
+ end
93
+ end
94
+
95
+ progress.done
86
96
 
87
- say "Generating master indexes (this may take a while)"
97
+ say "Generating master indexes (this may take a while)"
98
+ end
88
99
  end
89
100
  end
90
101
  end
@@ -95,14 +106,15 @@ class Gem::Indexer
95
106
 
96
107
  say "Moving index into production dir #{@dest_directory}" if verbose
97
108
 
98
- files = @master_index.files + @quick_index.files + @marshal_index.files
109
+ files = @master_index.files + @quick_index.files + @marshal_index.files +
110
+ @latest_index.files
99
111
 
100
112
  files.each do |file|
101
- relative_name = file[/\A#{Regexp.escape @directory}.(.*)/, 1]
102
- dest_name = File.join @dest_directory, relative_name
113
+ src_name = File.join @directory, file
114
+ dst_name = File.join @dest_directory, file
103
115
 
104
- FileUtils.rm_rf dest_name, :verbose => verbose
105
- FileUtils.mv file, @dest_directory, :verbose => verbose
116
+ FileUtils.rm_rf dst_name, :verbose => verbose
117
+ FileUtils.mv src_name, @dest_directory, :verbose => verbose
106
118
  end
107
119
  end
108
120
 
@@ -160,4 +172,5 @@ require 'rubygems/indexer/abstract_index_builder'
160
172
  require 'rubygems/indexer/master_index_builder'
161
173
  require 'rubygems/indexer/quick_index_builder'
162
174
  require 'rubygems/indexer/marshal_index_builder'
175
+ require 'rubygems/indexer/latest_index_builder'
163
176
 
@@ -22,16 +22,18 @@ class Gem::Indexer::AbstractIndexBuilder
22
22
  @files = []
23
23
  end
24
24
 
25
+ ##
25
26
  # Build a Gem index. Yields to block to handle the details of the
26
27
  # actual building. Calls +begin_index+, +end_index+ and +cleanup+ at
27
28
  # appropriate times to customize basic operations.
29
+
28
30
  def build
29
31
  FileUtils.mkdir_p @directory unless File.exist? @directory
30
32
  raise "not a directory: #{@directory}" unless File.directory? @directory
31
33
 
32
34
  file_path = File.join @directory, @filename
33
35
 
34
- @files << file_path
36
+ @files << @filename
35
37
 
36
38
  File.open file_path, "wb" do |file|
37
39
  @file = file
@@ -39,14 +41,20 @@ class Gem::Indexer::AbstractIndexBuilder
39
41
  yield
40
42
  end_index
41
43
  end
44
+
42
45
  cleanup
43
46
  ensure
44
47
  @file = nil
45
48
  end
46
49
 
50
+ ##
47
51
  # Compress the given file.
52
+
48
53
  def compress(filename, ext="rz")
49
- zipped = zip(File.open(filename, 'rb'){ |fp| fp.read })
54
+ data = open filename, 'rb' do |fp| fp.read end
55
+
56
+ zipped = zip data
57
+
50
58
  File.open "#{filename}.#{ext}", "wb" do |file|
51
59
  file.write zipped
52
60
  end
@@ -0,0 +1,35 @@
1
+ require 'rubygems/indexer'
2
+
3
+ ##
4
+ # Construct the latest Gem index file.
5
+
6
+ class Gem::Indexer::LatestIndexBuilder < Gem::Indexer::AbstractIndexBuilder
7
+
8
+ def start_index
9
+ super
10
+
11
+ @index = Gem::SourceIndex.new
12
+ end
13
+
14
+ def end_index
15
+ super
16
+
17
+ latest = @index.latest_specs.sort.map { |spec| spec.original_name }
18
+
19
+ @file.write latest.join("\n")
20
+ end
21
+
22
+ def cleanup
23
+ super
24
+
25
+ compress @file.path
26
+
27
+ @files.delete 'latest_index' # HACK installed via QuickIndexBuilder :/
28
+ end
29
+
30
+ def add(spec)
31
+ @index.add_spec(spec)
32
+ end
33
+
34
+ end
35
+
@@ -1,6 +1,8 @@
1
1
  require 'rubygems/indexer'
2
2
 
3
+ ##
3
4
  # Construct the master Gem index file.
5
+
4
6
  class Gem::Indexer::MasterIndexBuilder < Gem::Indexer::AbstractIndexBuilder
5
7
 
6
8
  def start_index
@@ -10,6 +12,7 @@ class Gem::Indexer::MasterIndexBuilder < Gem::Indexer::AbstractIndexBuilder
10
12
 
11
13
  def end_index
12
14
  super
15
+
13
16
  @file.puts "--- !ruby/object:#{@index.class}"
14
17
  @file.puts "gems:"
15
18
 
@@ -28,11 +31,9 @@ class Gem::Indexer::MasterIndexBuilder < Gem::Indexer::AbstractIndexBuilder
28
31
  index_file_name = File.join @directory, @filename
29
32
 
30
33
  compress index_file_name, "Z"
31
- compressed_file_name = "#{index_file_name}.Z"
32
-
33
- paranoid index_file_name, compressed_file_name
34
+ paranoid index_file_name, "#{index_file_name}.Z"
34
35
 
35
- @files << compressed_file_name
36
+ @files << "#{@filename}.Z"
36
37
  end
37
38
 
38
39
  def add(spec)
@@ -41,12 +42,12 @@ class Gem::Indexer::MasterIndexBuilder < Gem::Indexer::AbstractIndexBuilder
41
42
 
42
43
  private
43
44
 
44
- def paranoid(fn, compressed_fn)
45
- data = File.open(fn, 'rb') do |fp| fp.read end
46
- compressed_data = File.open(compressed_fn, 'rb') do |fp| fp.read end
45
+ def paranoid(path, compressed_path)
46
+ data = Gem.read_binary path
47
+ compressed_data = Gem.read_binary compressed_path
47
48
 
48
49
  if data != unzip(compressed_data) then
49
- fail "Compressed file #{compressed_fn} does not match uncompressed file #{fn}"
50
+ raise "Compressed file #{compressed_path} does not match uncompressed file #{path}"
50
51
  end
51
52
  end
52
53
 
@@ -1,7 +1,9 @@
1
1
  require 'rubygems/indexer'
2
2
 
3
+ ##
3
4
  # Construct a quick index file and all of the individual specs to support
4
5
  # incremental loading.
6
+
5
7
  class Gem::Indexer::QuickIndexBuilder < Gem::Indexer::AbstractIndexBuilder
6
8
 
7
9
  def initialize(filename, directory)
@@ -13,12 +15,12 @@ class Gem::Indexer::QuickIndexBuilder < Gem::Indexer::AbstractIndexBuilder
13
15
  def cleanup
14
16
  super
15
17
 
16
- quick_index_file = File.join(@directory, @filename)
18
+ quick_index_file = File.join @directory, @filename
17
19
  compress quick_index_file
18
20
 
19
21
  # the complete quick index is in a directory, so move it as a whole
20
- @files.delete quick_index_file
21
- @files << @directory
22
+ @files.delete 'index'
23
+ @files << 'quick'
22
24
  end
23
25
 
24
26
  def add(spec)
@@ -25,6 +25,12 @@ module Gem::InstallUpdateOptions
25
25
  options[:install_dir] = File.expand_path(value)
26
26
  end
27
27
 
28
+ add_option(:"Install/Update", '-n', '--bindir DIR',
29
+ 'Directory where binary files are',
30
+ 'located') do |value, options|
31
+ options[:bin_dir] = File.expand_path(value)
32
+ end
33
+
28
34
  add_option(:"Install/Update", '-d', '--[no-]rdoc',
29
35
  'Generate RDoc documentation for the gem on',
30
36
  'install') do |value, options|
@@ -37,7 +43,7 @@ module Gem::InstallUpdateOptions
37
43
  options[:generate_ri] = value
38
44
  end
39
45
 
40
- add_option(:"Install/Update", '-E', '--env-shebang',
46
+ add_option(:"Install/Update", '-E', '--[no-]env-shebang',
41
47
  "Rewrite the shebang line on installed",
42
48
  "scripts to use /usr/bin/env") do |value, options|
43
49
  options[:env_shebang] = value
@@ -63,6 +63,8 @@ class Gem::Installer
63
63
  :force => false,
64
64
  :install_dir => Gem.dir,
65
65
  :exec_format => false,
66
+ :env_shebang => false,
67
+ :bin_dir => nil
66
68
  }.merge options
67
69
 
68
70
  @env_shebang = options[:env_shebang]
@@ -73,6 +75,7 @@ class Gem::Installer
73
75
  @format_executable = options[:format_executable]
74
76
  @security_policy = options[:security_policy]
75
77
  @wrappers = options[:wrappers]
78
+ @bin_dir = options[:bin_dir]
76
79
 
77
80
  begin
78
81
  @format = Gem::Format.from_file_by_path @gem, @security_policy
@@ -103,7 +106,7 @@ class Gem::Installer
103
106
 
104
107
  unless @force then
105
108
  if rrv = @spec.required_ruby_version then
106
- unless rrv.satisfied_by? Gem::Version.new(RUBY_VERSION) then
109
+ unless rrv.satisfied_by? Gem.ruby_version then
107
110
  raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}"
108
111
  end
109
112
  end
@@ -224,7 +227,7 @@ class Gem::Installer
224
227
  # If the user has asked for the gem to be installed in a directory that is
225
228
  # the system gem directory, then use the system bin directory, else create
226
229
  # (or use) a new bin dir under the gem_home.
227
- bindir = Gem.bindir @gem_home
230
+ bindir = @bin_dir ? @bin_dir : (Gem.bindir @gem_home)
228
231
 
229
232
  Dir.mkdir bindir unless File.exist? bindir
230
233
  raise Gem::FilePermissionError.new(bindir) unless File.writable? bindir
@@ -302,7 +305,7 @@ class Gem::Installer
302
305
  # necessary.
303
306
  def shebang(bin_file_name)
304
307
  if @env_shebang then
305
- "#!/usr/bin/env ruby"
308
+ "#!/usr/bin/env " + Gem::ConfigMap[:ruby_install_name]
306
309
  else
307
310
  path = File.join @gem_dir, @spec.bindir, bin_file_name
308
311
 
@@ -351,10 +354,10 @@ TEXT
351
354
  <<-TEXT
352
355
  @ECHO OFF
353
356
  IF NOT "%~f0" == "~f0" GOTO :WinNT
354
- @"#{Gem.ruby}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
357
+ @"#{File.basename(Gem.ruby)}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
355
358
  GOTO :EOF
356
359
  :WinNT
357
- "%~dp0ruby.exe" "%~dpn0" %*
360
+ @"#{File.basename(Gem.ruby)}" "%~dpn0" %*
358
361
  TEXT
359
362
  end
360
363