acts-as-taggable-on 6.5.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/spec.yml +76 -0
  3. data/Appraisals +13 -9
  4. data/CHANGELOG.md +35 -5
  5. data/Gemfile +1 -0
  6. data/README.md +34 -9
  7. data/acts-as-taggable-on.gemspec +2 -2
  8. data/db/migrate/1_acts_as_taggable_on_migration.rb +5 -7
  9. data/db/migrate/2_add_missing_unique_indices.rb +6 -8
  10. data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +3 -6
  11. data/db/migrate/4_add_missing_taggable_index.rb +5 -7
  12. data/db/migrate/5_change_collation_for_tag_names.rb +4 -6
  13. data/db/migrate/6_add_missing_indexes_on_taggings.rb +15 -13
  14. data/db/migrate/7_add_tenant_to_taggings.rb +13 -0
  15. data/docker-compose.yml +15 -0
  16. data/gemfiles/activerecord_6.0.gemfile +5 -8
  17. data/gemfiles/{activerecord_5.2.gemfile → activerecord_6.1.gemfile} +6 -9
  18. data/gemfiles/{activerecord_5.0.gemfile → activerecord_7.0.gemfile} +6 -9
  19. data/lib/acts-as-taggable-on.rb +1 -1
  20. data/lib/acts_as_taggable_on/default_parser.rb +8 -10
  21. data/lib/acts_as_taggable_on/engine.rb +2 -0
  22. data/lib/acts_as_taggable_on/generic_parser.rb +2 -0
  23. data/lib/acts_as_taggable_on/tag.rb +34 -28
  24. data/lib/acts_as_taggable_on/tag_list.rb +8 -11
  25. data/lib/acts_as_taggable_on/taggable/cache.rb +64 -62
  26. data/lib/acts_as_taggable_on/taggable/collection.rb +178 -142
  27. data/lib/acts_as_taggable_on/taggable/core.rb +250 -236
  28. data/lib/acts_as_taggable_on/taggable/ownership.rb +110 -98
  29. data/lib/acts_as_taggable_on/taggable/related.rb +60 -47
  30. data/lib/acts_as_taggable_on/taggable/tag_list_type.rb +6 -2
  31. data/lib/acts_as_taggable_on/taggable/tagged_with_query/all_tags_query.rb +110 -106
  32. data/lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb +57 -53
  33. data/lib/acts_as_taggable_on/taggable/tagged_with_query/exclude_tags_query.rb +63 -60
  34. data/lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb +54 -46
  35. data/lib/acts_as_taggable_on/taggable/tagged_with_query.rb +14 -8
  36. data/lib/acts_as_taggable_on/taggable.rb +30 -12
  37. data/lib/acts_as_taggable_on/tagger.rb +10 -6
  38. data/lib/acts_as_taggable_on/tagging.rb +9 -5
  39. data/lib/acts_as_taggable_on/tags_helper.rb +3 -1
  40. data/lib/acts_as_taggable_on/utils.rb +4 -2
  41. data/lib/acts_as_taggable_on/version.rb +3 -1
  42. data/spec/acts_as_taggable_on/tag_spec.rb +16 -1
  43. data/spec/acts_as_taggable_on/taggable_spec.rb +7 -3
  44. data/spec/acts_as_taggable_on/tagging_spec.rb +26 -0
  45. data/spec/internal/app/models/taggable_model.rb +2 -0
  46. data/spec/internal/config/database.yml.sample +4 -8
  47. data/spec/internal/db/schema.rb +3 -0
  48. data/spec/support/database.rb +36 -26
  49. metadata +16 -24
  50. data/.travis.yml +0 -43
  51. data/UPGRADING.md +0 -8
  52. data/gemfiles/activerecord_5.1.gemfile +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4120fe17937a900a8bbe921880f0e3e8c83a4355483bfbbb6eba6e99738b7fda
4
- data.tar.gz: 1b8924e2cb3a360e6be90986e5be0460652aac74225869f570200bde2a734cf2
3
+ metadata.gz: 5f5bbdb5779f5a9c0feb7bda9b83f6bb581d8804e07beda16b7fea7dfda45a1b
4
+ data.tar.gz: 6feeaec2428cbab344f795f92fb3b48e2ab06f0fd0fbceb211b845bd214fb157
5
5
  SHA512:
6
- metadata.gz: 28ea6660e352e3e025311ed9a3d470b941d3b4bca6108b3ce7eaadc0fd0aac3d8ba7508baf002ab2a8ac09ecd7bf2795e1b0a26158e1d636c305722e2bff9ad7
7
- data.tar.gz: 2ddf924977f9bdb6c0e6665186ce3de7d2624abb00b933b06194f64866bb39d3b98c0bb7a0f2de635c046a0b655ad084392120fbd12afb5ed06057579b38961d
6
+ metadata.gz: a81076cf61cf23c3a2f8ae17dc6be030bc120cc0464994ca190ded1407c2e8bc50dc78ca2a0742b85c4c6c5d996255af4267493eb3708d9abc4693da28881a61
7
+ data.tar.gz: 36f2d2c63c87e0f6e4086b6ec692d846d2d8a04948b485073b351968411fbb62405730e06c535279434955ddcfbfa2dc30e8a40f62cc39cb3f46515eca9e2889
@@ -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,15 +1,19 @@
1
- appraise 'activerecord-5.2' do
2
- gem 'activerecord', '~> 5.2.0'
3
- end
1
+ # frozen_string_literal: true
4
2
 
