miscellany 0.1.31 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/miscellany/active_record/arbitrary_prefetch.rb +66 -4
- data/lib/miscellany/active_record/complex_query.rb +15 -6
- data/lib/miscellany/batching_csv_processor.rb +4 -2
- data/lib/miscellany/controller/http_error_handling.rb +4 -2
- data/lib/miscellany/controller/sliced_response.rb +14 -5
- data/lib/miscellany/local_lru_cache.rb +5 -6
- data/lib/miscellany/param_validator.rb +41 -8
- data/lib/miscellany/sort_lang.rb +4 -2
- data/lib/miscellany/version.rb +1 -1
- data/lib/miscellany.rb +9 -1
- data/miscellany.gemspec +3 -1
- data/spec/miscellany/arbitrary_prefetch_spec.rb +51 -0
- data/spec/miscellany/batch_matcher_spec.rb +130 -0
- data/spec/miscellany/batch_processor_spec.rb +75 -0
- data/spec/miscellany/batched_destruction_spec.rb +66 -0
- data/spec/miscellany/batching_csv_processor_spec.rb +138 -0
- data/spec/miscellany/complex_query_spec.rb +220 -0
- data/spec/miscellany/computed_columns_spec.rb +2 -1
- data/spec/miscellany/custom_preloaders_spec.rb +63 -0
- data/spec/miscellany/http_error_handling_spec.rb +137 -0
- data/spec/miscellany/jbuilder_partial_block_spec.rb +41 -0
- data/spec/miscellany/json_uploads_spec.rb +54 -0
- data/spec/miscellany/local_lru_cache_spec.rb +132 -0
- data/spec/miscellany/param_validator_spec.rb +97 -0
- data/spec/miscellany/require_spec.rb +34 -0
- data/spec/miscellany/sliced_response_spec.rb +31 -2
- data/spec/miscellany/sort_lang_spec.rb +33 -0
- metadata +48 -13
- data/config/initializers/cancancan.rb +0 -34
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: miscellany
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ethan Knapp
|
|
@@ -30,13 +30,13 @@ dependencies:
|
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: '9.0'
|
|
32
32
|
- !ruby/object:Gem::Dependency
|
|
33
|
-
name:
|
|
33
|
+
name: csv
|
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
|
35
35
|
requirements:
|
|
36
36
|
- - ">="
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
38
|
version: '0'
|
|
39
|
-
type: :
|
|
39
|
+
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
@@ -44,47 +44,61 @@ dependencies:
|
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
45
|
version: '0'
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
|
-
name:
|
|
47
|
+
name: rake
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
49
49
|
requirements:
|
|
50
50
|
- - ">="
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '
|
|
52
|
+
version: '0'
|
|
53
53
|
type: :development
|
|
54
54
|
prerelease: false
|
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
57
|
- - ">="
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '
|
|
59
|
+
version: '0'
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
|
-
name:
|
|
61
|
+
name: appraisal
|
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
|
64
64
|
- - "~>"
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: '
|
|
66
|
+
version: '2.4'
|
|
67
67
|
type: :development
|
|
68
68
|
prerelease: false
|
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
71
|
- - "~>"
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: '
|
|
73
|
+
version: '2.4'
|
|
74
74
|
- !ruby/object:Gem::Dependency
|
|
75
|
-
name:
|
|
75
|
+
name: database_cleaner
|
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - ">="
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '1.2'
|
|
81
|
+
type: :development
|
|
82
|
+
prerelease: false
|
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '1.2'
|
|
88
|
+
- !ruby/object:Gem::Dependency
|
|
89
|
+
name: rspec
|
|
76
90
|
requirement: !ruby/object:Gem::Requirement
|
|
77
91
|
requirements:
|
|
78
92
|
- - "~>"
|
|
79
93
|
- !ruby/object:Gem::Version
|
|
80
|
-
version: '
|
|
94
|
+
version: '3'
|
|
81
95
|
type: :development
|
|
82
96
|
prerelease: false
|
|
83
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
84
98
|
requirements:
|
|
85
99
|
- - "~>"
|
|
86
100
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '
|
|
101
|
+
version: '3'
|
|
88
102
|
- !ruby/object:Gem::Dependency
|
|
89
103
|
name: with_model
|
|
90
104
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -121,7 +135,6 @@ extra_rdoc_files: []
|
|
|
121
135
|
files:
|
|
122
136
|
- README.md
|
|
123
137
|
- app/views/miscellany/_slice.json.jbuilder
|
|
124
|
-
- config/initializers/cancancan.rb
|
|
125
138
|
- lib/miscellany.rb
|
|
126
139
|
- lib/miscellany/active_record/arbitrary_prefetch.rb
|
|
127
140
|
- lib/miscellany/active_record/batch_matcher.rb
|
|
@@ -143,9 +156,20 @@ files:
|
|
|
143
156
|
- miscellany.gemspec
|
|
144
157
|
- spec/db/database.yml
|
|
145
158
|
- spec/miscellany/arbitrary_prefetch_spec.rb
|
|
159
|
+
- spec/miscellany/batch_matcher_spec.rb
|
|
160
|
+
- spec/miscellany/batch_processor_spec.rb
|
|
161
|
+
- spec/miscellany/batched_destruction_spec.rb
|
|
162
|
+
- spec/miscellany/batching_csv_processor_spec.rb
|
|
163
|
+
- spec/miscellany/complex_query_spec.rb
|
|
146
164
|
- spec/miscellany/computed_columns_spec.rb
|
|
165
|
+
- spec/miscellany/custom_preloaders_spec.rb
|
|
147
166
|
- spec/miscellany/goldiload_value_spec.rb
|
|
167
|
+
- spec/miscellany/http_error_handling_spec.rb
|
|
168
|
+
- spec/miscellany/jbuilder_partial_block_spec.rb
|
|
169
|
+
- spec/miscellany/json_uploads_spec.rb
|
|
170
|
+
- spec/miscellany/local_lru_cache_spec.rb
|
|
148
171
|
- spec/miscellany/param_validator_spec.rb
|
|
172
|
+
- spec/miscellany/require_spec.rb
|
|
149
173
|
- spec/miscellany/sliced_response_spec.rb
|
|
150
174
|
- spec/miscellany/sort_lang_spec.rb
|
|
151
175
|
- spec/spec_helper.rb
|
|
@@ -172,9 +196,20 @@ summary: Gem for a bunch of random, re-usable Rails Concerns & Helpers
|
|
|
172
196
|
test_files:
|
|
173
197
|
- spec/db/database.yml
|
|
174
198
|
- spec/miscellany/arbitrary_prefetch_spec.rb
|
|
199
|
+
- spec/miscellany/batch_matcher_spec.rb
|
|
200
|
+
- spec/miscellany/batch_processor_spec.rb
|
|
201
|
+
- spec/miscellany/batched_destruction_spec.rb
|
|
202
|
+
- spec/miscellany/batching_csv_processor_spec.rb
|
|
203
|
+
- spec/miscellany/complex_query_spec.rb
|
|
175
204
|
- spec/miscellany/computed_columns_spec.rb
|
|
205
|
+
- spec/miscellany/custom_preloaders_spec.rb
|
|
176
206
|
- spec/miscellany/goldiload_value_spec.rb
|
|
207
|
+
- spec/miscellany/http_error_handling_spec.rb
|
|
208
|
+
- spec/miscellany/jbuilder_partial_block_spec.rb
|
|
209
|
+
- spec/miscellany/json_uploads_spec.rb
|
|
210
|
+
- spec/miscellany/local_lru_cache_spec.rb
|
|
177
211
|
- spec/miscellany/param_validator_spec.rb
|
|
212
|
+
- spec/miscellany/require_spec.rb
|
|
178
213
|
- spec/miscellany/sliced_response_spec.rb
|
|
179
214
|
- spec/miscellany/sort_lang_spec.rb
|
|
180
215
|
- spec/spec_helper.rb
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# This patch fixes an issue where CanCanCan wasn't properly handling
|
|
2
|
-
# existence checks for AR Scopes - instead of do a DB Query, it loaded the entire relation
|
|
3
|
-
module CanCan
|
|
4
|
-
module ConditionsMatcher
|
|
5
|
-
def condition_match?(attribute, value)
|
|
6
|
-
case value
|
|
7
|
-
when Hash
|
|
8
|
-
hash_condition_match?(attribute, value)
|
|
9
|
-
when Range
|
|
10
|
-
value.cover?(attribute)
|
|
11
|
-
when ActiveRecord::Relation
|
|
12
|
-
ar_condition_match?(attribute, value)
|
|
13
|
-
when Enumerable
|
|
14
|
-
value.include?(attribute)
|
|
15
|
-
else
|
|
16
|
-
attribute == value
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def ar_condition_match?(attribute, value)
|
|
21
|
-
return false if attribute.nil?
|
|
22
|
-
|
|
23
|
-
if attribute.is_a?(Array) || (defined?(ActiveRecord) && attribute.is_a?(ActiveRecord::Relation) && attribute.loaded?)
|
|
24
|
-
value.where(id: attribute.pluck(:id)).exists?
|
|
25
|
-
elsif (defined?(ActiveRecord) && attribute.is_a?(ActiveRecord::Relation))
|
|
26
|
-
value.where(id: attribute.select(:id)).exists?
|
|
27
|
-
elsif (defined?(ActiveRecord) && attribute.is_a?(ActiveRecord::Base))
|
|
28
|
-
value.where(id: attribute.id).exists?
|
|
29
|
-
else
|
|
30
|
-
value.where(id: attribute).exists?
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|