collate 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/circle.yml +2 -2
- data/collate.gemspec +10 -9
- data/lib/collate.rb +1 -0
- data/lib/collate/active_record_extension.rb +25 -2
- data/lib/collate/database.rb +5 -0
- data/lib/collate/filter.rb +14 -4
- data/lib/collate/version.rb +1 -1
- metadata +41 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd74069c85dcc3b7256daf1ce1494763cf549b80
|
4
|
+
data.tar.gz: 78720066818348405fb2f321e9c4b28c28a06473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 103708f1a0080664d45f75b3f1d3abad5aaed36eea0c74a48f53639424ca550999e7966b689d4863401c534a55176b639b31d5aa7ddc8ef635ee58ed6b6b6e35
|
7
|
+
data.tar.gz: 0f13c2ba71fc696271588d760f2a9660477a98c25ff12e6cb45821f87640057b0d00e791139f20cef2374952e17b1ff607db544ec31f4b2bb8ad7ca0490695ab
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.1
|
data/circle.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
dependencies:
|
2
2
|
override:
|
3
|
-
- rvm --default use ruby-2.
|
3
|
+
- rvm --default use ruby-2.4.1
|
4
4
|
- gem install bundler
|
5
5
|
- bundle
|
6
6
|
cache_directories:
|
7
|
-
- "/opt/circleci/.rvm/gems/ruby-2.
|
7
|
+
- "/opt/circleci/.rvm/gems/ruby-2.4.1"
|
8
8
|
|
9
9
|
database:
|
10
10
|
override:
|
data/collate.gemspec
CHANGED
@@ -28,15 +28,16 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.add_development_dependency "bundler",
|
32
|
-
spec.add_development_dependency "rake",
|
33
|
-
spec.add_development_dependency "rails",
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.14.6"
|
32
|
+
spec.add_development_dependency "rake", "~> 12.0.0"
|
33
|
+
spec.add_development_dependency "rails", "~> 5.0.2"
|
34
34
|
spec.add_development_dependency "single_test"
|
35
35
|
spec.add_development_dependency "rails-controller-testing"
|
36
|
-
spec.add_development_dependency "
|
37
|
-
spec.add_development_dependency "
|
38
|
-
spec.add_development_dependency "
|
39
|
-
spec.add_development_dependency "
|
40
|
-
spec.add_development_dependency "
|
41
|
-
spec.add_development_dependency "
|
36
|
+
spec.add_development_dependency "mysql2", "~> 0.4.5"
|
37
|
+
spec.add_development_dependency "pg", "~> 0.20.0"
|
38
|
+
spec.add_development_dependency "minitest", "~> 5.10.1", "< 5.10.2"
|
39
|
+
spec.add_development_dependency "pry-rescue", "~> 1.4.5"
|
40
|
+
spec.add_development_dependency "simplecov", "~> 0.14.1"
|
41
|
+
spec.add_development_dependency "coveralls", "~> 0.8.20"
|
42
|
+
spec.add_development_dependency "haml", "~> 4.0.7"
|
42
43
|
end
|
data/lib/collate.rb
CHANGED
@@ -13,9 +13,17 @@ module Collate
|
|
13
13
|
def collate_on field, opts={}
|
14
14
|
initialize_collate
|
15
15
|
|
16
|
+
new_filter = Collate::Filter.new(field, opts.merge({base_model_table_name: self.table_name}))
|
17
|
+
|
16
18
|
self.collate_filters[self.default_group] ||= {filters: []}.merge(self.group_options)
|
19
|
+
self.collate_filters[self.default_group][:filters] << new_filter
|
20
|
+
|
21
|
+
if self.default_field_group
|
22
|
+
self.collate_field_groups[self.default_group] ||= {filter_groups: {}}.merge(self.group_options)
|
17
23
|
|
18
|
-
|
24
|
+
self.collate_field_groups[self.default_group][:filter_groups][self.default_field_group] ||= {filters: {}}.merge(self.field_group_options)
|
25
|
+
self.collate_field_groups[self.default_group][:filter_groups][self.default_field_group][:filters][new_filter.field_group_type] = new_filter
|
26
|
+
end
|
19
27
|
end
|
20
28
|
|
21
29
|
def collate_group name, **opts, &blk
|
@@ -27,6 +35,18 @@ module Collate
|
|
27
35
|
blk.call
|
28
36
|
end
|
29
37
|
|
38
|
+
def collate_filter_group group_name, **opts, &blk
|
39
|
+
initialize_collate
|
40
|
+
|
41
|
+
opts[:label] ||= group_name.to_s.titleize
|
42
|
+
self.field_group_options = opts
|
43
|
+
self.default_field_group = group_name
|
44
|
+
|
45
|
+
blk.call
|
46
|
+
|
47
|
+
self.default_field_group = nil
|
48
|
+
end
|
49
|
+
|
30
50
|
def collate params
|
31
51
|
initialize_collate
|
32
52
|
|
@@ -62,13 +82,16 @@ module Collate
|
|
62
82
|
def initialize_collate
|
63
83
|
if !self.respond_to? :collate_filters
|
64
84
|
class << self
|
65
|
-
attr_accessor :collate_filters, :collate_sorters, :default_group,
|
85
|
+
attr_accessor :collate_filters, :collate_sorters, :default_group,
|
86
|
+
:group_options, :default_field_group, :collate_field_groups,
|
87
|
+
:field_group_options
|
66
88
|
end
|
67
89
|
|
68
90
|
self.collate_filters ||= {}
|
69
91
|
self.collate_sorters ||= []
|
70
92
|
self.default_group ||= :main
|
71
93
|
self.group_options ||= {}
|
94
|
+
self.collate_field_groups ||= {}
|
72
95
|
end
|
73
96
|
end
|
74
97
|
|
data/lib/collate/filter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Collate
|
2
2
|
class Filter
|
3
|
-
OPERATORS = [:eq, :ilike, :in, :le, :ge, :null, :contains, :present?,
|
3
|
+
OPERATORS = [:eq, :ilike, :in, :le, :ge, :null, :contains, :present?, :&, :like]
|
4
4
|
|
5
5
|
FIELD_TRANSFORMATIONS = [:date_difference, :date_part, :array_agg, :downcase, :split, :array_length]
|
6
6
|
AGGREGATE_TRANSFORMATIONS = [:array_agg]
|
@@ -8,7 +8,7 @@ module Collate
|
|
8
8
|
|
9
9
|
attr_accessor :field, :operator, :base_model_table_name, :field_transformations, :label,
|
10
10
|
:component, :joins, :value_transformations, :grouping, :html_id, :having,
|
11
|
-
:joins_prefix, :not, :or
|
11
|
+
:joins_prefix, :not, :or, :field_group_type
|
12
12
|
|
13
13
|
def initialize(field, opt={})
|
14
14
|
opt.each do |f, value|
|
@@ -27,8 +27,8 @@ module Collate
|
|
27
27
|
:eq
|
28
28
|
end
|
29
29
|
self.field = "#{base_model_table_name}.#{field}" if field.is_a? Symbol
|
30
|
-
self.field_transformations ||=
|
31
|
-
self.value_transformations ||=
|
30
|
+
self.field_transformations ||= []
|
31
|
+
self.value_transformations ||= []
|
32
32
|
|
33
33
|
self.html_id ||= param_key.gsub('{','').gsub('}','').gsub('.','_')
|
34
34
|
|
@@ -97,6 +97,16 @@ module Collate
|
|
97
97
|
elsif component[:tags]
|
98
98
|
self.component[:values] = []
|
99
99
|
end
|
100
|
+
|
101
|
+
## MySQL support
|
102
|
+
if Collate::database_type == :mysql2
|
103
|
+
# Translate all ILIKE operators to LIKE operators while downcasing values
|
104
|
+
if self.operator == :ilike
|
105
|
+
self.operator = :like
|
106
|
+
self.field_transformations << [:downcase]
|
107
|
+
self.value_transformations << [:downcase]
|
108
|
+
end
|
109
|
+
end
|
100
110
|
end
|
101
111
|
|
102
112
|
def param_key
|
data/lib/collate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Page
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -17,42 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 1.14.6
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 1.14.6
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 12.0.0
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 12.0.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rails
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 5.0.
|
48
|
+
version: 5.0.2
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 5.0.
|
55
|
+
version: 5.0.2
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: single_test
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,90 +81,101 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: mysql2
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.4.5
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.4.5
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: pg
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
102
|
- - "~>"
|
89
103
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
104
|
+
version: 0.20.0
|
91
105
|
type: :development
|
92
106
|
prerelease: false
|
93
107
|
version_requirements: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
109
|
- - "~>"
|
96
110
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
111
|
+
version: 0.20.0
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: minitest
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
101
115
|
requirements:
|
102
116
|
- - "~>"
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
118
|
+
version: 5.10.1
|
119
|
+
- - "<"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 5.10.2
|
105
122
|
type: :development
|
106
123
|
prerelease: false
|
107
124
|
version_requirements: !ruby/object:Gem::Requirement
|
108
125
|
requirements:
|
109
126
|
- - "~>"
|
110
127
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
128
|
+
version: 5.10.1
|
129
|
+
- - "<"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 5.10.2
|
112
132
|
- !ruby/object:Gem::Dependency
|
113
133
|
name: pry-rescue
|
114
134
|
requirement: !ruby/object:Gem::Requirement
|
115
135
|
requirements:
|
116
136
|
- - "~>"
|
117
137
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
119
|
-
- - ">="
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
version: 1.4.2
|
138
|
+
version: 1.4.5
|
122
139
|
type: :development
|
123
140
|
prerelease: false
|
124
141
|
version_requirements: !ruby/object:Gem::Requirement
|
125
142
|
requirements:
|
126
143
|
- - "~>"
|
127
144
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.4.2
|
145
|
+
version: 1.4.5
|
132
146
|
- !ruby/object:Gem::Dependency
|
133
147
|
name: simplecov
|
134
148
|
requirement: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
152
|
+
version: 0.14.1
|
139
153
|
type: :development
|
140
154
|
prerelease: false
|
141
155
|
version_requirements: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
157
|
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
159
|
+
version: 0.14.1
|
146
160
|
- !ruby/object:Gem::Dependency
|
147
161
|
name: coveralls
|
148
162
|
requirement: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
164
|
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.8.
|
166
|
+
version: 0.8.20
|
153
167
|
type: :development
|
154
168
|
prerelease: false
|
155
169
|
version_requirements: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - "~>"
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.8.
|
173
|
+
version: 0.8.20
|
160
174
|
- !ruby/object:Gem::Dependency
|
161
175
|
name: haml
|
162
176
|
requirement: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
178
|
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '4.0'
|
167
|
-
- - ">="
|
168
179
|
- !ruby/object:Gem::Version
|
169
180
|
version: 4.0.7
|
170
181
|
type: :development
|
@@ -172,9 +183,6 @@ dependencies:
|
|
172
183
|
version_requirements: !ruby/object:Gem::Requirement
|
173
184
|
requirements:
|
174
185
|
- - "~>"
|
175
|
-
- !ruby/object:Gem::Version
|
176
|
-
version: '4.0'
|
177
|
-
- - ">="
|
178
186
|
- !ruby/object:Gem::Version
|
179
187
|
version: 4.0.7
|
180
188
|
description: Add some DSL to your model, then run a single method in your controller,
|
@@ -187,6 +195,7 @@ extensions: []
|
|
187
195
|
extra_rdoc_files: []
|
188
196
|
files:
|
189
197
|
- ".gitignore"
|
198
|
+
- ".ruby-version"
|
190
199
|
- Gemfile
|
191
200
|
- LICENSE.txt
|
192
201
|
- README.md
|
@@ -203,6 +212,7 @@ files:
|
|
203
212
|
- lib/collate.rb
|
204
213
|
- lib/collate/action_view_extension.rb
|
205
214
|
- lib/collate/active_record_extension.rb
|
215
|
+
- lib/collate/database.rb
|
206
216
|
- lib/collate/engine.rb
|
207
217
|
- lib/collate/filter.rb
|
208
218
|
- lib/collate/sorter.rb
|
@@ -228,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
238
|
version: '0'
|
229
239
|
requirements: []
|
230
240
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.
|
241
|
+
rubygems_version: 2.6.11
|
232
242
|
signing_key:
|
233
243
|
specification_version: 4
|
234
244
|
summary: Facilitates the filtering of ActiveRecord models using simplified DSL.
|