redis_orm 0.4 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v0.4.1 [23-06-2011]
2
+ * fixed clitical bug: records after #destroy still available (added test for it)
3
+ * added simple atomicity test
4
+ * README.md: added link to my article "how to integrate redis_orm with paperclip"
5
+
1
6
  v0.4 [16-06-2011]
2
7
  * added :conditions key to the options hash in #find/#all methods
3
8
  * added #{property_name}_changed? instance method
data/Manifest CHANGED
@@ -12,6 +12,7 @@ lib/redis_orm/associations/has_one.rb
12
12
  lib/redis_orm/redis_orm.rb
13
13
  redis_orm.gemspec
14
14
  test/associations_test.rb
15
+ test/atomicity_test.rb
15
16
  test/basic_functionality_test.rb
16
17
  test/callbacks_test.rb
17
18
  test/changes_array_test.rb
data/README.md CHANGED
@@ -394,6 +394,10 @@ The object's id is stored in "model_name:ids" sorted set with Time.now.to_f as a
394
394
 
395
395
  Redis_orm also provides dirty methods to check whether the property has changed and what are these changes. To check it you could use 2 methods: #property_changed? (returns true or false) and #property_changes (returns array with changed values).
396
396
 
397
+ ## File attachment management with paperclip and redis
398
+
399
+ I wrote [3 simple steps](http://def-end.com/post/6669884103/file-attachment-management-with-paperclip-and-redis) you should follow to manage your file attachments with redis and paperclip.
400
+
397
401
  ## Tests
398
402
 
399
403
  Though I'm a big fan of the Test::Unit all tests are based on RSpec. And the only reason I did it are *before(:all)* and *after(:all)* hooks. So I could spawn/kill redis-server's process (from test_helper.rb):
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake'
4
4
  #=begin
5
5
  require 'echoe'
6
6
 
7
- Echoe.new('redis_orm', '0.4') do |p|
7
+ Echoe.new('redis_orm', '0.4.1') do |p|
8
8
  p.description = "ORM for Redis advanced key-value storage"
9
9
  p.url = "https://github.com/german/redis_orm"
10
10
  p.author = "Dmitrii Samoilov"
@@ -463,7 +463,7 @@ module RedisOrm
463
463
  end
464
464
 
465
465
  @@properties[model_name].each do |prop|
466
- $redis.hdel("#{model_name}:#{@id}", prop.to_s)
466
+ $redis.hdel("#{model_name}:#{@id}", prop[:name].to_s)
467
467
  end
468
468
 
469
469
  $redis.zrem "#{model_name}:ids", @id
data/redis_orm.gemspec CHANGED
@@ -2,22 +2,22 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{redis_orm}
5
- s.version = "0.4"
5
+ s.version = "0.4.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Dmitrii Samoilov}]
9
- s.date = %q{2011-06-15}
9
+ s.date = %q{2011-06-22}
10
10
  s.description = %q{ORM for Redis advanced key-value storage}
11
11
  s.email = %q{germaninthetown@gmail.com}
12
12
  s.extra_rdoc_files = [%q{CHANGELOG}, %q{LICENSE}, %q{README.md}, %q{lib/redis_orm.rb}, %q{lib/redis_orm/active_model_behavior.rb}, %q{lib/redis_orm/associations/belongs_to.rb}, %q{lib/redis_orm/associations/has_many.rb}, %q{lib/redis_orm/associations/has_many_proxy.rb}, %q{lib/redis_orm/associations/has_one.rb}, %q{lib/redis_orm/redis_orm.rb}]
13
- s.files = [%q{CHANGELOG}, %q{LICENSE}, %q{Manifest}, %q{README.md}, %q{Rakefile}, %q{lib/redis_orm.rb}, %q{lib/redis_orm/active_model_behavior.rb}, %q{lib/redis_orm/associations/belongs_to.rb}, %q{lib/redis_orm/associations/has_many.rb}, %q{lib/redis_orm/associations/has_many_proxy.rb}, %q{lib/redis_orm/associations/has_one.rb}, %q{lib/redis_orm/redis_orm.rb}, %q{redis_orm.gemspec}, %q{test/associations_test.rb}, %q{test/basic_functionality_test.rb}, %q{test/callbacks_test.rb}, %q{test/changes_array_test.rb}, %q{test/dynamic_finders_test.rb}, %q{test/exceptions_test.rb}, %q{test/has_one_has_many_test.rb}, %q{test/indices_test.rb}, %q{test/options_test.rb}, %q{test/polymorphic_test.rb}, %q{test/redis.conf}, %q{test/test_helper.rb}, %q{test/validations_test.rb}]
13
+ s.files = [%q{CHANGELOG}, %q{LICENSE}, %q{Manifest}, %q{README.md}, %q{Rakefile}, %q{lib/redis_orm.rb}, %q{lib/redis_orm/active_model_behavior.rb}, %q{lib/redis_orm/associations/belongs_to.rb}, %q{lib/redis_orm/associations/has_many.rb}, %q{lib/redis_orm/associations/has_many_proxy.rb}, %q{lib/redis_orm/associations/has_one.rb}, %q{lib/redis_orm/redis_orm.rb}, %q{redis_orm.gemspec}, %q{test/associations_test.rb}, %q{test/atomicity_test.rb}, %q{test/basic_functionality_test.rb}, %q{test/callbacks_test.rb}, %q{test/changes_array_test.rb}, %q{test/dynamic_finders_test.rb}, %q{test/exceptions_test.rb}, %q{test/has_one_has_many_test.rb}, %q{test/indices_test.rb}, %q{test/options_test.rb}, %q{test/polymorphic_test.rb}, %q{test/redis.conf}, %q{test/test_helper.rb}, %q{test/validations_test.rb}]
14
14
  s.homepage = %q{https://github.com/german/redis_orm}
15
15
  s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Redis_orm}, %q{--main}, %q{README.md}]
