rubygems-bundler 0.1.5 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,12 +6,14 @@ generated by rubygems aware of bundler.
6
6
  # Installation
7
7
 
8
8
  gem install rubygems-bundler
9
- gem regenerate_binstubs [-V]
9
+
10
+ And follow the on screen instructions
10
11
 
11
12
  # Description
12
13
 
13
14
  This gem is intended to fill in the integration gap between
14
- Bundler and Rubygems
15
+ Bundler and Rubygems, it also backoports shebang customization
16
+ from rubygems 1.9 to older versions - down to 1.3.7.
15
17
 
16
18
  With this gem rubygems generated wrappers will allow to
17
19
  use bundler when asked for.
@@ -19,20 +21,16 @@ use bundler when asked for.
19
21
  Using this gem solves problem of calling `bundle exec ...`
20
22
  with your every command.
21
23
 
22
- <h3 style="color: red; letter-spacing: 3px;">NOTE</h3>
23
-
24
- Please note that method introduced by this gem is not approved
25
- by rubygems neither bundler teams becouse of the following problem:
26
-
27
- Beware, it is important you understand that this gem can make
28
- your gem executables load in versions specified in Gemfile!
24
+ Please note that this gem can make your gem executables
25
+ load in versions specified in Gemfile!
29
26
 
30
27
  The problem with Gemfile is that you can have few of them,
31
28
  so expect that gem version for executable will be taken from
32
29
  `~/Gemfile` when your project is in `~/projects/my_project`
33
30
  and does not contain `Gemfile`
34
31
 
35
- Last note is that bundler handling can be used only when bundler is installed.
32
+ Last note is that bundler handling can be used only when bundler is
33
+ installed, but you will be warned when it is
36
34
 
37
35
  # Controlling the wrapper
38
36
 
@@ -47,7 +45,7 @@ To force usage of bundler:
47
45
 
48
46
  export USE_BUNDLER=force
49
47
 
50
- To make your choice persistent put this into `~/.rvmrc` or `~/.bashrc`.
48
+ To make your choice persistent put this into `~/.bashrc` or `~/.rvmrc`.
51
49
 
52
50
  # How it works
53
51
 
@@ -56,10 +54,7 @@ aware wrapper:
56
54
 
57
55
  gem install rubygems-bundler
58
56
 
59
- To make gems already installed aware of bundler call the following command,
60
- it will detect gems with executables and regenerate those executables:
61
-
62
- gem regenerate_binstubs [-V]
57
+ Follow onscreen instructions.
63
58
 
64
59
  Now for running haml can be controlled if it will using bundler code or not:
65
60
 
@@ -96,3 +91,4 @@ Now for running haml can be controlled if it will using bundler code or not:
96
91
  - Wayne E. Seguin : support in writing good code
97
92
  - Evan Phoenix : support on rubygems internalls
98
93
  - Andre Arko : claryfications how rubygems/bundler works
94
+ - Loren Segal : shebang customization idea and explanations
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ use_bundler = (ENV['USE_BUNDLER']||'').downcase
6
+ try_bundler = %w{try check possibly}.include? use_bundler
7
+ force_bundler = %w{force require yes true on}.include? use_bundler
8
+
9
+ if try_bundler || force_bundler
10
+ begin
11
+ require 'bundler/setup'
12
+ rescue LoadError
13
+ raise "\n\nPlease 'gem install bundler' first.\n\n" if force_bundler
14
+ end
15
+ end
16
+
17
+ file=ARGV.shift
18
+ eval File.read(file)
@@ -0,0 +1,18 @@
1
+ # Fake building extension
2
+ File.open('Makefile', 'w') { |f| f.write "all:\n\ninstall:\n\n" }
3
+ File.open('make', 'w') do |f|
4
+ f.write '#!/bin/sh'
5
+ f.chmod f.stat.mode | 0111
6
+ end
7
+ File.open('wrapper_installer.so', 'w') {}
8
+ File.open('wrapper_installer.dll', 'w') {}
9
+ File.open('nmake.bat', 'w') { |f| }
10
+
11
+ # Copy wrapper
12
+ require 'fileutils'
13
+ require 'rubygems'
14
+ wrapper=File.expand_path('../../bin/bundler_wrapper', Dir.getwd)
15
+ destination=File.expand_path('bin/bundler_wrapper', Gem.dir)
16
+ FileUtils.mkdir_p(File.join(Gem.dir, 'bin'), :verbose => true)
17
+ FileUtils.cp(wrapper, destination, :verbose => true)
18
+ File.chmod(0755, destination)
@@ -36,14 +36,10 @@ class RegenerateBinstubsCommand < Gem::Command
36
36
  cache_gem = File.join(org_gem_path, 'cache', spec.file_name)
