Skip to content

Commit

Permalink
added bundler_wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Jun 12, 2011
1 parent da057e8 commit 62a5f9f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 33 deletions.
25 changes: 10 additions & 15 deletions README.md
Expand Up @@ -6,33 +6,31 @@ generated by rubygems aware of bundler.
# Installation

gem install rubygems-bundler
gem regenerate_binstubs [-V]

And follow the on screen instructions

# Description

This gem is intended to fill in the integration gap between
Bundler and Rubygems
Bundler and Rubygems, it also backoports shebang customization
from rubygems 1.9 to older versions - down to 1.3.7.

With this gem rubygems generated wrappers will allow to
use bundler when asked for.

Using this gem solves problem of calling `bundle exec ...`
with your every command.

<h3 style="color: red; letter-spacing: 3px;">NOTE</h3>

Please note that method introduced by this gem is not approved
by rubygems neither bundler teams becouse of the following problem:

Beware, it is important you understand that this gem can make
your gem executables load in versions specified in Gemfile!
Please note that this gem can make your gem executables
load in versions specified in Gemfile!

The problem with Gemfile is that you can have few of them,
so expect that gem version for executable will be taken from
`~/Gemfile` when your project is in `~/projects/my_project`
and does not contain `Gemfile`

Last note is that bundler handling can be used only when bundler is installed.
Last note is that bundler handling can be used only when bundler is
installed, but you will be warned when it is

# Controlling the wrapper

Expand All @@ -47,7 +45,7 @@ To force usage of bundler:

export USE_BUNDLER=force

To make your choice persistent put this into `~/.rvmrc` or `~/.bashrc`.
To make your choice persistent put this into `~/.bashrc` or `~/.rvmrc`.

# How it works

Expand All @@ -56,10 +54,7 @@ aware wrapper:

gem install rubygems-bundler

To make gems already installed aware of bundler call the following command,
it will detect gems with executables and regenerate those executables:

gem regenerate_binstubs [-V]
Follow onscreen instructions.

Now for running haml can be controlled if it will using bundler code or not:

Expand Down
17 changes: 17 additions & 0 deletions bin/bundler_wrapper
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby

require 'rubygems'

use_bundler = (ENV['USE_BUNDLER']||'').downcase
try_bundler = %w{try check possibly}.include? use_bundler
force_bundler = %w{force require yes true on}.include? use_bundler

if try_bundler || force_bundler
begin
require 'bundler/setup'
rescue LoadError
raise "\n\nPlease 'gem install bundler' first.\n\n" if force_bundler
end
end

eval File.read(ARGV[0])
16 changes: 16 additions & 0 deletions ext/wrapper_installer/extconf.rb
@@ -0,0 +1,16 @@
# Fake building extension
File.open('Makefile', 'w') { |f| f.write "all:\n\ninstall:\n\n" }
File.open('make', 'w') do |f|
f.write '#!/bin/sh'
f.chmod f.stat.mode | 0111
end
File.open('wrapper_installer.so', 'w') {}
File.open('wrapper_installer.dll', 'w') {}
File.open('nmake.bat', 'w') { |f| }

# Copy wrapper
require 'fileutils'
wrapper=File.expand_path('../../../bin/bundler_wrapper',File.absolute_path(__FILE__))
destination=File.expand_path('bin/bundler_wrapper',Gem.dir)
FileUtils.cp(wrapper, destination, :verbose => true)
File.chmod(0755, destination)
2 changes: 1 addition & 1 deletion lib/rubygems_bundler/rubygems_bundler_installer.rb
Expand Up @@ -26,7 +26,7 @@ def self.shebang(inst, bin_file_name)
ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
path = inst.spec.bin_file bin_file_name
first_line = File.open(path, "rb") {|file| file.gets}
@@env_path ||= inst::ENV_PATHS.find {|env_path| File.executable? env_path }
@@env_path ||= Gem::Installer::ENV_PATHS.find {|env_path| File.executable? env_path }

if /\A#!/ =~ first_line then
# Preserve extra words on shebang line, like "-w". Thanks RPA.
Expand Down
38 changes: 21 additions & 17 deletions rubygems-bundler.gemspec
@@ -1,29 +1,33 @@
Gem::Specification.new do |s|
s.name = "rubygems-bundler"
s.version = "0.1.5"
s.date = "2011-06-08"
s.version = "0.2.0"
s.date = "2011-06-12"
s.summary = "Make rubygems generate bundler aware executable wrappers"
s.email = "mpapis@gmail.com"
s.homepage = "https://github.com/mpapis/rubygems-bundler"
s.description = "Integrate Rubygems, Bundler and RVM"
s.description = "Integrate Rubygems and Bundler"
s.has_rdoc = false
s.authors = ["Michal Papis"]
s.files = [
"lib/rubygems_bundler/regenerate_binstubs_command.rb",
"lib/rubygems_bundler/rubygems_bundler_installer.rb",
"lib/rubygems_bundler/fix_wrapper.rb",
"lib/rubygems_plugin.rb",
"README.md",
"rubygems-bundler.gemspec",
"LICENSE",
]
"bin/bundler_wrapper",
"ext/wrapper_installer/extconf.rb",
"lib/rubygems_bundler/regenerate_binstubs_command.rb",
"lib/rubygems_bundler/rubygems_bundler_installer.rb",
"lib/rubygems_bundler/fix_wrapper.rb",
"lib/rubygems_plugin.rb",
"LICENSE",
"README.md",
"rubygems-bundler.gemspec",
]
s.extensions = ["ext/wrapper_installer/extconf.rb"]
s.post_install_message = <<-TEXT
========================================================================
===============================================================================
Thanks for installing rubygems-bundler!
rubygems-bundler allows running gem executables in Gemfile specified versions!
It is important you understand that this gem can make your gem
executables load in versions specified in Gemfile!
First step is to add following line to ~/.gemrc
custom_shebang: $env bundler_wrapper
To make all the executables bundler compatible run:
Expand All @@ -33,14 +37,14 @@ To always use bundler add the following line to ~/.rvmrc or ~/.bashrc
export USE_BUNDLER=force
now relogin or call in every open shell:
Relogin or call in every open shell:
export USE_BUNDLER=force
For more information read:
https://github.com/mpapis/rubygems-bundler
========================================================================
===============================================================================
TEXT
end

0 comments on commit 62a5f9f

Please sign in to comment.