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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 355f7018df42de77b3733ed309257ac21a50e9df
4
- data.tar.gz: 512e39ffdcea42c36d3ed2ecdaa3b3f9fa7ba7fd
5
- SHA512:
6
- metadata.gz: 71219e4bbd9f003f58bbfb8631a25e9e799155cf442d316ce6fdb648bf1ed6afd0970fd2c78037b5a50fe1ae553cc6bcd17d99b4a24a1ca0807af16aa27b4c03
7
- data.tar.gz: a2ab1aa904a6195d84a0e1ca624952036aff42dd03293c9eef51a2a8618afbf74e4988fa3ed42de9b69905f5c7ec43e88e601c7c827c4b305cf532220900cdf5
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
@@ -1,3 +1,7 @@
1
+ ### 0.4.1
2
+
3
+ - Fixed a bug where updating to a `nil` value didn't update the index.
4
+
1
5
  ### 0.4.0
2
6
 
3
7
  - Do not index nil values. You can do a manual `to_f` in case you need to
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
- next if attr.nil?
224
-
225
- score = attr.to_f
226
- db.zadd(key, score, id)
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ohm-sorted'
3
- s.version = '0.4.0'
3
+ s.version = '0.4.1'
4
4
  s.summary = "Sorted indices for Ohm."
5
5
  s.description = "An plugin for Ohm that lets you create sorted indices."
6
6
  s.author = "Federico Bond"
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.0
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-05-20 00:00:00.000000000 Z
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
- - ".gitignore"
62
- - ".travis.yml"
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.2.2
93
+ rubygems_version: 2.0.0
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Sorted indices for Ohm.