5
- appraise 'activerecord-5.1' do
6
- gem 'activerecord', "~> 5.1.1"
3
+ appraise 'activerecord-6.0' do
4
+ gem 'activerecord', '~> 6.0.0'
5
+ gem 'pg'
6
+ gem 'mysql2', '~> 0.5'
7
7
  end
8
8
 
9
- appraise 'activerecord-5.0' do
10
- gem 'activerecord', "~> 5.0.3"
9
+ appraise 'activerecord-6.1' do
10
+ gem 'activerecord', '~> 6.1.0'
11
+ gem 'pg'
12
+ gem 'mysql2', '~> 0.5'
11
13
  end
12
14
 
13
- appraise 'activerecord-6.0' do
14
- gem 'activerecord', "~> 6.0.0.beta1"
15
+ appraise 'activerecord-7.0' do
16
+ gem 'activerecord', '~> 7.0.0'
17
+ gem 'pg'
18
+ gem 'mysql2', '~> 0.5'
15
19
  end
data/CHANGELOG.md CHANGED
@@ -10,19 +10,49 @@ 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
- ### [Master / Unreleased](https://github.com/mbleigh/acts-as-taggable-on/compare/v6.0.1...master)
13
+ ### [v9.0.0) / 2022-01-04](https://github.com/mbleigh/acts-as-taggable-on/compare/v8.1.0...v9.0.0)
14
+ * Fixes
15
+ * Support activerecord-7.0.0
16
+ * Support postgis adapter
17
+ * Fix migration syntax
18
+ * Features
19
+ * [@moliver-hemasystems Add support for a list of taggable IDs in tagging conditions](https://github.com/mbleigh/acts-as-taggable-on/pull/1053)
20
+ * Misc
21
+ * Add docker-compose.yml for local development
22
+
23
+ ### [v8.1.0) / 2021-06-19](https://github.com/mbleigh/acts-as-taggable-on/compare/v8.0.0...v8.1.0)
24
+ * Fixes
25
+ * [@ngouy Fix rollbackable tenant migrations](https://github.com/mbleigh/acts-as-taggable-on/pull/1038)
26
+ * [@ngouy Fix gem conflict with already existing tenant model](https://github.com/mbleigh/acts-as-taggable-on/pull/1037)
27
+
28
+ ### [v8.0.0) / 2021-06-07](https://github.com/mbleigh/acts-as-taggable-on/compare/v7.0.0...v8.0.0)
29
+ * Features
30
+ * [@lunaru Support tenants for taggings](https://github.com/mbleigh/acts-as-taggable-on/pull/1000)
31
+ * Fixes
32
+ * [@gr-eg Use none? instead of count.zero?](https://github.com/mbleigh/acts-as-taggable-on/pull/1030)
33
+
34
+ ### [v7.0.0) / 2020-12-31](https://github.com/mbleigh/acts-as-taggable-on/compare/v6.5.0...v7.0.0)
35
+ * Features
36
+ * [@kvokka Rails 6.1 support](https://github.com/mbleigh/acts-as-taggable-on/pull/1013)
37
+ * Fixes
38
+ * [@nbulaj Add support for Ruby 2.7 and it's kwargs](https://github.com/mbleigh/acts-as-taggable-on/pull/910)
39
+ * [@Andythurlow @endorfin case sensitivity fix for tagged_with](https://github.com/mbleigh/acts-as-taggable-on/pull/965)
40
+
41
+ ### [6.5.0 / 2019-11-07](https://github.com/mbleigh/acts-as-taggable-on/compare/v6.0.0...v6.5.0)
42
+
14
43
  * Features
15
44
  * [@mizukami234 @junmoka Make table names configurable](https://github.com/mbleigh/acts-as-taggable-on/pull/910)
45
+ * [@damianlegawiec Rails 6.0.0.beta1 support](https://github.com/mbleigh/acts-as-taggable-on/pull/937)
16
46
  * Fixes
17
47
  * [@tonyta Avoid overriding user-defined columns cache methods](https://github.com/mbleigh/acts-as-taggable-on/pull/911)
48
+ * [@hengwoon tags_count only need to join on the taggable's table if using STI](https://github.com/mbleigh/acts-as-taggable-on/pull/904)
49
+ * [@bduran82 Avoid unnecessary queries when finding or creating tags](https://github.com/mbleigh/acts-as-taggable-on/pull/839)
50
+ * [@iiwo simplify relation options syntax](https://github.com/mbleigh/acts-as-taggable-on/pull/940)
18
51
  * Misc
19
52
  * [@gssbzn Remove legacy code for an empty query and replace it with ` ActiveRecord::none`](https://github.com/mbleigh/acts-as-taggable-on/pull/906)
53
+ * [@iiwo remove unneeded spec case](https://github.com/mbleigh/acts-as-taggable-on/pull/941)
20
54
  * Documentation
21
55
  * [@tonyta Cleanup CHANGELOG.md formatting and references](https://github.com/mbleigh/acts-as-taggable-on/pull/913)
22
- ### [6.0.1 / 2018-06-27](https://github.com/mbleigh/acts-as-taggable-on/compare/v6.0.0...v6.0.1)
23
-
24
- * Fixes
25
- * [@hengwoon tags_count only need to join on the taggable's table if using STI](https://github.com/mbleigh/acts-as-taggable-on/pull/904)
26
56
 
27
57
  ### [6.0.0 / 2018-06-19](https://github.com/mbleigh/acts-as-taggable-on/compare/v5.0.0...v6.0.0)
28
58
 
data/Gemfile CHANGED
@@ -7,5 +7,6 @@ group :local_development do
7
7
  gem 'guard-rspec'
8
8
  gem 'appraisal'
9
9
  gem 'rake'
10
+ gem 'sqlite3'
10
11
  gem 'byebug', platforms: [:mri]
11
12
  end
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://secure.travis-ci.org/mbleigh/acts-as-taggable-on.svg)](http://travis-ci.org/mbleigh/acts-as-taggable-on)
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', '~> 6.0'
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
 
@@ -103,8 +105,8 @@ Setup
103
105
 
104
106
  ```ruby
105
107
  class User < ActiveRecord::Base
106
- acts_as_taggable # Alias for acts_as_taggable_on :tags
107
- acts_as_taggable_on :skills, :interests
108
+ acts_as_taggable_on :tags
109
+ acts_as_taggable_on :skills, :interests #You can also configure multiple tag types per model
108
110
  end
109
111
 
110
112
  class UsersController < ApplicationController
@@ -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
- For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/milestones
556
+ Versions >= 7.x are compatible with Ruby 2.3.7+ and Rails 5 and 6.
557
+
558
+ Versions >= 8.x are compatible with Ruby 2.3.7+ and Rails 5 and 6.
534
559
 
535
- ## TODO
560
+ Versions >= 9.x are compatible with Ruby 2.5.0 and Rails 6 and 7.
536
561
 
537
- - Write benchmark script
538
- - Resolve concurrency issues
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`. If you'd also like to [run the tests across all rubies and databases as configured for Travis CI, install and run `wwtd`](https://github.com/grosser/wwtd).
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
@@ -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.3.7'
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', '>= 5.0', '< 6.1'
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
- if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
- class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]; end
3
- else
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
@@ -26,7 +23,8 @@ ActsAsTaggableOnMigration.class_eval do
26
23
  end
27
24
 
28
25
  add_index ActsAsTaggableOn.taggings_table, :tag_id
29
- add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
26
+ add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type context],
27
+ name: 'taggings_taggable_context_idx'
30
28
  end
31
29
 
32
30
  def self.down
@@ -1,16 +1,13 @@
1
- if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
- class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
3
- else
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
- [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
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, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
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
- if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
- class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]; end
3
- else
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
- if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
- class AddMissingTaggableIndex < ActiveRecord::Migration[4.2]; end
3
- else
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, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
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
- if ActiveRecord.gem_version >= Gem::Version.new('5.0')
4
- class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end
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
- if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
- class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
3
- else
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, :taggable_id
10
- add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_type
11
- add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table, :tagger_id
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, [:tagger_id, :tagger_type]
15
- add_index ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
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, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
19
- add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
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
@@ -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
- case ENV["DB"]
5
- when "postgresql"
6
- gem 'pg'
7
- when "mysql"
8
- gem 'mysql2', '~> 0.3'
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
 
@@ -1,20 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
- gem "activerecord", "~> 5.2.0"
4
- case ENV["DB"]
5
- when "postgresql"
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", "~> 6.1.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,20 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
- gem "activerecord", "~> 5.0.3"
4
- case ENV["DB"]
5
- when "postgresql"
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
 
@@ -58,7 +58,7 @@ module ActsAsTaggableOn
58
58
  def self.glue
59
59
  setting = @configuration.delimiter
60
60
  delimiter = setting.kind_of?(Array) ? setting[0] : setting
61
- delimiter.ends_with?(' ') ? delimiter : "#{delimiter} "
61
+ delimiter.end_with?(' ') ? delimiter : "#{delimiter} "
62
62
  end
63
63
 
64
64
  class Configuration
@@ -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 delimiter))
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.kind_of?(Array)
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActsAsTaggableOn
2
4
  class Engine < Rails::Engine
3
5
  end
@@ -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.