ohm-sorted 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/CHANGELOG.md +4 -0
- data/lib/ohm/sorted.rb +6 -4
- data/ohm-sorted.gemspec +1 -1
- data/test/sorted_test.rb +8 -0
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGFlMjVmMzEzNjcwMzA2NTMwMzQ3OTJhOGNhYmQwY2IwZDc2MTVmYw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZmIzODJhYzE3MDhmMmQ0NmM1MGJlMjM3ZjExZGY1ZGRmYWZkM2I0NQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZWI3MjUzNjBhOTc4ODBjNmJhY2QyYzMyOTQ5YTBlZDJmNGZiZTJkODVlOGM4
|
10
|
+
MmE4ZDg2MDVmZWRjNDcxYTRmZmIyYmFlMTFhNjk1MzVlMjdjZWYxMDMyYjA5
|
11
|
+
YTE0YjRlZjM1N2VmNTU2MDA4ODRiMzAzMDQwMzJjMDBjNjVkM2E=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjQzMjE4YmNiMzEyY2MwMmE1MzIyMWFmNGVjMTc5YjBhYTI3YzdiN2ZmOTQ0
|
14
|
+
NWUyYjUzYmNiYTg2YTJkODMwZmE5MzkxYzdjNjE3MDFkYTU3YjQyNGE2MzUw
|
15
|
+
OWQ0ZmQzN2Q1MGVjNjI1MTUxYzBhNzkwOGNmNTQ3MTJjOGNlMjU=
|
data/CHANGELOG.md
CHANGED
data/lib/ohm/sorted.rb
CHANGED
@@ -220,10 +220,12 @@ module Ohm
|
|
220
220
|
def add_sorted_indices
|
221
221
|
update_sorted_indices do |key, attribute, options|
|
222
222
|
attr = send(attribute)
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
223
|
+
if attr
|
224
|
+
score = attr.to_f
|
225
|
+
db.zadd(key, score, id)
|
226
|
+
else
|
227
|
+
db.zrem(key, id)
|
228
|
+
end
|
227
229
|
end
|
228
230
|
end
|
229
231
|
|
data/ohm-sorted.gemspec
CHANGED
data/test/sorted_test.rb
CHANGED
@@ -109,6 +109,14 @@ class SortedTest < Test::Unit::TestCase
|
|
109
109
|
post = Post.create(status: "draft")
|
110
110
|
sorted_set = Post.sorted_find(:order, status: "draft")
|
111
111
|
assert_equal [], sorted_set.to_a
|
112
|
+
|
113
|
+
post.update(order: 1)
|
114
|
+
sorted_set = Post.sorted_find(:order, status: "draft")
|
115
|
+
assert_equal [post], sorted_set.to_a
|
116
|
+
|
117
|
+
post.update(order: nil)
|
118
|
+
sorted_set = Post.sorted_find(:order, status: "draft")
|
119
|
+
assert_equal [], sorted_set.to_a
|
112
120
|
end
|
113
121
|
|
114
122
|
def test_sorted_find_invalid
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohm-sorted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Bond
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
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
28
|
name: ohm
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ohm-contrib
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: An plugin for Ohm that lets you create sorted indices.
|
@@ -58,8 +58,8 @@ executables: []
|
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
|
-
-
|
62
|
-
-
|
61
|
+
- .gitignore
|
62
|
+
- .travis.yml
|
63
63
|
- Appraisals
|
64
64
|
- CHANGELOG.md
|
65
65
|
- Gemfile
|
@@ -80,17 +80,17 @@ require_paths:
|
|
80
80
|
- lib
|
81
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ! '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ! '>='
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.0.0
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Sorted indices for Ohm.
|