Browse files

simpler

  • Loading branch information...
1 parent 8578ab7 commit 35d6520a15af768c7c8855b8c0c40e996bee46c5 @joshbuddy joshbuddy committed Mar 28, 2012
Showing with 58 additions and 58 deletions.
  1. +0 −56 lib/noexec.rb
  2. +58 −2 lib/noexec/auto.rb
View
56 lib/noexec.rb
@@ -1,56 +0,0 @@
-DEBUG = ENV.key?('NOEXEC_DEBUG')
-
-begin
- require "rubygems"
- require "bundler"
-
- module Bundler
- class << self
- def reset!
- @load = nil
- end
- end
- end
-
- module Noexec
- CURRENT = Dir.pwd
-
- extend self
-
- def candidate?(gemfile, bin)
- ENV['BUNDLE_GEMFILE'] = gemfile
- Bundler.load.specs.each do |spec|
- next if spec.name == 'bundler'
- return spec if spec.executables.include?(bin)
- end
- nil
- ensure
- Bundler.reset!
- end
-
- def setup
- puts "Noexec" if DEBUG
- catch(:done) do
- throw :done, false if File.basename($0) == 'bundle'
- gemfile = File.join(CURRENT, "Gemfile")
- while true
- if File.exist?(gemfile)
- puts "Examining #{gemfile}" if DEBUG
- if Noexec.candidate?(gemfile, File.basename($0))
- puts "Using #{gemfile}" if DEBUG
- Bundler.setup
- throw :done, true
- end
- end
- new_gemfile = File.expand_path("../../Gemfile", gemfile)
- throw :done, false if new_gemfile == gemfile
- gemfile = new_gemfile
- end
- puts "No valid Gemfile found, moving on" if DEBUG
- false
- end
- end
- end
-rescue LoadError
- warn "bundler not being used, unable to load" if DEBUG
-end
View
60 lib/noexec/auto.rb
@@ -1,3 +1,59 @@
-require File.expand_path('../../noexec', __FILE__)
+DEBUG = ENV.key?('NOEXEC_DEBUG')
-Noexec.setup if Object.const_defined?(:Noexec)
+begin
+ require "rubygems"
+ require "bundler"
+
+ module Bundler
+ class << self
+ def reset!
+ @load = nil
+ end
+ end
+ end
+
+ module Noexec
+ CURRENT = Dir.pwd
+
+ extend self
+
+ def candidate?(gemfile, bin)
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ Bundler.load.specs.each do |spec|
+ next if spec.name == 'bundler'
+ return spec if spec.executables.include?(bin)
+ end
+ nil
+ ensure
+ Bundler.reset!
+ end
+
+ def setup
+ puts "Noexec" if DEBUG
+ catch(:done) do
+ throw :done if File.basename($0) == 'bundle'
+ throw :done if ENV['BUNDLE_GEMFILE']
+ gemfile = File.join(CURRENT, "Gemfile")
+ while true
+ if File.exist?(gemfile)
+ puts "Examining #{gemfile}" if DEBUG
+ if Noexec.candidate?(gemfile, File.basename($0))
+ puts "Using #{gemfile}" if DEBUG
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ Bundler.setup
+ throw :done
+ end
+ end
+ new_gemfile = File.expand_path("../../Gemfile", gemfile)
+ throw :done if new_gemfile == gemfile
+ gemfile = new_gemfile
+ end
+ puts "No valid Gemfile found, moving on" if DEBUG
+ end
+ end
+ end
+
+ Noexec.setup
+rescue LoadError
+ warn "bundler not being used, unable to load" if DEBUG
+end

0 comments on commit 35d6520

Please sign in to comment.