noexec 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -0
- data/lib/noexec/auto.rb +25 -6
- data/lib/noexec/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -12,6 +12,18 @@ Then, in your .profile (or somewhere you can set env variables)
|
|
12
12
|
|
13
13
|
And you're done!
|
14
14
|
|
15
|
+
## Configuration
|
16
|
+
|
17
|
+
Though you can let noexec do it's own thing and rely on looking up your binary via your Gemfile, you can also specify which binaries you want included or excluded. Create a .noexec.yaml file along side any Gemfiles you want to use. Then, to enable (or disable) the usage of your particular binary into your bundle, add an include or exclude section. For example:
|
18
|
+
|
19
|
+
### .noexec.yaml
|
20
|
+
|
21
|
+
exclude: [rake]
|
22
|
+
|
23
|
+
Or,
|
24
|
+
|
25
|
+
include: [irb, ruby]
|
26
|
+
|
15
27
|
## How does this work?
|
16
28
|
|
17
29
|
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/lib/noexec/auto.rb
CHANGED
@@ -17,27 +17,46 @@ begin
|
|
17
17
|
|
18
18
|
extend self
|
19
19
|
|
20
|
+
def log(msg)
|
21
|
+
puts msg if DEBUG
|
22
|
+
end
|
23
|
+
|
20
24
|
def candidate?(gemfile, bin)
|
25
|
+
config_file = File.expand_path('../.noexec.yaml', gemfile)
|
26
|
+
log "Considering #{config_file.inspect}"
|
27
|
+
if File.exist?(config_file)
|
28
|
+
log "Using config file at #{config_file}"
|
29
|
+
config = YAML::load_file(config_file)
|
30
|
+
raise "You cannot have both an include and exclude section in your #{config_file.inspect}" unless config['include'].nil? ^ config['exclude'].nil?
|
31
|
+
if config['include'] && config['include'].include?(bin)
|
32
|
+
log "Binary included by config"
|
33
|
+
return true
|
34
|
+
elsif config['exclude'] && config['exclude'].include?(bin)
|
35
|
+
log "Binary excluded by config"
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
log "Config based matching didn't find it, resorting to Gemfile lookup"
|
39
|
+
end
|
21
40
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
22
41
|
Bundler.load.specs.each do |spec|
|
23
42
|
next if spec.name == 'bundler'
|
24
|
-
return
|
43
|
+
return true if %w(ruby irb).include?(bin) || spec.executables.include?(bin)
|
25
44
|
end
|
26
|
-
|
45
|
+
false
|
27
46
|
ensure
|
28
47
|
Bundler.reset!
|
29
48
|
end
|
30
49
|
|
31
50
|
def setup
|
32
|
-
|
51
|
+
log "Noexec"
|
33
52
|
return if File.basename($0) == 'bundle'
|
34
53
|
return if ENV['BUNDLE_GEMFILE']
|
35
54
|
gemfile = File.join(CURRENT, "Gemfile")
|
36
55
|
while true
|
37
56
|
if File.exist?(gemfile)
|
38
|
-
|
57
|
+
log "Examining #{gemfile}"
|
39
58
|
if Noexec.candidate?(gemfile, File.basename($0))
|
40
|
-
|
59
|
+
log "Using #{gemfile}"
|
41
60
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
42
61
|
Bundler.setup
|
43
62
|
return
|
@@ -47,7 +66,7 @@ begin
|
|
47
66
|
break if new_gemfile == gemfile
|
48
67
|
gemfile = new_gemfile
|
49
68
|
end
|
50
|
-
|
69
|
+
log "No valid Gemfile found, moving on"
|
51
70
|
end
|
52
71
|
end
|
53
72
|
|
data/lib/noexec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noexec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -41,7 +41,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
segments:
|
43
43
|
- 0
|
44
|
-
hash:
|
44
|
+
hash: -2223861668915785317
|
45
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
46
|
none: false
|
47
47
|
requirements:
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
version: '0'
|
51
51
|
segments:
|
52
52
|
- 0
|
53
|
-
hash:
|
53
|
+
hash: -2223861668915785317
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project: noexec
|
56
56
|
rubygems_version: 1.8.15
|