actionset 0.8.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -5
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +1 -1
  5. data/CHANGELOG +67 -0
  6. data/Gemfile.lock +134 -126
  7. data/README.md +26 -0
  8. data/Rakefile +8 -1
  9. data/actionset.gemspec +2 -2
  10. data/lib/action_set.rb +8 -23
  11. data/lib/action_set/attribute_value.rb +7 -1
  12. data/lib/action_set/filter_instructions.rb +72 -0
  13. data/lib/action_set/helpers/helper_methods.rb +2 -1
  14. data/lib/action_set/helpers/pagination/record_description_for_helper.rb +20 -0
  15. data/lib/action_set/helpers/pagination/record_first_for_helper.rb +20 -0
  16. data/lib/action_set/helpers/pagination/record_last_for_helper.rb +26 -0
  17. data/lib/action_set/helpers/pagination/record_range_for_helper.rb +25 -0
  18. data/lib/action_set/helpers/pagination/record_size_for_helper.rb +9 -0
  19. data/lib/action_set/helpers/pagination/total_pages_for_helper.rb +3 -1
  20. data/lib/action_set/sort_instructions.rb +44 -0
  21. data/lib/active_set.rb +25 -2
  22. data/lib/active_set/active_record_set_instruction.rb +33 -32
  23. data/lib/active_set/attribute_instruction.rb +3 -3
  24. data/lib/active_set/enumerable_set_instruction.rb +13 -24
  25. data/lib/active_set/filtering/active_record/operators.rb +280 -0
  26. data/lib/active_set/filtering/active_record/query_column.rb +35 -0
  27. data/lib/active_set/filtering/active_record/query_value.rb +47 -0
  28. data/lib/active_set/filtering/active_record/set_instruction.rb +29 -0
  29. data/lib/active_set/filtering/active_record/strategy.rb +87 -0
  30. data/lib/active_set/filtering/constants.rb +349 -0
  31. data/lib/active_set/filtering/enumerable/operators.rb +308 -0
  32. data/lib/active_set/filtering/enumerable/set_instruction.rb +98 -0
  33. data/lib/active_set/filtering/enumerable/strategy.rb +90 -0
  34. data/lib/active_set/filtering/operation.rb +5 -8
  35. data/lib/active_set/paginating/active_record_strategy.rb +0 -2
  36. data/lib/active_set/sorting/active_record_strategy.rb +27 -3
  37. data/lib/active_set/sorting/enumerable_strategy.rb +12 -2
  38. data/lib/active_set/sorting/operation.rb +1 -2
  39. data/lib/helpers/flatten_keys_of.rb +53 -0
  40. data/lib/helpers/transform_to_sortable_numeric.rb +3 -3
  41. metadata +26 -13
  42. data/lib/active_set/filtering/active_record_strategy.rb +0 -85
  43. data/lib/active_set/filtering/enumerable_strategy.rb +0 -79
  44. data/lib/helpers/throws.rb +0 -19
  45. data/lib/patches/core_ext/hash/flatten_keys.rb +0 -58
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d8befffeaabf8526df7cdd15f501f2e9e99732b
4
- data.tar.gz: 9dc431b8b1af60ed1d6d57d8ba9e66ac6e6a0688
3
+ metadata.gz: 21803f62c8dc2bb44f5874c054dfb0e6ce02c2d6
4
+ data.tar.gz: 4434f51ffb36e00bcc2f4653d2470d68e393b6cd
5
5
  SHA512:
