-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:joshbuddy/noexec
Conflicts: .gitignore README.md
- Loading branch information
Showing
9 changed files
with
182 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.idea | ||
*.gem | ||
*.gem | ||
.bundle | ||
Gemfile.lock | ||
pkg/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in noexec.gemspec | ||
gemspec | ||
|
||
gem 'rake' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "bundler/gem_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env ruby | ||
|
||
print File.expand_path(File.expand_path("../../lib/noexec/auto.rb", __FILE__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
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 log(msg) | ||
puts msg if DEBUG | ||
end | ||
|
||
def candidate?(gemfile, bin) | ||
config_file = File.expand_path('../.noexec.yaml', gemfile) | ||
log "Considering #{config_file.inspect}" | ||
if File.exist?(config_file) | ||
log "Using config file at #{config_file}" | ||
config = YAML::load_file(config_file) | ||
raise "You cannot have both an include and exclude section in your #{config_file.inspect}" unless config['include'].nil? ^ config['exclude'].nil? | ||
if config['include'] && config['include'].include?(bin) | ||
log "Binary included by config" | ||
return true | ||
elsif config['exclude'] && config['exclude'].include?(bin) | ||
log "Binary excluded by config" | ||
return false | ||
end | ||
log "Config based matching didn't find it, resorting to Gemfile lookup" | ||
end | ||
ENV['BUNDLE_GEMFILE'] = gemfile | ||
Bundler.load.specs.each do |spec| | ||
next if spec.name == 'bundler' | ||
return true if %w(ruby irb).include?(bin) || spec.executables.include?(bin) | ||
end | ||
false | ||
ensure | ||
Bundler.reset! | ||
end | ||
|
||
def setup | ||
log "Noexec" | ||
return if File.basename($0) == 'bundle' | ||
return if ENV['BUNDLE_GEMFILE'] | ||
gemfile = File.join(CURRENT, "Gemfile") | ||
while true | ||
if File.exist?(gemfile) | ||
log "Examining #{gemfile}" | ||
if Noexec.candidate?(gemfile, File.basename($0)) | ||
log "Using #{gemfile}" | ||
ENV['BUNDLE_GEMFILE'] = gemfile | ||
Bundler.setup | ||
return | ||
end | ||
end | ||
new_gemfile = File.expand_path("../../Gemfile", gemfile) | ||
break if new_gemfile == gemfile | ||
gemfile = new_gemfile | ||
end | ||
log "No valid Gemfile found, moving on" | ||
end | ||
end | ||
|
||
Noexec.setup | ||
rescue LoadError | ||
warn "bundler not being used, unable to load" if DEBUG | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Noexec | ||
VERSION = "0.1.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "noexec/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "noexec" | ||
s.version = Noexec::VERSION | ||
s.authors = ["Josh Hull"] | ||
s.email = ["joshbuddy@gmail.com"] | ||
s.homepage = "https://github.com/joshbuddy/noexec" | ||
s.summary = %q{Stop using bundle exec} | ||
s.description = %q{Stop using bundle exec.} | ||
|
||
s.rubyforge_project = "noexec" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
end |