acts-as-taggable-array-on 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -9
- data/acts-as-taggable-array-on.gemspec +1 -1
- data/gemfiles/rails_5.gemfile +1 -1
- data/lib/acts-as-taggable-array-on/parser.rb +2 -0
- data/lib/acts-as-taggable-array-on/taggable.rb +9 -4
- data/lib/acts-as-taggable-array-on/version.rb +1 -1
- data/spec/acts_as_tag_pgarray/taggable_spec.rb +11 -3
- data/spec/spec_helper.rb +1 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a9425d37517e5fe36a4248c6dc73d7b07f624ed
|
4
|
+
data.tar.gz: 7dfb8aba8ed94a45b021a386022e4817f06c015b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ced512be1adc28265254dab4f10950f3c14d537efd63d686b87c4a4282c427116ad7cc0666214a6b4dc1cd2e4ad716aaaec08ae459b351bd7736f3c7d7f2d524
|
7
|
+
data.tar.gz: 48fe26c163b62f53f243e053d677c1fe19a1cb9dfa3b434fa5fe78cfc3be6ae9be86b55afbbf72cd3c8c3e75f5af0933290366dde2f4ec9409d08a3c3f85563b
|
data/.travis.yml
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.3
|
3
|
+
- 2.1.10
|
4
|
+
- 2.2.9
|
5
|
+
- 2.3.6
|
6
|
+
- 2.4.3
|
7
|
+
- 2.4.3
|
8
|
+
- 2.5.0
|
7
9
|
addons:
|
8
10
|
postgresql: 9.3
|
9
11
|
gemfile:
|
@@ -17,9 +19,5 @@ script:
|
|
17
19
|
- bundle exec rspec
|
18
20
|
matrix:
|
19
21
|
exclude:
|
20
|
-
- rvm: 2.
|
21
|
-
gemfile: gemfiles/rails_5.gemfile
|
22
|
-
- rvm: 2.1.1
|
23
|
-
gemfile: gemfiles/rails_5.gemfile
|
24
|
-
- rvm: 2.1.2
|
22
|
+
- rvm: 2.1.10
|
25
23
|
gemfile: gemfiles/rails_5.gemfile
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency 'activerecord', ['>= 4']
|
22
22
|
spec.add_runtime_dependency 'activesupport', ['>= 4']
|
23
23
|
|
24
|
-
spec.add_development_dependency 'pg'
|
24
|
+
spec.add_development_dependency 'pg', '~> 0.18'
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.5"
|
27
27
|
spec.add_development_dependency "rake"
|
data/gemfiles/rails_5.gemfile
CHANGED
@@ -1,18 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActsAsTaggableArrayOn
|
2
4
|
module Taggable
|
3
5
|
def self.included(base)
|
4
6
|
base.extend(ClassMethod)
|
5
7
|
end
|
6
8
|
|
9
|
+
TYPE_MATCHER = { string: 'varchar', text: 'text' }
|
10
|
+
|
7
11
|
module ClassMethod
|
8
12
|
def acts_as_taggable_array_on(*tag_def)
|
9
13
|
tag_name = tag_def.first
|
14
|
+
tag_array_type = TYPE_MATCHER[columns_hash[tag_name.to_s].type]
|
10
15
|
parser = ActsAsTaggableArrayOn.parser
|
11
16
|
|
12
|
-
scope :"with_any_#{tag_name}", ->(tags){ where("#{tag_name} && ARRAY[?]
|
13
|
-
scope :"with_all_#{tag_name}", ->(tags){ where("#{tag_name} @> ARRAY[?]
|
14
|
-
scope :"without_any_#{tag_name}", ->(tags){ where.not("#{tag_name} && ARRAY[?]
|
15
|
-
scope :"without_all_#{tag_name}", ->(tags){ where.not("#{tag_name} @> ARRAY[?]
|
17
|
+
scope :"with_any_#{tag_name}", ->(tags){ where("#{tag_name} && ARRAY[?]::#{tag_array_type}[]", parser.parse(tags)) }
|
18
|
+
scope :"with_all_#{tag_name}", ->(tags){ where("#{tag_name} @> ARRAY[?]::#{tag_array_type}[]", parser.parse(tags)) }
|
19
|
+
scope :"without_any_#{tag_name}", ->(tags){ where.not("#{tag_name} && ARRAY[?]::#{tag_array_type}[]", parser.parse(tags)) }
|
20
|
+
scope :"without_all_#{tag_name}", ->(tags){ where.not("#{tag_name} @> ARRAY[?]::#{tag_array_type}[]", parser.parse(tags)) }
|
16
21
|
|
17
22
|
self.class.class_eval do
|
18
23
|
define_method :"all_#{tag_name}" do |options = {}, &block|
|
@@ -2,11 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActsAsTaggableArrayOn::Taggable do
|
4
4
|
before do
|
5
|
-
@user1 = User.create name: 'Tom', colors: ['red', 'blue']
|
6
|
-
@user2 = User.create name: 'Ken', colors: ['black', 'white', 'red']
|
7
|
-
@user3 = User.create name: 'Joe', colors: ['black', 'blue']
|
5
|
+
@user1 = User.create name: 'Tom', colors: ['red', 'blue'], sizes: ['medium', 'large']
|
6
|
+
@user2 = User.create name: 'Ken', colors: ['black', 'white', 'red'], sizes: ['small', 'large']
|
7
|
+
@user3 = User.create name: 'Joe', colors: ['black', 'blue'], sizes: ['small', 'medium', 'large']
|
8
8
|
|
9
9
|
User.acts_as_taggable_array_on :colors
|
10
|
+
User.acts_as_taggable_array_on :sizes
|
10
11
|
end
|
11
12
|
|
12
13
|
describe "#acts_as_taggable_array_on" do
|
@@ -24,6 +25,13 @@ describe ActsAsTaggableArrayOn::Taggable do
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
it "should work with ::text typed array" do
|
29
|
+
expect(User.with_any_sizes(['small'])).to match_array([@user2,@user3])
|
30
|
+
expect(User.with_all_sizes(['small', 'large'])).to match_array([@user2,@user3])
|
31
|
+
expect(User.without_any_sizes('medium')).to match_array([@user2])
|
32
|
+
expect(User.without_all_sizes('medium')).to match_array([@user2])
|
33
|
+
end
|
34
|
+
|
27
35
|
describe "#with_any_tags" do
|
28
36
|
it "returns users having any tags of args" do
|
29
37
|
expect(User.with_any_colors(['red', 'blue'])).to match_array([@user1,@user2,@user3])
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-taggable-array-on
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takuya Miyamoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: pg
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '0.18'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '0.18'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
169
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.6.14
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Simple tagging gem for Rails using postgres array.
|