rubygems-bundler 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +14 -0
- data/README.md +98 -0
- data/lib/rubygems_bundler/fix_wrapper.rb +5 -0
- data/lib/rubygems_bundler/regenerate_binstubs_command.rb +63 -0
- data/lib/rubygems_bundler/rubygems_bundler_installer.rb +64 -0
- data/lib/rubygems_plugin.rb +6 -0
- data/rubygems-bundler.gemspec +46 -0
- metadata +57 -0
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (c) 2011 Michal Papis
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# About
|
2
|
+
|
3
|
+
Rubygems and Bundler integration, makes executable wrappers
|
4
|
+
generated by rubygems aware of bundler.
|
5
|
+
|
6
|
+
# Installation
|
7
|
+
|
8
|
+
gem install rubygems-bundler
|
9
|
+
gem regenerate_binstubs [-V]
|
10
|
+
|
11
|
+
# Description
|
12
|
+
|
13
|
+
This gem is intended to fill in the integration gap between
|
14
|
+
Bundler and Rubygems
|
15
|
+
|
16
|
+
With this gem rubygems generated wrappers will allow to
|
17
|
+
use bundler when asked for.
|
18
|
+
|
19
|
+
Using this gem solves problem of calling `bundle exec ...`
|
20
|
+
with your every command.
|
21
|
+
|
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!
|
29
|
+
|
30
|
+
The problem with Gemfile is that you can have few of them,
|
31
|
+
so expect that gem version for executable will be taken from
|
32
|
+
`~/Gemfile` when your project is in `~/projects/my_project`
|
33
|
+
and does not contain `Gemfile`
|
34
|
+
|
35
|
+
Last note is that bundler handling can be used only when bundler is installed.
|
36
|
+
|
37
|
+
# Controlling the wrapper
|
38
|
+
|
39
|
+
Wrappers generated by this gem will replace original rubygems wrapper,
|
40
|
+
but it will not change wrapper behavior unless explicitly asked for.
|
41
|
+
|
42
|
+
To allow using bundler when available, but fallback to rubygems when not:
|
43
|
+
|
44
|
+
export USE_BUNDLER=try
|
45
|
+
|
46
|
+
To force usage of bundler:
|
47
|
+
|
48
|
+
export USE_BUNDLER=force
|
49
|
+
|
50
|
+
To make your choice persistent put this into `~/.rvmrc` or `~/.bashrc`.
|
51
|
+
|
52
|
+
# How it works
|
53
|
+
|
54
|
+
Installation of gem will make any new installed gem use new bundler
|
55
|
+
aware wrapper:
|
56
|
+
|
57
|
+
gem install rubygems-bundler
|
58
|
+
|
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]
|
63
|
+
|
64
|
+
Now for running haml can be controlled if it will using bundler code or not:
|
65
|
+
|
66
|
+
mpapis@niczsoft:~/test> USE_BUNDLER=no haml -v
|
67
|
+
Haml 3.1.1 (Separated Sally)
|
68
|
+
|
69
|
+
mpapis@niczsoft:~/test> USE_BUNDLER=try haml -v
|
70
|
+
Haml/Sass 3.0.0 (Classy Cassidy)
|
71
|
+
|
72
|
+
mpapis@niczsoft:~/test> gem uninstall bundler
|
73
|
+
Remove executables:
|
74
|
+
bundle
|
75
|
+
in addition to the gem? [Yn] y
|
76
|
+
Removing bundle
|
77
|
+
Successfully uninstalled bundler-1.0.14
|
78
|
+
|
79
|
+
mpapis@niczsoft:~/test> USE_BUNDLER=force haml -v
|
80
|
+
/home/mpapis/.rvm/gems/ruby-1.9.2-p180@test-bundler/bin/haml:25:in `rescue in <main>': (RuntimeError)
|
81
|
+
|
82
|
+
Please install bundler first.
|
83
|
+
|
84
|
+
from /home/mpapis/.rvm/gems/ruby-1.9.2-p180@test-bundler/bin/haml:18:in `<main>'
|
85
|
+
|
86
|
+
mpapis@niczsoft:~/test> USE_BUNDLER=try haml -v
|
87
|
+
Haml 3.1.1 (Separated Sally)
|
88
|
+
|
89
|
+
# Author
|
90
|
+
|
91
|
+
- Michal Papis <mpapis@gmail.com>
|
92
|
+
|
93
|
+
# Thanks
|
94
|
+
|
95
|
+
- Yehuda Katz : the initial patch code
|
96
|
+
- Wayne E. Seguin : support in writing good code
|
97
|
+
- Evan Phoenix : support on rubygems internalls
|
98
|
+
- Andre Arko : claryfications how rubygems/bundler works
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rubygems/installer'
|
2
|
+
|
3
|
+
class RegenerateBinstubsCommand < Gem::Command
|
4
|
+
def initialize
|
5
|
+
super 'regenerate_binstubs', 'Re run generation of executable wrappers for gems.'
|
6
|
+
end
|
7
|
+
|
8
|
+
def arguments # :nodoc:
|
9
|
+
"STRING start of gem name to regenerate binstubs"
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage # :nodoc:
|
13
|
+
"#{program_name} [STRING]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def defaults_str # :nodoc:
|
17
|
+
""
|
18
|
+
end
|
19
|
+
|
20
|
+
def description # :nodoc:
|
21
|
+
'Re run generation of executable wrappers for all gems. '+
|
22
|
+
'Wrappers will be compatible with both rubygems and bundler. '+
|
23
|
+
'The switcher is BUNDLE_GEMFILE environment variable, '+
|
24
|
+
'when set it switches to bundler mode, when not set, '+
|
25
|
+
'then the command will work as it was with pure rubygems.'
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute
|
29
|
+
name = get_one_optional_argument || ''
|
30
|
+
specs = installed_gems.select{|spec| spec.name =~ /^#{name}/i }
|
31
|
+
specs.each do |spec|
|
32
|
+
unless spec.executables.empty?
|
33
|
+
org_gem_path = Gem.path.find{|path|
|
34
|
+
File.exists? File.join path, 'gems', spec.full_name
|
35
|
+
} || Gem.dir
|
36
|
+
cache_gem = File.join(org_gem_path, 'cache', spec.file_name)
|
37
|
+
if File.exist? cache_gem
|
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
|
44
|
+
RubyGemsBundlerInstaller.bundler_generate_bin(inst)
|
45
|
+
else
|
46
|
+
puts "##{spec.name} #{spec.version} not found in GEM_HOME"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def installed_gems
|
54
|
+
if Gem::VERSION > '1.8' then
|
55
|
+
Gem::Specification.to_a
|
56
|
+
else
|
57
|
+
Gem.source_index.map{|name,spec| spec}
|
58
|
+
end
|
59
|
+
|
60
|
+
Gem::VERSION > '1.8' ? Gem::Specification._all : Gem.source_index.map{|name,spec| spec}
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module RubyGemsBundlerInstaller
|
2
|
+
# Iterate through executables and generate wrapper for each one,
|
3
|
+
# extract of rubygems code
|
4
|
+
def self.bundler_generate_bin(inst)
|
5
|
+
return if inst.spec.executables.nil? or inst.spec.executables.empty?
|
6
|
+
bindir = inst.bin_dir ? inst.bin_dir : Gem.bindir(inst.gem_home)
|
7
|
+
inst.spec.executables.each do |filename|
|
8
|
+
filename.untaint
|
9
|
+
original = File.join inst.gem_dir, inst.spec.bindir, filename
|
10
|
+
if File.exists?( original )
|
11
|
+
bin_script_path = File.join bindir, inst.formatted_program_filename(filename)
|
12
|
+
FileUtils.rm_f bin_script_path
|
13
|
+
File.open bin_script_path, 'wb', 0755 do |file|
|
14
|
+
file.print bundler_app_script_text(inst, filename)
|
15
|
+
end
|
16
|
+
inst.say bin_script_path if Gem.configuration.really_verbose
|
17
|
+
else
|
18
|
+
inst.say "Can not find #{inst.spec.name} in GEM_PATH"
|
19
|
+
break
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Return the text for an application file.
|
25
|
+
def self.bundler_app_script_text(inst, bin_file_name)
|
26
|
+
<<-TEXT
|
27
|
+
#{inst.shebang bin_file_name}
|
28
|
+
#
|
29
|
+
# This file was generated by RubyGems extended wrapper.
|
30
|
+
#
|
31
|
+
# The application '#{inst.spec.name}' is installed as part of a gem, and
|
32
|
+
# this file is here to facilitate running it.
|
33
|
+
#
|
34
|
+
|
35
|
+
require 'rubygems'
|
36
|
+
|
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
|
+
version = "#{Gem::Requirement.default}"
|
42
|
+
|
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
|
58
|
+
end
|
59
|
+
|
60
|
+
load Gem.bin_path('#{inst.spec.name}', '#{bin_file_name}', version)
|
61
|
+
TEXT
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "rubygems-bundler"
|
3
|
+
s.version = "0.1.5"
|
4
|
+
s.date = "2011-06-08"
|
5
|
+
s.summary = "Make rubygems generate bundler aware executable wrappers"
|
6
|
+
s.email = "mpapis@gmail.com"
|
7
|
+
s.homepage = "https://github.com/mpapis/rubygems-bundler"
|
8
|
+
s.description = "Integrate Rubygems, Bundler and RVM"
|
9
|
+
s.has_rdoc = false
|
10
|
+
s.authors = ["Michal Papis"]
|
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
|
+
]
|
20
|
+
s.post_install_message = <<-TEXT
|
21
|
+
========================================================================
|
22
|
+
|
23
|
+
Thanks for installing rubygems-bundler!
|
24
|
+
|
25
|
+
It is important you understand that this gem can make your gem
|
26
|
+
executables load in versions specified in Gemfile!
|
27
|
+
|
28
|
+
To make all the executables bundler compatible run:
|
29
|
+
|
30
|
+
gem regenerate_binstubs # only once
|
31
|
+
|
32
|
+
To always use bundler add the following line to ~/.rvmrc or ~/.bashrc
|
33
|
+
|
34
|
+
export USE_BUNDLER=force
|
35
|
+
|
36
|
+
now relogin or call in every open shell:
|
37
|
+
|
38
|
+
export USE_BUNDLER=force
|
39
|
+
|
40
|
+
For more information read:
|
41
|
+
|
42
|
+
https://github.com/mpapis/rubygems-bundler
|
43
|
+
|
44
|
+
========================================================================
|
45
|
+
TEXT
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubygems-bundler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michal Papis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-06-08 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Integrate Rubygems, Bundler and RVM
|
15
|
+
email: mpapis@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/rubygems_bundler/regenerate_binstubs_command.rb
|
21
|
+
- lib/rubygems_bundler/rubygems_bundler_installer.rb
|
22
|
+
- lib/rubygems_bundler/fix_wrapper.rb
|
23
|
+
- lib/rubygems_plugin.rb
|
24
|
+
- README.md
|
25
|
+
- rubygems-bundler.gemspec
|
26
|
+
- LICENSE
|
27
|
+
homepage: https://github.com/mpapis/rubygems-bundler
|
28
|
+
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
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.5
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Make rubygems generate bundler aware executable wrappers
|
57
|
+
test_files: []
|