flipper-cloud 0.11.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/examples/cloud/basic.rb +26 -0
- data/flipper-cloud.gemspec +26 -0
- data/lib/flipper-cloud.rb +1 -0
- data/lib/flipper/cloud.rb +14 -0
- data/lib/flipper/version.rb +3 -0
- data/spec/flipper/cloud_spec.rb +51 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a5f051981db9d4bacba43772a5cf11ef5972e434
|
4
|
+
data.tar.gz: 67dee7f2edb938e487511268f03415321e94c8b5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f5675e8f0c007d5ae6acdbfd2f6ca111648d2436058903455ee5a1c0352ac85d27e3ff5349158d9f066cb95194d739cc1eaa85de8df702644f74c1a0b84a035
|
7
|
+
data.tar.gz: 8de4d89ce222617a39ecb6ed3d6783316dab81a9aab01ec80de591b274d0ad41e6d8902739abbb3570cb3ae3640efea2a0b3456eeed6d8f7a7d63e70a19a4562
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Usage (from the repo root):
|
2
|
+
# env TOKEN=<token> bundle exec ruby examples/cloud/basic.rb
|
3
|
+
require 'pathname'
|
4
|
+
require 'logger'
|
5
|
+
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
6
|
+
lib_path = root_path.join('lib')
|
7
|
+
$:.unshift(lib_path)
|
8
|
+
|
9
|
+
require 'flipper/cloud'
|
10
|
+
flipper = Flipper::Cloud.new(ENV.fetch('TOKEN'))
|
11
|
+
|
12
|
+
flipper[:stats].enable
|
13
|
+
|
14
|
+
if flipper[:stats].enabled?
|
15
|
+
puts 'Enabled!'
|
16
|
+
else
|
17
|
+
puts 'Disabled!'
|
18
|
+
end
|
19
|
+
|
20
|
+
flipper[:stats].disable
|
21
|
+
|
22
|
+
if flipper[:stats].enabled?
|
23
|
+
puts 'Enabled!'
|
24
|
+
else
|
25
|
+
puts 'Disabled!'
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/flipper/version', __FILE__)
|
3
|
+
|
4
|
+
flipper_cloud_files = lambda do |file|
|
5
|
+
file =~ /cloud/
|
6
|
+
end
|
7
|
+
|
8
|
+
Gem::Specification.new do |gem|
|
9
|
+
gem.authors = ['John Nunemaker']
|
10
|
+
gem.email = ['nunemaker@gmail.com']
|
11
|
+
gem.summary = 'FeatureFlipper.com adapter for Flipper'
|
12
|
+
gem.description = 'FeatureFlipper.com adapter for Flipper'
|
13
|
+
gem.license = 'MIT'
|
14
|
+
gem.homepage = 'https://github.com/jnunemaker/flipper'
|
15
|
+
|
16
|
+
extra_files = [
|
17
|
+
'lib/flipper/version.rb',
|
18
|
+
]
|
19
|
+
gem.files = `git ls-files`.split("\n").select(&flipper_cloud_files) + extra_files
|
20
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_cloud_files)
|
21
|
+
gem.name = 'flipper-cloud'
|
22
|
+
gem.require_paths = ['lib']
|
23
|
+
gem.version = Flipper::VERSION
|
24
|
+
|
25
|
+
gem.add_dependency 'flipper', "~> #{Flipper::VERSION}"
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "flipper/cloud"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "flipper/adapters/http"
|
2
|
+
|
3
|
+
module Flipper
|
4
|
+
module Cloud
|
5
|
+
def self.new(token, options = {})
|
6
|
+
url = options.fetch(:url) { "https://www.featureflipper.com/adapter" }
|
7
|
+
adapter = Flipper::Adapters::Http.new(uri: URI(url),
|
8
|
+
headers: {
|
9
|
+
"Feature-Flipper-Token" => token,
|
10
|
+
})
|
11
|
+
Flipper.new(adapter)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'flipper/cloud'
|
3
|
+
|
4
|
+
RSpec.describe Flipper::Cloud do
|
5
|
+
context "initialize with token" do
|
6
|
+
let(:token) { 'asdf' }
|
7
|
+
|
8
|
+
before do
|
9
|
+
@instance = described_class.new(token)
|
10
|
+
memoized_adapter = @instance.adapter
|
11
|
+
@http_adapter = memoized_adapter.adapter
|
12
|
+
@http_client = @http_adapter.instance_variable_get('@client')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns Flipper::DSL instance' do
|
16
|
+
expect(@instance).to be_instance_of(Flipper::DSL)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'configures instance to use http adapter' do
|
20
|
+
expect(@http_adapter).to be_instance_of(Flipper::Adapters::Http)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sets up correct url' do
|
24
|
+
uri = @http_client.instance_variable_get('@uri')
|
25
|
+
expect(uri.scheme).to eq('https')
|
26
|
+
expect(uri.host).to eq('www.featureflipper.com')
|
27
|
+
expect(uri.path).to eq('/adapter')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'sets correct token header' do
|
31
|
+
headers = @http_client.instance_variable_get('@headers')
|
32
|
+
expect(headers['Feature-Flipper-Token']).to eq(token)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'initialize with token and options' do
|
37
|
+
before do
|
38
|
+
@instance = described_class.new('asdf', url: 'https://www.fakeflipper.com/sadpanda')
|
39
|
+
memoized_adapter = @instance.adapter
|
40
|
+
@http_adapter = memoized_adapter.adapter
|
41
|
+
@http_client = @http_adapter.instance_variable_get('@client')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'sets correct url' do
|
45
|
+
uri = @http_client.instance_variable_get('@uri')
|
46
|
+
expect(uri.scheme).to eq('https')
|
47
|
+
expect(uri.host).to eq('www.fakeflipper.com')
|
48
|
+
expect(uri.path).to eq('/sadpanda')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flipper-cloud
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.11.0.beta1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Nunemaker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: flipper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.11.0.beta1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.11.0.beta1
|
27
|
+
description: FeatureFlipper.com adapter for Flipper
|
28
|
+
email:
|
29
|
+
- nunemaker@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- examples/cloud/basic.rb
|
35
|
+
- flipper-cloud.gemspec
|
36
|
+
- lib/flipper-cloud.rb
|
37
|
+
- lib/flipper/cloud.rb
|
38
|
+
- lib/flipper/version.rb
|
39
|
+
- spec/flipper/cloud_spec.rb
|
40
|
+
homepage: https://github.com/jnunemaker/flipper
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.3.1
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.5.2
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: FeatureFlipper.com adapter for Flipper
|
64
|
+
test_files:
|
65
|
+
- spec/flipper/cloud_spec.rb
|