flipper-cache_store 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ lib/**/*.rb
2
+ -
3
+ LICENSE.txt
@@ -0,0 +1,48 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+
14
+ # jeweler generated
15
+ pkg
16
+
17
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
18
+ #
19
+ # * Create a file at ~/.gitignore
20
+ # * Include files you want ignored
21
+ # * Run: git config --global core.excludesfile ~/.gitignore
22
+ #
23
+ # After doing this, these files will be ignored in all your git projects,
24
+ # saving you from having to 'pollute' every project you touch with them
25
+ #
26
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
27
+ #
28
+ # For MacOS:
29
+ #
30
+ #.DS_Store
31
+
32
+ # For TextMate
33
+ #*.tmproj
34
+ #tmtags
35
+
36
+ # For emacs:
37
+ #*~
38
+ #\#*
39
+ #.\#*
40
+
41
+ # For vim:
42
+ #*.swp
43
+
44
+ # For redcar:
45
+ #.redcar
46
+
47
+ # For rubinius:
48
+ #*.rbc
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "bundler", "~> 1.2.0"
7
+ gem "jeweler", "~> 1.6.4"
8
+ end
9
+
10
+ group :development, :test do
11
+ gem "rspec", "~>2.0"
12
+ end
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ flipper-cache_store (0.0.1)
5
+ activesupport (>= 3.0)
6
+ flipper (~> 0.2.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activesupport (3.2.11)
12
+ i18n (~> 0.6)
13
+ multi_json (~> 1.0)
14
+ diff-lcs (1.1.3)
15
+ flipper (0.2.1)
16
+ git (1.2.5)
17
+ i18n (0.6.1)
18
+ jeweler (1.6.4)
19
+ bundler (~> 1.0)
20
+ git (>= 1.2.5)
21
+ rake
22
+ multi_json (1.5.0)
23
+ rake (10.0.3)
24
+ rspec (2.11.0)
25
+ rspec-core (~> 2.11.0)
26
+ rspec-expectations (~> 2.11.0)
27
+ rspec-mocks (~> 2.11.0)
28
+ rspec-core (2.11.1)
29
+ rspec-expectations (2.11.3)
30
+ diff-lcs (~> 1.1.3)
31
+ rspec-mocks (2.11.3)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 1.2.0)
38
+ flipper-cache_store!
39
+ jeweler (~> 1.6.4)
40
+ rspec (~> 2.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Jason Nochlin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ flipper-cache_store
2
+ =============
3
+
4
+ Flipper adapter for ActiveSupport::Cache::Store children
5
+
6
+ Currently only works with Flipper 0.2.*
7
+
8
+ Installation
9
+ ============
10
+
11
+ Add to your Gemfile:
12
+
13
+ `gem 'flipper-cache_store', '~> 0.0.1'
14
+
15
+
16
+ TODO
17
+ ====
18
+
19
+ Flipper 0.3 support
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require "bundler/gem_tasks"
15
+
16
+ require 'rspec/core/rake_task'
17
+ RSpec::Core::RakeTask.new(:spec) do |t|
18
+ t.rspec_opts = '--color'
19
+ end
20
+
21
+ task :default => :spec
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/flipper/adapters/cache_store/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jason Nochlin"]
6
+ gem.description = "Use ActiveSupport::Cache::Store as the backend for Flipper (https://github.com/jnunemaker/flipper)"
7
+ gem.email = ["hundredwatt@gmail.com"]
8
+ gem.homepage = "http://github.com/hundredwatt/flipper-cache_store"
9
+ gem.summary = "Use ActiveSupport::Cache::Store as the backend for Flipper"
10
+
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.name = "flipper-cache_store"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Flipper::Adapters::CacheStore::VERSION
16
+ gem.add_dependency 'flipper', '~> 0.2.0'
17
+ gem.add_dependency 'activesupport', '>= 3.0'
18
+ end
@@ -0,0 +1,2 @@
1
+ require 'active_support'
2
+ require 'flipper/adapters/cache_store'
@@ -0,0 +1,45 @@
1
+ module Flipper
2
+ module Adapters
3
+ class CacheStore
4
+ def initialize(cache_store)
5
+ @cache_store = cache_store
6
+ end
7
+
8
+ def read(key)
9
+ @cache_store.read key.to_s
10
+ end
11
+
12
+ def write(key, value)
13
+ @cache_store.write key.to_s, value
14
+ end
15
+
16
+ def delete(key)
17
+ @cache_store.delete key.to_s
18
+ end
19
+
20
+ def set_add(key, value)
21
+ ensure_set_initialized(key)
22
+ set = read(key)
23
+ set.add value
24
+ write(key, set)
25
+ end
26
+
27
+ def set_delete(key, value)
28
+ ensure_set_initialized(key)
29
+ set = read(key)
30
+ set.delete value
31
+ write(key, set)
32
+ end
33
+
34
+ def set_members(key)
35
+ ensure_set_initialized(key)
36
+ @cache_store.read key.to_s
37
+ end
38
+
39
+ private
40
+ def ensure_set_initialized(key)
41
+ @cache_store.fetch(key) { Set.new }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,7 @@
1
+ module Flipper
2
+ module Adapters
3
+ class CacheStore
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'flipper/adapters/cache_store'
3
+ require 'flipper/spec/shared_adapter_specs'
4
+
5
+ describe Flipper::Adapters::CacheStore do
6
+ let(:cache_store) { ActiveSupport::Cache::MemoryStore.new }
7
+
8
+ subject { Flipper::Adapters::CacheStore.new(cache_store) }
9
+
10
+ def read_key(key)
11
+ cache_store.read(key)
12
+ end
13
+
14
+ def write_key(key, value)
15
+ cache_store.write(key,value)
16
+ end
17
+
18
+ it_should_behave_like 'a flipper adapter'
19
+ end
@@ -0,0 +1,5 @@
1
+ $:.unshift(File.expand_path('../../lib', __FILE__))
2
+
3
+ Bundler.require(:default, :test)
4
+
5
+ require 'flipper-rails'
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flipper-cache_store
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Nochlin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: flipper
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ description: Use ActiveSupport::Cache::Store as the backend for Flipper (https://github.com/jnunemaker/flipper)
47
+ email:
48
+ - hundredwatt@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .document
54
+ - .gitignore
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENSE.txt
58
+ - README.md
59
+ - Rakefile
60
+ - flipper-cache_store.gemspec
61
+ - lib/flipper-cache_store.rb
62
+ - lib/flipper/adapters/cache_store.rb
63
+ - lib/flipper/adapters/cache_store/version.rb
64
+ - spec/flipper/adapaters/cache_store_spec.rb
65
+ - spec/spec_helper.rb
66
+ homepage: http://github.com/hundredwatt/flipper-cache_store
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ segments:
79
+ - 0
80
+ hash: 4464876890437254363
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ segments:
88
+ - 0
89
+ hash: 4464876890437254363
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 1.8.24
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Use ActiveSupport::Cache::Store as the backend for Flipper
96
+ test_files:
97
+ - spec/flipper/adapaters/cache_store_spec.rb
98
+ - spec/spec_helper.rb