6
- metadata.gz: 076e19f851950c2a0c2ac377c51a04eaf16198060ce8a1e6a766339f659c61eab1ae125c34005db809b27b0b0c02aad85e9ad1502f13c11ad04a821be6d40d0d
7
- data.tar.gz: c2de49f8fb3a36ecf86dfc00c51a880b675ea8f7db129de84a0eace0565c9175528cd53fcf25096ff04151c727189ce09c53ac54b50221df20784e8ba8e52270
6
+ metadata.gz: 89ab3bb66e3bed9a16fe3a10119d8afe7f447222e0d2b3bc92ba1f6dc7039f3c47a237a4ee8b9f808dbf9f4c15c00f237d2a47d68b98a2ccb26258c3bc1345e2
7
+ data.tar.gz: 4c01159e0767446c421823d1f168829a2b9f107a9da6d6610cf128053960aea7fd799143224d1d7ab20c3a1bf9883e41450e81d347c9be47152de0dfc58086f2
data/.rubocop.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.4
3
+ Exclude:
4
+ - 'actionset.gemspec'
5
+ - 'spec/**/*'
3
6
  Metrics/LineLength:
4
7
  Max: 120
5
8
  # To make it possible to copy or click on URIs in the code, we allow lines
@@ -10,13 +13,10 @@ Metrics/LineLength:
10
13
  - https
11
14
  Style/Documentation:
12
15
  Enabled: false
16
+ Metrics/MethodLength:
17
+ Enabled: false
13
18
  Style/SignalException:
14
19
  EnforcedStyle: semantic
15
- Metrics/BlockLength:
16
- Exclude:
17
- - 'activeset.gemspec'
18
- - 'spec/**/*_spec.rb'
19
- - '**/schema.rb'
20
20
  Naming/VariableNumber:
21
21
  EnforcedStyle: snake_case
22
22
  Style/DateTime:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.4.9
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
4
+ - 2.4.9
5
5
  before_install:
6
6
  - gem install bundler -v 1.15.4
7
7
  - export TZ=America/New_York
data/CHANGELOG CHANGED
@@ -1,3 +1,70 @@
1
+ v 0.11.0
2
+ - Don't eager load collection into memory to check pagination condition
3
+ v 0.10.0
4
+ - Bump testing internals to Rails 5.2
5
+ - Fix deprecation notice on sorts.
6
+ - Prevent additional types from checking for empty strings in blank queries. These DB types will not support empty strings, so we do not need to check for those values (and doing so corrupts the SQL).
7
+ - Do not attach wildcards to boolean search values. They have no meaning when searching boolean fields and all get transformed to "true"
8
+ v 0.9.2
9
+ - allow for form-friendly filter parameters
10
+ ```
11
+ {
12
+ '0': {
13
+ attribute: :foo,
14
+ operator: :EQ,
15
+ query: 'query'
16
+ },
17
+ '1': {
18
+ attribute: :bar,
19
+ operator: :GT,
20
+ query: 'value'
21
+ }
22
+ }
23
+
24
+ { foo: 'query', bar(GT): 'value' }
25
+ ```
26
+ - allow for form-friendly sort parameters
27
+ ```
28
+ {
29
+ '0': {
30
+ attribute: :foo,
31
+ direction: :desc
32
+ },
33
+ '1': {
34
+ attribute: :bar,
35
+ direction: :asc
36
+ }
37
+ }
38
+
39
+ { foo: 'desc', bar: 'asc' }
40
+ ```
41
+
42
+ v 0.9.1
43
+ - ensure that our RubyGems build is stable, since we had a TravisCI build problem in the last version
44
+ v 0.9.0
45
+ - Add Enumerable support for the base filtering operations
46
+ + EQ, NOT_EQ, EQ_ANY, EQ_ALL, NOT_EQ_ANY, NOT_EQ_ALL
47
+ + IN, NOT_IN, IN_ANY, IN_ALL, NOT_IN_ANY, NOT_IN_ALL
48
+ + MATCHES, DOES_NOT_MATCH, MATCHES_ANY, MATCHES_ALL, DOES_NOT_MATCH_ANY, DOES_NOT_MATCH_ALL
49
+ + LT, LTEQ, LT_ANY, LT_ALL, LTEQ_ANY, LTEQ_ALL
50
+ + GT, GTEQ, GT_ANY, GT_ALL, GTEQ_ANY, GTEQ_ALL
51
+ + BETWEEN, NOT_BETWEEN
52
+ - Add unary predicate filtering operators, for both ActiveRecord and Enumerable
53
+ + IS_TRUE, IS_FALSE
54
+ + IS_NULL, NOT_NULL
55
+ + IS_PRESENT, IS_BLANK
56
+ - Add computed matcher filtering operators, for both ActiveRecord and Enumerable
57
+ + MATCH_START, MATCH_START_ANY, MATCH_START_ALL, MATCH_NOT_START, MATCH_NOT_START_ANY, MATCH_NOT_START_ALL
58
+ + MATCH_END, MATCH_END_ANY, MATCH_END_ALL, MATCH_NOT_END, MATCH_NOT_END_ANY, MATCH_NOT_END_ALL
59
+ + MATCH_CONTAIN, MATCH_CONTAIN_ANY, MATCH_CONTAIN_ALL, MATCH_NOT_CONTAIN, MATCH_NOT_CONTAIN_ANY, MATCH_NOT_CONTAIN_ALL
60
+ - Add view helpers for the range of records shown on the current page
61
+ - Use ActiveRecord's data dictionary to look up database column types when converting filter params to filter instructions
62
+ - Allow app to define type hints for filter attributes when converting filter params to filter instructions
63
+ - Allow sort params to be passed in short or long form
64
+ + e.g. { attribute: x, direction: x } or { attribute: direction }
65
+ - Fix enumerable intersection filtering when working across associations
66
+ v 0.8.2
67
+ - add `ActiveSet.configuration.on_asc_sort_nils_come` configuration
1
68
  v 0.8.1
2
69
  - add a case-insensitive filtering/sorting option (`/i/`)
3
70
  - standardize how filtering by class scopes behaves
data/Gemfile.lock CHANGED
@@ -1,196 +1,204 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actionset (0.8.1)
4
+ actionset (0.11.0)
5
5
  activesupport (>= 4.0.2)
6
6
  railties
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (5.1.6.1)
12
- actionpack (= 5.1.6.1)
11
+ actioncable (5.2.5)
12
+ actionpack (= 5.2.5)
13
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)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.5)
16
+ actionpack (= 5.2.5)
17
+ actionview (= 5.2.5)
18
+ activejob (= 5.2.5)
19
19
  mail (~> 2.5, >= 2.5.4)
20
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)
21
+ actionpack (5.2.5)
22
+ actionview (= 5.2.5)
23
+ activesupport (= 5.2.5)
24
+ rack (~> 2.0, >= 2.0.8)
25
25
  rack-test (>= 0.6.3)
26
26
  rails-dom-testing (~> 2.0)
27
27
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.1.6.1)
29
- activesupport (= 5.1.6.1)
28
+ actionview (5.2.5)
29
+ activesupport (= 5.2.5)
30
30
  builder (~> 3.1)
31
31
  erubi (~> 1.4)
32
32
  rails-dom-testing (~> 2.0)
33
33
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
- activejob (5.1.6.1)
35
- activesupport (= 5.1.6.1)
34
+ activejob (5.2.5)
35
+ activesupport (= 5.2.5)
36
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)
37
+ activemodel (5.2.5)
38
+ activesupport (= 5.2.5)
39
+ activerecord (5.2.5)
40
+ activemodel (= 5.2.5)
41
+ activesupport (= 5.2.5)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.5)
44
+ actionpack (= 5.2.5)
45
+ activerecord (= 5.2.5)
46
+ marcel (~> 1.0.0)
47
+ activesupport (5.2.5)
44
48
  concurrent-ruby (~> 1.0, >= 1.0.2)
45
49
  i18n (>= 0.7, < 2)
46
50
  minitest (~> 5.1)
47
51
  tzinfo (~> 1.1)
48
- addressable (2.5.2)
49
- public_suffix (>= 2.0.2, < 4.0)
52
+ addressable (2.7.0)
53
+ public_suffix (>= 2.0.2, < 5.0)
50
54
  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
+ arel (9.0.0)
56
+ ast (2.4.2)
57
+ builder (3.2.4)
58
+ capybara (3.32.2)
55
59
  addressable
56
60
  mini_mime (>= 0.1.3)
