dkastner-moneta 0.7.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/shared.rb ADDED
@@ -0,0 +1,126 @@
1
+ shared_examples_for "a read/write Moneta cache" do
2
+ types = {
3
+ "String" => ["key", "key2"],
4
+ "Object" => [{:foo => :bar}, {:bar => :baz}]
5
+ }
6
+
7
+ types.each do |type, (key, key2)|
8
+ it "reads from keys that are #{type}s like a Hash" do
9
+ @cache[key].should == nil
10
+ end
11
+
12
+ it "writes String values to keys that are #{type}s like a Hash" do
13
+ @cache[key] = "value"
14
+ @cache[key].should == "value"
15
+ end
16
+
17
+ it "guarantees that a different String value is retrieved from the #{type} key" do
18
+ value = "value"
19
+ @cache[key] = value
20
+ @cache[key].should_not be_equal(value)
21
+ end
22
+
23
+ it "writes Object values to keys that are #{type}s like a Hash" do
24
+ @cache[key] = {:foo => :bar}
25
+ @cache[key].should == {:foo => :bar}
26
+ end
27
+
28
+ it "guarantees that a different Object value is retrieved from the #{type} key" do
29
+ value = {:foo => :bar}
30
+ @cache[key] = value
31
+ @cache[key].should_not be_equal(:foo => :bar)
32
+ end
33
+
34
+ it "returns false from key? if a #{type} key is not available" do
35
+ @cache.key?(key).should be_false
36
+ end
37
+
38
+ it "returns true from key? if a #{type} key is available" do
39
+ @cache[key] = "value"
40
+ @cache.key?(key).should be_true
41
+ end
42
+
43
+ it "removes and returns an element with a #{type} key from the backing store via delete if it exists" do
44
+ @cache[key] = "value"
45
+ @cache.delete(key).should == "value"
46
+ @cache.key?(key).should be_false
47
+ end
48
+
49
+ it "returns nil from delete if an element for a #{type} key does not exist" do
50
+ @cache.delete(key).should be_nil
51
+ end
52
+
53
+ it "removes all #{type} keys from the store with clear" do
54
+ @cache[key] = "value"
55
+ @cache[key2] = "value2"
56
+ @cache.clear
57
+ @cache.key?(key).should_not be_true
58
+ @cache.key?(key2).should_not be_true
59
+ end
60
+
61
+ it "fetches a #{type} key with a default value with fetch, if the key is not available" do
62
+ @cache.fetch(key, "value").should == "value"
63
+ end
64
+
65
+ it "fetches a #{type} key with a block with fetch, if the key is not available" do
66
+ @cache.fetch(key) { |k| "value" }.should == "value"
67
+ end
68
+
69
+ it "does not run the block if the #{type} key is available" do
70
+ @cache[key] = "value"
71
+ unaltered = "unaltered"
72
+ @cache.fetch(key) { unaltered = "altered" }
73
+ unaltered.should == "unaltered"
74
+ end
75
+
76
+ it "fetches a #{type} key with a default value with fetch, if the key is available" do
77
+ @cache[key] = "value2"
78
+ @cache.fetch(key, "value").should == "value2"
79
+ end
80
+
81
+ it "stores #{key} values with #store" do
82
+ @cache.store(key, "value")
83
+ @cache[key].should == "value"
84
+ end
85
+ end
86
+
87
+ it "refuses to #[] from keys that cannot be marshalled" do
88
+ lambda do
89
+ @cache[Struct.new(:foo).new(:bar)]
90
+ end.should raise_error(TypeError)
91
+ end
92
+
93
+ it "refuses to fetch from keys that cannot be marshalled" do
94
+ lambda do
95
+ @cache.fetch(Struct.new(:foo).new(:bar), true)
96
+ end.should raise_error(TypeError)
97
+ end
98
+
99
+ it "refuses to #[]= to keys that cannot be marshalled" do
100
+ lambda do
101
+ @cache[Struct.new(:foo).new(:bar)] = "value"
102
+ end.should raise_error(TypeError)
103
+ end
104
+
105
+ it "refuses to store to keys that cannot be marshalled" do
106
+ lambda do
107
+ @cache.store Struct.new(:foo).new(:bar), "value"
108
+ end.should raise_error(TypeError)
109
+ end
110
+
111
+ it "refuses to check for key? if the key cannot be marshalled" do
112
+ lambda do
113
+ @cache.key? Struct.new(:foo).new(:bar)
114
+ end.should raise_error(TypeError)
115
+ end
116
+
117
+ it "refuses to delete a key if the key cannot be marshalled" do
118
+ lambda do
119
+ @cache.delete Struct.new(:foo).new(:bar)
120
+ end.should raise_error(TypeError)
121
+ end
122
+
123
+ it "specifies that it is writable via frozen?" do
124
+ @cache.should_not be_frozen
125
+ end
126
+ end
@@ -0,0 +1,7 @@
1
+ $TESTING=true
2
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
+
4
+ require "rubygems"
5
+ require "moneta"
6
+
7
+ require File.expand_path(File.join(File.dirname(__FILE__), "shared"))
metadata CHANGED
@@ -3,24 +3,64 @@ name: dkastner-moneta
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
+ - 1
6
7
  - 0
