record_redis 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/redis_record/base.rb +8 -5
- data/lib/redis_record/version.rb +1 -1
- data/spec/fixtures/network.yml +6 -1
- data/spec/lib/redis_record/base_spec.rb +18 -3
- data/spec/lib/redis_record/fixture_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2QyMTdjMzNjMzcxMTQ2ZmNmYmQwM2NjN2JlZGVkNjMwMDczNDJiNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDBhMGE0Njc4YjFjODYyNGE1ZWYzOGNhYmFhMjk0MmQ2ODJjNGY1Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWY3MTQ4NTJiYzc5YmRiNTg1MjUzNmQwYWM2N2M1ODE3ZjVkYzQ0NDQ4ZmJm
|
10
|
+
ZWQ1OGEyNDNhMDQ4ZWM2ZDgwMzg2ODg1YmU0NGJkZWE5NGVkMDQwYzFhZmZi
|
11
|
+
MzljZjQ4NDNlYzU2MGNhYjI0MWE5YmYxOWUwOGE5N2I3NmRhY2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWNjM2ViMmRkYzNiZWVhZTQzZjUxNTQ0NzhhYmEzYzA1NDMxYWMwNDljZjIz
|
14
|
+
ODhlOGRhY2FjYTY3ZDAyM2EyNWQ1YjljZTA4NmExMDMwY2ZmODEwZjkwMjA0
|
15
|
+
Yjg4ODdmYjcyY2I1MDc1OGFkZGM3MGE0OGMyZjcxNDZkNjAxYzM=
|
data/lib/redis_record/base.rb
CHANGED
@@ -47,13 +47,13 @@ module RedisRecord
|
|
47
47
|
def self.redis_sort(elements,order)
|
48
48
|
attribute= order.split(" ").first
|
49
49
|
direction= order.split(" ").last
|
50
|
-
|
50
|
+
result = Array.new
|
51
51
|
if direction=="dsc"
|
52
|
-
elements.sort {|a,b| b.send(attribute) <=> a.send(attribute)}
|
52
|
+
result= elements.sort {|a,b| b.send(attribute) <=> a.send(attribute)}
|
53
53
|
else
|
54
|
-
elements.sort {|a,b| a.send(attribute) <=> b.send(attribute)}
|
54
|
+
result= elements.sort {|a,b| a.send(attribute) <=> b.send(attribute)}
|
55
55
|
end
|
56
|
-
|
56
|
+
result
|
57
57
|
|
58
58
|
end
|
59
59
|
def update(attributes)
|
@@ -126,12 +126,15 @@ module RedisRecord
|
|
126
126
|
|
127
127
|
def self.make_all_selectors(name)
|
128
128
|
class_eval <<-EOD
|
129
|
-
def self.find_all_by_#{name}(value)
|
129
|
+
def self.find_all_by_#{name}(value,*args)
|
130
130
|
models= Array.new
|
131
131
|
results= self.find_all
|
132
132
|
results.each do |result|
|
133
133
|
models << result if result.#{name}==value
|
134
134
|
end
|
135
|
+
if args.size > 0
|
136
|
+
models = redis_sort(models,args.first[:sort]) if args.first[:sort]
|
137
|
+
end
|
135
138
|
models
|
136
139
|
end
|
137
140
|
EOD
|
data/lib/redis_record/version.rb
CHANGED
data/spec/fixtures/network.yml
CHANGED
@@ -65,15 +65,28 @@ describe RedisRecord::Base do
|
|
65
65
|
result= Network.find_by_Name("f_name")
|
66
66
|
result.Name.should == name
|
67
67
|
end
|
68
|
+
|
68
69
|
end
|
69
70
|
|
70
71
|
describe '#find_all_by_' do
|
72
|
+
|
73
|
+
before(:all) do
|
74
|
+
redis_fixture= RedisRecord::Fixture.new
|
75
|
+
redis_fixture.fixture "Network"
|
76
|
+
end
|
77
|
+
|
71
78
|
it 'must find all Entries for the given attribute' do
|
72
79
|
Network.create({"Name" => "testNetwork", "Key" => "t1"})
|
73
80
|
Network.create({"Name" => "testNetwork", "Key" => "tt1"})
|
74
81
|
results= Network.find_all_by_Name("testNetwork")
|
75
82
|
results.size.should == 2
|
76
83
|
end
|
84
|
+
|
85
|
+
it 'must return as first Entry with the given format and sort order a Network with name s_name' do
|
86
|
+
networks= Network.find_all_by_Format("s_format",:order => "Name asc")
|
87
|
+
networks.first.Name.should == "s_name"
|
88
|
+
end
|
89
|
+
|
77
90
|
end
|
78
91
|
|
79
92
|
describe '#update' do
|
@@ -94,12 +107,14 @@ describe RedisRecord::Base do
|
|
94
107
|
|
95
108
|
describe '#find_all with sort' do
|
96
109
|
|
97
|
-
|
98
|
-
|
110
|
+
before(:all) do
|
111
|
+
redis_fixture= RedisRecord::Fixture.new
|
112
|
+
redis_fixture.fixture "Network"
|
113
|
+
end
|
99
114
|
|
100
115
|
it 'must find all Entries for the given attribute sort by a attribute' do
|
101
116
|
networks = Network.find_all({:sort => "Name dsc"})
|
102
|
-
networks.first.Name.should == "
|
117
|
+
networks.first.Name.should == "x_name"
|
103
118
|
end
|
104
119
|
|
105
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcel Schlimper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|