acts-as-taggable-on 7.0.0 → 9.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/spec.yml +76 -0
- data/Appraisals +13 -13
- data/CHANGELOG.md +27 -2
- data/Gemfile +1 -0
- data/README.md +32 -7
- data/acts-as-taggable-on.gemspec +2 -2
- data/db/migrate/1_acts_as_taggable_on_migration.rb +5 -8
- data/db/migrate/2_add_missing_unique_indices.rb +6 -8
- data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +3 -6
- data/db/migrate/4_add_missing_taggable_index.rb +5 -7
- data/db/migrate/5_change_collation_for_tag_names.rb +4 -6
- data/db/migrate/6_add_missing_indexes_on_taggings.rb +15 -13
- data/db/migrate/7_add_tenant_to_taggings.rb +13 -0
- data/docker-compose.yml +15 -0
- data/gemfiles/activerecord_6.0.gemfile +5 -8
- data/gemfiles/activerecord_6.1.gemfile +3 -8
- data/gemfiles/{activerecord_5.2.gemfile → activerecord_7.0.gemfile} +6 -9
- data/lib/acts_as_taggable_on/default_parser.rb +8 -10
- data/lib/acts_as_taggable_on/engine.rb +2 -0
- data/lib/acts_as_taggable_on/generic_parser.rb +2 -0
- data/lib/acts_as_taggable_on/tag.rb +33 -27
- data/lib/acts_as_taggable_on/tag_list.rb +8 -11
- data/lib/acts_as_taggable_on/taggable/cache.rb +64 -62
- data/lib/acts_as_taggable_on/taggable/collection.rb +178 -142
- data/lib/acts_as_taggable_on/taggable/core.rb +250 -236
- data/lib/acts_as_taggable_on/taggable/ownership.rb +110 -98
- data/lib/acts_as_taggable_on/taggable/related.rb +60 -47
- data/lib/acts_as_taggable_on/taggable/tag_list_type.rb +6 -2
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/all_tags_query.rb +110 -106
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb +57 -53
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/exclude_tags_query.rb +63 -60
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb +54 -46
- data/lib/acts_as_taggable_on/taggable/tagged_with_query.rb +14 -8
- data/lib/acts_as_taggable_on/taggable.rb +30 -12
- data/lib/acts_as_taggable_on/tagger.rb +9 -5
- data/lib/acts_as_taggable_on/tagging.rb +8 -4
- data/lib/acts_as_taggable_on/tags_helper.rb +3 -1
- data/lib/acts_as_taggable_on/utils.rb +4 -2
- data/lib/acts_as_taggable_on/version.rb +3 -1
- data/spec/acts_as_taggable_on/tag_spec.rb +16 -1
- data/spec/acts_as_taggable_on/taggable_spec.rb +6 -2
- data/spec/acts_as_taggable_on/tagging_spec.rb +26 -0
- data/spec/internal/app/models/taggable_model.rb +2 -0
- data/spec/internal/config/database.yml.sample +4 -8
- data/spec/internal/db/schema.rb +3 -0
- data/spec/support/database.rb +36 -26
- metadata +13 -22
- data/.travis.yml +0 -49
- data/UPGRADING.md +0 -8
- data/gemfiles/activerecord_5.0.gemfile +0 -21
- data/gemfiles/activerecord_5.1.gemfile +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8092ec2f51d34ba23b735fbae7cce7a4f68e4ad5900d04903b054e3607667c6b
|
4
|
+
data.tar.gz: 1a813362d4fd80918b68b5b1ffbf2a3ffcad35a3967d77f3f9ef8f71979b4c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2ff8897bea6054e879775a8e50cd9f1e63624b86ec4accdfa488fb43fcff35a5e2d90ea4a4cdb7aa7ea400e00826d5e67b1585549c79d4af950662c86aa28a3
|
7
|
+
data.tar.gz: 05aa619c3f4b174398d20675ebc91fc04ce0ef496d54b402262acaa338a43f5ffc0f62bf69c4d9ccb5f41270b71fdeada04b74c0521a758b013b072a4ac4bafb
|
@@ -0,0 +1,76 @@
|
|
1
|
+
name: spec
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
continue-on-error: ${{ matrix.ruby == 'head' }}
|
9
|
+
env:
|
10
|
+
DB: ${{ matrix.db }}
|
11
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby:
|
15
|
+
- "3.0"
|
16
|
+
- 2.7
|
17
|
+
- 2.6
|
18
|
+
- 2.5
|
19
|
+
gemfile:
|
20
|
+
- gemfiles/activerecord_6.0.gemfile
|
21
|
+
- gemfiles/activerecord_6.1.gemfile
|
22
|
+
- gemfiles/activerecord_7.0.gemfile
|
23
|
+
db:
|
24
|
+
- mysql
|
25
|
+
- postgresql
|
26
|
+
- sqlite3
|
27
|
+
include:
|
28
|
+
- ruby: truffleruby-head
|
29
|
+
db: postgresql
|
30
|
+
gemfile: gemfiles/activerecord_6.1.gemfile
|
31
|
+
- ruby: truffleruby-head
|
32
|
+
db: postgresql
|
33
|
+
gemfile: gemfiles/activerecord_7.0.gemfile
|
34
|
+
exclude:
|
35
|
+
- ruby: 2.5
|
36
|
+
gemfile: gemfiles/activerecord_7.0.gemfile
|
37
|
+
- ruby: 2.6
|
38
|
+
gemfile: gemfiles/activerecord_7.0.gemfile
|
39
|
+
|
40
|
+
services:
|
41
|
+
postgres:
|
42
|
+
image: postgres:10
|
43
|
+
env:
|
44
|
+
POSTGRES_USER: postgres
|
45
|
+
POSTGRES_DB: acts_as_taggable_on
|
46
|
+
POSTGRES_PASSWORD: postgres
|
47
|
+
ports: ['5432:5432']
|
48
|
+
options: >-
|
49
|
+
--health-cmd pg_isready
|
50
|
+
--health-interval 10s
|
51
|
+
--health-timeout 5s
|
52
|
+
--health-retries 5
|
53
|
+
mysql:
|
54
|
+
image: mysql:8
|
55
|
+
env:
|
56
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
57
|
+
ports: ['3306:3306']
|
58
|
+
options: >-
|
59
|
+
--health-cmd "mysqladmin ping"
|
60
|
+
--health-interval 10s
|
61
|
+
--health-timeout 5s
|
62
|
+
--health-retries 5
|
63
|
+
steps:
|
64
|
+
- uses: actions/checkout@v2
|
65
|
+
- name: Set up Ruby
|
66
|
+
uses: ruby/setup-ruby@v1
|
67
|
+
with:
|
68
|
+
ruby-version: ${{ matrix.ruby }}
|
69
|
+
bundler-cache: true
|
70
|
+
- name: Create MySQL test database with utf8mb4 charset
|
71
|
+
if: ${{ matrix.db == 'mysql' }}
|
72
|
+
run: |
|
73
|
+
mysql -uroot --host=127.0.0.1 -e "CREATE DATABASE acts_as_taggable_on CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
|
74
|
+
- name: Build and test with Rake
|
75
|
+
run: |
|
76
|
+
bundle exec rake
|
data/Appraisals
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
|
2
|
-
gem 'activerecord', '~> 5.2.0'
|
3
|
-
end
|
4
|
-
|
5
|
-
appraise 'activerecord-5.1' do
|
6
|
-
gem 'activerecord', "~> 5.1.1"
|
7
|
-
end
|
8
|
-
|
9
|
-
appraise 'activerecord-5.0' do
|
10
|
-
gem 'activerecord', "~> 5.0.3"
|
11
|
-
end
|
1
|
+
# frozen_string_literal: true
|
12
2
|
|
13
3
|
appraise 'activerecord-6.0' do
|
14
|
-
gem 'activerecord',
|
4
|
+
gem 'activerecord', '~> 6.0.0'
|
5
|
+
gem 'pg'
|
6
|
+
gem 'mysql2', '~> 0.5'
|
15
7
|
end
|
16
8
|
|
17
9
|
appraise 'activerecord-6.1' do
|
18
|
-
gem 'activerecord',
|
10
|
+
gem 'activerecord', '~> 6.1.0'
|
11
|
+
gem 'pg'
|
12
|
+
gem 'mysql2', '~> 0.5'
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise 'activerecord-7.0' do
|
16
|
+
gem 'activerecord', '~> 7.0.1'
|
17
|
+
gem 'pg'
|
18
|
+
gem 'mysql2', '~> 0.5'
|
19
19
|
end
|
data/CHANGELOG.md
CHANGED
@@ -10,12 +10,37 @@ Each change should fall into categories that would affect whether the release is
|
|
10
10
|
|
11
11
|
As such, _Breaking Changes_ are major. _Features_ would map to either major or minor. _Fixes_, _Performance_, and _Misc_ are either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding _Documentation_ (including tests) would be patch level.
|
12
12
|
|
13
|
+
### [v9.0.1) / 2022-01-07](https://github.com/mbleigh/acts-as-taggable-on/compare/v8.1.0...v9.0.0)
|
14
|
+
* Fixes
|
15
|
+
* Fix migration that generate default index
|
16
|
+
|
17
|
+
### [v9.0.0) / 2022-01-04](https://github.com/mbleigh/acts-as-taggable-on/compare/v8.1.0...v9.0.0)
|
18
|
+
* Fixes
|
19
|
+
* Support activerecord-7.0.0
|
20
|
+
* Support postgis adapter
|
21
|
+
* Fix migration syntax
|
22
|
+
* Features
|
23
|
+
* [@moliver-hemasystems Add support for a list of taggable IDs in tagging conditions](https://github.com/mbleigh/acts-as-taggable-on/pull/1053)
|
24
|
+
* Misc
|
25
|
+
* Add docker-compose.yml for local development
|
26
|
+
|
27
|
+
### [v8.1.0) / 2021-06-19](https://github.com/mbleigh/acts-as-taggable-on/compare/v8.0.0...v8.1.0)
|
28
|
+
* Fixes
|
29
|
+
* [@ngouy Fix rollbackable tenant migrations](https://github.com/mbleigh/acts-as-taggable-on/pull/1038)
|
30
|
+
* [@ngouy Fix gem conflict with already existing tenant model](https://github.com/mbleigh/acts-as-taggable-on/pull/1037)
|
31
|
+
|
32
|
+
### [v8.0.0) / 2021-06-07](https://github.com/mbleigh/acts-as-taggable-on/compare/v7.0.0...v8.0.0)
|
33
|
+
* Features
|
34
|
+
* [@lunaru Support tenants for taggings](https://github.com/mbleigh/acts-as-taggable-on/pull/1000)
|
35
|
+
* Fixes
|
36
|
+
* [@gr-eg Use none? instead of count.zero?](https://github.com/mbleigh/acts-as-taggable-on/pull/1030)
|
37
|
+
|
13
38
|
### [v7.0.0) / 2020-12-31](https://github.com/mbleigh/acts-as-taggable-on/compare/v6.5.0...v7.0.0)
|
14
39
|
* Features
|
15
40
|
* [@kvokka Rails 6.1 support](https://github.com/mbleigh/acts-as-taggable-on/pull/1013)
|
16
41
|
* Fixes
|
17
|
-
* [@nbulaj Add support for Ruby 2.7 and it's kwargs](https://github.com/mbleigh/acts-as-taggable-on/pull/910)
|
18
|
-
* [@Andythurlow @endorfin case sensitivity fix for tagged_with](https://github.com/mbleigh/acts-as-taggable-on/pull/965)
|
42
|
+
* [@nbulaj Add support for Ruby 2.7 and it's kwargs](https://github.com/mbleigh/acts-as-taggable-on/pull/910)
|
43
|
+
* [@Andythurlow @endorfin case sensitivity fix for tagged_with](https://github.com/mbleigh/acts-as-taggable-on/pull/965)
|
19
44
|
|
20
45
|
### [6.5.0 / 2019-11-07](https://github.com/mbleigh/acts-as-taggable-on/compare/v6.0.0...v6.5.0)
|
21
46
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
[![Join the chat at https://gitter.im/mbleigh/acts-as-taggable-on](https://badges.gitter.im/mbleigh/acts-as-taggable-on.svg)](https://gitter.im/mbleigh/acts-as-taggable-on?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
34
34
|
[![Gem Version](https://badge.fury.io/rb/acts-as-taggable-on.svg)](http://badge.fury.io/rb/acts-as-taggable-on)
|
35
|
-
[![Build Status](https://
|
35
|
+
[![Build Status](https://github.com/mbleigh/acts-as-taggable-on/workflows/spec/badge.svg)](https://github.com/mbleigh/acts-as-taggable-on/actions)
|
36
36
|
[![Code Climate](https://codeclimate.com/github/mbleigh/acts-as-taggable-on.svg)](https://codeclimate.com/github/mbleigh/acts-as-taggable-on)
|
37
37
|
[![Inline docs](http://inch-ci.org/github/mbleigh/acts-as-taggable-on.svg)](http://inch-ci.org/github/mbleigh/acts-as-taggable-on)
|
38
38
|
[![Security](https://hakiri.io/github/mbleigh/acts-as-taggable-on/master.svg)](https://hakiri.io/github/mbleigh/acts-as-taggable-on/master)
|
@@ -57,7 +57,7 @@ was used.
|
|
57
57
|
To use it, add it to your Gemfile:
|
58
58
|
|
59
59
|
```ruby
|
60
|
-
gem 'acts-as-taggable-on', '~>
|
60
|
+
gem 'acts-as-taggable-on', '~> 9.0'
|
61
61
|
```
|
62
62
|
|
63
63
|
and bundle:
|
@@ -80,6 +80,8 @@ Review the generated migrations then migrate :
|
|
80
80
|
rake db:migrate
|
81
81
|
```
|
82
82
|
|
83
|
+
If you do not wish or need to support multi-tenancy, the migration for `add_tenant_to_taggings` is optional and can be discarded safely.
|
84
|
+
|
83
85
|
#### For MySql users
|
84
86
|
You can circumvent at any time the problem of special characters [issue 623](https://github.com/mbleigh/acts-as-taggable-on/issues/623) by setting in an initializer file:
|
85
87
|
|
@@ -390,6 +392,27 @@ def remove_owned_tag
|
|
390
392
|
end
|
391
393
|
```
|
392
394
|
|
395
|
+
### Tag Tenancy
|
396
|
+
|
397
|
+
Tags support multi-tenancy. This is useful for applications where a Tag belongs to a scoped set of models:
|
398
|
+
|
399
|
+
```ruby
|
400
|
+
class Account < ActiveRecord::Base
|
401
|
+
has_many :photos
|
402
|
+
end
|
403
|
+
|
404
|
+
class User < ActiveRecord::Base
|
405
|
+
belongs_to :account
|
406
|
+
acts_as_taggable_on :tags
|
407
|
+
acts_as_taggable_tenant :account_id
|
408
|
+
end
|
409
|
+
|
410
|
+
@user1.tag_list = ["foo", "bar"] # these taggings will automatically have the tenant saved
|
411
|
+
@user2.tag_list = ["bar", "baz"]
|
412
|
+
|
413
|
+
ActsAsTaggableOn::Tag.for_tenant(@user1.account.id) # returns Tag models for "foo" and "bar", but not "baz"
|
414
|
+
```
|
415
|
+
|
393
416
|
### Dirty objects
|
394
417
|
|
395
418
|
```ruby
|
@@ -530,12 +553,13 @@ Versions >= 3.x are compatible with Ruby 1.9.3+ and Rails 3 and 4.
|
|
530
553
|
|
531
554
|
Versions >= 4.x are compatible with Ruby 2.0.0+ and Rails 4 and 5.
|
532
555
|
|
533
|
-
|
556
|
+
Versions >= 7.x are compatible with Ruby 2.3.7+ and Rails 5 and 6.
|
534
557
|
|
535
|
-
|
558
|
+
Versions >= 8.x are compatible with Ruby 2.3.7+ and Rails 5 and 6.
|
536
559
|
|
537
|
-
|
538
|
-
|
560
|
+
Versions >= 9.x are compatible with Ruby 2.5.0 and Rails 6 and 7.
|
561
|
+
|
562
|
+
For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/milestones
|
539
563
|
|
540
564
|
## Testing
|
541
565
|
|
@@ -547,7 +571,8 @@ bundle
|
|
547
571
|
rake spec
|
548
572
|
```
|
549
573
|
|
550
|
-
You can run all the tests across all the Rails versions by running `rake appraise`.
|
574
|
+
You can run all the tests across all the Rails versions by running `rake appraise`.
|
575
|
+
If you'd also like to [run the tests across all rubies and databases as configured for Github Actions, install and run `wwtd`](https://github.com/grosser/wwtd).
|
551
576
|
|
552
577
|
|
553
578
|
## License
|
data/acts-as-taggable-on.gemspec
CHANGED
@@ -16,13 +16,13 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
17
|
gem.test_files = gem.files.grep(%r{^spec/})
|
18
18
|
gem.require_paths = ['lib']
|
19
|
-
gem.required_ruby_version = '>= 2.
|
19
|
+
gem.required_ruby_version = '>= 2.5.0'
|
20
20
|
|
21
21
|
if File.exist?('UPGRADING.md')
|
22
22
|
gem.post_install_message = File.read('UPGRADING.md')
|
23
23
|
end
|
24
24
|
|
25
|
-
gem.add_runtime_dependency 'activerecord', '>=
|
25
|
+
gem.add_runtime_dependency 'activerecord', '>= 6.0', '< 7.1'
|
26
26
|
|
27
27
|
gem.add_development_dependency 'rspec-rails'
|
28
28
|
gem.add_development_dependency 'rspec-its'
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class ActsAsTaggableOnMigration < ActiveRecord::Migration; end
|
5
|
-
end
|
6
|
-
ActsAsTaggableOnMigration.class_eval do
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ActsAsTaggableOnMigration < ActiveRecord::Migration[6.0]
|
7
4
|
def self.up
|
8
5
|
create_table ActsAsTaggableOn.tags_table do |t|
|
9
6
|
t.string :name
|
@@ -25,8 +22,8 @@ ActsAsTaggableOnMigration.class_eval do
|
|
25
22
|
t.datetime :created_at
|
26
23
|
end
|
27
24
|
|
28
|
-
add_index ActsAsTaggableOn.taggings_table,
|
29
|
-
|
25
|
+
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type context],
|
26
|
+
name: 'taggings_taggable_context_idx'
|
30
27
|
end
|
31
28
|
|
32
29
|
def self.down
|
@@ -1,16 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class AddMissingUniqueIndices < ActiveRecord::Migration; end
|
5
|
-
end
|
6
|
-
AddMissingUniqueIndices.class_eval do
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddMissingUniqueIndices < ActiveRecord::Migration[6.0]
|
7
4
|
def self.up
|
8
5
|
add_index ActsAsTaggableOn.tags_table, :name, unique: true
|
9
6
|
|
10
7
|
remove_index ActsAsTaggableOn.taggings_table, :tag_id if index_exists?(ActsAsTaggableOn.taggings_table, :tag_id)
|
11
8
|
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_taggable_context_idx'
|
12
9
|
add_index ActsAsTaggableOn.taggings_table,
|
13
|
-
[
|
10
|
+
%i[tag_id taggable_id taggable_type context tagger_id tagger_type],
|
14
11
|
unique: true, name: 'taggings_idx'
|
15
12
|
end
|
16
13
|
|
@@ -20,6 +17,7 @@ AddMissingUniqueIndices.class_eval do
|
|
20
17
|
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_idx'
|
21
18
|
|
22
19
|
add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists?(ActsAsTaggableOn.taggings_table, :tag_id)
|
23
|
-
add_index ActsAsTaggableOn.taggings_table, [
|
20
|
+
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type context],
|
21
|
+
name: 'taggings_taggable_context_idx'
|
24
22
|
end
|
25
23
|
end
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration; end
|
5
|
-
end
|
6
|
-
AddTaggingsCounterCacheToTags.class_eval do
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[6.0]
|
7
4
|
def self.up
|
8
5
|
add_column ActsAsTaggableOn.tags_table, :taggings_count, :integer, default: 0
|
9
6
|
|
@@ -1,11 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class AddMissingTaggableIndex < ActiveRecord::Migration; end
|
5
|
-
end
|
6
|
-
AddMissingTaggableIndex.class_eval do
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddMissingTaggableIndex < ActiveRecord::Migration[6.0]
|
7
4
|
def self.up
|
8
|
-
add_index ActsAsTaggableOn.taggings_table, [
|
5
|
+
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type context],
|
6
|
+
name: 'taggings_taggable_context_idx'
|
9
7
|
end
|
10
8
|
|
11
9
|
def self.down
|
@@ -1,11 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This migration is added to circumvent issue #623 and have special characters
|
2
4
|
# work properly
|
3
|
-
|
4
|
-
|
5
|
-
else
|
6
|
-
class ChangeCollationForTagNames < ActiveRecord::Migration; end
|
7
|
-
end
|
8
|
-
ChangeCollationForTagNames.class_eval do
|
5
|
+
|
6
|
+
class ChangeCollationForTagNames < ActiveRecord::Migration[6.0]
|
9
7
|
def up
|
10
8
|
if ActsAsTaggableOn::Utils.using_mysql?
|
11
9
|
execute("ALTER TABLE #{ActsAsTaggableOn.tags_table} MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
|
@@ -1,22 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
|
5
|
-
end
|
6
|
-
AddMissingIndexesOnTaggings.class_eval do
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[6.0]
|
7
4
|
def change
|
8
5
|
add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists? ActsAsTaggableOn.taggings_table, :tag_id
|
9
|
-
add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table,
|
10
|
-
|
11
|
-
add_index ActsAsTaggableOn.taggings_table, :
|
6
|
+
add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table,
|
7
|
+
:taggable_id
|
8
|
+
add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table,
|
9
|
+
:taggable_type
|
10
|
+
add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table,
|
11
|
+
:tagger_id
|
12
12
|
add_index ActsAsTaggableOn.taggings_table, :context unless index_exists? ActsAsTaggableOn.taggings_table, :context
|
13
13
|
|
14
|
-
unless index_exists? ActsAsTaggableOn.taggings_table, [
|
15
|
-
add_index ActsAsTaggableOn.taggings_table, [
|
14
|
+
unless index_exists? ActsAsTaggableOn.taggings_table, %i[tagger_id tagger_type]
|
15
|
+
add_index ActsAsTaggableOn.taggings_table, %i[tagger_id tagger_type]
|
16
16
|
end
|
17
17
|
|
18
|
-
unless index_exists? ActsAsTaggableOn.taggings_table, [
|
19
|
-
|
18
|
+
unless index_exists? ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type tagger_id context],
|
19
|
+
name: 'taggings_idy'
|
20
|
+
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type tagger_id context],
|
21
|
+
name: 'taggings_idy'
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddTenantToTaggings < ActiveRecord::Migration[6.0]
|
4
|
+
def self.up
|
5
|
+
add_column ActsAsTaggableOn.taggings_table, :tenant, :string, limit: 128
|
6
|
+
add_index ActsAsTaggableOn.taggings_table, :tenant unless index_exists? ActsAsTaggableOn.taggings_table, :tenant
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.down
|
10
|
+
remove_index ActsAsTaggableOn.taggings_table, :tenant
|
11
|
+
remove_column ActsAsTaggableOn.taggings_table, :tenant
|
12
|
+
end
|
13
|
+
end
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
version: '3.9'
|
2
|
+
services:
|
3
|
+
postgres:
|
4
|
+
image: postgres:10
|
5
|
+
environment:
|
6
|
+
POSTGRES_USER: postgres
|
7
|
+
POSTGRES_DB: acts_as_taggable_on
|
8
|
+
POSTGRES_PASSWORD: postgres
|
9
|
+
ports: ['5432:5432']
|
10
|
+
mysql:
|
11
|
+
image: mysql:8
|
12
|
+
environment:
|
13
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
14
|
+
MYSQL_DATABASE: acts_as_taggable_on
|
15
|
+
ports: ['3306:3306']
|
@@ -1,20 +1,17 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
5
|
gem "activerecord", "~> 6.0.0"
|
4
|
-
|
5
|
-
|
6
|
-
gem 'pg'
|
7
|
-
when "mysql"
|
8
|
-
gem 'mysql2', '~> 0.4'
|
9
|
-
else
|
10
|
-
gem 'sqlite3'
|
11
|
-
end
|
6
|
+
gem "pg"
|
7
|
+
gem "mysql2", "~> 0.5"
|
12
8
|
|
13
9
|
group :local_development do
|
14
10
|
gem "guard"
|
15
11
|
gem "guard-rspec"
|
16
12
|
gem "appraisal"
|
17
13
|
gem "rake"
|
14
|
+
gem "sqlite3"
|
18
15
|
gem "byebug", platforms: [:mri]
|
19
16
|
end
|
20
17
|
|
@@ -3,20 +3,15 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "activerecord", "~> 6.1.0"
|
6
|
-
|
7
|
-
|
8
|
-
gem 'pg'
|
9
|
-
when "mysql"
|
10
|
-
gem 'mysql2', '~> 0.5'
|
11
|
-
else
|
12
|
-
gem 'sqlite3'
|
13
|
-
end
|
6
|
+
gem "pg"
|
7
|
+
gem "mysql2", "~> 0.5"
|
14
8
|
|
15
9
|
group :local_development do
|
16
10
|
gem "guard"
|
17
11
|
gem "guard-rspec"
|
18
12
|
gem "appraisal"
|
19
13
|
gem "rake"
|
14
|
+
gem "sqlite3"
|
20
15
|
gem "byebug", platforms: [:mri]
|
21
16
|
end
|
22
17
|
|
@@ -1,20 +1,17 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
|
-
gem "activerecord", "~>
|
4
|
-
|
5
|
-
|
6
|
-
gem 'pg'
|
7
|
-
when "mysql"
|
8
|
-
gem 'mysql2', '~> 0.3'
|
9
|
-
else
|
10
|
-
gem "sqlite3", "~> 1.3", "< 1.4"
|
11
|
-
end
|
5
|
+
gem "activerecord", "~> 7.0.0"
|
6
|
+
gem "pg"
|
7
|
+
gem "mysql2", "~> 0.5"
|
12
8
|
|
13
9
|
group :local_development do
|
14
10
|
gem "guard"
|
15
11
|
gem "guard-rspec"
|
16
12
|
gem "appraisal"
|
17
13
|
gem "rake"
|
14
|
+
gem "sqlite3"
|
18
15
|
gem "byebug", platforms: [:mri]
|
19
16
|
end
|
20
17
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActsAsTaggableOn
|
2
4
|
##
|
3
5
|
# Returns a new TagList using the given tag string.
|
@@ -6,7 +8,6 @@ module ActsAsTaggableOn
|
|
6
8
|
# tag_list = ActsAsTaggableOn::DefaultParser.parse("One , Two, Three")
|
7
9
|
# tag_list # ["One", "Two", "Three"]
|
8
10
|
class DefaultParser < GenericParser
|
9
|
-
|
10
11
|
def parse
|
11
12
|
string = @tag_list
|
12
13
|
|
@@ -14,33 +15,32 @@ module ActsAsTaggableOn
|
|
14
15
|
TagList.new.tap do |tag_list|
|
15
16
|
string = string.to_s.dup
|
16
17
|
|
17
|
-
string.gsub!(double_quote_pattern)
|
18
|
+
string.gsub!(double_quote_pattern) do
|
18
19
|
# Append the matched tag to the tag list
|
19
20
|
tag_list << Regexp.last_match[2]
|
20
21
|
# Return the matched delimiter ($3) to replace the matched items
|
21
22
|
''
|
22
|
-
|
23
|
+
end
|
23
24
|
|
24
|
-
string.gsub!(single_quote_pattern)
|
25
|
+
string.gsub!(single_quote_pattern) do
|
25
26
|
# Append the matched tag ($2) to the tag list
|
26
27
|
tag_list << Regexp.last_match[2]
|
27
28
|
# Return an empty string to replace the matched items
|
28
29
|
''
|
29
|
-
|
30
|
+
end
|
30
31
|
|
31
32
|
# split the string by the delimiter
|
32
33
|
# and add to the tag_list
|
33
|
-
tag_list.add(string.split(Regexp.new
|
34
|
+
tag_list.add(string.split(Regexp.new(delimiter)))
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
38
|
# private
|
39
39
|
def delimiter
|
40
40
|
# Parse the quoted tags
|
41
41
|
d = ActsAsTaggableOn.delimiter
|
42
42
|
# Separate multiple delimiters by bitwise operator
|
43
|
-
d = d.join('|') if d.
|
43
|
+
d = d.join('|') if d.is_a?(Array)
|
44
44
|
d
|
45
45
|
end
|
46
46
|
|
@@ -73,7 +73,5 @@ module ActsAsTaggableOn
|
|
73
73
|
def single_quote_pattern
|
74
74
|
/(\A|#{delimiter})\s*'(.*?)'\s*(?=#{delimiter}\s*|\z)/
|
75
75
|
end
|
76
|
-
|
77
76
|
end
|
78
|
-
|
79
77
|
end
|