activeset 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +2 -0
- data/activeset.gemspec +1 -1
- data/lib/active_set/sorting/enumerable_strategy.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a35c45c1515b720f53f45bbaf0f56a3de6b36af
|
4
|
+
data.tar.gz: 65588202096e28453bd828643884b51489aa5f4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 691731355d82e7fd51af5b76ce8caffe3e54f4decef98986595f67b8916c043ae52cdf3fbbd694d568844302d2f609988befa62df5e6720e1b808111a59f93a7
|
7
|
+
data.tar.gz: 2c66f5a2d7ae05fbeebf0267ac36736f6ab42c0e42d9f70189af65b03f429ae88de4159489b7725c6f89a677c760230a7f14b9db518c287402f57f9220f38490
|
data/CHANGELOG
CHANGED
data/activeset.gemspec
CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.platform = Gem::Platform::RUBY
|
8
8
|
spec.name = 'activeset'
|
9
|
-
spec.version = '0.8.
|
9
|
+
spec.version = '0.8.3'
|
10
10
|
spec.authors = ['Stephen Margheim']
|
11
11
|
spec.email = ['stephen.margheim@gmail.com']
|
12
12
|
|
@@ -14,7 +14,19 @@ class ActiveSet
|
|
14
14
|
# http://brandon.dimcheff.com/2009/11/18/rubys-sort-vs-sort-by/
|
15
15
|
@set.sort_by do |item|
|
16
16
|
@attribute_instructions.map do |instruction|
|
17
|
-
sortable_numeric_for(instruction, item)
|
17
|
+
value_for_comparison = sortable_numeric_for(instruction, item)
|
18
|
+
direction_multiplier = direction_multiplier(instruction.value)
|
19
|
+
|
20
|
+
# in an ASC sort, nils float to the end of the list. In a DESC
|
21
|
+
# sort, nils float to the start of the list. This is achieved by
|
22
|
+
# wrapping each value_for_comparison in a tuple with 0 as the first
|
23
|
+
# element, and wrapping nil values with either 1 or -1 as the first
|
24
|
+
# element
|
25
|
+
if value_for_comparison.nil?
|
26
|
+
[direction_multiplier, 0]
|
27
|
+
else
|
28
|
+
[0, value_for_comparison * direction_multiplier]
|
29
|
+
end
|
18
30
|
end
|
19
31
|
end
|
20
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Margheim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|