actionset 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.hound.yml +32 -0
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -0
- data/CHANGELOG +17 -0
- data/Gemfile.lock +222 -0
- data/actionset.gemspec +12 -10
- data/bin/console +17 -3
- data/lib/action_set/attribute_value.rb +8 -2
- data/lib/action_set/helpers/helper_methods.rb +2 -0
- data/lib/action_set/helpers/pagination/links_for_helper.rb +6 -6
- data/lib/action_set/helpers/sort/next_direction_for_helper.rb +0 -1
- data/lib/active_set.rb +78 -0
- data/lib/active_set/attribute_instruction.rb +74 -0
- data/lib/active_set/column_instruction.rb +46 -0
- data/lib/active_set/exporting/csv_strategy.rb +43 -0
- data/lib/active_set/exporting/operation.rb +30 -0
- data/lib/active_set/filtering/active_record_strategy.rb +98 -0
- data/lib/active_set/filtering/enumerable_strategy.rb +78 -0
- data/lib/active_set/filtering/operation.rb +46 -0
- data/lib/active_set/paginating/active_record_strategy.rb +28 -0
- data/lib/active_set/paginating/enumerable_strategy.rb +33 -0
- data/lib/active_set/paginating/operation.rb +54 -0
- data/lib/active_set/sorting/active_record_strategy.rb +80 -0
- data/lib/active_set/sorting/enumerable_strategy.rb +56 -0
- data/lib/active_set/sorting/operation.rb +35 -0
- data/lib/helpers/throws.rb +19 -0
- data/lib/helpers/transform_to_sortable_numeric.rb +53 -0
- data/lib/patches/core_ext/hash/flatten_keys.rb +58 -0
- metadata +62 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4c9246a4316813c78ee58c47708a977b5811c2c
|
4
|
+
data.tar.gz: d6f45a1104daad185b971f7e9a4ac47abc698432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df2cc22b86dfc5bc3579bd9f84964844920afe47a3906ed31ed150f297e1eea0c9feecfdd0767c9c8e3dcec03e82d721ab1a5cd4a3a98833ea94b7f956cce03f
|
7
|
+
data.tar.gz: 9851ffa5d0e416ed93af12ae5a939fbbbe60b49a4670386e085af9a9d9c38f8d7bd313125d04710c891b3c950e296de1940e2f7c6137976f069669ef58a9bf0c
|
data/.gitignore
CHANGED
data/.hound.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
rubocop:
|
2
|
+
config_file: .rubocop.yml
|
3
|
+
|
4
|
+
reek:
|
5
|
+
enabled: true
|
6
|
+
|
7
|
+
coffeescript:
|
8
|
+
enabled: false
|
9
|
+
credo:
|
10
|
+
enabled: false
|
11
|
+
css:
|
12
|
+
enabled: false
|
13
|
+
eslint:
|
14
|
+
enabled: false
|
15
|
+
flake8:
|
16
|
+
enabled: false
|
17
|
+
golint:
|
18
|
+
enabled: false
|
19
|
+
haml:
|
20
|
+
enabled: false
|
21
|
+
jshint:
|
22
|
+
enabled: false
|
23
|
+
sass-lint:
|
24
|
+
enabled: false
|
25
|
+
scss:
|
26
|
+
enabled: false
|
27
|
+
shellcheck:
|
28
|
+
enabled: false
|
29
|
+
swiftlint:
|
30
|
+
enabled: false
|
31
|
+
tslint:
|
32
|
+
enabled: false
|
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
v 0.8.0
|
2
|
+
- merge ActiveSet and ActionSet into a monorepo
|
3
|
+
- merge and overhaul the specs
|
4
|
+
+ run a random subset of request specs to test ActionSet wiring to ActiveSet
|
5
|
+
+ polish the ActiveSet specs
|
6
|
+
- update the scopes filtering specs to be more generalized and exhaustive
|
7
|
+
- get all new features/fixes from current ActiveSet
|
8
|
+
+ fix a bug where ActiveRecord sorting didn't treat NULL values in the same way as Enumerable sorting
|
9
|
+
* where NULL values are sorted as if larger than any non-null value
|
10
|
+
+ fix a bug with ActiveRecord scope filtering
|
11
|
+
* if we try to use a class method scope that returns something other than an ActiveRecord::Relation
|
12
|
+
+ fix a bug in Enumerable class method filtering when method returns object, not array
|
13
|
+
+ fix a bug transforming Date objects into sortable integers to ensure UTC
|
14
|
+
+ fix a bug to allow sorting of computed attributes on sets that include nil values
|
15
|
+
+ fix a bug that prevents enumerable sets from being filtered down to empty sets
|
16
|
+
- fix Rubocop offenses (safely)
|
17
|
+
- use Bundler version 2.x
|
1
18
|
v 0.7.0
|
2
19
|
- overhaul the specs
|
3
20
|
+ update the data model to be more extensive and expressive
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,222 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
actionset (0.8.0)
|
5
|
+
activesupport (>= 4.0.2)
|
6
|
+
railties
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actioncable (5.1.6.1)
|
12
|
+
actionpack (= 5.1.6.1)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (~> 0.6.1)
|
15
|
+
actionmailer (5.1.6.1)
|
16
|
+
actionpack (= 5.1.6.1)
|
17
|
+
actionview (= 5.1.6.1)
|
18
|
+
activejob (= 5.1.6.1)
|
19
|
+
mail (~> 2.5, >= 2.5.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
actionpack (5.1.6.1)
|
22
|
+
actionview (= 5.1.6.1)
|
23
|
+
activesupport (= 5.1.6.1)
|
24
|
+
rack (~> 2.0)
|
25
|
+
rack-test (>= 0.6.3)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
28
|
+
actionview (5.1.6.1)
|
29
|
+
activesupport (= 5.1.6.1)
|
30
|
+
builder (~> 3.1)
|
31
|
+
erubi (~> 1.4)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
34
|
+
activejob (5.1.6.1)
|
35
|
+
activesupport (= 5.1.6.1)
|
36
|
+
globalid (>= 0.3.6)
|
37
|
+
activemodel (5.1.6.1)
|
38
|
+
activesupport (= 5.1.6.1)
|
39
|
+
activerecord (5.1.6.1)
|
40
|
+
activemodel (= 5.1.6.1)
|
41
|
+
activesupport (= 5.1.6.1)
|
42
|
+
arel (~> 8.0)
|
43
|
+
activesupport (5.1.6.1)
|
44
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
45
|
+
i18n (>= 0.7, < 2)
|
46
|
+
minitest (~> 5.1)
|
47
|
+
tzinfo (~> 1.1)
|
48
|
+
addressable (2.5.2)
|
49
|
+
public_suffix (>= 2.0.2, < 4.0)
|
50
|
+
ansi (1.5.0)
|
51
|
+
arel (8.0.0)
|
52
|
+
ast (2.4.0)
|
53
|
+
builder (3.2.3)
|
54
|
+
capybara (3.12.0)
|
55
|
+
addressable
|
56
|
+
mini_mime (>= 0.1.3)
|
57
|
+
nokogiri (~> 1.8)
|
58
|
+
rack (>= 1.6.0)
|
59
|
+
rack-test (>= 0.6.3)
|
60
|
+
regexp_parser (~> 1.2)
|
61
|
+
xpath (~> 3.2)
|
62
|
+
codecov (0.1.14)
|
63
|
+
json
|
64
|
+
simplecov
|
65
|
+
url
|
66
|
+
combustion (0.7.0)
|
67
|
+
activesupport (>= 3.0.0)
|
68
|
+
railties (>= 3.0.0)
|
69
|
+
thor (>= 0.14.6)
|
70
|
+
concurrent-ruby (1.1.4)
|
71
|
+
crass (1.0.4)
|
72
|
+
database_cleaner (1.6.2)
|
73
|
+
diff-lcs (1.3)
|
74
|
+
docile (1.1.5)
|
75
|
+
erubi (1.7.1)
|
76
|
+
factory_bot (4.8.2)
|
77
|
+
activesupport (>= 3.0.0)
|
78
|
+
faker (1.8.7)
|
79
|
+
i18n (>= 0.7)
|
80
|
+
globalid (0.4.1)
|
81
|
+
activesupport (>= 4.2.0)
|
82
|
+
hirb (0.7.3)
|
83
|
+
i18n (1.2.0)
|
84
|
+
concurrent-ruby (~> 1.0)
|
85
|
+
jaro_winkler (1.5.1)
|
86
|
+
json (2.1.0)
|
87
|
+
loofah (2.2.3)
|
88
|
+
crass (~> 1.0.2)
|
89
|
+
nokogiri (>= 1.5.9)
|
90
|
+
mail (2.7.1)
|
91
|
+
mini_mime (>= 0.1.1)
|
92
|
+
method_source (0.9.2)
|
93
|
+
mini_mime (1.0.1)
|
94
|
+
mini_portile2 (2.4.0)
|
95
|
+
minitest (5.11.3)
|
96
|
+
nio4r (2.3.1)
|
97
|
+
nokogiri (1.9.0)
|
98
|
+
mini_portile2 (~> 2.4.0)
|
99
|
+
parallel (1.12.1)
|
100
|
+
parser (2.5.3.0)
|
101
|
+
ast (~> 2.4.0)
|
102
|
+
powerpack (0.1.2)
|
103
|
+
public_suffix (3.0.3)
|
104
|
+
rack (2.0.6)
|
105
|
+
rack-test (1.1.0)
|
106
|
+
rack (>= 1.0, < 3)
|
107
|
+
rails (5.1.6.1)
|
108
|
+
actioncable (= 5.1.6.1)
|
109
|
+
actionmailer (= 5.1.6.1)
|
110
|
+
actionpack (= 5.1.6.1)
|
111
|
+
actionview (= 5.1.6.1)
|
112
|
+
activejob (= 5.1.6.1)
|
113
|
+
activemodel (= 5.1.6.1)
|
114
|
+
activerecord (= 5.1.6.1)
|
115
|
+
activesupport (= 5.1.6.1)
|
116
|
+
bundler (>= 1.3.0)
|
117
|
+
railties (= 5.1.6.1)
|
118
|
+
sprockets-rails (>= 2.0.0)
|
119
|
+
rails-dom-testing (2.0.3)
|
120
|
+
activesupport (>= 4.2.0)
|
121
|
+
nokogiri (>= 1.6)
|
122
|
+
rails-html-sanitizer (1.0.4)
|
123
|
+
loofah (~> 2.2, >= 2.2.2)
|
124
|
+
railties (5.1.6.1)
|
125
|
+
actionpack (= 5.1.6.1)
|
126
|
+
activesupport (= 5.1.6.1)
|
127
|
+
method_source
|
128
|
+
rake (>= 0.8.7)
|
129
|
+
thor (>= 0.18.1, < 2.0)
|
130
|
+
rainbow (3.0.0)
|
131
|
+
rake (10.5.0)
|
132
|
+
ransack (2.1.1)
|
133
|
+
actionpack (>= 5.0)
|
134
|
+
activerecord (>= 5.0)
|
135
|
+
activesupport (>= 5.0)
|
136
|
+
i18n
|
137
|
+
regexp_parser (1.3.0)
|
138
|
+
rspec (3.8.0)
|
139
|
+
rspec-core (~> 3.8.0)
|
140
|
+
rspec-expectations (~> 3.8.0)
|
141
|
+
rspec-mocks (~> 3.8.0)
|
142
|
+
rspec-core (3.8.0)
|
143
|
+
rspec-support (~> 3.8.0)
|
144
|
+
rspec-expectations (3.8.2)
|
145
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
146
|
+
rspec-support (~> 3.8.0)
|
147
|
+
rspec-mocks (3.8.0)
|
148
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
149
|
+
rspec-support (~> 3.8.0)
|
150
|
+
rspec-rails (3.8.1)
|
151
|
+
actionpack (>= 3.0)
|
152
|
+
activesupport (>= 3.0)
|
153
|
+
railties (>= 3.0)
|
154
|
+
rspec-core (~> 3.8.0)
|
155
|
+
rspec-expectations (~> 3.8.0)
|
156
|
+
rspec-mocks (~> 3.8.0)
|
157
|
+
rspec-support (~> 3.8.0)
|
158
|
+
rspec-support (3.8.0)
|
159
|
+
rubocop (0.61.1)
|
160
|
+
jaro_winkler (~> 1.5.1)
|
161
|
+
parallel (~> 1.10)
|
162
|
+
parser (>= 2.5, != 2.5.1.1)
|
163
|
+
powerpack (~> 0.1)
|
164
|
+
rainbow (>= 2.2.2, < 4.0)
|
165
|
+
ruby-progressbar (~> 1.7)
|
166
|
+
unicode-display_width (~> 1.4.0)
|
167
|
+
ruby-progressbar (1.10.0)
|
168
|
+
simplecov (0.15.1)
|
169
|
+
docile (~> 1.1.0)
|
170
|
+
json (>= 1.8, < 3)
|
171
|
+
simplecov-html (~> 0.10.0)
|
172
|
+
simplecov-console (0.4.2)
|
173
|
+
ansi
|
174
|
+
hirb
|
175
|
+
simplecov
|
176
|
+
simplecov-html (0.10.2)
|
177
|
+
sprockets (3.7.2)
|
178
|
+
concurrent-ruby (~> 1.0)
|
179
|
+
rack (> 1, < 3)
|
180
|
+
sprockets-rails (3.2.1)
|
181
|
+
actionpack (>= 4.0)
|
182
|
+
activesupport (>= 4.0)
|
183
|
+
sprockets (>= 3.0.0)
|
184
|
+
sqlite3 (1.3.13)
|
185
|
+
thor (0.20.3)
|
186
|
+
thread_safe (0.3.6)
|
187
|
+
tzinfo (1.2.5)
|
188
|
+
thread_safe (~> 0.1)
|
189
|
+
unicode-display_width (1.4.0)
|
190
|
+
url (0.3.2)
|
191
|
+
websocket-driver (0.6.5)
|
192
|
+
websocket-extensions (>= 0.1.0)
|
193
|
+
websocket-extensions (0.1.3)
|
194
|
+
xpath (3.2.0)
|
195
|
+
nokogiri (~> 1.8)
|
196
|
+
|
197
|
+
PLATFORMS
|
198
|
+
ruby
|
199
|
+
|
200
|
+
DEPENDENCIES
|
201
|
+
actionpack
|
202
|
+
actionset!
|
203
|
+
activerecord
|
204
|
+
bundler
|
205
|
+
capybara
|
206
|
+
codecov
|
207
|
+
combustion
|
208
|
+
database_cleaner
|
209
|
+
factory_bot
|
210
|
+
faker
|
211
|
+
rails (~> 5.1.0)
|
212
|
+
rake
|
213
|
+
ransack
|
214
|
+
rspec
|
215
|
+
rspec-rails
|
216
|
+
rubocop
|
217
|
+
simplecov
|
218
|
+
simplecov-console
|
219
|
+
sqlite3
|
220
|
+
|
221
|
+
BUNDLED WITH
|
222
|
+
2.0.1
|
data/actionset.gemspec
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
+
spec.platform = Gem::Platform::RUBY
|
7
8
|
spec.name = 'actionset'
|
8
|
-
spec.version = '0.
|
9
|
+
spec.version = '0.8.0'
|
9
10
|
spec.authors = ['Stephen Margheim']
|
10
11
|
spec.email = ['stephen.margheim@gmail.com']
|
11
12
|
|
12
|
-
spec.summary = 'A toolkit
|
13
|
-
spec.description = 'Easily filter, sort, and paginate
|
13
|
+
spec.summary = 'A toolkit for working with collections.'
|
14
|
+
spec.description = 'Easily filter, sort, and paginate collections.'
|
14
15
|
spec.homepage = 'https://github.com/fractaledmind/actionset'
|
15
16
|
spec.license = 'MIT'
|
16
17
|
|
@@ -21,20 +22,21 @@ Gem::Specification.new do |spec|
|
|
21
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
23
|
spec.require_paths = ['lib']
|
23
24
|
|
24
|
-
spec.add_dependency 'activeset', '>= 0.8.0'
|
25
25
|
spec.add_dependency 'activesupport', '>= 4.0.2'
|
26
26
|
spec.add_dependency 'railties'
|
27
27
|
|
28
|
-
spec.add_development_dependency 'rails', '~> 5.1.0'
|
29
28
|
spec.add_development_dependency 'bundler'
|
30
|
-
spec.add_development_dependency 'rake'
|
31
|
-
spec.add_development_dependency 'rspec'
|
32
|
-
spec.add_development_dependency 'database_cleaner'
|
33
29
|
spec.add_development_dependency 'capybara'
|
30
|
+
spec.add_development_dependency 'codecov'
|
34
31
|
spec.add_development_dependency 'combustion'
|
32
|
+
spec.add_development_dependency 'database_cleaner'
|
35
33
|
spec.add_development_dependency 'factory_bot'
|
36
34
|
spec.add_development_dependency 'faker'
|
35
|
+
spec.add_development_dependency 'rails', '~> 5.1.0'
|
36
|
+
spec.add_development_dependency 'rake'
|
37
|
+
spec.add_development_dependency 'ransack'
|
38
|
+
spec.add_development_dependency 'rspec'
|
39
|
+
spec.add_development_dependency 'rubocop'
|
37
40
|
spec.add_development_dependency 'simplecov'
|
38
41
|
spec.add_development_dependency 'simplecov-console'
|
39
|
-
spec.add_development_dependency 'ransack'
|
40
42
|
end
|
data/bin/console
CHANGED
@@ -1,10 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
ENV['RAILS_ENV'] ||= 'test'
|
5
|
+
|
6
|
+
require 'bundler'
|
7
|
+
require 'simplecov'
|
8
|
+
require 'combustion'
|
9
|
+
|
10
|
+
Combustion.initialize! :active_record, :action_controller, :action_view
|
11
|
+
Bundler.require :default, :development
|
2
12
|
|
3
13
|
require 'bundler/setup'
|
4
|
-
require '
|
14
|
+
require 'active_set'
|
15
|
+
require 'ostruct'
|
5
16
|
|
6
|
-
|
7
|
-
|
17
|
+
begin
|
18
|
+
FactoryBot.find_definitions
|
19
|
+
rescue FactoryBot::DuplicateDefinitionError
|
20
|
+
nil
|
21
|
+
end
|
8
22
|
|
9
23
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
24
|
# require "pry"
|
@@ -12,6 +12,7 @@ module ActionSet
|
|
12
12
|
adapters.reduce(nil) do |_, adapter|
|
13
13
|
mayble_value_or_nil = adapter.new(@raw, to).process
|
14
14
|
next if mayble_value_or_nil.nil?
|
15
|
+
|
15
16
|
return mayble_value_or_nil
|
16
17
|
end
|
17
18
|
|
@@ -32,6 +33,7 @@ module ActionSet
|
|
32
33
|
|
33
34
|
def process
|
34
35
|
return @raw if @raw.is_a? @target
|
36
|
+
|
35
37
|
possible_values.find { |v| v.is_a? @target }
|
36
38
|
end
|
37
39
|
|
@@ -51,7 +53,7 @@ module ActionSet
|
|
51
53
|
|
52
54
|
def typecast(method_name)
|
53
55
|
@raw.send(method_name)
|
54
|
-
rescue
|
56
|
+
rescue StandardError
|
55
57
|
nil
|
56
58
|
end
|
57
59
|
end
|
@@ -70,6 +72,7 @@ module ActionSet
|
|
70
72
|
|
71
73
|
def process
|
72
74
|
return @raw if @raw.is_a? @target
|
75
|
+
|
73
76
|
possible_values.find { |v| v.is_a? @target }
|
74
77
|
end
|
75
78
|
|
@@ -90,6 +93,7 @@ module ActionSet
|
|
90
93
|
|
91
94
|
def typecast(to_type, value)
|
92
95
|
return to_type.type_cast(value) if to_type.respond_to? :type_cast
|
96
|
+
|
93
97
|
to_type.cast(value)
|
94
98
|
end
|
95
99
|
|
@@ -101,7 +105,7 @@ module ActionSet
|
|
101
105
|
|
102
106
|
def init_typecaster(const_name)
|
103
107
|
type_class.const_get(const_name).new
|
104
|
-
rescue
|
108
|
+
rescue StandardError
|
105
109
|
nil
|
106
110
|
end
|
107
111
|
|
@@ -121,6 +125,7 @@ module ActionSet
|
|
121
125
|
def process
|
122
126
|
return if @raw.is_a? @target
|
123
127
|
return unless @target.eql?(TrueClass) || @target.eql?(FalseClass)
|
128
|
+
|
124
129
|
# ActiveModel::Type::Boolean is too expansive in its casting; will get false positives
|
125
130
|
to_bool
|
126
131
|
end
|
@@ -131,6 +136,7 @@ module ActionSet
|
|
131
136
|
return @raw if @raw.is_a?(TrueClass) || @raw.is_a?(FalseClass)
|
132
137
|
return true if %w[true yes 1 t].include? @raw.to_s.downcase
|
133
138
|
return false if %w[false no 0 f].include? @raw.to_s.downcase
|
139
|
+
|
134
140
|
nil
|
135
141
|
end
|
136
142
|
end
|