flipper-cloud 0.11.0.beta3 → 0.11.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flipper/cloud.rb +34 -6
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/cloud_spec.rb +20 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35b32dfc86bd5320e6e9c71472ebc882c82c197b
|
4
|
+
data.tar.gz: a2813c39e2b5ddddde7712ee88a48a3c4e14c919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1632d38593bb9a06532729397948afb14539c00d72a636a79f2510ac501bb208159f7df87d9ed7a5d5da44c6efc79c0542ee29af6a27be644bb30544da71a761
|
7
|
+
data.tar.gz: f1b34ba791300fd32c0747caf9744eb278c9caccf61663eb8abc17b28d0d9b38c276e15d2afae856be71d5900223f6a0a55d57797ed66c5dd88f1b3e896bde15
|
data/lib/flipper/cloud.rb
CHANGED
@@ -1,14 +1,42 @@
|
|
1
1
|
require "flipper/adapters/http"
|
2
|
+
require "flipper/instrumenters/noop"
|
2
3
|
|
3
4
|
module Flipper
|
4
5
|
module Cloud
|
6
|
+
# The default adapter wrapper which doesn't wrap at all.
|
7
|
+
DEFAULT_ADAPTER_WRAPPER_BLOCK = ->(adapter) { adapter }
|
8
|
+
|
9
|
+
# The default url should be the one, the only, the website.
|
10
|
+
DEFAULT_URL = "https://www.featureflipper.com/adapter".freeze
|
11
|
+
|
12
|
+
# Public: Returns a new Flipper instance with an http adapter correctly
|
13
|
+
# configured for flipper cloud.
|
14
|
+
#
|
15
|
+
# token - The String token for the environment from the website.
|
16
|
+
# options - The Hash of options.
|
17
|
+
# # :url - The url to point at (defaults to DEFAULT_URL).
|
18
|
+
# # :adapter_wrapper - The adapter wrapper block. Block should
|
19
|
+
# receive an adapter and return an adapter.
|
20
|
+
# Allows you to wrap the http adapter with
|
21
|
+
# other adapters to make instrumentation and
|
22
|
+
# caching easy.
|
23
|
+
# # :instrumenter - The optional instrumenter to use for the
|
24
|
+
# Flipper::DSL instance (defaults to Noop).
|
5
25
|
def self.new(token, options = {})
|
6
|
-
url = options.fetch(:url)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
26
|
+
url = options.fetch(:url, DEFAULT_URL)
|
27
|
+
http_options = {
|
28
|
+
uri: URI(url),
|
29
|
+
headers: {
|
30
|
+
"Feature-Flipper-Token" => token,
|
31
|
+
},
|
32
|
+
}
|
33
|
+
adapter = Flipper::Adapters::Http.new(http_options)
|
34
|
+
|
35
|
+
adapter_wrapper = options.fetch(:adapter_wrapper, DEFAULT_ADAPTER_WRAPPER_BLOCK)
|
36
|
+
adapter = adapter_wrapper.call(adapter)
|
37
|
+
|
38
|
+
instrumenter = options.fetch(:instrumenter, Flipper::Instrumenters::Noop)
|
39
|
+
Flipper.new(adapter, instrumenter: instrumenter)
|
12
40
|
end
|
13
41
|
end
|
14
42
|
end
|
data/lib/flipper/version.rb
CHANGED
data/spec/flipper/cloud_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'flipper/cloud'
|
3
|
+
require 'flipper/adapters/instrumented'
|
3
4
|
|
4
5
|
RSpec.describe Flipper::Cloud do
|
5
6
|
context "initialize with token" do
|
@@ -31,6 +32,10 @@ RSpec.describe Flipper::Cloud do
|
|
31
32
|
headers = @http_client.instance_variable_get('@headers')
|
32
33
|
expect(headers['Feature-Flipper-Token']).to eq(token)
|
33
34
|
end
|
35
|
+
|
36
|
+
it 'uses noop instrumenter' do
|
37
|
+
expect(@instance.instrumenter).to be(Flipper::Instrumenters::Noop)
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
context 'initialize with token and options' do
|
@@ -48,4 +53,19 @@ RSpec.describe Flipper::Cloud do
|
|
48
53
|
expect(uri.path).to eq('/sadpanda')
|
49
54
|
end
|
50
55
|
end
|
56
|
+
|
57
|
+
it 'can set instrumenter' do
|
58
|
+
instrumenter = Object.new
|
59
|
+
instance = described_class.new('asdf', instrumenter: instrumenter)
|
60
|
+
expect(instance.instrumenter).to be(instrumenter)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'allows wrapping adapter with another adapter like the instrumenter' do
|
64
|
+
adapter_wrapper = lambda do |adapter|
|
65
|
+
Flipper::Adapters::Instrumented.new(adapter)
|
66
|
+
end
|
67
|
+
instance = described_class.new('asdf', adapter_wrapper: adapter_wrapper)
|
68
|
+
# instance.adapter is memoizable adapter instance
|
69
|
+
expect(instance.adapter.adapter).to be_instance_of(Flipper::Adapters::Instrumented)
|
70
|
+
end
|
51
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.0.
|
4
|
+
version: 0.11.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flipper
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.11.0.
|
19
|
+
version: 0.11.0.beta4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.11.0.
|
26
|
+
version: 0.11.0.beta4
|
27
27
|
description: FeatureFlipper.com adapter for Flipper
|
28
28
|
email:
|
29
29
|
- nunemaker@gmail.com
|