ampere 1.2.1 → 1.2.2
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.
- data/.rspec +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/VERSION +1 -1
- data/ampere.gemspec +5 -2
- data/lib/ampere/keys.rb +1 -5
- data/lib/ampere/model.rb +3 -2
- data/lib/ampere.rb +0 -2
- data/spec/models/indices_spec.rb +3 -3
- data/spec/models/model_spec.rb +31 -26
- data/spec/models/relationships/has_many_spec.rb +6 -6
- data/spec/module/ampere_spec.rb +14 -8
- data/spec/module/collections_ennumerable_spec.rb +12 -0
- data/spec/module/collections_spec.rb +9 -9
- metadata +19 -3
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -30,6 +30,7 @@ GEM
|
|
30
30
|
rake
|
31
31
|
json (1.7.3)
|
32
32
|
multi_json (1.3.6)
|
33
|
+
nyan-cat-formatter (0.0.7)
|
33
34
|
rake (0.9.2.2)
|
34
35
|
rdoc (3.12)
|
35
36
|
json (~> 1.4)
|
@@ -62,6 +63,7 @@ DEPENDENCIES
|
|
62
63
|
bundler (>= 1.0.0)
|
63
64
|
cucumber
|
64
65
|
jeweler (~> 1.6.4)
|
66
|
+
nyan-cat-formatter
|
65
67
|
rdoc
|
66
68
|
redis
|
67
69
|
rspec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.2
|
data/ampere.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ampere"
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Max Thom Stahl"]
|
12
|
-
s.date = "2012-07-
|
12
|
+
s.date = "2012-07-24"
|
13
13
|
s.description = "An ActiveRecord/Mongoid-esque object model for the Redis key/value data store."
|
14
14
|
s.email = "max@villainousindustri.es"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -138,6 +138,7 @@ Gem::Specification.new do |s|
|
|
138
138
|
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
139
139
|
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
140
140
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
141
|
+
s.add_development_dependency(%q<nyan-cat-formatter>, [">= 0"])
|
141
142
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
142
143
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
143
144
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
@@ -149,6 +150,7 @@ Gem::Specification.new do |s|
|
|
149
150
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
150
151
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
151
152
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
153
|
+
s.add_dependency(%q<nyan-cat-formatter>, [">= 0"])
|
152
154
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
153
155
|
s.add_dependency(%q<rspec>, [">= 0"])
|
154
156
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
@@ -161,6 +163,7 @@ Gem::Specification.new do |s|
|
|
161
163
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
162
164
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
163
165
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
166
|
+
s.add_dependency(%q<nyan-cat-formatter>, [">= 0"])
|
164
167
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
165
168
|
s.add_dependency(%q<rspec>, [">= 0"])
|
166
169
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
data/lib/ampere/keys.rb
CHANGED
data/lib/ampere/model.rb
CHANGED
@@ -18,8 +18,8 @@ module Ampere
|
|
18
18
|
|
19
19
|
include(Ampere::Keys)
|
20
20
|
|
21
|
-
attr_reader
|
22
|
-
|
21
|
+
attr_reader :id
|
22
|
+
attr_accessor :destroyed
|
23
23
|
|
24
24
|
attr_accessor :fields
|
25
25
|
attr_accessor :field_defaults
|
@@ -229,6 +229,7 @@ module Ampere
|
|
229
229
|
def delete(id)
|
230
230
|
record = find(id)
|
231
231
|
Ampere.connection.del(key_for_find(self, id))
|
232
|
+
record.destroyed = true
|
232
233
|
record
|
233
234
|
end
|
234
235
|
|
data/lib/ampere.rb
CHANGED
data/spec/models/indices_spec.rb
CHANGED
@@ -136,9 +136,9 @@ describe "Model indices", :indices => true do
|
|
136
136
|
brandi.first.employee_id_number.should == "31415929"
|
137
137
|
end
|
138
138
|
|
139
|
-
it 'should still be able to search on just one field of a compound index' do
|
140
|
-
|
141
|
-
end
|
139
|
+
# it 'should still be able to search on just one field of a compound index' do
|
140
|
+
# pending
|
141
|
+
# end
|
142
142
|
end
|
143
143
|
|
144
144
|
###
|
data/spec/models/model_spec.rb
CHANGED
@@ -2,6 +2,14 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
|
|
2
2
|
|
3
3
|
describe "Base models", :model => true do
|
4
4
|
context "by themselves" do
|
5
|
+
class Post
|
6
|
+
include Ampere::Model
|
7
|
+
|
8
|
+
field :title
|
9
|
+
field :byline
|
10
|
+
field :content
|
11
|
+
end
|
12
|
+
|
5
13
|
before :all do
|
6
14
|
Ampere.connect
|
7
15
|
|
@@ -9,13 +17,6 @@ describe "Base models", :model => true do
|
|
9
17
|
Redis.new.flushall
|
10
18
|
|
11
19
|
# Define a model class here.
|
12
|
-
class Post
|
13
|
-
include Ampere::Model
|
14
|
-
|
15
|
-
field :title
|
16
|
-
field :byline
|
17
|
-
field :content
|
18
|
-
end
|
19
20
|
|
20
21
|
end
|
21
22
|
|
@@ -171,26 +172,30 @@ describe "Base models", :model => true do
|
|
171
172
|
post.new?.should be_false
|
172
173
|
end
|
173
174
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
175
|
+
# context 'deletion' do
|
176
|
+
it "should be deleteable from the model class", wip:true do
|
177
|
+
post = Post.create :title => "This post should be deleted",
|
178
|
+
:byline => "because it's awful",
|
179
|
+
:content => "and it doesn't even make sense."
|
180
|
+
id = post.id
|
181
|
+
post.should_not be_nil
|
182
|
+
deleted_post = Post.delete(id)
|
183
|
+
deleted_post.should eq(post)
|
184
|
+
deleted_post.title.should eq(post.title)
|
185
|
+
deleted_post.should be_destroyed
|
186
|
+
Post.find(id).should be_nil
|
187
|
+
end
|
185
188
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
189
|
+
it "should be destroyable by itself" do
|
190
|
+
another_post = Post.create :title => "This one too, probably.",
|
191
|
+
:byline => "Just seems like one big",
|
192
|
+
:content => "non sequitor."
|
193
|
+
id = another_post.id
|
194
|
+
another_post.destroy.should eq(another_post)
|
195
|
+
another_post.should be_destroyed
|
196
|
+
Post.find(id).should be_nil
|
197
|
+
end
|
198
|
+
# end
|
194
199
|
|
195
200
|
it "should be findable by ID" do
|
196
201
|
post = Post.create :title => "foo",
|
@@ -57,13 +57,13 @@ describe 'has_many relationships', :has_many => true do
|
|
57
57
|
@car.passengers.should include(@passenger)
|
58
58
|
end
|
59
59
|
|
60
|
-
it 'should be able to remove items from has_many relationships' do
|
61
|
-
|
62
|
-
end
|
60
|
+
# it 'should be able to remove items from has_many relationships' do
|
61
|
+
# pending
|
62
|
+
# end
|
63
63
|
|
64
|
-
it 'should be able to query has_many relationships' do
|
65
|
-
|
66
|
-
end
|
64
|
+
# it 'should be able to query has_many relationships' do
|
65
|
+
# pending
|
66
|
+
# end
|
67
67
|
|
68
68
|
###
|
69
69
|
|
data/spec/module/ampere_spec.rb
CHANGED
@@ -7,16 +7,22 @@ describe 'Ampere', :ampere => true do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should be able to connect' do
|
10
|
-
Ampere.
|
11
|
-
|
12
|
-
|
10
|
+
Ampere.should be_connected
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should be able to flush' do
|
14
|
+
value = "%016x" % rand(2 ** 64)
|
15
|
+
Ampere.should be_connected
|
16
|
+
Ampere.connection.setex("ampere.test.flush_test", 60, value)
|
17
|
+
Ampere.flush
|
18
|
+
Ampere.connection.get("ampere.test.flush_test").should_not eq(value)
|
13
19
|
end
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
it 'should be able to disconnect' do
|
22
|
+
# NOTE: This test must always be run last
|
23
|
+
Ampere.disconnect
|
24
|
+
Ampere.should_not be_connected
|
25
|
+
end
|
20
26
|
|
21
27
|
after :all do
|
22
28
|
Redis.new.flushall
|
@@ -35,6 +35,18 @@ describe 'Collections are Ennumerable', :collections => true, :ennumerable => tr
|
|
35
35
|
]
|
36
36
|
end
|
37
37
|
|
38
|
+
it 'should lazily evaluate the #[] method' do
|
39
|
+
presidents = President.all
|
40
|
+
|
41
|
+
presidents[2].name.should eq('Abraham Lincoln')
|
42
|
+
presidents[2].name.should eq('Abraham Lincoln')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should be comparable to an array' do
|
46
|
+
President.all.should == President.all.to_a
|
47
|
+
President.all.should_not be(President.all.to_a)
|
48
|
+
end
|
49
|
+
|
38
50
|
# These are just a handful of methods to ensure that the Enumerable module is
|
39
51
|
# being included correctly. They can safely be factored out since the #each
|
40
52
|
# one above should cover Enumerable if it's being included correctly.
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
|
2
2
|
|
3
3
|
describe 'Collections', :collections => true do
|
4
|
+
class President
|
5
|
+
include Ampere::Model
|
6
|
+
|
7
|
+
field :name
|
8
|
+
field :party
|
9
|
+
|
10
|
+
index :party
|
11
|
+
end
|
12
|
+
|
4
13
|
before :all do
|
5
14
|
Redis.new.flushall
|
6
15
|
Ampere.connect
|
7
|
-
|
8
|
-
class President
|
9
|
-
include Ampere::Model
|
10
|
-
|
11
|
-
field :name
|
12
|
-
field :party
|
13
|
-
|
14
|
-
index :party
|
15
|
-
end
|
16
16
|
|
17
17
|
President.create :name => "Millard Fillmore" , :party => "Whig"
|
18
18
|
President.create :name => "Ulysses S. Grant" , :party => "Republican"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ampere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -107,6 +107,22 @@ dependencies:
|
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 1.6.4
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: nyan-cat-formatter
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
110
126
|
- !ruby/object:Gem::Dependency
|
111
127
|
name: simplecov
|
112
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -299,7 +315,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
299
315
|
version: '0'
|
300
316
|
segments:
|
301
317
|
- 0
|
302
|
-
hash:
|
318
|
+
hash: -2731344431471118659
|
303
319
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
304
320
|
none: false
|
305
321
|
requirements:
|