ampere 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format NyanCatFormatter
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.2
4
+
5
+ * Increased code coverage to everything but really bizarre edge cases.
6
+ * Cleaned things up a little bit here and there.
7
+
3
8
  ## 1.2.1
4
9
 
5
10
  * Model saves and multi-attribute updates are now completely atomic, using
data/Gemfile CHANGED
@@ -13,6 +13,7 @@ group :development do
13
13
  gem "cucumber", ">= 0"
14
14
  gem "bundler", ">= 1.0.0"
15
15
  gem "jeweler", "~> 1.6.4"
16
+ gem "nyan-cat-formatter"
16
17
  gem 'simplecov', :require => false, :group => :test
17
18
  gem "rspec"
18
19
  gem "rdoc"
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
+ 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.1"
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"
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
@@ -26,11 +26,7 @@ module Ampere #:nodoc:
26
26
  private
27
27
 
28
28
  def model_name
29
- if self.class == Class then
30
- to_s
31
- else
32
- self.class.to_s
33
- end
29
+ self.class.to_s
34
30
  end
35
31
 
36
32
  end
data/lib/ampere/model.rb CHANGED
@@ -18,8 +18,8 @@ module Ampere
18
18
 
19
19
  include(Ampere::Keys)
20
20
 
21
- attr_reader :id
22
- attr_reader :destroyed
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
@@ -1,7 +1,5 @@
1
- # require "active_support"
2
1
  require "active_record"
3
2
  require "redis"
4
- require "pp"
5
3
 
6
4
  # The Ampere module contains methods to connect/disconnect and gives access to
7
5
  # the Redis connection directly (though you really shouldn't need to use it).
@@ -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
- pending
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
  ###
@@ -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
- it "should be deleteable from the model class" do
175
- post = Post.create :title => "This post should be deleted",
176
- :byline => "because it's awful",
177
- :content => "and it doesn't even make sense."
178
- id = post.id
179
- post.should_not be_nil
180
- deleted_post = Post.delete(id)
181
- deleted_post.should eq(post)
182
- deleted_post.title.should eq(post.title)
183
- Post.find(id).should be_nil
184
- end
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
- it "should be destroyable by itself" do
187
- another_post = Post.create :title => "This one too, probably.",
188
- :byline => "Just seems like one big",
189
- :content => "non sequitor."
190
- id = another_post.id
191
- another_post.destroy.should eq(another_post)
192
- Post.find(id).should be_nil
193
- end
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
- pending
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
- pending
66
- end
64
+ # it 'should be able to query has_many relationships' do
65
+ # pending
66
+ # end
67
67
 
68
68
  ###
69
69
 
@@ -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.connected?.should be_true
11
- Ampere.disconnect
12
- Ampere.connected?.should be_false
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
- # context 'Redis data store', :redis => true do
16
- # it 'should come with a __guid set' do
17
- # Redis.new['guid'].should == 0
18
- # end
19
- # end
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.1
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 00:00:00.000000000 Z
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: 1755195159909274501
318
+ hash: -2731344431471118659
303
319
  required_rubygems_version: !ruby/object:Gem::Requirement
304
320
  none: false
305
321
  requirements: