hari 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/hari.gemspec +10 -2
- data/lib/hari.rb +8 -4
- data/lib/hari/configuration/redis.rb +6 -2
- data/lib/hari/entity.rb +10 -20
- data/lib/hari/entity/property.rb +19 -4
- data/lib/hari/entity/property/builder.rb +18 -3
- data/lib/hari/entity/repository.rb +11 -3
- data/lib/hari/entity/serialization.rb +53 -9
- data/lib/hari/entity/serialization/array.rb +21 -0
- data/lib/hari/entity/serialization/hash.rb +31 -0
- data/lib/hari/keys.rb +5 -0
- data/lib/hari/keys/hash.rb +67 -0
- data/lib/hari/keys/key.rb +24 -3
- data/lib/hari/keys/list.rb +10 -8
- data/lib/hari/keys/set.rb +8 -8
- data/lib/hari/keys/sorted_set.rb +20 -8
- data/lib/hari/node.rb +19 -2
- data/lib/hari/node/index.rb +152 -0
- data/lib/hari/node/queries.rb +32 -17
- data/lib/hari/node/queries/relation.rb +14 -1
- data/lib/hari/node/queries/relation/backend/sorted_set.rb +41 -90
- data/lib/hari/node/queries/relation/backend/sorted_set/count_step.rb +16 -0
- data/lib/hari/node/queries/relation/backend/sorted_set/node_step.rb +91 -0
- data/lib/hari/node/queries/type.rb +69 -4
- data/lib/hari/node/repository.rb +36 -0
- data/lib/hari/node/serialization.rb +11 -10
- data/lib/hari/object.rb +6 -0
- data/lib/hari/serialization.rb +3 -0
- data/lib/hari/version.rb +1 -1
- data/spec/hari/entity/repository_spec.rb +17 -0
- data/spec/hari/entity/serialization/hash_spec.rb +16 -0
- data/spec/hari/entity/serialization_spec.rb +14 -4
- data/spec/hari/keys/hash_spec.rb +55 -0
- data/spec/hari/keys/lists_spec.rb +27 -0
- data/spec/hari/node/index_spec.rb +199 -0
- data/spec/hari/node_spec.rb +84 -0
- data/spec/hari/serialization_spec.rb +41 -0
- data/spec/spec_helper.rb +6 -2
- metadata +27 -4
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hari::Serialization do
|
4
|
+
|
5
|
+
class TestSerialization
|
6
|
+
include Hari::Serialization
|
7
|
+
|
8
|
+
property :name
|
9
|
+
property :male, type: Boolean, default: true
|
10
|
+
property :active, type: Boolean
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestObject < Hari::Object
|
14
|
+
|
15
|
+
property :test, type: Boolean
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'adds serialization skills to class' do
|
20
|
+
object = TestSerialization.new(name: 'Chuck')
|
21
|
+
object.to_hash.should eq('name' => 'Chuck', 'male' => true, 'active' => false)
|
22
|
+
object.attribute(:name).should eq('Chuck')
|
23
|
+
object.has_attribute?(:name).should be_true
|
24
|
+
object.has_attribute?(:nome).should be_false
|
25
|
+
object.attribute(:active).should be_false
|
26
|
+
object.attribute(:male).should be_true
|
27
|
+
|
28
|
+
object.to_json.should eq('{"name":"Chuck","male":true,"active":false}')
|
29
|
+
|
30
|
+
from_json = TestSerialization.from_json('{"name":"Chuck","male":true,"active":false}')
|
31
|
+
from_json.name.should eq('Chuck')
|
32
|
+
from_json.male.should be_true
|
33
|
+
from_json.male?.should be_true
|
34
|
+
from_json.active?.should be_false
|
35
|
+
|
36
|
+
object = TestObject.new(test: true)
|
37
|
+
object.test.should be_true
|
38
|
+
object.test?.should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,8 +7,12 @@ require 'active_support/core_ext/numeric/time'
|
|
7
7
|
|
8
8
|
class TestEntity < Hari::Entity
|
9
9
|
property :name
|
10
|
-
property :
|
11
|
-
property :
|
10
|
+
property :country, default: 'US'
|
11
|
+
property :birth, type: Date
|
12
|
+
property :points, type: Integer
|
13
|
+
property :preferences, type: Hash
|
14
|
+
property :friends_ids, type: Array
|
15
|
+
property :male, type: Boolean, default: true
|
12
16
|
end
|
13
17
|
|
14
18
|
class TestNode < Hari::Node
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Rodrigues
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -165,7 +165,13 @@ dependencies:
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
description: |2
|
168
|
-
Hari is a
|
168
|
+
Hari is a tool to abstract complex relationships between
|
169
|
+
Ruby objects onto Redis data structures.
|
170
|
+
|
171
|
+
It allows for expressive querying of those relationships
|
172
|
+
as well, in an easy way. It is mostly geared towards
|
173
|
+
typical social networking concepts like news feeds,
|
174
|
+
activity logs, friends of friends, mutual friends, and so on.
|
169
175
|
email: victorc.rodrigues@gmail.com
|
170
176
|
executables: []
|
171
177
|
extensions: []
|
@@ -186,32 +192,40 @@ files:
|
|
186
192
|
- lib/hari/entity/property/builder.rb
|
187
193
|
- lib/hari/entity/repository.rb
|
188
194
|
- lib/hari/entity/serialization.rb
|
195
|
+
- lib/hari/entity/serialization/array.rb
|
189
196
|
- lib/hari/entity/serialization/boolean.rb
|
190
197
|
- lib/hari/entity/serialization/date.rb
|
191
198
|
- lib/hari/entity/serialization/datetime.rb
|
192
199
|
- lib/hari/entity/serialization/float.rb
|
200
|
+
- lib/hari/entity/serialization/hash.rb
|
193
201
|
- lib/hari/entity/serialization/integer.rb
|
194
202
|
- lib/hari/entity/serialization/string.rb
|
195
203
|
- lib/hari/entity/serialization/time.rb
|
196
204
|
- lib/hari/errors.rb
|
197
205
|
- lib/hari/keys.rb
|
206
|
+
- lib/hari/keys/hash.rb
|
198
207
|
- lib/hari/keys/key.rb
|
199
208
|
- lib/hari/keys/list.rb
|
200
209
|
- lib/hari/keys/set.rb
|
201
210
|
- lib/hari/keys/sorted_set.rb
|
202
211
|
- lib/hari/keys/string.rb
|
203
212
|
- lib/hari/node.rb
|
213
|
+
- lib/hari/node/index.rb
|
204
214
|
- lib/hari/node/queries.rb
|
205
215
|
- lib/hari/node/queries/relation.rb
|
206
216
|
- lib/hari/node/queries/relation/backend/sorted_set.rb
|
217
|
+
- lib/hari/node/queries/relation/backend/sorted_set/count_step.rb
|
218
|
+
- lib/hari/node/queries/relation/backend/sorted_set/node_step.rb
|
207
219
|
- lib/hari/node/queries/relation/runnable.rb
|
208
220
|
- lib/hari/node/queries/relation/start.rb
|
209
221
|
- lib/hari/node/queries/relation/step.rb
|
210
222
|
- lib/hari/node/queries/type.rb
|
211
223
|
- lib/hari/node/repository.rb
|
212
224
|
- lib/hari/node/serialization.rb
|
225
|
+
- lib/hari/object.rb
|
213
226
|
- lib/hari/relation.rb
|
214
227
|
- lib/hari/relation/sorted_set.rb
|
228
|
+
- lib/hari/serialization.rb
|
215
229
|
- lib/hari/version.rb
|
216
230
|
- spec/hari/configuration_spec.rb
|
217
231
|
- spec/hari/entity/repository_spec.rb
|
@@ -219,16 +233,20 @@ files:
|
|
219
233
|
- spec/hari/entity/serialization/date_spec.rb
|
220
234
|
- spec/hari/entity/serialization/datetime_spec.rb
|
221
235
|
- spec/hari/entity/serialization/float_spec.rb
|
236
|
+
- spec/hari/entity/serialization/hash_spec.rb
|
222
237
|
- spec/hari/entity/serialization/integer_spec.rb
|
223
238
|
- spec/hari/entity/serialization/string_spec.rb
|
224
239
|
- spec/hari/entity/serialization/time_spec.rb
|
225
240
|
- spec/hari/entity/serialization_spec.rb
|
241
|
+
- spec/hari/keys/hash_spec.rb
|
226
242
|
- spec/hari/keys/key_spec.rb
|
227
243
|
- spec/hari/keys/lists_spec.rb
|
228
244
|
- spec/hari/keys/sets_spec.rb
|
229
245
|
- spec/hari/keys/sorted_sets_spec.rb
|
230
246
|
- spec/hari/keys/string_spec.rb
|
247
|
+
- spec/hari/node/index_spec.rb
|
231
248
|
- spec/hari/node_spec.rb
|
249
|
+
- spec/hari/serialization_spec.rb
|
232
250
|
- spec/hari_spec.rb
|
233
251
|
- spec/spec_helper.rb
|
234
252
|
homepage: http://github.com/Clubjudge/hari
|
@@ -254,7 +272,8 @@ rubyforge_project:
|
|
254
272
|
rubygems_version: 2.0.3
|
255
273
|
signing_key:
|
256
274
|
specification_version: 4
|
257
|
-
summary:
|
275
|
+
summary: A tool to abstract complex relationships between Ruby objects onto Redis
|
276
|
+
data structures.
|
258
277
|
test_files:
|
259
278
|
- spec/hari/configuration_spec.rb
|
260
279
|
- spec/hari/entity/repository_spec.rb
|
@@ -262,15 +281,19 @@ test_files:
|
|
262
281
|
- spec/hari/entity/serialization/date_spec.rb
|
263
282
|
- spec/hari/entity/serialization/datetime_spec.rb
|
264
283
|
- spec/hari/entity/serialization/float_spec.rb
|
284
|
+
- spec/hari/entity/serialization/hash_spec.rb
|
265
285
|
- spec/hari/entity/serialization/integer_spec.rb
|
266
286
|
- spec/hari/entity/serialization/string_spec.rb
|
267
287
|
- spec/hari/entity/serialization/time_spec.rb
|
268
288
|
- spec/hari/entity/serialization_spec.rb
|
289
|
+
- spec/hari/keys/hash_spec.rb
|
269
290
|
- spec/hari/keys/key_spec.rb
|
270
291
|
- spec/hari/keys/lists_spec.rb
|
271
292
|
- spec/hari/keys/sets_spec.rb
|
272
293
|
- spec/hari/keys/sorted_sets_spec.rb
|
273
294
|
- spec/hari/keys/string_spec.rb
|
295
|
+
- spec/hari/node/index_spec.rb
|
274
296
|
- spec/hari/node_spec.rb
|
297
|
+
- spec/hari/serialization_spec.rb
|
275
298
|
- spec/hari_spec.rb
|
276
299
|
- spec/spec_helper.rb
|