7
- - 7
8
8
  - 0
9
- version: 0.7.0
9
+ version: 1.0.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Yehuda Katz
13
13
  - Derek Kastner
14
- autorequire: moneta
14
+ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-26 00:00:00 -05:00
18
+ date: 2011-02-10 00:00:00 -05:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bundler
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ prerelease: false
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id003
22
60
  description: A unified interface to key/value stores
23
- email: dkastner@gmail.com
61
+ email:
62
+ - wycats@gmail.com
63
+ - dkastner@gmail.com
24
64
  executables: []
25
65
 
26
66
  extensions: []
@@ -28,34 +68,62 @@ extensions: []
28
68
  extra_rdoc_files:
29
69
  - README
30
70
  - LICENSE
31
- - TODO
32
71
  files:
33
- - lib/moneta/builder.rb
34
- - lib/moneta/adapters/tyrant.rb
72
+ - .gitignore
73
+ - Gemfile
74
+ - LICENSE
75
+ - README
76
+ - Rakefile
77
+ - SPEC.markdown
78
+ - benchmarks/various.rb
79
+ - dkastner-moneta.gemspec
80
+ - lib/moneta.rb
81
+ - lib/moneta/adapters/active_record.rb
35
82
  - lib/moneta/adapters/basic_file.rb
36
- - lib/moneta/adapters/pstore.rb
37
- - lib/moneta/adapters/rackspace.rb
38
- - lib/moneta/adapters/xattr.rb
39
- - lib/moneta/adapters/sdbm.rb
40
- - lib/moneta/adapters/redis.rb
41
- - lib/moneta/adapters/fog.rb
83
+ - lib/moneta/adapters/couch.rb
42
84
  - lib/moneta/adapters/datamapper.rb
85
+ - lib/moneta/adapters/file.rb
86
+ - lib/moneta/adapters/fog.rb
87
+ - lib/moneta/adapters/lmc.rb
43
88
  - lib/moneta/adapters/memcache.rb
89
+ - lib/moneta/adapters/memory.rb
44
90
  - lib/moneta/adapters/mongodb.rb
45
- - lib/moneta/adapters/couch.rb
91
+ - lib/moneta/adapters/pstore.rb
92
+ - lib/moneta/adapters/rackspace.rb
93
+ - lib/moneta/adapters/redis.rb
46
94
  - lib/moneta/adapters/s3.rb
47
- - lib/moneta/adapters/lmc.rb
48
- - lib/moneta/adapters/memory.rb
49
- - lib/moneta/adapters/file.rb
50
- - lib/moneta/adapters/yaml.rb
95
+ - lib/moneta/adapters/sdbm.rb
51
96
  - lib/moneta/adapters/tokyo_cabinet.rb
