offs 1.3.0 → 1.4.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
  SHA1:
3
- metadata.gz: c7db6d39408404296ef58f569ece95b32633ef09
4
- data.tar.gz: 2eaa89d57e80b8c512819fcf96fe6bb562bb9ba6
3
+ metadata.gz: 205ff73781d83a027350f1de8da287e0a8fec834
4
+ data.tar.gz: 4f6e7f8bdd804461590bdbbd0b81b54f36748b08
5
5
  SHA512:
6
- metadata.gz: d3996fa7d6619ba57aa666114d805a66f29c17fa4285c5223dcbe610d1c210d6d6c15192fd6382c67006caabe843525008ef9d0395dd4408acbabc89b7fc4557
7
- data.tar.gz: 2f44320aed399e0a488f397e2ec8738e36fc627fff2e33536870c08efcc44cec361d8dcb9e856c53082339deb7afef48c38c7a6b90a05ce75ee5ca9070c09e2c
6
+ metadata.gz: 72aaffded2072d1316c5bb33b6c235d113e1737a7db79d52d643f6e6879d0f538b70f2b5f6ef65d5e431f2766f6b8f7a12f9fab75b0f28206cb0f4dd181d9305
7
+ data.tar.gz: a73eff40479677cc647c291c166b9ada2e79465da6b582673478abfa9957d60cc4f527504a538d14420474a3b200024833123242b68de906815bf0128a2ca548
data/lib/offs/flags.rb CHANGED
@@ -27,7 +27,12 @@ class OFFS
27
27
  end
28
28
 
29
29
  def enabled?(flag)
30
- !!feature_flags[flag]
30
+ status = feature_flags[flag]
31
+ if status.respond_to?(:call)
32
+ status.call
33
+ else
34
+ !!status
35
+ end
31
36
  end
32
37
 
33
38
  def valid?(flag)
data/lib/offs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class OFFS
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
data/spec/offs_spec.rb CHANGED
@@ -16,6 +16,7 @@ describe OFFS do
16
16
  let(:feature_flags) {
17
17
  OFFS::Flags.set do |f|
18
18
  f.flag :my_cool_new_feature, feature_status
19
+ f.flag :my_runtime_feature, ->{ feature_status }
19
20
  end
20
21
  }
21
22
 
@@ -47,9 +48,7 @@ describe OFFS do
47
48
  end
48
49
  end
49
50
 
50
- context "and the feature is turned on by default" do
51
- let(:feature_status) { true }
52
-
51
+ shared_examples_for 'the feature is enabled' do
53
52
  it 'executes the would_like_to block' do
54
53
  expect(would_like_to_blk).to receive(:call)
55
54
  do_it
@@ -86,9 +85,19 @@ describe OFFS do
86
85
  end
87
86
  end
88
87
 
89
- context "and the feature is turned off by default" do
90
- let(:feature_status) { false }
88
+ context "and the feature is turned on by default" do
89
+ let(:feature_status) { true }
90
+
91
+ it_behaves_like 'the feature is enabled'
92
+
93
+ context "and the feature status is a Proc" do
94
+ let(:flag) { :my_runtime_feature }
95
+
96
+ it_behaves_like 'the feature is enabled'
97
+ end
98
+ end
91
99
 
100
+ shared_examples_for 'the feature is disabled' do
92
101
  it "executes the may_still_need_to block" do
93
102
  expect(may_still_need_to_blk).to receive(:call)
94
103
  do_it
@@ -125,5 +134,17 @@ describe OFFS do
125
134
  raise_error(OFFS::FeatureDisabled, /my_cool_new_feature/)
126
135
  end
127
136
  end
137
+
138
+ context "and the feature is turned off by default" do
139
+ let(:feature_status) { false }
140
+
141
+ it_behaves_like 'the feature is disabled'
142
+
143
+ context "and the feature status is a Proc" do
144
+ let(:flag) { :my_runtime_feature }
145
+
146
+ it_behaves_like 'the feature is disabled'
147
+ end
148
+ end
128
149
  end
129
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: offs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wilger