active_redis 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +6 -14
  2. data/README.md +9 -5
  3. data/Rakefile +7 -0
  4. data/active_redis.gemspec +3 -0
  5. data/lib/active_redis.rb +9 -0
  6. data/lib/active_redis/associations.rb +25 -24
  7. data/lib/active_redis/associations/association.rb +36 -0
  8. data/lib/active_redis/associations/belongs_to_association.rb +32 -0
  9. data/lib/active_redis/associations/has_many_association.rb +26 -0
  10. data/lib/active_redis/associations/has_one_association.rb +24 -0
  11. data/lib/active_redis/attributes.rb +5 -4
  12. data/lib/active_redis/attributes/integer_attribute.rb +2 -2
  13. data/lib/active_redis/attributes/string_attribute.rb +2 -2
  14. data/lib/active_redis/attributes/time_attribute.rb +2 -2
  15. data/lib/active_redis/base.rb +4 -4
  16. data/lib/active_redis/config.rb +13 -10
  17. data/lib/active_redis/connection_ext/finders_layer.rb +12 -3
  18. data/lib/active_redis/constants.rb +2 -0
  19. data/lib/active_redis/errors.rb +6 -0
  20. data/lib/active_redis/helpers/lua_scripts.rb +7 -0
  21. data/lib/active_redis/inspector.rb +1 -1
  22. data/lib/active_redis/logs/basic_log.rb +11 -0
  23. data/lib/active_redis/logs/console_log.rb +14 -0
  24. data/lib/active_redis/logs/query_logger.rb +29 -0
  25. data/lib/active_redis/lua_scripts/main.lua +127 -50
  26. data/lib/active_redis/naming.rb +2 -0
  27. data/lib/active_redis/persistence.rb +12 -1
  28. data/lib/active_redis/query_chainer.rb +61 -0
  29. data/lib/active_redis/query_executor.rb +24 -0
  30. data/lib/active_redis/query_iterator.rb +27 -0
  31. data/lib/active_redis/railtie.rb +4 -2
  32. data/lib/active_redis/relation.rb +18 -0
  33. data/lib/active_redis/version.rb +1 -1
  34. data/specs/associations_spec.rb +94 -0
  35. data/specs/attributes_spec.rb +221 -0
  36. data/specs/calculations_spec.rb +28 -0
  37. data/specs/config_spec.rb +27 -0
  38. data/specs/inspector_spec.rb +45 -0
  39. data/specs/naming_spec.rb +56 -0
  40. data/specs/test_helper.rb +7 -0
  41. metadata +77 -18
  42. data/lib/active_redis/finders.rb +0 -22
@@ -0,0 +1,56 @@
1
+ require File.dirname(File.realdirpath(__FILE__)) + '/test_helper.rb'
2
+ require 'active_redis/naming'
3
+
4
+ describe ActiveRedis::Naming do
5
+
6
+ subject { TestObject.new }
7
+
8
+ before do
9
+ TestObject.send :extend, ActiveRedis::Naming
10
+ end
11
+
12
+ describe "#table_name" do
13
+
14
+ describe "when id isn't passed" do
15
+
16
+ it "is contains pluralize class name" do
17
+ TestObject.table_name.must_match /testobjects\:item\:/
18
+ end
19
+
20
+ end
21
+
22
+ describe "when id passed" do
23
+
24
+ it "is contains passed id" do
25
+ TestObject.table_name("some_id").must_match /testobjects\:item\:some_id/
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ describe "#key_name" do
33
+
34
+ it "is contains table_name with closing asterisk" do
35
+ TestObject.key_name.must_match /testobjects\:item\:*/
36
+ end
37
+
38
+ end
39
+
40
+ describe "#info_table_name" do
41
+
42
+ it "is consists with pluralize class name and closing 'info'" do
43
+ TestObject.info_table_name.must_match /testobjects\:info/
44
+ end
45
+
46
+ end
47
+
48
+ describe "#foreign_key_name" do
49
+
50
+ it "is contains class name with suffix _id" do
51
+ TestObject.foreign_key_name.must_match /testobject_id/
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,7 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'mocha/setup'
4
+ require 'turn/autorun'
5
+
6
+ class TestObject
7
+ end
metadata CHANGED
@@ -1,44 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Gernyak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-29 00:00:00.000000000 Z
11
+ date: 2013-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: redis
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - ! '>='
17
+ - - '>='
17
18
  - !ruby/object:Gem::Version
18
19
  version: '0'
19
20
  type: :runtime
20
21
  prerelease: false
21
- name: redis
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: activesupport
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
31
46
  - !ruby/object:Gem::Version
32
47
  version: '0'
33
48
  type: :runtime
34
49
  prerelease: false
35
- name: activesupport
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ! '>='
52
+ - - '>='
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
56
+ name: bundler
42
57
  requirement: !ruby/object:Gem::Requirement
