ensurable 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/README.markdown +4 -2
- data/lib/ensurable.rb +9 -2
- data/lib/ensurable/version.rb +1 -1
- data/test/ensurable_test.rb +8 -8
- data/test/helper.rb +2 -0
- metadata +4 -4
data/README.markdown
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Ensurable
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
-
FYI this is very alpha software, also it's not meant to be used in production.
|
|
4
|
+
FYI this is very alpha software, also it's not meant to be used in production. It just noops in production.
|
|
5
5
|
|
|
6
6
|
Use Case
|
|
7
7
|
-------
|
|
@@ -19,7 +19,7 @@ Installation
|
|
|
19
19
|
|
|
20
20
|
In your Gemfile:
|
|
21
21
|
|
|
22
|
-
gem 'ensurable'
|
|
22
|
+
gem 'ensurable', :group => [:development, :test]
|
|
23
23
|
|
|
24
24
|
If you're using Rails you'll want to include this in your application.rb before the `require 'rails/all'`. This makes sure that this gem gets executed as early as possible and is able to ensure things before your app cries that it needs Msyql or Redis or something.
|
|
25
25
|
|
|
@@ -29,6 +29,8 @@ If you're using Rails you'll want to include this in your application.rb before
|
|
|
29
29
|
require 'ensurable/now'
|
|
30
30
|
require 'rails/all'
|
|
31
31
|
|
|
32
|
+
Otherwise if you're using Bundler you'll want to `require 'ensurable/now'` before Bundler.require for best results.
|
|
33
|
+
|
|
32
34
|
Usage
|
|
33
35
|
-----
|
|
34
36
|
|
data/lib/ensurable.rb
CHANGED
|
@@ -13,11 +13,18 @@ module Ensurable
|
|
|
13
13
|
# @yield optional block to allow any ensurables to be required
|
|
14
14
|
def ensure(file = nil, &bloc)
|
|
15
15
|
abortables = []
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
abortables << Rails.env
|
|
19
|
+
rescue NameError, NoMethodError
|
|
20
|
+
end
|
|
17
21
|
abortables << ENV['RAILS_ENV']
|
|
18
22
|
abortables << ENV['RACK_ENV']
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
if abortables.any? {|a| a == 'production'}
|
|
25
|
+
$stderr.puts("Ensurable gem is not meant for use in production, nooping.")
|
|
26
|
+
return
|
|
27
|
+
end
|
|
21
28
|
|
|
22
29
|
if file
|
|
23
30
|
instance_eval file.read
|
data/lib/ensurable/version.rb
CHANGED
data/test/ensurable_test.rb
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
require 'helper'
|
|
2
2
|
|
|
3
3
|
class EnsurableTest < MiniTest::Unit::TestCase
|
|
4
|
-
def
|
|
4
|
+
def test_noops_if_rails_env_is_production
|
|
5
5
|
Rails.env = 'production'
|
|
6
6
|
|
|
7
|
-
Ensurable.expects(:
|
|
7
|
+
Ensurable.expects(:instance_eval).never
|
|
8
8
|
Ensurable.ensure {}
|
|
9
9
|
|
|
10
10
|
Rails.env = nil
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def
|
|
13
|
+
def test_works_if_rails_env_is_development
|
|
14
14
|
Rails.env = 'development'
|
|
15
15
|
|
|
16
|
-
Ensurable.expects(:
|
|
16
|
+
Ensurable.expects(:instance_eval)
|
|
17
17
|
Ensurable.ensure {}
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def
|
|
20
|
+
def test_noop_if_rails_env_var_is_production
|
|
21
21
|
ENV['RAILS_ENV'] = 'production'
|
|
22
22
|
|
|
23
|
-
Ensurable.expects(:
|
|
23
|
+
Ensurable.expects(:instance_eval).never
|
|
24
24
|
Ensurable.ensure {}
|
|
25
25
|
|
|
26
26
|
ENV['RAILS_ENV'] = nil
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def
|
|
29
|
+
def test_noop_if_rack_env_var_is_production
|
|
30
30
|
ENV['RACK_ENV'] = 'production'
|
|
31
31
|
|
|
32
|
-
Ensurable.expects(:
|
|
32
|
+
Ensurable.expects(:instance_eval).never
|
|
33
33
|
Ensurable.ensure {}
|
|
34
34
|
|
|
35
35
|
ENV['RACK_ENV'] = nil
|
data/test/helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ensurable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 27
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.0.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Jesse Storimer
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2011-02-
|
|
18
|
+
date: 2011-02-03 00:00:00 -05:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|