57
61
  nokogiri (~> 1.8)
58
62
  rack (>= 1.6.0)
59
63
  rack-test (>= 0.6.3)
60
- regexp_parser (~> 1.2)
64
+ regexp_parser (~> 1.5)
61
65
  xpath (~> 3.2)
62
- codecov (0.1.14)
63
- json
64
- simplecov
65
- url
66
- combustion (0.7.0)
66
+ codecov (0.5.1)
67
+ simplecov (>= 0.15, < 0.22)
68
+ combustion (1.3.1)
67
69
  activesupport (>= 3.0.0)
68
70
  railties (>= 3.0.0)
69
71
  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)
72
+ concurrent-ruby (1.1.8)
73
+ crass (1.0.6)
74
+ database_cleaner (2.0.1)
75
+ database_cleaner-active_record (~> 2.0.0)
76
+ database_cleaner-active_record (2.0.0)
77
+ activerecord (>= 5.a)
78
+ database_cleaner-core (~> 2.0.0)
79
+ database_cleaner-core (2.0.1)
80
+ diff-lcs (1.4.4)
81
+ docile (1.3.5)
82
+ erubi (1.10.0)
83
+ factory_bot (5.2.0)
84
+ activesupport (>= 4.2.0)
85
+ faker (2.12.0)
86
+ i18n (>= 1.6, < 2)
87
+ globalid (0.4.2)
81
88
  activesupport (>= 4.2.0)
82
- hirb (0.7.3)
83
- i18n (1.2.0)
89
+ i18n (1.8.10)
84
90
  concurrent-ruby (~> 1.0)
85
- jaro_winkler (1.5.1)
86
- json (2.1.0)
87
- loofah (2.2.3)
91
+ loofah (2.9.1)
88
92
  crass (~> 1.0.2)
89
93
  nokogiri (>= 1.5.9)
90
94
  mail (2.7.1)
91
95
  mini_mime (>= 0.1.1)
92
- method_source (0.9.2)
93
- mini_mime (1.0.1)
96
+ marcel (1.0.1)
97
+ method_source (1.0.0)
98
+ mini_mime (1.1.0)
94
99
  mini_portile2 (2.4.0)
95
- minitest (5.11.3)
96
- nio4r (2.3.1)
97
- nokogiri (1.9.0)
100
+ minitest (5.14.4)
101
+ nio4r (2.5.7)
102
+ nokogiri (1.10.10)
98
103
  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)
104
+ parallel (1.20.1)
105
+ parser (3.0.1.0)
106
+ ast (~> 2.4.1)
107
+ public_suffix (4.0.6)
108
+ rack (2.2.3)
105
109
  rack-test (1.1.0)
106
110
  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)
111
+ rails (5.2.5)
112
+ actioncable (= 5.2.5)
113
+ actionmailer (= 5.2.5)
114
+ actionpack (= 5.2.5)
115
+ actionview (= 5.2.5)
116
+ activejob (= 5.2.5)
117
+ activemodel (= 5.2.5)
118
+ activerecord (= 5.2.5)
119
+ activestorage (= 5.2.5)
120
+ activesupport (= 5.2.5)
116
121
  bundler (>= 1.3.0)
117
- railties (= 5.1.6.1)
122
+ railties (= 5.2.5)
118
123
  sprockets-rails (>= 2.0.0)
119
124
  rails-dom-testing (2.0.3)
120
125
  activesupport (>= 4.2.0)
121
126
  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
+ rails-html-sanitizer (1.3.0)
128
+ loofah (~> 2.3)
129
+ railties (5.2.5)
130
+ actionpack (= 5.2.5)
131
+ activesupport (= 5.2.5)
127
132
  method_source
128
133
  rake (>= 0.8.7)
129
- thor (>= 0.18.1, < 2.0)
134
+ thor (>= 0.19.0, < 2.0)
130
135
  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
+ rake (13.0.3)
137
+ ransack (2.4.1)
138
+ activerecord (>= 5.2.4)
139
+ activesupport (>= 5.2.4)
136
140
  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)
