flipper-fallback 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8b00f30c489590951f155d673511d0e74766413c
4
+ data.tar.gz: 5fc83acd782352c45533b9a478dd0d92270059fa
5
+ SHA512:
6
+ metadata.gz: 8f1f74e3db8cd1e741109402960144590fa87c8899b68ddd99fd11ab8cdf956d1dcdadbd301402852eb5b825ced47de5ba2cc3ff206f0b3a32095e6f1eaacf72
7
+ data.tar.gz: 4689281861eceb786d1435fd4c7452742f707e21b2310fee4bde0f4969e77b2522475c61be8b6ac7d40faa7f91272cd5e3c4d43a02072c3298b91e33aa191d81
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flipper-fallback.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Chris Lundquist
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Flipper::Fallback
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'flipper-fallback'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install flipper-fallback
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/flipper-fallback/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/fallback_spec.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'helper'
2
+ require 'flipper/adapters/redis'
3
+ require 'flipper/adapters/fallback'
4
+ require 'flipper/spec/shared_adapter_specs'
5
+
6
+ describe Flipper::Adapters::Fallback do
7
+ context "when redis is available" do
8
+ let(:client) {
9
+ options = {}
10
+
11
+ if ENV['BOXEN_REDIS_URL']
12
+ options[:url] = ENV['BOXEN_REDIS_URL']
13
+ end
14
+
15
+ Redis.new(options)
16
+ }
17
+
18
+ subject { described_class.new(Flipper::Adapters::Redis.new(client)) }
19
+
20
+ before do
21
+ client.flushdb
22
+ end
23
+
24
+ it_should_behave_like 'a flipper adapter'
25
+ end
26
+
27
+ context "when redis is not available" do
28
+ let(:client) {
29
+ options = {}
30
+
31
+ if ENV['BOXEN_REDIS_URL']
32
+ options[:url] = "redis://doesnotexit:1"
33
+ end
34
+
35
+ Redis.new(options)
36
+ }
37
+
38
+ subject { described_class.new(Flipper::Adapters::Redis.new(client)) }
39
+
40
+ it_should_behave_like 'a flipper adapter'
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flipper/adapters/fallback'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flipper-fallback"
8
+ spec.version = Flipper::Adapters::Fallback::VERSION
9
+ spec.authors = ["Chris Lundquist"]
10
+ spec.email = ["chris.lundquist@github.com"]
11
+ spec.summary = %q{Fallback to another flipper adapter when the primary one fails.}
12
+ spec.description = %q{Fallback to another flipper adapter when the primary one fails.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'flipper'
22
+ spec.add_development_dependency 'bundler', '~> 1.6'
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'flipper-redis'
25
+ spec.add_development_dependency 'rspec', '< 3.0.0' #upstream
26
+ end
@@ -0,0 +1,7 @@
1
+ module Flipper
2
+ module Adapters
3
+ class Fallback
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ require 'flipper'
2
+ require 'flipper/adapters/memory'
3
+ require 'delegate'
4
+
5
+ module Flipper
6
+ module Adapters
7
+ class Fallback < SimpleDelegator
8
+ VERSION = '0.0.1'
9
+ def initialize(primary_adapter, fallback_adapter = Flipper::Adapters::Memory.new)
10
+ super(primary_adapter)
11
+ @primary_adapter = primary_adapter
12
+ @fallback_adapter = fallback_adapter
13
+
14
+ @delegate_sd_obj = primary_adapter
15
+ end
16
+
17
+ def method_missing(m, *args, &block)
18
+ super
19
+ rescue => e
20
+ STDERR.puts("[Flipper::Adapters::Fallback] Primary adapter(#{@primary_adapter.inspect}) Failure! #{e}")
21
+ STDERR.puts("[Flipper::Adapters::Fallback] Falling back to #{@fallback_adapter.inspect})")
22
+ @fallback_adapter.__send__(m, *args, &block)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ module Flipper
2
+ module Fallback
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require "flipper/fallback/version"
@@ -0,0 +1 @@
1
+ require 'flipper/adapters/fallback'
@@ -0,0 +1,42 @@
1
+ require 'helper'
2
+ require 'flipper/adapters/redis'
3
+ require 'flipper/adapters/fallback'
4
+ require 'flipper/spec/shared_adapter_specs'
5
+
6
+ describe Flipper::Adapters::Fallback do
7
+ context "when redis is available" do
8
+ let(:client) {
9
+ options = {}
10
+
11
+ if ENV['BOXEN_REDIS_URL']
12
+ options[:url] = ENV['BOXEN_REDIS_URL']
13
+ end
14
+
15
+ Redis.new(options)
16
+ }
17
+
18
+ subject { described_class.new(Flipper::Adapters::Redis.new(client)) }
19
+
20
+ before do
21
+ client.flushdb
22
+ end
23
+
24
+ it_should_behave_like 'a flipper adapter'
25
+ end
26
+
27
+ context "when redis is not available" do
28
+ let(:client) {
29
+ options = {}
30
+
31
+ if ENV['BOXEN_REDIS_URL']
32
+ options[:url] = "redis://doesnotexit:1"
33
+ end
34
+
35
+ Redis.new(options)
36
+ }
37
+
38
+ subject { described_class.new(Flipper::Adapters::Redis.new(client)) }
39
+
40
+ it_should_behave_like 'a flipper adapter'
41
+ end
42
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'flipper-redis'
4
+
5
+ RSpec.configure do |config|
6
+ config.filter_run :focused => true
7
+ config.alias_example_to :fit, :focused => true
8
+ config.alias_example_to :xit, :pending => true
9
+ config.run_all_when_everything_filtered = true
10
+ config.fail_fast = true
11
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flipper-fallback
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Lundquist
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-26 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: flipper-redis
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ description: Fallback to another flipper adapter when the primary one fails.
84
+ email:
85
+ - chris.lundquist@github.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - fallback_spec.rb
96
+ - flipper-fallback.gemspec
97
+ - lib/flipper-fallback.rb
98
+ - lib/flipper/adapters/fallback.rb
99
+ - lib/flipper/adapters/fallback/version.rb
100
+ - lib/flipper/fallback.rb
101
+ - lib/flipper/fallback/version.rb
102
+ - spec/fallback_spec.rb
103
+ - spec/helper.rb
104
+ homepage: ''
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.2
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Fallback to another flipper adapter when the primary one fails.
128
+ test_files:
129
+ - spec/fallback_spec.rb
130
+ - spec/helper.rb