rubygems-bundler 0.3.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .idea
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.8.7
data/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+ # Changelog
2
+
3
+ ## 0.9.0
4
+ date: 2012-04-03
5
+
6
+ - joining forces with noexec from
7
+ [Joshua Hull - @joshbuddy](https://github.com/joshbuddy)
8
+
9
+ ## 0.3.0
10
+ date: 2012-04-02
11
+
12
+ - add support for [noexec gem](https://github.com/joshbuddy/noexec)
13
+ from [Joshua Hull - @joshbuddy](https://github.com/joshbuddy)
14
+
15
+ ## 0.2.8
16
+ date: 2011-12-27
17
+
18
+ - fix #8 fixed bindir for systems with Gem.bindir outside of Gem.dir
19
+ - merge #9 Prepend "ruby_" to wrapper filename
20
+
21
+ ## 0.2.7
22
+ date: 2011-09-21
23
+
24
+ - added uninstallation note
25
+ - possibly fixed installation issue for older rubygems version (yaml related)
26
+
27
+ ## 0.2.6
28
+ date: 2011-09-16
29
+
30
+ - improved default blacklist handling
31
+ - set $PROGRAM_NAME - update for thin
32
+ - add group write permisions for binary
33
+
34
+ ## 0.2.5
35
+ date: 2011-06-28
36
+
37
+ - let `bundle*` commands handle bundler by itself
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2012 Michal Papis
1
+ Copyright (c) 2011-2012 Josh Hull and Michal Papis
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -1,15 +1,64 @@
1
- # About
1
+ # rubygems-bundler && Noexec
2
2
 
3
- Rubygems and Bundler integration, makes executable wrappers
4
- generated by rubygems aware of bundler.
3
+ Let's stop using bundle exec, kthx.
5
4
 
6
- # Installation
5
+ ## Installation
7
6
 
8
7
  gem install rubygems-bundler
9
8
 
10
- And follow the on screen instructions
9
+ Add / Change a line in ~/.gemrc to:
10
+
11
+ custom_shebang: $env ruby_noexec_wrapper
12
+
13
+ Next run (once):
14
+
15
+ gem regenerate_binstubs
16
+
17
+ And you're done!
18
+
19
+ Alternatively, in your .bashrc (or somewhere you can set env variables):
20
+
21
+ export RUBYOPT="-r`noexec`"
22
+
23
+
24
+ ## Configuration
25
+
26
+ Though you can let noexec do it's own thing and rely on looking up your binary via your Gemfile,
27
+ you can also specify which binaries you want included or excluded.
28
+ Create a .noexec.yaml file along side any Gemfiles you want to use.
29
+ Then, to enable (or disable) the usage of your particular binary into your bundle,
30
+ add an include or exclude section. For example:
31
+
32
+ ### .noexec.yaml
33
+
34
+ exclude: [rake]
35
+
36
+ Or,
37
+
38
+ include: [irb, ruby]
39
+
40
+ ## Problems?
11
41
 
12
- # Description
42
+ Things not going the way you'd like? Try your command again with
43
+ NOEXEC_DEBUG=1 set and create a ticket. I'll fix it right away!
44
+
45
+ ### IRC support:
46
+
47
+ [#rubygems-bundler on irc.freenode.net](http://webchat.freenode.net/?channels=#rubygems-bundler)
48
+
49
+
50
+ ## How does this work?
51
+
52
+ It adds a script to every execution of ruby via the RUBYOPT environment variable.
53
+ Then, when you run ruby, it takes a look at your working directory,
54
+ and every directory above it until it can find a `Gemfile`.
55
+ If the executable you're running is present in your Gemfile,
56
+ it switches to using that `Gemfile` instead (via `Bundle.setup`).
57
+
58
+ Rubygems and Bundler integration, makes executable wrappers
59
+ generated by rubygems aware of bundler.
60
+
61
+ # Old description
13
62
 
14
63
  This gem is intended to fill in the integration gap between
15
64
  Bundler and Rubygems, it also backports shebang customization
@@ -32,91 +81,53 @@ and does not contain `Gemfile`
32
81
  Last note is that bundler handling can be used only when bundler is
33
82
  installed, but you will be warned when it is
34
83
 
35
- # Controlling the wrapper
36
-
37
- Wrappers generated by this gem will replace original rubygems wrapper,
38
- but it will not change wrapper behavior unless explicitly asked for.
39
-
40
- To allow using bundler when available, but fallback to rubygems when not:
41
-
42
- export USE_BUNDLER=try
43
-
44
- To force usage of bundler:
45
-
46
- export USE_BUNDLER=force
84
+ # Uninstallation
47
85
 
48
- Some gems should not be called with bundler support,
49
- to blacklist them use the following line:
86
+ Before uninstalling change a line in `~/.gemrc` to:
50
87
 
51
- BUNDLER_BLACKLIST="cheat heroku"
88
+ custom_shebang: $env ruby
52
89
 
53
- To make your choices persistent put them into `~/.bashrc` or `~/.rvmrc`.
90
+ and run `gem regenerate_binstubs`
54
91
 
55
- # Alternate use with noexec
92
+ this will set all gems to `/usr/bin/env ruby` which is one of the safest choices (especially when using rvm).
56
93
 
57
- [Joshua Hull - @joshbuddy](https://github.com/joshbuddy) created
58
- [noexec gem](https://github.com/joshbuddy/noexec),
59
- It allows detecting Gemfile and loading Bundler only when it is required.
94
+ # Controlling the wrapper - the old way, the old wrapper
60
95
 
61
- To automatically use noexec change a line in ~/.gemrc to:
96
+ Add / Change a line in ~/.gemrc to:
62
97
 
63
- custom_shebang: $env ruby_noexec_wrapper
98
+ custom_shebang: $env ruby_bundler_wrapper
64
99
 
65
- And run (once):
100
+ Next run (once):
66
101
 
67
102
  gem regenerate_binstubs
68
103
 
104
+ Wrappers generated by this gem will replace original rubygems wrapper,
105
+ but it will not change wrapper behavior unless explicitly asked for.
69
106
 
70
- # How it works
71
-
72
- Installation of gem will make any new installed gem use new bundler
73
- aware wrapper:
74
-
75
- gem install rubygems-bundler
76
-
77
- Follow onscreen instructions.
78
-
79
- Now for running haml can be controlled if it will using bundler code or not:
80
-
81
- mpapis@niczsoft:~/test> USE_BUNDLER=no haml -v
82
- Haml 3.1.1 (Separated Sally)
83
-
84
- mpapis@niczsoft:~/test> USE_BUNDLER=try haml -v
85
- Haml/Sass 3.0.0 (Classy Cassidy)
86
-
87
- mpapis@niczsoft:~/test> gem uninstall bundler
88
- Remove executables:
89
- bundle
90
- in addition to the gem? [Yn] y
91
- Removing bundle
92
- Successfully uninstalled bundler-1.0.14
93
-
94
- mpapis@niczsoft:~/test> USE_BUNDLER=force haml -v
95
- /home/mpapis/.rvm/gems/ruby-1.9.2-p180@test-bundler/bin/haml:25:in `rescue in <main>': (RuntimeError)
96
-
97
- Please install bundler first.
107
+ To allow using bundler when available, but fallback to rubygems when not:
98
108
 
99
- from /home/mpapis/.rvm/gems/ruby-1.9.2-p180@test-bundler/bin/haml:18:in `<main>'
109
+ export USE_BUNDLER=try
100
110
 
101
- mpapis@niczsoft:~/test> USE_BUNDLER=try haml -v
102
- Haml 3.1.1 (Separated Sally)
111
+ To force usage of bundler:
103
112
 
104
- # Uninstallation
113
+ export USE_BUNDLER=force
105
114
 
106
- Before uninstalling change a line in `~/.gemrc` to:
115
+ Some gems should not be called with bundler support,
116
+ to blacklist them use the following line:
107
117
 
108
- custom_shebang: $env ruby
118
+ BUNDLER_BLACKLIST="cheat heroku"
109
119
 
110
- and run `gem regenerate_binstubs`
120
+ To make your choices persistent put them into `~/.bashrc` or `~/.rvmrc`.
111
121
 
112
- this will set all gems to `/usr/bin/env ruby` which is one of the safest choices (especially when using rvm).
113
122
 
114
- # Author
123
+ # Authors
115
124
 
125
+ - Joshua Hull <joshbuddy@gmail.com>
116
126
  - Michal Papis <mpapis@gmail.com>
117
127
 
118
128
  # Thanks
119
129
 
130
+ - Carl Lerche : help with the noexec code
120
131
  - Yehuda Katz : the initial patch code
121
132
  - Wayne E. Seguin : support in writing good code
122
133
  - Evan Phoenix : support on rubygems internalls
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/noexec ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ print File.expand_path(File.expand_path("../../lib/rubygems-bundler/noexec.rb", __FILE__))
@@ -6,8 +6,9 @@ $PROGRAM_NAME=original_file
6
6
 
7
7
  require 'rubygems'
8
8
  begin
9
- require 'noexec/auto'
9
+ require 'rubygems-bundler/noexec'
10
10
  rescue LoadError
11
+ warn "unable to load rubygems-bundler/noexec" if ENV.key?('NOEXEC_DEBUG')
11
12
  end
12
13
 
13
14
  eval File.read(original_file), binding, original_file
@@ -0,0 +1,76 @@
1
+ DEBUG = ENV.key?('NOEXEC_DEBUG')
2
+
3
+ begin
4
+ require "rubygems"
5
+ require "bundler"
6
+
7
+ module Bundler
8
+ class << self
9
+ def reset!
10
+ @load = nil
11
+ end
12
+ end
13
+ end
14
+
15
+ module Noexec
16
+ CURRENT = Dir.pwd
17
+
18
+ extend self
19
+
20
+ def log(msg)
21
+ puts msg if DEBUG
22
+ end
23
+
24
+ def candidate?(gemfile, bin)
25
+ config_file = File.expand_path('../.noexec.yaml', gemfile)
26
+ log "Considering #{config_file.inspect}"
27
+ if File.exist?(config_file)
28
+ log "Using config file at #{config_file}"
29
+ config = YAML::load_file(config_file)
30
+ raise "You cannot have both an include and exclude section in your #{config_file.inspect}" unless config['include'].nil? ^ config['exclude'].nil?
31
+ if config['include'] && config['include'].include?(bin)
32
+ log "Binary included by config"
33
+ return true
34
+ elsif config['exclude'] && config['exclude'].include?(bin)
35
+ log "Binary excluded by config"
36
+ return false
37
+ end
38
+ log "Config based matching didn't find it, resorting to Gemfile lookup"
39
+ end
40
+ ENV['BUNDLE_GEMFILE'] = gemfile
41
+ Bundler.load.specs.each do |spec|
42
+ next if spec.name == 'bundler'
43
+ return true if %w(ruby irb).include?(bin) || spec.executables.include?(bin)
44
+ end
45
+ false
46
+ ensure
47
+ Bundler.reset!
48
+ end
49
+
50
+ def setup
51
+ log "Noexec"
52
+ return if File.basename($0) == 'bundle'
53
+ return if ENV['BUNDLE_GEMFILE']
54
+ gemfile = File.join(CURRENT, "Gemfile")
55
+ while true
56
+ if File.exist?(gemfile)
57
+ log "Examining #{gemfile}"
58
+ if Noexec.candidate?(gemfile, File.basename($0))
59
+ log "Using #{gemfile}"
60
+ ENV['BUNDLE_GEMFILE'] = gemfile
61
+ Bundler.setup
62
+ return
63
+ end
64
+ end
65
+ new_gemfile = File.expand_path("../../Gemfile", gemfile)
66
+ break if new_gemfile == gemfile
67
+ gemfile = new_gemfile
68
+ end
69
+ log "No valid Gemfile found, moving on"
70
+ end
71
+ end
72
+
73
+ Noexec.setup
74
+ rescue LoadError
75
+ warn "bundler not being used, unable to load" if DEBUG
76
+ end
@@ -0,0 +1,3 @@
1
+ module RubygemsBundler
2
+ VERSION = "0.9.0"
3
+ end
@@ -1,8 +1,9 @@
1
1
  require 'rubygems/command_manager'
2
- require 'rubygems_bundler/rubygems_bundler_installer'
3
- require 'rubygems_bundler/regenerate_binstubs_command'
2
+ require 'rubygems-bundler/rubygems_bundler_installer'
3
+ require 'rubygems-bundler/regenerate_binstubs_command'
4
+
4
5
  if Gem::VERSION < '1.9' then
5
- require 'rubygems_bundler/fix_wrapper'
6
+ require 'rubygems-bundler/fix_wrapper'
6
7
  end
7
8
 
8
9
  Gem::CommandManager.instance.register_command :regenerate_binstubs
@@ -1,53 +1,23 @@
1
- Gem::Specification.new do |s|
2
- s.name = "rubygems-bundler"
3
- s.version = "0.3.0"
4
- s.date = "2012-04-02"
5
- s.summary = "Make rubygems generate bundler aware executable wrappers"
6
- s.email = "mpapis@gmail.com"
7
- s.homepage = "http://mpapis.github.com/rubygems-bundler"
8
- s.description = "Integrate Rubygems and Bundler"
9
- s.has_rdoc = false
10
- s.authors = ["Michal Papis"]
11
- s.files = [
12
- "bin/ruby_bundler_wrapper",
13
- "bin/ruby_noexec_wrapper",
14
- "ext/wrapper_installer/extconf.rb",
15
- "lib/rubygems_bundler/regenerate_binstubs_command.rb",
16
- "lib/rubygems_bundler/rubygems_bundler_installer.rb",
17
- "lib/rubygems_bundler/fix_wrapper.rb",
18
- "lib/rubygems_plugin.rb",
19
- "LICENSE",
20
- "README.md",
21
- "rubygems-bundler.gemspec",
22
- ]
23
- s.extensions = ["ext/wrapper_installer/extconf.rb"]
24
- s.post_install_message = <<-TEXT
25
- ==================================================================================
26
-
27
- rubygems-bundler allows running gem executables in Gemfile specified versions!
28
-
29
- Note: from 0.2.8 the wrapper name changes, you need to repeat instructions bellow.
30
-
31
- First step is to add following line to ~/.gemrc
32
-
33
- custom_shebang: $env ruby_bundler_wrapper
34
-
35
- To make all the executables bundler compatible run:
36
-
37
- gem regenerate_binstubs # only once
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require "rubygems-bundler/version"
38
5
 
39
- To always use bundler add the following line to ~/.rvmrc or ~/.bashrc
40
-
41
- export USE_BUNDLER=force
42
-
43
- Relogin or call in every open shell:
44
-
45
- export USE_BUNDLER=force
46
-
47
- For more information read:
48
-
49
- https://github.com/mpapis/rubygems-bundler
50
-
51
- ==================================================================================
52
- TEXT
6
+ Gem::Specification.new do |s|
7
+ s.name = "rubygems-bundler"
8
+ s.version = RubygemsBundler::VERSION
9
+ s.authors = ["Josh Hull", "Michal Papis"]
10
+ s.email = ["joshbuddy@gmail.com", "mpapis@gmail.conf"]
11
+ s.homepage = "http://mpapis.github.com/rubygems-bundler"
12
+ s.summary = %q{Stop using bundle exec}
13
+ s.description = %q{Stop using bundle exec. Integrate Rubygems and Bundler. Make rubygems generate bundler aware executable wrappers.}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = ["noexec"]
18
+ s.extensions = ["ext/wrapper_installer/extconf.rb"]
19
+
20
+ # Can do we have to depend on those two ? Can we have two simple tasks doing the same ?
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "bundler"
53
23
  end
metadata CHANGED
@@ -1,74 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-bundler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 9
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.9.0
11
11
  platform: ruby
12
12
  authors:
13
+ - Josh Hull
13
14
  - Michal Papis
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2012-04-02 00:00:00 Z
19
- dependencies: []
20
-
21
- description: Integrate Rubygems and Bundler
22
- email: mpapis@gmail.com
23
- executables: []
24
-
19
+ date: 2012-04-09 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rake
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: bundler
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ description: Stop using bundle exec. Integrate Rubygems and Bundler. Make rubygems generate bundler aware executable wrappers.
50
+ email:
51
+ - joshbuddy@gmail.com
52
+ - mpapis@gmail.conf
53
+ executables:
54
+ - noexec
25
55
  extensions:
26
56
  - ext/wrapper_installer/extconf.rb
27
57
  extra_rdoc_files: []
28
58
 
29
59
  files:
60
+ - .gitignore
61
+ - .ruby-version
62
+ - CHANGELOG.md
63
+ - Gemfile
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - bin/noexec
30
68
  - bin/ruby_bundler_wrapper
31
69
  - bin/ruby_noexec_wrapper
32
70
  - ext/wrapper_installer/extconf.rb
33
- - lib/rubygems_bundler/regenerate_binstubs_command.rb
34
- - lib/rubygems_bundler/rubygems_bundler_installer.rb
35
- - lib/rubygems_bundler/fix_wrapper.rb
71
+ - lib/rubygems-bundler/fix_wrapper.rb
72
+ - lib/rubygems-bundler/noexec.rb
73
+ - lib/rubygems-bundler/regenerate_binstubs_command.rb
74
+ - lib/rubygems-bundler/rubygems_bundler_installer.rb
75
+ - lib/rubygems-bundler/version.rb
36
76
  - lib/rubygems_plugin.rb
37
- - LICENSE
38
- - README.md
39
77
  - rubygems-bundler.gemspec
40
78
  homepage: http://mpapis.github.com/rubygems-bundler
41
79
  licenses: []
42
80
 
43
- post_install_message: |
44
- ==================================================================================
45
-
46
- rubygems-bundler allows running gem executables in Gemfile specified versions!
47
-
48
- Note: from 0.2.8 the wrapper name changes, you need to repeat instructions bellow.
49
-
50
- First step is to add following line to ~/.gemrc
51
-
52
- custom_shebang: $env ruby_bundler_wrapper
53
-
54
- To make all the executables bundler compatible run:
55
-
56
- gem regenerate_binstubs # only once
57
-
58
- To always use bundler add the following line to ~/.rvmrc or ~/.bashrc
59
-
60
- export USE_BUNDLER=force
61
-
62
- Relogin or call in every open shell:
63
-
64
- export USE_BUNDLER=force
65
-
66
- For more information read:
67
-
68
- https://github.com/mpapis/rubygems-bundler
69
-
70
- ==================================================================================
71
-
81
+ post_install_message:
72
82
  rdoc_options: []
73
83
 
74
84
  require_paths:
@@ -97,6 +107,6 @@ rubyforge_project:
97
107
  rubygems_version: 1.8.21
98
108
  signing_key:
99
109
  specification_version: 3
100
- summary: Make rubygems generate bundler aware executable wrappers
110
+ summary: Stop using bundle exec
101
111
  test_files: []
102
112