bundler-bouncer 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/Readme.md +48 -0
- data/lib/bundler/bouncer/messages.rb +1 -1
- data/spec/bundler-bouncer_spec.rb +14 -5
- data/spec/mock_projects/with_bundler/Gemfile.lock +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +3 -4
- data/spec/mock_projects/dummy_gem-1.0.0.gem +0 -0
data/Rakefile
CHANGED
@@ -18,7 +18,8 @@ end
|
|
18
18
|
spec = Gem::Specification.new do |s|
|
19
19
|
s.name = "bundler-bouncer"
|
20
20
|
s.version = File.read 'Version.txt'
|
21
|
-
s.summary = "Exits app if you forgot to run under bundle exec"
|
21
|
+
s.summary = "Exits app if you forgot to run under bundle exec."
|
22
|
+
s.description = "Should your app run in the Bundler sandbox? Well then make sure it is, let bundler-bouncer kick you out of your app if you forgot to `bundle exec` it. Prevents absurdly difficult to find bugs, prevents you from propagating your system with bad data, eases the mind."
|
22
23
|
s.author = "Joshua Cheek"
|
23
24
|
s.email = "josh.cheek@gmail.com"
|
24
25
|
s.homepage = "https://github.com/JoshCheek/bundler-bouncer"
|
data/Readme.md
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
bundler-bouncer
|
2
|
+
===============
|
3
|
+
|
4
|
+
Description
|
5
|
+
-----------
|
6
|
+
|
7
|
+
Should your app run in the Bundler sandbox? Well then make sure it is, let bundler-bouncer kick you out of your app if you forgot to `bundle exec` it. Prevents absurdly difficult to find bugs, prevents you from propagating your system with bad data, eases the mind. In the [Pragmatic Programmer](http://pragprog.com/the-pragmatic-programmer/extracts/tips), Dave Thomas and Andy Hunt say to Crash Early, because "The alternative may be to continue, writing corrupted data to some vital database" which, I did, because I wasn't using Bundler on one rake task. Then, later, when I tried to deserialize that data with Bundler running, it was invalid, sending me on a 2 day goose chase trying to figure out what was wrong. Don't let yourself get in my situation, get your app a bouncer.
|
8
|
+
|
9
|
+
|
10
|
+
Features
|
11
|
+
--------
|
12
|
+
|
13
|
+
If you set the environment variable USE_BUNDLER to 'no', it will warn you that it isn't using Bundler, but won't kick you out. This enables you to use tools like [rubygems-bundler](https://rubygems.org/gems/rubygems-bundler).
|
14
|
+
|
15
|
+
|
16
|
+
Usage
|
17
|
+
-----
|
18
|
+
|
19
|
+
Given a Gemfile that looks like this:
|
20
|
+
|
21
|
+
source :rubygems
|
22
|
+
gem 'bundler-bouncer', '=0.1.0'
|
23
|
+
|
24
|
+
*(don't forget to `bundle install`)*
|
25
|
+
|
26
|
+
And a main.rb that looks like this:
|
27
|
+
|
28
|
+
require "bundler/bouncer"
|
29
|
+
puts "hello world"
|
30
|
+
|
31
|
+
When you run `bundle exec ruby main.rb`, your app will print `hello world`, just like you'd expect.
|
32
|
+
|
33
|
+
|
34
|
+
But when you forget, and run `ruby main.rb` You will get bounced out:
|
35
|
+
|
36
|
+
Try running this app again with `bundle exec`
|
37
|
+
|
38
|
+
|
39
|
+
Recommendation
|
40
|
+
--------------
|
41
|
+
|
42
|
+
Stick it at the top of your Rakefile.
|
43
|
+
|
44
|
+
|
45
|
+
Install
|
46
|
+
-------
|
47
|
+
|
48
|
+
`$ gem install bundler-bouncer`
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Bundler
|
2
2
|
module Bouncer
|
3
3
|
Messages = {
|
4
|
-
:missing_bundler => "\e[
|
4
|
+
:missing_bundler => "\e[31mNo dice, pal. Try again when you can remember to `bundle exec`.\e[0m",
|
5
5
|
:turned_off => "\e[33mWarning: Bundler is not running.\e[0m",
|
6
6
|
}
|
7
7
|
end
|
@@ -2,28 +2,37 @@ require "#{File.dirname __FILE__}/spec_helper"
|
|
2
2
|
describe 'bundler-bouncer' do
|
3
3
|
|
4
4
|
context 'from a file invoked with `bundle exec`' do
|
5
|
-
subject { run_app
|
6
|
-
its(:exitstatus) { should
|
5
|
+
subject { run_app :bundler => true }
|
6
|
+
its(:exitstatus) { should == 0 }
|
7
7
|
its(:stderr) { should == '' }
|
8
8
|
its(:stdout) { should == '' }
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'from a file invoked without `bundle exec`' do
|
12
12
|
context 'with USE_BUNDLER set to no' do
|
13
|
-
subject { run_app
|
13
|
+
subject { run_app :bundler => false, :USE_BUNDLER => 'no' }
|
14
14
|
its(:exitstatus) { should == 0 }
|
15
15
|
its(:stdout) { should == '' }
|
16
16
|
its(:stderr) { should == bouncer_message(:turned_off) }
|
17
17
|
its(:stderr) { should be_coloured :yellow }
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
subject { run_app 'without_bundler', :bundler => false, :USE_BUNDLER => 'force' }
|
20
|
+
shared_examples_for 'USE_BUNDLER set to something other than "no"' do
|
22
21
|
its(:exitstatus) { should == 1 }
|
23
22
|
its(:stdout) { should == '' }
|
24
23
|
its(:stderr) { should == bouncer_message(:missing_bundler) }
|
25
24
|
its(:stderr) { should be_coloured :red }
|
26
25
|
end
|
26
|
+
|
27
|
+
context 'with USE_BUNDLER set to force' do
|
28
|
+
subject { run_app :bundler => false, :USE_BUNDLER => 'force' }
|
29
|
+
it_should_behave_like 'USE_BUNDLER set to something other than "no"'
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with USE_BUNDLER not set' do
|
33
|
+
subject { run_app :bundler => false }
|
34
|
+
it_should_behave_like 'USE_BUNDLER set to something other than "no"'
|
35
|
+
end
|
27
36
|
end
|
28
37
|
|
29
38
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -63,8 +63,8 @@ class InvokedApp < Struct.new(:exitstatus, :stdout, :stderr)
|
|
63
63
|
end
|
64
64
|
|
65
65
|
|
66
|
-
def run_app(
|
67
|
-
Dir.chdir "#{File.dirname __FILE__}/mock_projects
|
66
|
+
def run_app(options)
|
67
|
+
Dir.chdir "#{File.dirname __FILE__}/mock_projects/with#{options[:bundler] ? '' : 'out'}_bundler" do
|
68
68
|
use_bundler_env options[:USE_BUNDLER] do
|
69
69
|
InvokedApp.invoke app_command(options)
|
70
70
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bundler-bouncer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Joshua Cheek
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: 1.0.15
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id002
|
37
|
-
description:
|
37
|
+
description: Should your app run in the Bundler sandbox? Well then make sure it is, let bundler-bouncer kick you out of your app if you forgot to `bundle exec` it. Prevents absurdly difficult to find bugs, prevents you from propagating your system with bad data, eases the mind.
|
38
38
|
email: josh.cheek@gmail.com
|
39
39
|
executables: []
|
40
40
|
|
@@ -47,7 +47,6 @@ files:
|
|
47
47
|
- Rakefile
|
48
48
|
- Readme.md
|
49
49
|
- spec/bundler-bouncer_spec.rb
|
50
|
-
- spec/mock_projects/dummy_gem-1.0.0.gem
|
51
50
|
- spec/mock_projects/with_bundler/app.rb
|
52
51
|
- spec/mock_projects/with_bundler/Gemfile
|
53
52
|
- spec/mock_projects/with_bundler/Gemfile.lock
|
@@ -81,6 +80,6 @@ rubyforge_project:
|
|
81
80
|
rubygems_version: 1.8.5
|
82
81
|
signing_key:
|
83
82
|
specification_version: 3
|
84
|
-
summary: Exits app if you forgot to run under bundle exec
|
83
|
+
summary: Exits app if you forgot to run under bundle exec.
|
85
84
|
test_files: []
|
86
85
|
|
Binary file
|