ment 0.0.1 → 0.1.0
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.
- checksums.yaml +4 -4
- data/README.md +17 -1
- data/lib/ment.rb +4 -2
- data/test/ment/cuba_test.rb +12 -0
- data/test/ment/hobbit_test.rb +12 -0
- data/test/ment_test.rb +64 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4785be29cbbbf67e5a6ef11fa0384742765e41ba
|
4
|
+
data.tar.gz: b1807bf0bc46e24d6f9b9a88b6fb6cf48a84db75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0f2218ae6b375ccf24fbc9eb4f1b7fef50c40258b04ec3bd57bb504f8e05f683a78945b51c28f5531b796f8dbbc277567486d6a8abf382d9db820136e7961e3
|
7
|
+
data.tar.gz: 432d857006b3c9c7173e3c16266e01b7d01b7fc630031e9c0001af209ee00de2c3a3d7986805d3f700f62a1cd658d0c3dcc3598bb9323bffcc5ee70122af1275
|
data/README.md
CHANGED
@@ -31,7 +31,23 @@ Ment adds the following methods to your Rack app:
|
|
31
31
|
* `::production?`/`#production?`: returns `true` if `ENV['RACK_ENV'] == 'production'`
|
32
32
|
* `::test?`/`#test?`: returns `true` if `ENV['RACK_ENV'] == 'test'`
|
33
33
|
|
34
|
-
### Using
|
34
|
+
### Using Ment directly
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'ment'
|
38
|
+
|
39
|
+
proc = Proc.new do
|
40
|
+
if Ment.production?
|
41
|
+
[200, {}, ['This is production']]
|
42
|
+
else
|
43
|
+
[200, {}, ["The current environment is #{Ment.environment}"]]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
run proc
|
48
|
+
```
|
49
|
+
|
50
|
+
### Using [Rack](https://github.com/rack/rack)
|
35
51
|
|
36
52
|
```ruby
|
37
53
|
require 'ment'
|
data/lib/ment.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module Ment
|
2
|
-
VERSION = '0.0
|
2
|
+
VERSION = '0.1.0'
|
3
|
+
|
4
|
+
extend self
|
3
5
|
|
4
6
|
def self.included(othermod)
|
5
7
|
othermod.extend self
|
6
8
|
end
|
7
9
|
|
8
10
|
def environment
|
9
|
-
ENV['RACK_ENV'].to_sym
|
11
|
+
(ENV['RACK_ENV'] || 'development').to_sym
|
10
12
|
end
|
11
13
|
|
12
14
|
%w(development production test).each do |env|
|
data/test/ment/cuba_test.rb
CHANGED
@@ -11,6 +11,12 @@ scope 'Cuba integration' do
|
|
11
11
|
assert_equal :development, Cuba.environment
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
test 'returns :development if there is no current environment' do
|
16
|
+
with_env(nil) do
|
17
|
+
assert_equal :development, Cuba.environment
|
18
|
+
end
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
22
|
scope '#environment' do
|
@@ -19,6 +25,12 @@ scope 'Cuba integration' do
|
|
19
25
|
assert_equal :development, @app.environment
|
20
26
|
end
|
21
27
|
end
|
28
|
+
|
29
|
+
test 'returns :development if there is no current environment' do
|
30
|
+
with_env(nil) do
|
31
|
+
assert_equal :development, @app.environment
|
32
|
+
end
|
33
|
+
end
|
22
34
|
end
|
23
35
|
|
24
36
|
scope '::development?' do
|
data/test/ment/hobbit_test.rb
CHANGED
@@ -11,6 +11,12 @@ scope 'Hobbit integration' do
|
|
11
11
|
assert_equal :development, HobbitApp.environment
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
test 'returns :development if there is no current environment' do
|
16
|
+
with_env(nil) do
|
17
|
+
assert_equal :development, HobbitApp.environment
|
18
|
+
end
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
22
|
scope '#environment' do
|
@@ -19,6 +25,12 @@ scope 'Hobbit integration' do
|
|
19
25
|
assert_equal :development, @app.to_app.class.environment
|
20
26
|
end
|
21
27
|
end
|
28
|
+
|
29
|
+
test 'returns :development if there is no current environment' do
|
30
|
+
with_env(nil) do
|
31
|
+
assert_equal :development, @app.to_app.class.environment
|
32
|
+
end
|
33
|
+
end
|
22
34
|
end
|
23
35
|
|
24
36
|
scope '::development?' do
|
data/test/ment_test.rb
CHANGED
@@ -5,12 +5,70 @@ scope Ment do
|
|
5
5
|
@app = App.new
|
6
6
|
end
|
7
7
|
|
8
|
+
scope do
|
9
|
+
scope '::environment' do
|
10
|
+
test 'returns the current environment' do
|
11
|
+
with_env('development') do
|
12
|
+
assert_equal :development, Ment.environment
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'returns :development if there is no current environment' do
|
17
|
+
with_env(nil) do
|
18
|
+
assert_equal :development, Ment.environment
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
scope '::development?' do
|
24
|
+
test "returns true if ENV['RACK_ENV'] = :development" do
|
25
|
+
with_env('development') do
|
26
|
+
assert Ment.development?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
test "returns false if ENV['RACK_ENV'] != :development" do
|
31
|
+
assert !Ment.development?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
scope '::production?' do
|
36
|
+
test "returns true if ENV['RACK_ENV'] = :production" do
|
37
|
+
with_env('production') do
|
38
|
+
assert Ment.production?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
test "returns false if ENV['RACK_ENV'] != :production" do
|
43
|
+
assert !Ment.production?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
scope '::test?' do
|
48
|
+
test "returns true if ENV['RACK_ENV'] = :test" do
|
49
|
+
assert Ment.test?
|
50
|
+
end
|
51
|
+
|
52
|
+
test "returns false if ENV['RACK_ENV'] != :test" do
|
53
|
+
with_env('development') do
|
54
|
+
assert !Ment.test?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
8
60
|
scope '::environment' do
|
9
61
|
test 'returns the current environment' do
|
10
62
|
with_env('development') do
|
11
63
|
assert_equal :development, App.environment
|
12
64
|
end
|
13
65
|
end
|
66
|
+
|
67
|
+
test 'returns :development if there is no current environment' do
|
68
|
+
with_env(nil) do
|
69
|
+
assert_equal :development, App.environment
|
70
|
+
end
|
71
|
+
end
|
14
72
|
end
|
15
73
|
|
16
74
|
scope '#environment' do
|
@@ -19,6 +77,12 @@ scope Ment do
|
|
19
77
|
assert_equal :development, @app.environment
|
20
78
|
end
|
21
79
|
end
|
80
|
+
|
81
|
+
test 'returns :development if there is no current environment' do
|
82
|
+
with_env(nil) do
|
83
|
+
assert_equal :development, @app.environment
|
84
|
+
end
|
85
|
+
end
|
22
86
|
end
|
23
87
|
|
24
88
|
scope '::development?' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio Mac Adden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|