16
16
  s.require_paths = [%q{lib}]
17
17
  s.rubyforge_project = %q{redis_orm}
18
18
  s.rubygems_version = %q{1.8.5}
19
19
  s.summary = %q{ORM for Redis advanced key-value storage}
20
- s.test_files = [%q{test/options_test.rb}, %q{test/dynamic_finders_test.rb}, %q{test/associations_test.rb}, %q{test/validations_test.rb}, %q{test/test_helper.rb}, %q{test/polymorphic_test.rb}, %q{test/exceptions_test.rb}, %q{test/has_one_has_many_test.rb}, %q{test/indices_test.rb}, %q{test/changes_array_test.rb}, %q{test/callbacks_test.rb}, %q{test/basic_functionality_test.rb}]
20
+ s.test_files = [%q{test/options_test.rb}, %q{test/dynamic_finders_test.rb}, %q{test/associations_test.rb}, %q{test/validations_test.rb}, %q{test/test_helper.rb}, %q{test/polymorphic_test.rb}, %q{test/atomicity_test.rb}, %q{test/exceptions_test.rb}, %q{test/has_one_has_many_test.rb}, %q{test/indices_test.rb}, %q{test/changes_array_test.rb}, %q{test/callbacks_test.rb}, %q{test/basic_functionality_test.rb}]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  s.specification_version = 3
@@ -0,0 +1,25 @@
1
+ require File.dirname(File.expand_path(__FILE__)) + '/test_helper.rb'
2
+
3
+ class Article < RedisOrm::Base
4
+ property :title, String
5
+ property :karma, Integer
6
+ end
7
+
8
+ describe "check atomicity" do
9
+ it "should properly increment property's value" do
10
+ @article = Article.new :title => "Simple test atomicity with multiple threads", :karma => 1
11
+ @article.save
12
+
13
+ @threads = []
14
+
15
+ 50.times do |i|
16
+ @threads << Thread.new(i) do
17
+ @article.update_attribute :karma, (@article.karma + 1)
18
+ end
19
+ end
20
+
21
+ @threads.each{|thread| thread.join}
22
+
23
+ Article.first.karma.should == 51
24
+ end
25
+ end
@@ -76,9 +76,12 @@ describe "check basic functionality" do
76
76
  user.name.should == "german"
77
77
 
78
78
  User.count.should == 1
79
-
79
+ id = user.id
80
+
80
81
  user.destroy
81
82
  User.count.should == 0
83
+ $redis.zrank("user:ids", id).should == nil
84
+ $redis.hgetall("user:#{id}").should == {}
82
85
  end
83
86
 
84
87
  it "should return first and last objects" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_orm
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-15 00:00:00.000000000Z
12
+ date: 2011-06-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &81951070 !ruby/object:Gem::Requirement
16
+ requirement: &79232740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *81951070
24
+ version_requirements: *79232740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activemodel
27
- requirement: &81950820 !ruby/object:Gem::Requirement
27
+ requirement: &79232430 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *81950820
35
+ version_requirements: *79232430
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: redis
38
- requirement: &81950570 !ruby/object:Gem::Requirement
38
+ requirement: &79232120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *81950570
46
+ version_requirements: *79232120
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &81950320 !ruby/object:Gem::Requirement
49
+ requirement: &79231810 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 2.5.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *81950320
57
+ version_requirements: *79231810
58
58
  description: ORM for Redis advanced key-value storage
59
59
  email: germaninthetown@gmail.com
60
60
  executables: []
@@ -85,6 +85,7 @@ files:
85
85
  - lib/redis_orm/redis_orm.rb
86
86
  - redis_orm.gemspec
87
87
  - test/associations_test.rb
88
+ - test/atomicity_test.rb
88
89
  - test/basic_functionality_test.rb
89
90
  - test/callbacks_test.rb
90
91
  - test/changes_array_test.rb
@@ -134,6 +135,7 @@ test_files:
134
135
  - test/validations_test.rb
135
136
  - test/test_helper.rb
136
137
  - test/polymorphic_test.rb
138
+ - test/atomicity_test.rb
137
139
  - test/exceptions_test.rb
138
140
  - test/has_one_has_many_test.rb
139
141
  - test/indices_test.rb