rubygems-bundler 1.3.0.rc2 → 1.3.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,99 +1,106 @@
1
+ require "rubygems"
1
2
  require "yaml"
2
3
 
3
- module RubygemsBundler
4
- end
5
- RubygemsBundler::DEBUG = ENV.key?('NOEXEC_DEBUG')
6
-
7
- if %w(bundle rubygems-bundler-uninstaller).include?(File.basename($0))
8
- puts "Noexec - skipped binary: #{File.basename($0)}" if RubygemsBundler::DEBUG
9
-
10
- elsif ENV['NOEXEC_EXCLUDE'] && ENV['NOEXEC_EXCLUDE'].split(/ /).include?(File.basename($0))
11
- puts "Noexec - ENV skipped binary: #{File.basename($0)}" if RubygemsBundler::DEBUG
12
-
13
- elsif ENV['BUNDLE_GEMFILE'] && ENV['BUNDLE_BIN_PATH'] && ENV['RUBYOPT']
14
- puts "Noexec - already in 'bundle exec'" if RubygemsBundler::DEBUG
4
+ class Noexec
5
+ DEBUG = ENV.key?('NOEXEC_DEBUG')
6
+ CURRENT = Dir.pwd
15
7
 
16
- elsif %w(0 skip).include?( ENV['NOEXEC'] ) || ENV.key?('NOEXEC_DISABLE')
17
- #TODO: deprecated in 1.1.0, to be removed in 1.2.0 -- 2012.09.05
18
- $stderr.puts "Warning, 'NOEXEC' environment variable is deprecated, switch to 'NOEXEC_DISABLE=1'." if ENV.key?('NOEXEC')
19
- puts "Noexec - disabled with environment variable" if RubygemsBundler::DEBUG
8
+ attr_reader :bin
20
9
 
21
- else
22
- begin
23
- puts "Noexec - starting check" if RubygemsBundler::DEBUG
24
- require "rubygems"
25
- require "bundler-unload"
26
-
27
- module Noexec
28
- RubygemsBundler::CURRENT = Dir.pwd
10
+ def initialize(bin)
11
+ @bin = bin
12
+ end
29
13
 
30
- extend self
14
+ def log(msg)
15
+ puts msg if Noexec::DEBUG
16
+ end
31
17
 
32
- def log(msg)
33
- puts msg if RubygemsBundler::DEBUG
18
+ def candidate?(gemfile)
19
+ config_file = File.expand_path('../.noexec.yaml', gemfile)
20
+ log "Considering #{config_file.inspect}"
21
+ if File.exist?(config_file)
22
+ log "Using config file at #{config_file}"
23
+ config = YAML::load_file(config_file)
24
+ raise "You cannot have both an include and exclude section in your #{config_file.inspect}" unless config['include'].nil? ^ config['exclude'].nil?
25
+ if config['include'] && config['include'].include?(bin)
26
+ log "Binary included by config"
27
+ return true
28
+ elsif config['exclude'] && config['exclude'].include?(bin)
29
+ log "Binary excluded by config"
30
+ return false
34
31
  end
35
-
36
- def candidate?(gemfile, bin, rubygems_spec)
37
- config_file = File.expand_path('../.noexec.yaml', gemfile)
38
- log "Considering #{config_file.inspect}"
39
- if File.exist?(config_file)
40
- log "Using config file at #{config_file}"
41
- config = YAML::load_file(config_file)
42
- raise "You cannot have both an include and exclude section in your #{config_file.inspect}" unless config['include'].nil? ^ config['exclude'].nil?
43
- if config['include'] && config['include'].include?(bin)
44
- log "Binary included by config"
45
- return true
46
- elsif config['exclude'] && config['exclude'].include?(bin)
47
- log "Binary excluded by config"
48
- return false
49
- end
50
- log "Config based matching didn't find it, resorting to Gemfile lookup"
51
- end
52
- return true if %w(ruby irb).include?(bin)
53
- ENV['BUNDLE_GEMFILE'] = gemfile
54
- Bundler.with_bundle do |runtime|
55
- if rubygems_spec
56
- missing_spec = runtime.
57
- instance_variable_get(:@definition).
58
- missing_specs.
59
- detect{|spec| spec.name == rubygems_spec.name}
60
- if missing_spec
61
- puts "\e[31mCould not find proper version of #{missing_spec.to_s} in any of the sources\e[0m"
62
- puts "\e[33mRun `bundle install` to install missing gems.\e[0m"
63
- exit Bundler::GemNotFound.new.status_code
64
- end
65
- end
66
- return true if runtime.specs.detect{ |spec| spec.executables.include?(bin) }
32
+ log "Config based matching didn't find it, resorting to Gemfile lookup"
33
+ end
34
+ return true if %w(ruby irb).include?(bin)
35
+ ENV['BUNDLE_GEMFILE'] = gemfile
36
+ Bundler.with_bundle do |runtime|
37
+ if rubygems_spec
38
+ missing_spec = runtime.
39
+ instance_variable_get(:@definition).
40
+ missing_specs.
41
+ detect{|spec| spec.name == rubygems_spec.name}
42
+ if missing_spec
43
+ puts "\e[31mCould not find proper version of #{missing_spec.to_s} in any of the sources\e[0m"
44
+ puts "\e[33mRun `bundle install` to install missing gems.\e[0m"
45
+ exit Bundler::GemNotFound.new.status_code
67
46
  end
68
- false
69
- rescue Bundler::BundlerError, Bundler::GemfileError => e
70
- warn "Ignoring candidate #{gemfile}:\n#{e}" if RubygemsBundler::DEBUG
71
- false
72
47
  end
48
+ return true if runtime.specs.detect{ |spec| spec.executables.include?(bin) }
49
+ end
50
+ false
51
+ rescue Bundler::BundlerError, Bundler::GemfileError => e
52
+ warn "Ignoring candidate #{gemfile}:\n#{e}" if Noexec::DEBUG
53
+ false
54
+ end
73
55
 
74
- def setup(bin)
75
- gemfile = ENV['BUNDLE_GEMFILE'] || File.join(RubygemsBundler::CURRENT, "Gemfile")
76
- rubygems_spec = Bundler.rubygems.plain_specs.detect{|spec| spec.executables.include?(bin) }
77
- while true
78
- if File.file?(gemfile)
79
- log "Examining #{gemfile}"
80
- if Noexec.candidate?(gemfile, bin, rubygems_spec)
81
- log "Using #{gemfile}"
82
- ENV['BUNDLE_GEMFILE'] = gemfile
83
- Bundler.setup
84
- return
85
- end
86
- end
87
- new_gemfile = File.expand_path("../../Gemfile", gemfile)
88
- break if new_gemfile == gemfile
89
- gemfile = new_gemfile
56
+ def rubygems_spec
57
+ @rubygems_spec ||= Bundler.rubygems.plain_specs.detect{|spec| spec.executables.include?(bin) }
58
+ end
59
+
60
+ def setup
61
+ puts "Noexec - starting check" if Noexec::DEBUG
62
+ require "bundler-unload"
63
+
64
+ gemfile = ENV['BUNDLE_GEMFILE'] || File.join(Noexec::CURRENT, "Gemfile")
65
+ while true
66
+ if File.file?(gemfile)
67
+ log "Examining #{gemfile}"
68
+ if candidate?(gemfile)
69
+ log "Using #{gemfile}"
70
+ ENV['BUNDLE_GEMFILE'] = gemfile
71
+ Bundler.setup
72
+ return
90
73
  end
91
- log "No valid Gemfile found, moving on"
92
74
  end
75
+ new_gemfile = File.expand_path("../../Gemfile", gemfile)
76
+ break if new_gemfile == gemfile
77
+ gemfile = new_gemfile
93
78
  end
94
-
95
- Noexec.setup(File.basename($0))
79
+ log "No valid Gemfile found, moving on"
96
80
  rescue LoadError
97
- warn "bundler not being used, unable to load" if RubygemsBundler::DEBUG
81
+ warn "bundler not being used, unable to load" if Noexec::DEBUG
98
82
  end
83
+
84
+ def check
85
+ if %w(bundle rubygems-bundler-uninstaller).include?(bin)
86
+ log "Noexec - skipped binary: #{bin}"
87
+
88
+ elsif ENV['NOEXEC_EXCLUDE'] && ENV['NOEXEC_EXCLUDE'].split(/ /).include?(bin)
89
+ log "Noexec - ENV skipped binary: #{bin}"
90
+
91
+ elsif ENV['BUNDLE_GEMFILE'] && ENV['BUNDLE_BIN_PATH'] && ENV['RUBYOPT']
92
+ log "Noexec - already in 'bundle exec'"
93
+
94
+ elsif %w(0 skip).include?( ENV['NOEXEC'] ) || ENV.key?('NOEXEC_DISABLE')
95
+ #TODO: deprecated in 1.1.0, to be removed later -- 2012.09.05
96
+ $stderr.puts "Warning, 'NOEXEC' environment variable is deprecated, switch to 'NOEXEC_DISABLE=1'." if ENV.key?('NOEXEC')
97
+ log "Noexec - disabled with environment variable"
98
+
99
+ else
100
+ setup
101
+ end
102
+ end
103
+
99
104
  end
105
+
106
+ Noexec.new(File.basename($0)).check
@@ -1,3 +1,3 @@
1
1
  module RubygemsBundler
2
- VERSION = "1.3.0.rc2"
2
+ VERSION = "1.3.0.rc3"
3
3
  end
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://mpapis.github.com/rubygems-bundler"
12
12
  s.summary = %q{Stop using bundle exec}
13
13
  s.description = %q{Stop using bundle exec. Integrate Rubygems and Bundler. Make rubygems generate bundler aware executable wrappers.}
14
+ s.license = 'Apache License, Version 2.0'
14
15
 
15
16
  s.files = `git ls-files`.split("\n")
16
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-bundler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 995727847
4
+ hash: -1353073098
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
10
  - rc
11
- - 2
12
- version: 1.3.0.rc2
11
+ - 3
12
+ version: 1.3.0.rc3
13
13
  platform: ruby
14
14
  authors:
15
15
  - Josh Hull
@@ -93,8 +93,8 @@ files:
93
93
  - test/dtf/rails_and_gemfile_comment_test.sh
94
94
  - test/dtf/rubygems_comment_test.sh
95
95
  homepage: http://mpapis.github.com/rubygems-bundler
96
- licenses: []
97
-
96
+ licenses:
97
+ - Apache License, Version 2.0
98
98
  post_install_message:
99
99
  rdoc_options: []
100
100