noexec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +6 -0
- data/README.md +17 -0
- data/Rakefile +1 -0
- data/bin/noexec +3 -0
- data/lib/noexec.rb +54 -0
- data/lib/noexec/auto.rb +3 -0
- data/lib/noexec/version.rb +3 -0
- data/noexec.gemspec +20 -0
- metadata +61 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Noexec
|
2
|
+
|
3
|
+
Let's stop using bundle exec, kthx.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install noexec
|
8
|
+
|
9
|
+
Then, in your .profile (or somewhere you can set env variables)
|
10
|
+
|
11
|
+
RUBYOPT="-r`noexec`"
|
12
|
+
|
13
|
+
And you're done!
|
14
|
+
|
15
|
+
## How does this work?
|
16
|
+
|
17
|
+
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`).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/noexec
ADDED
data/lib/noexec.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
begin
|
2
|
+
require "bundler"
|
3
|
+
|
4
|
+
module Bundler
|
5
|
+
class << self
|
6
|
+
def reset!
|
7
|
+
@load = nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Noexec
|
13
|
+
CURRENT = Dir.pwd
|
14
|
+
DEBUG = ENV.key?('NOEXEC_DEBUG')
|
15
|
+
|
16
|
+
extend self
|
17
|
+
|
18
|
+
def candidate?(gemfile, bin)
|
19
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
20
|
+
Bundler.load.specs.each do |spec|
|
21
|
+
next if spec.name == 'bundler'
|
22
|
+
return spec if spec.executables.include?(bin)
|
23
|
+
end
|
24
|
+
nil
|
25
|
+
ensure
|
26
|
+
Bundler.reset!
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup
|
30
|
+
puts "Noexec" if DEBUG
|
31
|
+
catch(:done) do
|
32
|
+
throw :done, false if File.basename($0) == 'bundle'
|
33
|
+
gemfile = File.join(CURRENT, "Gemfile")
|
34
|
+
while true
|
35
|
+
if File.exist?(gemfile)
|
36
|
+
puts "Examining #{gemfile}" if DEBUG
|
37
|
+
if Noexec.candidate?(gemfile, File.basename($0))
|
38
|
+
puts "Using #{gemfile}" if DEBUG
|
39
|
+
Bundler.setup
|
40
|
+
throw :done, true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
new_gemfile = File.expand_path("../../Gemfile", gemfile)
|
44
|
+
throw :done, false if new_gemfile == gemfile
|
45
|
+
gemfile = new_gemfile
|
46
|
+
end
|
47
|
+
puts "No valid Gemfile found, moving on" if DEBUG
|
48
|
+
false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
rescue LoadError
|
53
|
+
warn "bundler not being used, unable to load"
|
54
|
+
end
|
data/lib/noexec/auto.rb
ADDED
data/noexec.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "noexec/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "noexec"
|
7
|
+
s.version = Noexec::VERSION
|
8
|
+
s.authors = ["Josh Hull"]
|
9
|
+
s.email = ["joshbuddy@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/joshbuddy/noexec"
|
11
|
+
s.summary = %q{Stop using bundle exec}
|
12
|
+
s.description = %q{Stop using bundle exec.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "noexec"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: noexec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Hull
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-28 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Stop using bundle exec.
|
15
|
+
email:
|
16
|
+
- joshbuddy@gmail.com
|
17
|
+
executables:
|
18
|
+
- noexec
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- bin/noexec
|
27
|
+
- lib/noexec.rb
|
28
|
+
- lib/noexec/auto.rb
|
29
|
+
- lib/noexec/version.rb
|
30
|
+
- noexec.gemspec
|
31
|
+
homepage: https://github.com/joshbuddy/noexec
|
32
|
+
licenses: []
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
hash: -778489064666384165
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
hash: -778489064666384165
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project: noexec
|
57
|
+
rubygems_version: 1.8.15
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: Stop using bundle exec
|
61
|
+
test_files: []
|