37
37
  if File.exist? cache_gem
38
38
  puts "#{spec.name} #{spec.version}"
39
- inst = Gem::Installer.new Dir[cache_gem].first, :wrappers => true, :force => true
40
- org_gem_path = File.join org_gem_path, 'gems'
41
- inst.spec.instance_variable_set :@gems_dir, org_gem_path
42
- inst.spec.instance_variable_set :@gem_dir, nil
43
- inst.spec.loaded_from = org_gem_path
39
+ inst = Gem::Installer.new Dir[cache_gem].first, :wrappers => true, :force => true, :install_dir => org_gem_path
44
40
  RubyGemsBundlerInstaller.bundler_generate_bin(inst)
45
41
  else
46
- puts "##{spec.name} #{spec.version} not found in GEM_HOME"
42
+ puts "##{spec.name} #{spec.version} not found in GEM_PATH"
47
43
  end
48
44
  end
49
45
  end
@@ -56,8 +52,5 @@ class RegenerateBinstubsCommand < Gem::Command
56
52
  else
57
53
  Gem.source_index.map{|name,spec| spec}
58
54
  end
59
-
60
- Gem::VERSION > '1.8' ? Gem::Specification._all : Gem.source_index.map{|name,spec| spec}
61
-
62
55
  end
63
56
  end
@@ -6,7 +6,7 @@ module RubyGemsBundlerInstaller
6
6
  bindir = inst.bin_dir ? inst.bin_dir : Gem.bindir(inst.gem_home)
7
7
  inst.spec.executables.each do |filename|
8
8
  filename.untaint
9
- original = File.join inst.gem_dir, inst.spec.bindir, filename
9
+ original = File.join bindir, filename
10
10
  if File.exists?( original )
11
11
  bin_script_path = File.join bindir, inst.formatted_program_filename(filename)
12
12
  FileUtils.rm_f bin_script_path
@@ -21,12 +21,53 @@ module RubyGemsBundlerInstaller
21
21
  end
22
22
  end
23
23
 
