realize 1.0.0.pre.alpha.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/lib/realize/collection/sort.rb +3 -7
- data/lib/realize/collection/sort/direction.rb +5 -27
- data/lib/realize/version.rb +1 -1
- data/realize.gemspec +1 -1
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5725ecd097c45ce632cd82af3b5c03cd7f54dec0503c007ee28498a2ebe2f0e
|
4
|
+
data.tar.gz: c6731e9b7f14b3c7109e7a680ba107702dc2c65336e5cea75194f6f61501e796
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dc9995383fa3a27c3414cd1549871724583c19a1dccbda403b6dc6224927711a4d3309a894ddb9ed0c94587a2d7d37ac870a1fbe9fcc45a017073db39570ce0
|
7
|
+
data.tar.gz: 2cc2a27d5faa2aa2cd188c94051beaa1cf92acc2e499b1cf3762f667a0e4e27c2f9a750cfd687990cbdfcf52d86ee494278b4062af0ab091aa117b1ab7db035f
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'sort/direction'
|
4
|
+
|
3
5
|
module Realize
|
4
6
|
class Collection
|
5
|
-
# Transformer to take an array of
|
7
|
+
# Transformer to take an array of objects and sort by the given key
|
6
8
|
# and by the given sort direction. Defaulting to ascending.
|
7
9
|
class Sort
|
8
|
-
module Direction
|
9
|
-
ASCENDING = 'ASC'
|
10
|
-
ASC = 'ASC'
|
11
|
-
DESCENDING = 'DESC'
|
12
|
-
DESC = 'DESC'
|
13
|
-
end
|
14
10
|
include Arrays
|
15
11
|
include Direction
|
16
12
|
acts_as_hashable
|
@@ -1,35 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'sort/direction'
|
4
|
-
|
5
3
|
module Realize
|
6
4
|
class Collection
|
7
|
-
# Transformer to take an array of oibjects and sort by the given key
|
8
|
-
# and by the given sort direction. Defaulting to ascending.
|
9
5
|
class Sort
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
attr_reader :key, :order
|
17
|
-
|
18
|
-
def initialize(key:, order: DEFAULT_ORDER)
|
19
|
-
raise ArgumentError, 'key is required' if key.to_s.empty?
|
20
|
-
|
21
|
-
@key = key
|
22
|
-
@order = Direction.const_get(order.to_s.upcase.to_sym)
|
23
|
-
|
24
|
-
freeze
|
25
|
-
end
|
26
|
-
|
27
|
-
def transform(_resolver, value, _time, _record)
|
28
|
-
records = array(value)
|
29
|
-
|
30
|
-
sorted = records.sort_by { |hsh| hsh[key.to_sym] }
|
31
|
-
|
32
|
-
order == DESCENDING ? sorted.reverse : sorted
|
6
|
+
# Constants describing the possible values of 'direction' for a Sort instance.
|
7
|
+
module Direction
|
8
|
+
# providing a few different ways to specify.
|
9
|
+
ASCENDING = ASC = 'ASC'
|
10
|
+
DESCENDING = DESC = 'DESC'
|
33
11
|
end
|
34
12
|
end
|
35
13
|
end
|
data/lib/realize/version.rb
CHANGED
data/realize.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
|
29
29
|
s.required_ruby_version = '>= 2.5'
|
30
30
|
|
31
|
-
s.add_dependency('acts_as_hashable', '
|
31
|
+
s.add_dependency('acts_as_hashable', '~>1', '>=1.2.0')
|
32
32
|
s.add_dependency('objectable', '~>1')
|
33
33
|
|
34
34
|
s.add_development_dependency('guard-rspec', '~>4.7')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
@@ -14,16 +14,22 @@ dependencies:
|
|
14
14
|
name: acts_as_hashable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1
|
19
|
+
version: '1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.2.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1
|
29
|
+
version: '1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: objectable
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,9 +206,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
206
|
version: '2.5'
|
201
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
208
|
requirements:
|
203
|
-
- - "
|
209
|
+
- - ">="
|
204
210
|
- !ruby/object:Gem::Version
|
205
|
-
version:
|
211
|
+
version: '0'
|
206
212
|
requirements: []
|
207
213
|
rubygems_version: 3.0.3
|
208
214
|
signing_key:
|