-
-
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.
- Loading branch information
0 parents
commit 9674eaf
Showing
9 changed files
with
111 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Noexec | ||
|
||
Let's stop using bundle exec, kthx. | ||
|
||
## Installation | ||
|
||
gem install noexec | ||
|
||
Then, in your .profile (or somewhere you can set env variables) | ||
|
||
RUBYOPT="-r`noexec`" | ||
|
||
And you're done! | ||
|
||
## How does this work? | ||
|
||
It adds a script to every execution of ruby via the RUBYOPT environment variable. Then, when you run ruby, it takes a look at your working directory, and every directory above it until it can find a `Gemfile`. If the executable you're running is present in your Gemfile, it switches to using that `Gemfile` instead (via `Bundle.setup`). |
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,54 @@ | ||
begin | ||
require "bundler" | ||
|
||
module Bundler | ||
class << self | ||
def reset! | ||
@load = nil | ||
end | ||
end | ||
end | ||
|
||
module Noexec | ||
CURRENT = Dir.pwd | ||
DEBUG = ENV.key?('NOEXEC_DEBUG') | ||
|
||
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" | ||
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 @@ | ||
require File.expand_path('../../noexec', __FILE__) | ||
|
||
Noexec.setup |
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.0.1" | ||
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 |