slimgems 1.3.9.1 → 1.3.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,9 @@ gem_disabled = !defined? Gem
7
7
 
8
8
  unless gem_disabled
9
9
  # Nuke the Quickloader stuff
10
- Gem::QuickLoader.remove if defined?(Gem::QuickLoader)
10
+ if defined?(Gem::QuickLoader) && Gem::QuickLoader.respond_to?(:remove)
11
+ Gem::QuickLoader.remove
12
+ end
11
13
  end
12
14
 
13
15
  require 'rubygems/defaults'
@@ -104,7 +106,7 @@ require 'thread'
104
106
  module Gem
105
107
  NAME = 'SlimGems'
106
108
  GEM_NAME = 'slimgems'
107
- VERSION = '1.3.9.1'
109
+ VERSION = '1.3.9.2'
108
110
  SlimGemsVersion = RubyGemsVersion = VERSION
109
111
 
110
112
  ##
@@ -36,7 +36,22 @@ module Kernel
36
36
 
37
37
  raise load_error
38
38
  end
39
+
40
+ if RUBY_VERSION < '1.8.7'
41
+ undef require
42
+ def require(path)
43
+ gem_original_require path
44
+ rescue LoadError => load_error
45
+ if load_error.message.rindex(path) == load_error.message.size - path.size
46
+ if Gem.try_activate(path)
47
+ return gem_original_require(path)
48
+ end
49
+ end
39
50
 
51
+ raise load_error
52
+ end
53
+ end
54
+
40
55
  private :require
41
56
  private :gem_original_require
42
57
 
@@ -347,6 +347,17 @@ class Gem::Installer
347
347
  ##
348
348
  # Generates a #! line for +bin_file_name+'s wrapper copying arguments if
349
349
  # necessary.
350
+ #
351
+ # If the :custom_shebang config is set, then it is used as a template
352
+ # for how to create the shebang used for to run a gem's executables.
353
+ #
354
+ # The template supports 4 expansions:
355
+ #
356
+ # $env the path to the unix env utility
357
+ # $ruby the path to the currently running ruby interpreter
358
+ # $exec the path to the gem's executable
359
+ # $name the name of the gem the executable is for
360
+ #
350
361
 
351
362
  def shebang(bin_file_name)
352
363
  ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
@@ -360,6 +371,25 @@ class Gem::Installer
360
371
  shebang.strip! # Avoid nasty ^M issues.
361
372
  end
362
373
 
374
+ if which = Gem.configuration[:custom_shebang]
375
+ which = which.gsub(/\$(\w+)/) do
376
+ case $1
377
+ when "env"
378
+ @env_path ||= ENV_PATHS.find do |env_path|
379
+ File.executable? env_path
380
+ end
381
+ when "ruby"
382
+ "#{Gem.ruby}#{opts}"
383
+ when "exec"
384
+ bin_file_name
385
+ when "name"
386
+ spec.name
387
+ end
388
+ end
389
+
390
+ return "#!#{which}"
391
+ end
392
+
363
393
  if not ruby_name then
364
394
  "#!#{Gem.ruby}#{opts}"
365
395
  elsif opts then
@@ -2,6 +2,16 @@ require File.expand_path('../gem_installer_test_case', __FILE__)
2
2
 
3
3
  class TestGemInstaller < GemInstallerTestCase
4
4
 
5
+ def setup
6
+ super
7
+ @config = Gem.configuration
8
+ end
9
+
10
+ def teardown
11
+ super
12
+ Gem.configuration = @config
13
+ end
14
+
5
15
  def test_app_script_text
6
16
  util_make_exec '2', ''
7
17
 
@@ -817,6 +827,45 @@ load Gem.bin_path('a', 'my_exec', version)
817
827
  assert_equal "#!#{Gem.ruby} -ws", shebang
818
828
  end
819
829
 
830
+ def test_shebang_custom
831
+ conf = Gem::ConfigFile.new []
832
+ conf[:custom_shebang] = 'test'
833
+
834
+ Gem.configuration = conf
835
+
836
+ util_make_exec '2', "#!/usr/bin/ruby"
837
+
838
+ shebang = @installer.shebang 'my_exec'
839
+
840
+ assert_equal "#!test", shebang
841
+ end
842
+
843
+ def test_shebang_custom_with_expands
844
+ conf = Gem::ConfigFile.new []
845
+ conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec 4 $name'
846
+
847
+ Gem.configuration = conf
848
+
849
+ util_make_exec '2', "#!/usr/bin/ruby"
850
+
851
+ shebang = @installer.shebang 'my_exec'
852
+
853
+ assert_equal "#!1 /usr/bin/env 2 #{Gem.ruby} 3 my_exec 4 a", shebang
854
+ end
855
+
856
+ def test_shebang_custom_with_expands_and_arguments
857
+ conf = Gem::ConfigFile.new []
858
+ conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec'
859
+
860
+ Gem.configuration = conf
861
+
862
+ util_make_exec '2', "#!/usr/bin/ruby -ws"
863
+
864
+ shebang = @installer.shebang 'my_exec'
865
+
866
+ assert_equal "#!1 /usr/bin/env 2 #{Gem.ruby} -ws 3 my_exec", shebang
867
+ end
868
+
820
869
  def test_unpack
821
870
  util_setup_gem
822
871
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: slimgems
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.3.9.1
5
+ version: 1.3.9.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jim Weirich
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-06-03 00:00:00 -04:00
16
+ date: 2011-06-14 00:00:00 -04:00
17
17
  default_executable:
18
18
  dependencies: []
19
19
 
@@ -223,7 +223,7 @@ has_rdoc: true
223
223
  homepage: http://slimgems.github.com
224
224
  licenses: []
225
225
 
226
- post_install_message: "Upgraded from RubyGems to SlimGems 1.3.9.1\n\
226
+ post_install_message: "Upgraded from RubyGems to SlimGems 1.3.9.2\n\
227
227
  \xEF\xBB\xBF=== 1.3.9.1 / 2011-06-03\n\n\
228
228
  SlimGems is a drop-in replacement for RubyGems. See README.md for more.\n\n\
229
229
  * Fixes slimgems getting uninstalled when `gem uninstall GEM` is called.\n\n"
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  requirements: []
247
247
 
248
248
  rubyforge_project:
249
- rubygems_version: 1.3.9.1
249
+ rubygems_version: 1.3.9.2
250
250
  signing_key:
251
251
  specification_version: 3
252
252
  summary: SlimGems is a package management framework for Ruby