24
+
25
+ def self.shebang(inst, bin_file_name)
26
+ ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
27
+ bindir = inst.bin_dir ? inst.bin_dir : Gem.bindir(inst.gem_home)
28
+ path = File.join bindir, inst.formatted_program_filename(bin_file_name)
29
+ first_line = File.open(path, "rb") {|file| file.gets}
30
+ @@env_path ||= Gem::Installer::ENV_PATHS.find {|env_path| File.executable? env_path }
31
+
32
+ if /\A#!/ =~ first_line then
33
+ # Preserve extra words on shebang line, like "-w". Thanks RPA.
34
+ shebang = first_line.sub(/\A\#!.*?ruby\S*(?=(\s+\S+))/, "#!#{Gem.ruby}")
35
+ opts = $1
36
+ shebang.strip! # Avoid nasty ^M issues.
37
+ end
38
+
39
+ if which = Gem.configuration[:custom_shebang]
40
+ which = which.gsub(/\$(\w+)/) do
41
+ case $1
42
+ when "env"
43
+ @@env_path
44
+ when "ruby"
45
+ "#{Gem.ruby}#{opts}"
46
+ when "exec"
47
+ bin_file_name
48
+ when "name"
49
+ inst.spec.name
50
+ end
51
+ end
52
+
53
+ return "#!#{which}"
54
+ end
55
+
56
+ if not ruby_name then
57
+ "#!#{Gem.ruby}#{opts}"
58
+ elsif inst.opts then
59
+ "#!/bin/sh\n'exec' #{ruby_name.dump} '-x' \"$0\" \"$@\"\n#{shebang}"
60
+ else
61
+ "#!#{@@env_path} #{ruby_name}"
62
+ end
63
+ end
64
+
24
65
  # Return the text for an application file.
25
66
  def self.bundler_app_script_text(inst, bin_file_name)
26
67
  <<-TEXT
27
- #{inst.shebang bin_file_name}
68
+ #{shebang inst, bin_file_name}
28
69
  #
29
- # This file was generated by RubyGems extended wrapper.
70
+ # This file was generated by RubyGems.
30
71
  #
31
72
  # The application '#{inst.spec.name}' is installed as part of a gem, and
32
73
  # this file is here to facilitate running it.
@@ -34,29 +75,14 @@ module RubyGemsBundlerInstaller
34
75
 
35
76
  require 'rubygems'
36
77
 
37
- use_bundler = (ENV['USE_BUNDLER']||'').downcase
38
-
39
- try_bundler = %w{try check possibly}.include? use_bundler
40
- force_bundler = %w{force require yes true on}.include? use_bundler
41
78
  version = "#{Gem::Requirement.default}"
42
79
 
43
- if try_bundler || force_bundler
44
- begin
45
- require 'bundler/setup'
46
- rescue LoadError
47
- raise '\n\nPlease \\\'gem install bundler\\\' first.\n\n' if force_bundler
48
- try_bundler = false
49
- end
50
- end
51
-
52
- unless try_bundler
53
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
54
- version = $1
55
- ARGV.shift
56
- end
57
- gem '#{inst.spec.name}', version
80
+ if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
81
+ version = $1
82
+ ARGV.shift
58
83
  end
59
84
 
85
+ gem '#{inst.spec.name}', version
60
86
  load Gem.bin_path('#{inst.spec.name}', '#{bin_file_name}', version)
61
87
  TEXT
62
88
  end
@@ -1,6 +1,8 @@
1
1
  require 'rubygems/command_manager'
2
2
  require 'rubygems_bundler/rubygems_bundler_installer'
3
- require 'rubygems_bundler/fix_wrapper'
4
3
  require 'rubygems_bundler/regenerate_binstubs_command'
4
+ if Gem::VERSION < '1.9' then
5
+ require 'rubygems_bundler/fix_wrapper'
6
+ end
5
7
 
6
- Gem::CommandManager.instance.register_command :regenerate_binstubs
8
+ Gem::CommandManager.instance.register_command :regenerate_binstubs
@@ -1,29 +1,33 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rubygems-bundler"
3
- s.version = "0.1.5"
4
- s.date = "2011-06-08"
3
+ s.version = "0.2.3"
4
+ s.date = "2011-06-13"
5
5
  s.summary = "Make rubygems generate bundler aware executable wrappers"
6
6
  s.email = "mpapis@gmail.com"
7
7
  s.homepage = "https://github.com/mpapis/rubygems-bundler"
8
- s.description = "Integrate Rubygems, Bundler and RVM"
8
+ s.description = "Integrate Rubygems and Bundler"
9
9
  s.has_rdoc = false
10
10
  s.authors = ["Michal Papis"]
11
11
  s.files = [
12
- "lib/rubygems_bundler/regenerate_binstubs_command.rb",
13
- "lib/rubygems_bundler/rubygems_bundler_installer.rb",
14
- "lib/rubygems_bundler/fix_wrapper.rb",
15
- "lib/rubygems_plugin.rb",
16
- "README.md",
17
- "rubygems-bundler.gemspec",
18
- "LICENSE",
19
- ]
12
+ "bin/bundler_wrapper",
13
+ "ext/wrapper_installer/extconf.rb",
14
+ "lib/rubygems_bundler/regenerate_binstubs_command.rb",
15
+ "lib/rubygems_bundler/rubygems_bundler_installer.rb",
16
+ "lib/rubygems_bundler/fix_wrapper.rb",
17
+ "lib/rubygems_plugin.rb",
18
+ "LICENSE",
19
+ "README.md",
20
+ "rubygems-bundler.gemspec",
21
+ ]
22
+ s.extensions = ["ext/wrapper_installer/extconf.rb"]
20
23
  s.post_install_message = <<-TEXT
21
- ========================================================================
24
+ ===============================================================================
22
25
 
23
- Thanks for installing rubygems-bundler!
26
+ rubygems-bundler allows running gem executables in Gemfile specified versions!
24
27
 
