metka 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -0
- data/.travis.yml +2 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +118 -105
- data/gemfiles/rails52.gemfile +1 -1
- data/gemfiles/rails6.gemfile +2 -2
- data/gemfiles/rails61.gemfile +6 -0
- data/lib/metka/generic_parser.rb +2 -2
- data/lib/metka/model.rb +5 -5
- data/lib/metka/query_builder.rb +7 -5
- data/lib/metka/query_builder/base_query.rb +1 -0
- data/lib/metka/version.rb +1 -1
- metadata +5 -4
- data/gemfiles/rails5.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ea5e1ca3ea95cdb4f0beb2704afc1d92986b0a7c38aa49a70e794b2653c5764
|
4
|
+
data.tar.gz: e9994da8c7db21d1d079c5464d2ffae2bf06ee742f2a664df505f144b1d995be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c8da36cf3bec90c63888d24ac7d09dbec00219ca547df88289b3f858c25eb7f6a0ca729ee46021bfe47f7086a0cb7209a309ae95d8a88bb1b696acd0e772901
|
7
|
+
data.tar.gz: 4f7791a9be469c60ed1505d9f037653eccb0e81c1dcb18954c90daca440264eb9c0ca57067770c4d7222a86b2fca1c6a0ae1ad977becaad7d92ecda5ebf4513a
|
data/.rubocop.yml
CHANGED
@@ -19,7 +19,7 @@ Style/TrailingCommaInArrayLiteral:
|
|
19
19
|
Style/TrailingCommaInHashLiteral:
|
20
20
|
EnforcedStyleForMultiline: no_comma
|
21
21
|
|
22
|
-
Layout/
|
22
|
+
Layout/ParameterAlignment:
|
23
23
|
EnforcedStyle: with_first_parameter
|
24
24
|
|
25
25
|
# See https://github.com/rubocop-hq/rubocop/issues/4222
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.2
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,184 +8,197 @@ PATH
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (5.
|
12
|
-
actionpack (
|
11
|
+
actioncable (5.2.4.4)
|
12
|
+
actionpack (= 5.2.4.4)
|
13
13
|
nio4r (~> 2.0)
|
14
|
-
websocket-driver (
|
15
|
-
actionmailer (5.
|
16
|
-
actionpack (
|
17
|
-
actionview (
|
18
|
-
activejob (= 5.
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailer (5.2.4.4)
|
16
|
+
actionpack (= 5.2.4.4)
|
17
|
+
actionview (= 5.2.4.4)
|
18
|
+
activejob (= 5.2.4.4)
|
19
19
|
mail (~> 2.5, >= 2.5.4)
|
20
20
|
rails-dom-testing (~> 2.0)
|
21
|
-
actionpack (
|
22
|
-
actionview (=
|
23
|
-
activesupport (=
|
21
|
+
actionpack (5.2.4.4)
|
22
|
+
actionview (= 5.2.4.4)
|
23
|
+
activesupport (= 5.2.4.4)
|
24
24
|
rack (~> 2.0, >= 2.0.8)
|
25
25
|
rack-test (>= 0.6.3)
|
26
26
|
rails-dom-testing (~> 2.0)
|
27
|
-
rails-html-sanitizer (~> 1.0, >= 1.2
|
28
|
-
actionview (
|
29
|
-
activesupport (=
|
27
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
28
|
+
actionview (5.2.4.4)
|
29
|
+
activesupport (= 5.2.4.4)
|
30
30
|
builder (~> 3.1)
|
31
31
|
erubi (~> 1.4)
|
32
32
|
rails-dom-testing (~> 2.0)
|
33
|
-
rails-html-sanitizer (~> 1.
|
34
|
-
activejob (5.
|
35
|
-
activesupport (
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
34
|
+
activejob (5.2.4.4)
|
35
|
+
activesupport (= 5.2.4.4)
|
36
36
|
globalid (>= 0.3.6)
|
37
|
-
activemodel (5.
|
38
|
-
activesupport (
|
39
|
-
activerecord (5.
|
40
|
-
activemodel (= 5.
|
41
|
-
activesupport (
|
42
|
-
arel (
|
43
|
-
|
37
|
+
activemodel (5.2.4.4)
|
38
|
+
activesupport (= 5.2.4.4)
|
39
|
+
activerecord (5.2.4.4)
|
40
|
+
activemodel (= 5.2.4.4)
|
41
|
+
activesupport (= 5.2.4.4)
|
42
|
+
arel (>= 9.0)
|
43
|
+
activestorage (5.2.4.4)
|
44
|
+
actionpack (= 5.2.4.4)
|
45
|
+
activerecord (= 5.2.4.4)
|
46
|
+
marcel (~> 0.3.1)
|
47
|
+
activesupport (5.2.4.4)
|
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
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
49
52
|
ammeter (1.1.4)
|
50
53
|
activesupport (>= 3.0)
|
51
54
|
railties (>= 3.0)
|
52
55
|
rspec-rails (>= 2.2)
|
53
|
-
arel (
|
54
|
-
ast (2.4.
|
56
|
+
arel (9.0.0)
|
57
|
+
ast (2.4.1)
|
55
58
|
builder (3.2.4)
|
56
|
-
coderay (1.1.
|
59
|
+
coderay (1.1.3)
|
57
60
|
concurrent-ruby (1.1.7)
|
58
61
|
crass (1.0.6)
|
59
|
-
database_cleaner (1.
|
60
|
-
diff-lcs (1.
|
61
|
-
dry-configurable (0.11.
|
62
|
+
database_cleaner (1.8.5)
|
63
|
+
diff-lcs (1.4.4)
|
64
|
+
dry-configurable (0.11.6)
|
62
65
|
concurrent-ruby (~> 1.0)
|
63
66
|
dry-core (~> 0.4, >= 0.4.7)
|
64
67
|
dry-equalizer (~> 0.2)
|
65
|
-
dry-core (0.
|
68
|
+
dry-core (0.5.0)
|
66
69
|
concurrent-ruby (~> 1.0)
|
67
70
|
dry-equalizer (0.3.0)
|
68
|
-
erubi (1.
|
69
|
-
faker (2.
|
70
|
-
i18n (>= 1.6, <
|
71
|
+
erubi (1.10.0)
|
72
|
+
faker (2.15.1)
|
73
|
+
i18n (>= 1.6, < 2)
|
71
74
|
globalid (0.4.2)
|
72
75
|
activesupport (>= 4.2.0)
|
73
|
-
i18n (1.
|
76
|
+
i18n (1.8.5)
|
74
77
|
concurrent-ruby (~> 1.0)
|
75
|
-
|
76
|
-
|
77
|
-
rubocop-
|
78
|
-
|
79
|
-
|
80
|
-
loofah (2.7.0)
|
78
|
+
jetrockets-standard (1.0.7)
|
79
|
+
rubocop-rails (~> 2.8.1)
|
80
|
+
rubocop-rspec (~> 1.43.2)
|
81
|
+
standard (~> 0.6.1)
|
82
|
+
loofah (2.8.0)
|
81
83
|
crass (~> 1.0.2)
|
82
84
|
nokogiri (>= 1.5.9)
|
83
85
|
mail (2.7.1)
|
84
86
|
mini_mime (>= 0.1.1)
|
85
|
-
|
87
|
+
marcel (0.3.3)
|
88
|
+
mimemagic (~> 0.3.2)
|
89
|
+
method_source (1.0.0)
|
90
|
+
mimemagic (0.3.5)
|
86
91
|
mini_mime (1.0.2)
|
87
92
|
mini_portile2 (2.4.0)
|
88
93
|
minitest (5.14.2)
|
89
|
-
nio4r (2.5.
|
94
|
+
nio4r (2.5.4)
|
90
95
|
nokogiri (1.10.10)
|
91
96
|
mini_portile2 (~> 2.4.0)
|
92
|
-
parallel (1.
|
93
|
-
parser (2.
|
94
|
-
ast (~> 2.4.
|
95
|
-
pg (1.
|
96
|
-
pry (0.
|
97
|
-
coderay (~> 1.1
|
98
|
-
method_source (~>
|
97
|
+
parallel (1.20.1)
|
98
|
+
parser (2.7.2.0)
|
99
|
+
ast (~> 2.4.1)
|
100
|
+
pg (1.2.3)
|
101
|
+
pry (0.13.1)
|
102
|
+
coderay (~> 1.1)
|
103
|
+
method_source (~> 1.0)
|
99
104
|
rack (2.2.3)
|
100
105
|
rack-test (1.1.0)
|
101
106
|
rack (>= 1.0, < 3)
|
102
|
-
rails (5.
|
103
|
-
actioncable (= 5.
|
104
|
-
actionmailer (= 5.
|
105
|
-
actionpack (
|
106
|
-
actionview (
|
107
|
-
activejob (= 5.
|
108
|
-
activemodel (= 5.
|
109
|
-
activerecord (= 5.
|
110
|
-
|
107
|
+
rails (5.2.4.4)
|
108
|
+
actioncable (= 5.2.4.4)
|
109
|
+
actionmailer (= 5.2.4.4)
|
110
|
+
actionpack (= 5.2.4.4)
|
111
|
+
actionview (= 5.2.4.4)
|
112
|
+
activejob (= 5.2.4.4)
|
113
|
+
activemodel (= 5.2.4.4)
|
114
|
+
activerecord (= 5.2.4.4)
|
115
|
+
activestorage (= 5.2.4.4)
|
116
|
+
activesupport (= 5.2.4.4)
|
111
117
|
bundler (>= 1.3.0)
|
112
|
-
railties (= 5.
|
118
|
+
railties (= 5.2.4.4)
|
113
119
|
sprockets-rails (>= 2.0.0)
|
114
120
|
rails-dom-testing (2.0.3)
|
115
121
|
activesupport (>= 4.2.0)
|
116
122
|
nokogiri (>= 1.6)
|
117
123
|
rails-html-sanitizer (1.3.0)
|
118
124
|
loofah (~> 2.3)
|
119
|
-
railties (5.
|
120
|
-
actionpack (
|
121
|
-
activesupport (
|
125
|
+
railties (5.2.4.4)
|
126
|
+
actionpack (= 5.2.4.4)
|
127
|
+
activesupport (= 5.2.4.4)
|
122
128
|
method_source
|
123
129
|
rake (>= 0.8.7)
|
124
|
-
thor (>= 0.
|
130
|
+
thor (>= 0.19.0, < 2.0)
|
125
131
|
rainbow (3.0.0)
|
126
|
-
rake (13.0.
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
rspec-
|
131
|
-
|
132
|
-
rspec-
|
133
|
-
rspec-
|
132
|
+
rake (13.0.3)
|
133
|
+
regexp_parser (2.0.1)
|
134
|
+
rexml (3.2.4)
|
135
|
+
rspec (3.10.0)
|
136
|
+
rspec-core (~> 3.10.0)
|
137
|
+
rspec-expectations (~> 3.10.0)
|
138
|
+
rspec-mocks (~> 3.10.0)
|
139
|
+
rspec-core (3.10.0)
|
140
|
+
rspec-support (~> 3.10.0)
|
141
|
+
rspec-expectations (3.10.0)
|
134
142
|
diff-lcs (>= 1.2.0, < 2.0)
|
135
|
-
rspec-support (~> 3.
|
136
|
-
rspec-mocks (3.
|
143
|
+
rspec-support (~> 3.10.0)
|
144
|
+
rspec-mocks (3.10.0)
|
137
145
|
diff-lcs (>= 1.2.0, < 2.0)
|
138
|
-
rspec-support (~> 3.
|
139
|
-
rspec-rails (
|
140
|
-
actionpack (>=
|
141
|
-
activesupport (>=
|
142
|
-
railties (>=
|
143
|
-
rspec-core (~> 3.9
|
144
|
-
rspec-expectations (~> 3.9
|
145
|
-
rspec-mocks (~> 3.9
|
146
|
-
rspec-support (~> 3.9
|
147
|
-
rspec-support (3.
|
148
|
-
rubocop (0.
|
149
|
-
jaro_winkler (~> 1.5.1)
|
146
|
+
rspec-support (~> 3.10.0)
|
147
|
+
rspec-rails (4.0.1)
|
148
|
+
actionpack (>= 4.2)
|
149
|
+
activesupport (>= 4.2)
|
150
|
+
railties (>= 4.2)
|
151
|
+
rspec-core (~> 3.9)
|
152
|
+
rspec-expectations (~> 3.9)
|
153
|
+
rspec-mocks (~> 3.9)
|
154
|
+
rspec-support (~> 3.9)
|
155
|
+
rspec-support (3.10.0)
|
156
|
+
rubocop (0.91.1)
|
150
157
|
parallel (~> 1.10)
|
151
|
-
parser (>= 2.
|
158
|
+
parser (>= 2.7.1.1)
|
152
159
|
rainbow (>= 2.2.2, < 4.0)
|
160
|
+
regexp_parser (>= 1.7)
|
161
|
+
rexml
|
162
|
+
rubocop-ast (>= 0.4.0, < 1.0)
|
153
163
|
ruby-progressbar (~> 1.7)
|
154
|
-
unicode-display_width (>= 1.4.0, <
|
155
|
-
rubocop-
|
156
|
-
|
157
|
-
rubocop-
|
164
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
165
|
+
rubocop-ast (0.8.0)
|
166
|
+
parser (>= 2.7.1.5)
|
167
|
+
rubocop-performance (1.8.1)
|
168
|
+
rubocop (>= 0.87.0)
|
169
|
+
rubocop-ast (>= 0.4.0)
|
170
|
+
rubocop-rails (2.8.1)
|
171
|
+
activesupport (>= 4.2.0)
|
158
172
|
rack (>= 1.1)
|
159
|
-
rubocop (>= 0.
|
160
|
-
rubocop-rspec (1.
|
161
|
-
rubocop (
|
173
|
+
rubocop (>= 0.87.0)
|
174
|
+
rubocop-rspec (1.43.2)
|
175
|
+
rubocop (~> 0.87)
|
162
176
|
ruby-progressbar (1.10.1)
|
163
177
|
sprockets (4.0.2)
|
164
178
|
concurrent-ruby (~> 1.0)
|
165
179
|
rack (> 1, < 3)
|
166
|
-
sprockets-rails (3.2.
|
180
|
+
sprockets-rails (3.2.2)
|
167
181
|
actionpack (>= 4.0)
|
168
182
|
activesupport (>= 4.0)
|
169
183
|
sprockets (>= 3.0.0)
|
170
|
-
standard (0.
|
171
|
-
rubocop (
|
172
|
-
rubocop-performance (
|
173
|
-
thor (0.
|
184
|
+
standard (0.6.2)
|
185
|
+
rubocop (= 0.91.1)
|
186
|
+
rubocop-performance (= 1.8.1)
|
187
|
+
thor (1.0.1)
|
174
188
|
thread_safe (0.3.6)
|
175
|
-
timecop (0.9.
|
176
|
-
tzinfo (1.2.
|
189
|
+
timecop (0.9.2)
|
190
|
+
tzinfo (1.2.9)
|
177
191
|
thread_safe (~> 0.1)
|
178
|
-
unicode-display_width (1.
|
179
|
-
websocket-driver (0.
|
192
|
+
unicode-display_width (1.7.0)
|
193
|
+
websocket-driver (0.7.3)
|
180
194
|
websocket-extensions (>= 0.1.0)
|
181
195
|
websocket-extensions (0.1.5)
|
182
|
-
zeitwerk (2.4.0)
|
183
196
|
|
184
197
|
PLATFORMS
|
185
198
|
ruby
|
186
199
|
|
187
200
|
DEPENDENCIES
|
188
|
-
activerecord (
|
201
|
+
activerecord (>= 5.2.4, < 6.2)
|
189
202
|
ammeter (>= 1.1)
|
190
203
|
bundler (>= 1.3)
|
191
204
|
database_cleaner (>= 1.7)
|
data/gemfiles/rails52.gemfile
CHANGED
data/gemfiles/rails6.gemfile
CHANGED
data/lib/metka/generic_parser.rb
CHANGED
@@ -25,7 +25,7 @@ module Metka
|
|
25
25
|
gsub_quote_pattern!(tag_list, value, double_quote_pattern)
|
26
26
|
gsub_quote_pattern!(tag_list, value, single_quote_pattern)
|
27
27
|
|
28
|
-
tag_list.merge value.split(Regexp.new
|
28
|
+
tag_list.merge value.split(Regexp.new(delimiter)).map(&:strip).reject(&:empty?)
|
29
29
|
when Enumerable
|
30
30
|
tag_list.merge value.reject(&:empty?)
|
31
31
|
end
|
@@ -46,7 +46,7 @@ module Metka
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def single_quote_pattern
|
49
|
-
|
49
|
+
@single_quote_pattern[delimiter] ||= /(\A|#{delimiter})\s*'(.*?)'\s*(?=#{delimiter}\s*|\z)/
|
50
50
|
end
|
51
51
|
|
52
52
|
def double_quote_pattern
|
data/lib/metka/model.rb
CHANGED
@@ -43,10 +43,10 @@ module Metka
|
|
43
43
|
|
44
44
|
base.class_eval do
|
45
45
|
columns.each do |column|
|
46
|
-
scope "with_all_#{column}",
|
47
|
-
scope "with_any_#{column}",
|
48
|
-
scope "without_all_#{column}", ->(tags) { tagged_with(tags, on: [
|
49
|
-
scope "without_any_#{column}", ->(tags) { tagged_with(tags, on: [
|
46
|
+
scope "with_all_#{column}", ->(tags) { tagged_with(tags, on: [column]) }
|
47
|
+
scope "with_any_#{column}", ->(tags) { tagged_with(tags, on: [column], any: true) }
|
48
|
+
scope "without_all_#{column}", ->(tags) { tagged_with(tags, on: [column], exclude: true) }
|
49
|
+
scope "without_any_#{column}", ->(tags) { tagged_with(tags, on: [column], any: true, exclude: true) }
|
50
50
|
end
|
51
51
|
|
52
52
|
unless respond_to?(:tagged_with)
|
@@ -66,7 +66,7 @@ module Metka
|
|
66
66
|
prepared_unnest = columns.map { |column| "#{table_name}.#{column}" }.join(' || ')
|
67
67
|
subquery = all.select("UNNEST(#{prepared_unnest}) AS tag_name")
|
68
68
|
|
69
|
-
unscoped.from(subquery).group(:tag_name).pluck(:tag_name, 'COUNT(*) AS taggings_count')
|
69
|
+
unscoped.from(subquery).group(:tag_name).pluck(:tag_name, Arel.sql('COUNT(*) AS taggings_count'))
|
70
70
|
end
|
71
71
|
|
72
72
|
columns.each do |column|
|
data/lib/metka/query_builder.rb
CHANGED
@@ -10,11 +10,11 @@ module Metka
|
|
10
10
|
def call(model, columns, tags, options)
|
11
11
|
strategy = options_to_strategy(options)
|
12
12
|
|
13
|
-
query = join(options[:join_operator])
|
13
|
+
query = join(options[:join_operator]) {
|
14
14
|
columns.map do |column|
|
15
15
|
build_query(strategy, model, column, tags)
|
16
16
|
end
|
17
|
-
|
17
|
+
}
|
18
18
|
|
19
19
|
if options[:exclude].present?
|
20
20
|
Arel::Nodes::Not.new(query)
|
@@ -43,11 +43,13 @@ module Metka
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
# @param nodes [Array<Arel::Node>, Arel::Node]
|
47
|
-
# @return [Arel::Node]
|
46
|
+
# @param nodes [Array<Arel::Nodes::Node>, Arel::Nodes::Node]
|
47
|
+
# @return [Arel::Nodes::Node]
|
48
48
|
def join_or(nodes)
|
49
|
+
node_base_klass = defined?(::Arel::Nodes::Node) ? ::Arel::Nodes::Node : ::Arel::Node
|
50
|
+
|
49
51
|
case nodes
|
50
|
-
when
|
52
|
+
when node_base_klass
|
51
53
|
nodes
|
52
54
|
when Array
|
53
55
|
l, *r = nodes
|
data/lib/metka/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Alexandrov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-configurable
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- ".gitignore"
|
206
206
|
- ".rspec"
|
207
207
|
- ".rubocop.yml"
|
208
|
+
- ".ruby-version"
|
208
209
|
- ".travis.yml"
|
209
210
|
- CODE_OF_CONDUCT.md
|
210
211
|
- Gemfile
|
@@ -214,9 +215,9 @@ files:
|
|
214
215
|
- Rakefile
|
215
216
|
- bin/console
|
216
217
|
- bin/setup
|
217
|
-
- gemfiles/rails5.gemfile
|
218
218
|
- gemfiles/rails52.gemfile
|
219
219
|
- gemfiles/rails6.gemfile
|
220
|
+
- gemfiles/rails61.gemfile
|
220
221
|
- lib/generators/metka/strategies/materialized_view/materialized_view_generator.rb
|
221
222
|
- lib/generators/metka/strategies/materialized_view/templates/migration.rb.erb
|
222
223
|
- lib/generators/metka/strategies/view/templates/migration.rb.erb
|
@@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
251
|
- !ruby/object:Gem::Version
|
251
252
|
version: '0'
|
252
253
|
requirements: []
|
253
|
-
rubygems_version: 3.
|
254
|
+
rubygems_version: 3.1.4
|
254
255
|
signing_key:
|
255
256
|
specification_version: 4
|
256
257
|
summary: Rails tagging system based on PostgreSQL arrays
|