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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4ebcdda544e379922fa793a74525a10004b5fbbe0363b5eecb65645836961f1
4
- data.tar.gz: 5b5267ac736e22c8caeccdcd66acafc6e2c0daa6998f279a72bdba7ecca26fc8
3
+ metadata.gz: 65aa521fa0d331670c1850a44f75aae0cfdb2863ab63d66541eded9d02a76810
4
+ data.tar.gz: 1be70e54cf0e0cd50de1bed4dca36989e8c72807f115286ac5796d742566f0ac
5
5
  SHA512:
6
- metadata.gz: 9f7a2c709d07eeb6b4a1176f237d7f9968d8a9d5d96941a51793e3b633292d99b9e92a9f443814d5290fc9179b1117559f250d2540fea0fc4ace4bf17dfeec45
7
- data.tar.gz: e048c980065e2c2357ca5e8cfb0b5190ec785f5526e46c50caa4da912bf5e5ddb6308d9e0dbf308d05c1df9541e4ad001b5d59a003152608b00f464423db2cc8
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
@@ -6,7 +6,7 @@ module A9n
6
6
 
7
7
  def initialize(file_path, scope, env)
8
8
  @scope = scope
9
- @env = env.to_s
9
+ @env = ::A9n::StringInquirer.new(env.to_s)
10
10
  @local_file = file_path
11
11
  @example_file = "#{file_path}.example"
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module A9n
2
- VERSION = "0.5.7"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -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.5.7
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-12 00:00:00.000000000 Z
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