25
- It is important you understand that this gem can make your gem
26
- executables load in versions specified in Gemfile!
28
+ First step is to add following line to ~/.gemrc
29
+
30
+ custom_shebang: $env bundler_wrapper
27
31
 
28
32
  To make all the executables bundler compatible run:
29
33
 
@@ -33,7 +37,7 @@ To always use bundler add the following line to ~/.rvmrc or ~/.bashrc
33
37
 
34
38
  export USE_BUNDLER=force
35
39
 
36
- now relogin or call in every open shell:
40
+ Relogin or call in every open shell:
37
41
 
38
42
  export USE_BUNDLER=force
39
43
 
@@ -41,6 +45,6 @@ For more information read:
41
45
 
42
46
  https://github.com/mpapis/rubygems-bundler
43
47
 
44
- ========================================================================
48
+ ===============================================================================
45
49
  TEXT
46
50
  end
metadata CHANGED
@@ -1,57 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rubygems-bundler
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.5
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.2.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Michal Papis
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-08 00:00:00.000000000Z
12
+
13
+ date: 2011-06-13 00:00:00 Z
13
14
  dependencies: []
14
- description: Integrate Rubygems, Bundler and RVM
15
+
16
+ description: Integrate Rubygems and Bundler
15
17
  email: mpapis@gmail.com
16
18
  executables: []
17
- extensions: []
19
+
20
+ extensions:
21
+ - ext/wrapper_installer/extconf.rb
18
22
  extra_rdoc_files: []
19
- files:
23
+
24
+ files:
25
+ - bin/bundler_wrapper
26
+ - ext/wrapper_installer/extconf.rb
20
27
  - lib/rubygems_bundler/regenerate_binstubs_command.rb
21
28
  - lib/rubygems_bundler/rubygems_bundler_installer.rb
22
29
  - lib/rubygems_bundler/fix_wrapper.rb
23
30
  - lib/rubygems_plugin.rb
31
+ - LICENSE
24
32
  - README.md
25
33
  - rubygems-bundler.gemspec
26
- - LICENSE
27
34
  homepage: https://github.com/mpapis/rubygems-bundler
28
35
  licenses: []
29
- post_install_message: ! "========================================================================\n\nThanks
30
- for installing rubygems-bundler!\n\nIt is important you understand that this gem
31
- can make your gem \nexecutables load in versions specified in Gemfile!\n\nTo make
32
- all the executables bundler compatible run:\n\n gem regenerate_binstubs # only
33
- once\n\nTo always use bundler add the following line to ~/.rvmrc or ~/.bashrc\n\n
34
- \ export USE_BUNDLER=force\n\nnow relogin or call in every open shell:\n\n export
35
- USE_BUNDLER=force\n\nFor more information read:\n\n https://github.com/mpapis/rubygems-bundler\n\n========================================================================\n"
36
+
37
+ post_install_message: |
38
+ ===============================================================================
39
+
40
+ rubygems-bundler allows running gem executables in Gemfile specified versions!
41
+
42
+ First step is to add following line to ~/.gemrc
43
+
44
+ custom_shebang: $env bundler_wrapper
45
+
46
+ To make all the executables bundler compatible run:
47
+
48
+ gem regenerate_binstubs # only once
49
+
50
+ To always use bundler add the following line to ~/.rvmrc or ~/.bashrc
51
+
52
+ export USE_BUNDLER=force
53
+
54
+ Relogin or call in every open shell:
55
+
56
+ export USE_BUNDLER=force
57
+
58
+ For more information read:
59
+
60
+ https://github.com/mpapis/rubygems-bundler
61
+
62
+ ===============================================================================
63
+
36
64
  rdoc_options: []
37
- require_paths:
65
+
66
+ require_paths:
38
67
  - lib
39
- required_ruby_version: !ruby/object:Gem::Requirement
68
+ required_ruby_version: !ruby/object:Gem::Requirement
40
69
  none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
45
- required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
75
  none: false
47
- requirements:
48
- - - ! '>='
49
- - !ruby/object:Gem::Version
50
- version: '0'
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
51
80
  requirements: []
81
+
52
82
  rubyforge_project:
53
83
  rubygems_version: 1.8.5
54
84
  signing_key:
55
85
  specification_version: 3
56
86
  summary: Make rubygems generate bundler aware executable wrappers
57
87
  test_files: []
88
+