43
58
  requirements:
44
59
  - - ~>
@@ -46,38 +61,65 @@ dependencies:
46
61
  version: '1.3'
47
62
  type: :development
48
63
  prerelease: false
49
- name: bundler
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - ~>
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.3'
55
69
  - !ruby/object:Gem::Dependency
70
+ name: rake
56
71
  requirement: !ruby/object:Gem::Requirement
57
72
  requirements:
58
- - - ! '>='
73
+ - - '>='
59
74
  - !ruby/object:Gem::Version
60
75
  version: '0'
61
76
  type: :development
62
77
  prerelease: false
63
- name: rake
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ! '>='
80
+ - - '>='
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
84
+ name: rake-notes
70
85
  requirement: !ruby/object:Gem::Requirement
71
86
  requirements:
72
- - - ! '>='
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mocha
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: turn
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
73
116
  - !ruby/object:Gem::Version
74
117
  version: '0'
75
118
  type: :development
76
119
  prerelease: false
77
- name: rake-notes
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
- - - ! '>='
122
+ - - '>='
81
123
  - !ruby/object:Gem::Version
82
124
  version: '0'
83
125
  description: Small childly ORM for Redis
@@ -96,6 +138,10 @@ files:
96
138
  - lib/active_redis.rb
97
139
  - lib/active_redis/adapters/basic_adapter.rb
98
140
  - lib/active_redis/associations.rb
141
+ - lib/active_redis/associations/association.rb
142
+ - lib/active_redis/associations/belongs_to_association.rb
143
+ - lib/active_redis/associations/has_many_association.rb
144
+ - lib/active_redis/associations/has_one_association.rb
99
145
  - lib/active_redis/attributes.rb
100
146
  - lib/active_redis/attributes/attribute.rb
101
147
  - lib/active_redis/attributes/integer_attribute.rb
@@ -111,17 +157,30 @@ files:
111
157
  - lib/active_redis/connection_ext/scripts_layer.rb
112
158
  - lib/active_redis/constants.rb
113
159
  - lib/active_redis/errors.rb
114
- - lib/active_redis/finders.rb
115
160
  - lib/active_redis/helpers/lua_scripts.rb
116
161
  - lib/active_redis/inspector.rb
162
+ - lib/active_redis/logs/basic_log.rb
163
+ - lib/active_redis/logs/console_log.rb
164
+ - lib/active_redis/logs/query_logger.rb
117
165
  - lib/active_redis/lua_scripts/main.lua
118
166
  - lib/active_redis/naming.rb
119
167
  - lib/active_redis/persistence.rb
168
+ - lib/active_redis/query_chainer.rb
169
+ - lib/active_redis/query_executor.rb
170
+ - lib/active_redis/query_iterator.rb
120
171
  - lib/active_redis/railtie.rb
172
+ - lib/active_redis/relation.rb
121
173
  - lib/active_redis/version.rb
122
174
  - lib/generators/active_redis.rb
123
175
  - lib/generators/active_redis/model/model_generator.rb
124
176
  - lib/generators/active_redis/model/templates/model.rb
177
+ - specs/associations_spec.rb
178
+ - specs/attributes_spec.rb
179
+ - specs/calculations_spec.rb
180
+ - specs/config_spec.rb
181
+ - specs/inspector_spec.rb
182
+ - specs/naming_spec.rb
183
+ - specs/test_helper.rb
125
184
  homepage: ''
126
185
  licenses:
127
186
  - MIT
@@ -132,12 +191,12 @@ require_paths:
132
191
  - lib
133
192
  required_ruby_version: !ruby/object:Gem::Requirement
134
193
  requirements:
135
- - - ! '>='
194
+ - - '>='
136
195
  - !ruby/object:Gem::Version
137
196
  version: '0'
138
197
  required_rubygems_version: !ruby/object:Gem::Requirement
139
198
  requirements:
140
- - - ! '>='
199
+ - - '>='
141
200
  - !ruby/object:Gem::Version
142
201
  version: '0'
143
202
  requirements: []
@@ -1,22 +0,0 @@
1
- module ActiveRedis
2
- module Finders
3
-
4
- def find(*ids)
5
- res = ids.inject([]) do |result, id|
6
- attrs = ActiveRedis.connection.fetch_row(self, id)
7
- result << self.new(attrs) if attrs.any?
8
- result
9
- end
10
- ids.count == 1 ? res.first : res
11
- end
12
-
13
- def where(params)
14
- ActiveRedis.connection.fetch_where(self, params).map { |attrs| self.new(attrs) }
15
- end
16
-
17
- def all
18
- ActiveRedis.connection.fetch_all(self).map { |attrs| self.new(attrs) }
19
- end
20
-
21
- end
22
- end