a9n 0.5.7 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/a9n.rb +2 -1
- data/lib/a9n/ext/string_inquirer.rb +18 -0
- data/lib/a9n/loader.rb +1 -1
- data/lib/a9n/version.rb +1 -1
- data/spec/unit/a9n_spec.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65aa521fa0d331670c1850a44f75aae0cfdb2863ab63d66541eded9d02a76810
|
4
|
+
data.tar.gz: 1be70e54cf0e0cd50de1bed4dca36989e8c72807f115286ac5796d742566f0ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 333ff3ed889e726a0768640eac415d8d558710706716df1356af8db02b31970f1c963fbf6cd2dba4da21d9490dd5fd48e8d66efe67614eefb798b59cebecca97
|
7
|
+
data.tar.gz: 37e5dc7c5fda2108ccdfe072525c954216bcd4b5af6e0127bf6cfdd6d5cf8ec0b750843c43a236304a4851fdb547e84f4dc913e9c25396fca3585ff227fa5cbd
|
data/lib/a9n.rb
CHANGED
@@ -7,6 +7,7 @@ require "a9n/version"
|
|
7
7
|
require "a9n/exceptions"
|
8
8
|
require "a9n/struct"
|
9
9
|
require "a9n/scope"
|
10
|
+
require "a9n/ext/string_inquirer"
|
10
11
|
require "a9n/ext/hash"
|
11
12
|
require "a9n/loader"
|
12
13
|
|
@@ -18,7 +19,7 @@ module A9n
|
|
18
19
|
|
19
20
|
class << self
|
20
21
|
def env
|
21
|
-
@env ||= app_env || env_var("RAILS_ENV") || env_var("RACK_ENV") || env_var("APP_ENV")
|
22
|
+
@env ||= ::A9n::StringInquirer.new(app_env || env_var("RAILS_ENV") || env_var("RACK_ENV") || env_var("APP_ENV"))
|
22
23
|
end
|
23
24
|
|
24
25
|
def env=(value)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# https://github.com/rails/rails/edit/master/activesupport/lib/active_support/string_inquirer.rb
|
2
|
+
module A9n
|
3
|
+
class StringInquirer < String
|
4
|
+
private
|
5
|
+
|
6
|
+
def respond_to_missing?(method_name, include_private = false)
|
7
|
+
(method_name[-1] == "?") || super
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(method_name, *arguments)
|
11
|
+
if method_name[-1] == "?"
|
12
|
+
self == method_name[0..-2]
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/a9n/loader.rb
CHANGED
data/lib/a9n/version.rb
CHANGED
data/spec/unit/a9n_spec.rb
CHANGED
@@ -10,12 +10,14 @@ RSpec.describe A9n do
|
|
10
10
|
|
11
11
|
context "app_env is set" do
|
12
12
|
before do
|
13
|
-
expect(subject).to receive(:app).and_return(double(env: "dwarf_env")).exactly(3).times
|
13
|
+
expect(subject).to receive(:app).and_return(double(env: ::A9n::StringInquirer.new("dwarf_env"))).exactly(3).times
|
14
14
|
expect(subject).to receive(:env_var).never
|
15
15
|
end
|
16
16
|
|
17
17
|
it do
|
18
18
|
expect(subject.env).to eq("dwarf_env")
|
19
|
+
expect(subject.env.dwarf_env?).to eq(true)
|
20
|
+
expect(subject.env.production?).to eq(false)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -29,6 +31,8 @@ RSpec.describe A9n do
|
|
29
31
|
|
30
32
|
it do
|
31
33
|
expect(subject.env).to eq("dwarf_env")
|
34
|
+
expect(subject.env.dwarf_env?).to eq(true)
|
35
|
+
expect(subject.env.production?).to eq(false)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: a9n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Knapik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/a9n/capistrano/ver2x.rb
|
104
104
|
- lib/a9n/exceptions.rb
|
105
105
|
- lib/a9n/ext/hash.rb
|
106
|
+
- lib/a9n/ext/string_inquirer.rb
|
106
107
|
- lib/a9n/loader.rb
|
107
108
|
- lib/a9n/scope.rb
|
108
109
|
- lib/a9n/struct.rb
|