deepsort 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/deepsort.rb +15 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzlkNjkzMTNmY2Q4NDQ4MTY0NTc3MmM3MjNjYmM1NDVjNTJkYTM3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDJkYTVhMTEyM2JjMGEwZTUwNTU1YzYwMTdlMmI0ZWZkYjNiZDdmZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDA5Mzk0OTNkMWE5YjNiMWVmOTdmNmUzMmFjZGMyZmM5ZGRhNjk0ZGM4Y2Iz
|
10
|
+
NjYzZDYwMDc5MmRlODhhNjBlZTkzNTBhMTBhNThhZmU3YjY1MTk4MjlkYzgz
|
11
|
+
MWE2YjA2ZGJjOGUyYmFmMmE4MTdjOWZiMjYwZjkwOTEyMDM1YTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTE1MDU2OWZiNmI1OTY3ZGU0ZjlhMWMwYzVhNGQ3OWUwM2Q1YjIxM2JlMzlm
|
14
|
+
ZDE4ZWNkM2NkODg3NDMxN2QwM2M4YzBhMWZjNWY0ZWQ4MmE1MjhlNTdiNjU1
|
15
|
+
MWY1MTE1NDY3YjAxNTkzOTUzM2E3ODQ1YTk3ZmVjYmU3MWIyODk=
|
data/lib/deepsort.rb
CHANGED
@@ -27,25 +27,25 @@ module DeepSort
|
|
27
27
|
def deep_sort_by(&block)
|
28
28
|
self.map do |value|
|
29
29
|
if value.respond_to? :deep_sort_by
|
30
|
-
value.deep_sort_by
|
30
|
+
value.deep_sort_by(&block)
|
31
31
|
elsif value.respond_to? :sort_by
|
32
|
-
value.sort_by
|
32
|
+
value.sort_by(&block)
|
33
33
|
else
|
34
34
|
value
|
35
35
|
end
|
36
|
-
end.sort_by
|
36
|
+
end.sort_by(&block)
|
37
37
|
end
|
38
38
|
|
39
39
|
def deep_sort_by!(&block)
|
40
40
|
self.map! do |value|
|
41
41
|
if value.respond_to? :deep_sort_by!
|
42
|
-
value.deep_sort_by!
|
42
|
+
value.deep_sort_by!(&block)
|
43
43
|
elsif value.respond_to? :sort_by!
|
44
|
-
value.sort_by!
|
44
|
+
value.sort_by!(&block)
|
45
45
|
else
|
46
46
|
value
|
47
47
|
end
|
48
|
-
end.sort_by!
|
48
|
+
end.sort_by!(&block)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -63,22 +63,22 @@ module DeepSort
|
|
63
63
|
def deep_sort_by(&block)
|
64
64
|
Hash[self.map do |key, value|
|
65
65
|
[if key.respond_to? :deep_sort_by
|
66
|
-
key.deep_sort_by
|
66
|
+
key.deep_sort_by(&block)
|
67
67
|
elsif key.respond_to? :sort_by
|
68
|
-
key.sort_by
|
68
|
+
key.sort_by(&block)
|
69
69
|
else
|
70
70
|
key
|
71
71
|
end,
|
72
72
|
|
73
73
|
if value.respond_to? :deep_sort_by
|
74
|
-
value.deep_sort_by
|
74
|
+
value.deep_sort_by(&block)
|
75
75
|
elsif value.respond_to? :sort_by
|
76
|
-
value.sort_by
|
76
|
+
value.sort_by(&block)
|
77
77
|
else
|
78
78
|
value
|
79
79
|
end]
|
80
80
|
|
81
|
-
end.sort_by
|
81
|
+
end.sort_by(&block)]
|
82
82
|
end
|
83
83
|
|
84
84
|
# Ruby Hashes don't have in-place-modification like map!, each!, or sort!
|
@@ -87,15 +87,15 @@ module DeepSort
|
|
87
87
|
def deep_sort_by!(&block)
|
88
88
|
Hash[self.map do |key, value|
|
89
89
|
if key.respond_to? :deep_sort_by!
|
90
|
-
key.deep_sort_by!
|
90
|
+
key.deep_sort_by!(&block)
|
91
91
|
elsif key.respond_to? :sort_by!
|
92
|
-
key.sort_by!
|
92
|
+
key.sort_by!(&block)
|
93
93
|
end
|
94
94
|
|
95
95
|
if value.respond_to? :deep_sort!
|
96
|
-
value.deep_sort_by!
|
96
|
+
value.deep_sort_by!(&block)
|
97
97
|
elsif value.respond_to? :sort_by!
|
98
|
-
value.sort_by!
|
98
|
+
value.sort_by!(&block)
|
99
99
|
end
|
100
100
|
|
101
101
|
[key, value]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deepsort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Crossen
|
@@ -36,7 +36,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
36
|
version: '0'
|
37
37
|
requirements: []
|
38
38
|
rubyforge_project:
|
39
|
-
rubygems_version: 2.4.
|
39
|
+
rubygems_version: 2.4.5
|
40
40
|
signing_key:
|
41
41
|
specification_version: 4
|
42
42
|
summary: A utility to deep sort arrays and hashes.
|