52
- - lib/moneta.rb
53
- - LICENSE
54
- - README
55
- - Rakefile
56
- - TODO
97
+ - lib/moneta/adapters/tyrant.rb
98
+ - lib/moneta/adapters/xattr.rb
99
+ - lib/moneta/adapters/yaml.rb
100
+ - lib/moneta/builder.rb
101
+ - lib/moneta/monetas.rb
102
+ - lib/moneta/version.rb
103
+ - script/destroy
104
+ - script/generate
105
+ - spec/moneta_active_record_spec.rb
106
+ - spec/moneta_basic_file_spec.rb
107
+ - spec/moneta_couch_spec.rb
108
+ - spec/moneta_datamapper_spec.rb
109
+ - spec/moneta_file_spec.rb
110
+ - spec/moneta_lmc_spec.rb
111
+ - spec/moneta_memcache_spec.rb
112
+ - spec/moneta_memory_spec.rb
113
+ - spec/moneta_mongodb_spec.rb
114
+ - spec/moneta_pstore_spec.rb
115
+ - spec/moneta_rackspace_spec.rb
116
+ - spec/moneta_redis_spec.rb
117
+ - spec/moneta_s3_spec.rb
118
+ - spec/moneta_sdbm_spec.rb
119
+ - spec/moneta_tokyo_cabinet_spec.rb
120
+ - spec/moneta_tyrant_spec.rb
121
+ - spec/moneta_xattr_spec.rb
122
+ - spec/moneta_yaml_spec.rb
123
+ - spec/shared.rb
124
+ - spec/spec_helper.rb
57
125
  has_rdoc: true
58
- homepage: http://www.yehudakatz.com
126
+ homepage: http://github.com/dkastner/moneta
59
127
  licenses: []
60
128
 
61
129
  post_install_message:
@@ -68,6 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
136
  requirements:
69
137
  - - ">="
70
138
  - !ruby/object:Gem::Version
139
+ hash: -1558155670169839568
71
140
  segments:
72
141
  - 0
73
142
  version: "0"
@@ -76,6 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
145
  requirements:
77
146
  - - ">="
78
147
  - !ruby/object:Gem::Version
148
+ hash: -1558155670169839568
79
149
  segments:
80
150
  - 0
81
151
  version: "0"
@@ -85,6 +155,25 @@ rubyforge_project:
85
155
  rubygems_version: 1.3.7
86
156
  signing_key:
87
157
  specification_version: 3
88
- summary: A unified interface to key/value stores
89
- test_files: []
90
-
158
+ summary: A unified interface to key/value stores, including MongoDB, Redis, Tokyo, and ActiveRecord
159
+ test_files:
160
+ - spec/moneta_active_record_spec.rb
161
+ - spec/moneta_basic_file_spec.rb
162
+ - spec/moneta_couch_spec.rb
163
+ - spec/moneta_datamapper_spec.rb
164
+ - spec/moneta_file_spec.rb
165
+ - spec/moneta_lmc_spec.rb
166
+ - spec/moneta_memcache_spec.rb
167
+ - spec/moneta_memory_spec.rb
168
+ - spec/moneta_mongodb_spec.rb
169
+ - spec/moneta_pstore_spec.rb
170
+ - spec/moneta_rackspace_spec.rb
171
+ - spec/moneta_redis_spec.rb
172
+ - spec/moneta_s3_spec.rb
173
+ - spec/moneta_sdbm_spec.rb
174
+ - spec/moneta_tokyo_cabinet_spec.rb
175
+ - spec/moneta_tyrant_spec.rb
176
+ - spec/moneta_xattr_spec.rb
177
+ - spec/moneta_yaml_spec.rb
178
+ - spec/shared.rb
179
+ - spec/spec_helper.rb
data/TODO DELETED
@@ -1,4 +0,0 @@
1
- TODO:
2
- Fix LICENSE with your name
3
- Fix Rakefile with your name and contact info
4
- Add your code to lib/<%= name %>.rb