141
+ regexp_parser (1.8.2)
142
+ rexml (3.2.5)
143
+ rspec (3.10.0)
144
+ rspec-core (~> 3.10.0)
145
+ rspec-expectations (~> 3.10.0)
146
+ rspec-mocks (~> 3.10.0)
147
+ rspec-core (3.10.1)
148
+ rspec-support (~> 3.10.0)
149
+ rspec-expectations (3.10.1)
145
150
  diff-lcs (>= 1.2.0, < 2.0)
146
- rspec-support (~> 3.8.0)
147
- rspec-mocks (3.8.0)
151
+ rspec-support (~> 3.10.0)
152
+ rspec-mocks (3.10.2)
148
153
  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)
154
+ rspec-support (~> 3.10.0)
155
+ rspec-rails (5.0.1)
156
+ actionpack (>= 5.2)
157
+ activesupport (>= 5.2)
158
+ railties (>= 5.2)
159
+ rspec-core (~> 3.10)
160
+ rspec-expectations (~> 3.10)
161
+ rspec-mocks (~> 3.10)
162
+ rspec-support (~> 3.10)
163
+ rspec-support (3.10.2)
164
+ rubocop (1.12.1)
161
165
  parallel (~> 1.10)
162
- parser (>= 2.5, != 2.5.1.1)
163
- powerpack (~> 0.1)
166
+ parser (>= 3.0.0.0)
164
167
  rainbow (>= 2.2.2, < 4.0)
168
+ regexp_parser (>= 1.8, < 3.0)
169
+ rexml
170
+ rubocop-ast (>= 1.2.0, < 2.0)
165
171
  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)
172
+ unicode-display_width (>= 1.4.0, < 3.0)
173
+ rubocop-ast (1.4.1)
174
+ parser (>= 2.7.1.5)
175
+ ruby-progressbar (1.11.0)
176
+ simplecov (0.18.5)
177
+ docile (~> 1.1)
178
+ simplecov-html (~> 0.11)
179
+ simplecov-console (0.9.1)
173
180
  ansi
174
- hirb
175
181
  simplecov
176
- simplecov-html (0.10.2)
182
+ terminal-table
183
+ simplecov-html (0.12.3)
177
184
  sprockets (3.7.2)
178
185
  concurrent-ruby (~> 1.0)
179
186
  rack (> 1, < 3)
180
- sprockets-rails (3.2.1)
187
+ sprockets-rails (3.2.2)
181
188
  actionpack (>= 4.0)
182
189
  activesupport (>= 4.0)
183
190
  sprockets (>= 3.0.0)
184
- sqlite3 (1.3.13)
185
- thor (0.20.3)
191
+ sqlite3 (1.4.2)
192
+ terminal-table (3.0.0)
193
+ unicode-display_width (~> 1.1, >= 1.1.1)
194
+ thor (1.1.0)
186
195
  thread_safe (0.3.6)
187
- tzinfo (1.2.5)
196
+ tzinfo (1.2.9)
188
197
  thread_safe (~> 0.1)
189
- unicode-display_width (1.4.0)
190
- url (0.3.2)
191
- websocket-driver (0.6.5)
198
+ unicode-display_width (1.7.0)
199
+ websocket-driver (0.7.3)
192
200
  websocket-extensions (>= 0.1.0)
193
- websocket-extensions (0.1.3)
201
+ websocket-extensions (0.1.5)
194
202
  xpath (3.2.0)
195
203
  nokogiri (~> 1.8)
196
204
 
@@ -208,7 +216,7 @@ DEPENDENCIES
208
216
  database_cleaner
209
217
  factory_bot
210
218
  faker
211
- rails (~> 5.1.0)
219
+ rails (~> 5.2.0)
212
220
  rake
213
221
  ransack
214
222
  rspec
@@ -219,4 +227,4 @@ DEPENDENCIES
219
227
  sqlite3
220
228
 
221
229
  BUNDLED WITH
222
- 2.0.1
230
+ 2.1.4