feature_flag_client 0.2.2 → 0.3.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: 10eaa56f76079b041f451559fdba1ba2d3e1d12d5d3a497f319c1e6253b9f326
4
- data.tar.gz: e5104709f1d61669e7190909ff75734f0d63449a5d0f274b184c93351448924c
3
+ metadata.gz: 7065c7ae5de763c0b60757abd3acd69d954cfbcd061fc7111dc1eaa2528b07a7
4
+ data.tar.gz: 4bbf3c3ea64cfe1e0d930b7c8354b5e1d9d7d9bb14ac79f6d64976c7554e38d1
5
5
  SHA512:
6
- metadata.gz: 49fcb38b5df36aed09a6f2841a88d2055c3080a72ed681538965e3ffad100a6d8012566d8f15098a37de2a79d9111d6d07c41e9f02bf24baa6ce6a02fe3b1a47
7
- data.tar.gz: 9ce9be77d991a86dcd8ef6603126fc8f0d57c4a907e8de3e8c642e07dea82b1ee86218258c27d6585d94effebcc6781e67a0dcd8e5f199ad40a7efc282bce751
6
+ metadata.gz: 4f46c05adc2f1ab77e7346bdaafe93dcb9a45c24cd02776c8eba35271eb39aa2d60a0bf38ad98c813ff611c50d4a79c49881fe339145968959fcfc0d3cecbd31
7
+ data.tar.gz: bb6dca6a4596fd467c59738befcf6966cdc5b7665e0caee51139bf6dbe29197c7931aa3e8c3306ab9dda6c4bbc480cecd18d9bdbc3799f3682464c616d352fcc
@@ -1,3 +1,7 @@
1
+ ## 0.3.0
2
+
3
+ * Fix the wrong documentation on configuration in README
4
+ * Add `FeaturesCollection` to improve the interface of feature data
1
5
  ## 0.2.2
2
6
 
3
7
  * Update readme with usage and out of date description
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feature_flag_client (0.2.1)
4
+ feature_flag_client (0.3.0)
5
5
  httparty (~> 0.17.3)
6
6
  mini_cache (~> 1.1)
7
7
 
@@ -19,7 +19,7 @@ GEM
19
19
  multi_xml (>= 0.5.2)
20
20
  mime-types (3.3.1)
21
21
  mime-types-data (~> 3.2015)
22
- mime-types-data (3.2019.1009)
22
+ mime-types-data (3.2020.1104)
23
23
  mini_cache (1.1.0)
24
24
  multi_xml (0.6.0)
25
25
  parallel (1.19.2)
data/README.md CHANGED
@@ -24,23 +24,31 @@ Or install it yourself as:
24
24
  require 'feature_flag_client'
25
25
 
26
26
  # In some initializer
27
- FeatureFlagClient::Configure do |config|
27
+ FeatureFlagClient::Client.configure do |config|
28
28
  # Main resource API to get feature flags
29
- config.api_base_url = 'https://api-feature-flag-service.eu-west-1.elb.amazonaws.com/api/v1'
29
+ config.api_base_url = 'https://yeahrnb59i.execute-api.eu-west-1.amazonaws.com/dev/api/v1'
30
30
 
31
31
  # Featureflag service Auth api to get access token
32
- config.auth_url = 'https://api-feature-flag-service.eu-west-1.elb.amazonaws.com/auth/token'
32
+ config.auth_url = 'https://yeahrnb59i.execute-api.eu-west-1.amazonaws.com/dev/auth/token'
33
33
 
34
34
  # client id and secret to get access token
35
- config.client_id = '645da701fce2a12c'
36
- config.client_secret = '13c77fa6f8e742fa036cd9f9afa912A@' # store this in a secret manager
35
+ config.client_id = 'xxxx'
36
+ config.client_secret = 'xxxxxxxxxxxxxxxxxxxx' # store this in a secret manager
37
37
  end
38
38
 
39
39
  # Elsewhere in the code
40
40
  client = FeatureFlagClient.new
41
41
  product_name = 'cool product'
42
- client.features('cool product')
43
- # => {"feature name"=>#<OpenStruct name="feature name", enabled=false, createdAt="2020-09-08T22:08:07.971Z", updatedAt="2020-09-18T23:37:59.479Z">, "feature name 2"=>#<OpenStruct name="feature name 2", enabled=true, createdAt="2020-09-08T22:08:14.309Z", updatedAt="2020-09-11T14:27:29.678Z">, "Magic Feature"=>#<OpenStruct name="Magic Feature", enabled=true, createdAt="2020-09-11T14:27:39.515Z", updatedAt="2020-09-11T14:27:45.873Z">}
42
+ features = client.features('cool product')
43
+ # => #<FeatureFlagClient::FeatureCollection:0x00007fb1981a32f8 @features={"qr-logo"=>#<OpenStruct name="qr-logo", enabled=true, createdAt="2020-12-15T14:07:50.274Z", updatedAt="2020-12-15T15:28:46.162Z">, "qr code 2"=>#<OpenStruct name="qr code 2", enabled=false, createdAt="2020-12-15T15:28:52.065Z", updatedAt="2020-12-15T15:28:52.066Z">}>
44
+
45
+ features.feature('qr-logo').enabled
46
+ # => true
47
+
48
+ # When looking for a non-existing feature
49
+ features.feature('non-existing')
50
+ # => nil
51
+
44
52
  ```
45
53
 
46
54
  ## Development
@@ -52,12 +52,31 @@ module FeatureFlagClient
52
52
  end
53
53
  end
54
54
 
55
+ class FeatureCollection
56
+ attr_reader :features
57
+
58
+ def initialize(_features)
59
+ p _features
60
+ @features = _features
61
+ end
62
+
63
+ def feature(name)
64
+ features[name]
65
+ end
66
+
67
+ def to_json(*_args)
68
+ features.keys.each_with_object({}) do |feature_name, result|
69
+ result[feature_name] = feature(feature_name).marshal_dump
70
+ end.to_json
71
+ end
72
+ end
73
+
55
74
  # Api Client class to fetch the features
56
75
  class Client
57
76
  include FeatureFlagClient::Version
58
77
 
59
78
  CACHE_KEY = 'features'
60
- CACHE_TTL = 3600
79
+ CACHE_TTL = 60
61
80
 
62
81
  def self.config
63
82
  @config ||= FeatureFlagClient::Configuration.new
@@ -84,7 +103,7 @@ module FeatureFlagClient
84
103
 
85
104
  raise ClientError, response.error unless response.ok?
86
105
 
87
- cache.set("#{CACHE_KEY}_#{product_name}", response.parsed, expires_in: CACHE_TTL)
106
+ cache.set("#{CACHE_KEY}_#{product_name}", FeatureCollection.new(response.parsed), expires_in: CACHE_TTL)
88
107
  end
89
108
 
90
109
  cache.get("#{CACHE_KEY}_#{product_name}")
@@ -2,6 +2,6 @@
2
2
 
3
3
  module FeatureFlagClient
4
4
  module Version
5
- VERSION = '0.2.2'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature_flag_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ardeshir Eshghi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2020-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty