featureswitches 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/featureswitches/version.rb +1 -1
- data/lib/featureswitches.rb +18 -7
- 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: 3a271eaf67a7a93bd229bd038363e9519cb0714e
|
4
|
+
data.tar.gz: 691348e77ddf74622e9097f83257040416f43604
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 178b8e912dd12aff7aa8a85b1703e8a303f8513e5ccadafaea3c8f904d49b63835634f36bb6629bd66d727879abdbf17acd58c7ab006f378fd3ee223b1779cb3
|
7
|
+
data.tar.gz: 0f38529ce654a05049bace5c4b6ed2a40f45157e9c1d16495e2ea6fae5d15a7510c6d355a5ca298e0d4f6ada227d5cd512601fc5ff066eb920a78255b379721e
|
data/lib/featureswitches.rb
CHANGED
@@ -15,7 +15,9 @@ class Featureswitches
|
|
15
15
|
|
16
16
|
@cache = Cache.new
|
17
17
|
|
18
|
-
@
|
18
|
+
if @cache_timeout > 0
|
19
|
+
@dirty_check_thread = do_dirty_check
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
def authenticate
|
@@ -27,13 +29,16 @@ class Featureswitches
|
|
27
29
|
|
28
30
|
def sync
|
29
31
|
endpoint = 'features'
|
30
|
-
response = api_request(endpoint)
|
31
32
|
|
32
|
-
|
33
|
+
if @cache_timeout > 0
|
34
|
+
response = api_request(endpoint)
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
features = response[:data]['features']
|
37
|
+
|
38
|
+
features.each do |feature|
|
39
|
+
feature['last_sync'] = Time.now.to_i
|
40
|
+
@cache[feature['feature_key']] = feature
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
@@ -91,7 +96,9 @@ class Featureswitches
|
|
91
96
|
feature = response[:data]['feature']
|
92
97
|
|
93
98
|
feature['last_sync'] = Time.now.to_i
|
94
|
-
@
|
99
|
+
if @cache_timeout > 0
|
100
|
+
@cache[feature['feature_key']] = feature
|
101
|
+
end
|
95
102
|
|
96
103
|
return feature
|
97
104
|
end
|
@@ -122,6 +129,10 @@ class Featureswitches
|
|
122
129
|
end
|
123
130
|
|
124
131
|
def cache_is_stale(feature)
|
132
|
+
if @cache_timeout == 0
|
133
|
+
return true
|
134
|
+
end
|
135
|
+
|
125
136
|
cache_expiration = (Time.now.to_i - @cache_timeout)
|
126
137
|
if feature['last_sync'] > cache_expiration and @last_dirty_check > cache_expiration
|
127
138
|
return false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: featureswitches
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Weirauch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|