acts-as-taggable-on 10.0.0 → 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/spec.yml +8 -10
  3. data/Appraisals +10 -6
  4. data/CHANGELOG.md +12 -3
  5. data/Gemfile +0 -1
  6. data/README.md +7 -4
  7. data/acts-as-taggable-on.gemspec +4 -3
  8. data/gemfiles/activerecord_7.1.gemfile +1 -1
  9. data/gemfiles/{activerecord_6.0.gemfile → activerecord_7.2.gemfile} +2 -2
  10. data/gemfiles/{activerecord_6.1.gemfile → activerecord_8.0.gemfile} +3 -2
  11. data/lib/{acts_as_taggable_on → acts-as-taggable-on}/tag.rb +1 -1
  12. data/lib/acts-as-taggable-on/taggable/caching.rb +46 -0
  13. data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/collection.rb +5 -4
  14. data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/core.rb +4 -6
  15. data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/ownership.rb +5 -7
  16. data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable.rb +8 -8
  17. data/lib/{acts_as_taggable_on → acts-as-taggable-on}/tagger.rb +2 -4
  18. data/lib/{acts_as_taggable_on → acts-as-taggable-on}/version.rb +1 -1
  19. data/lib/acts-as-taggable-on.rb +7 -28
  20. data/lib/tasks/install_initializer.rake +2 -2
  21. data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +5 -10
  22. data/spec/acts_as_taggable_on/caching_spec.rb +0 -4
  23. data/spec/acts_as_taggable_on/tag_list_spec.rb +1 -1
  24. data/spec/acts_as_taggable_on/tag_spec.rb +1 -1
  25. data/spec/acts_as_taggable_on/taggable_spec.rb +1 -1
  26. data/spec/acts_as_taggable_on/tagging_spec.rb +1 -1
  27. data/spec/support/database.rb +1 -5
  28. metadata +56 -38
  29. data/gemfiles/activerecord_7.0.gemfile +0 -18
  30. data/lib/acts_as_taggable_on/taggable/cache.rb +0 -92
  31. data/lib/acts_as_taggable_on.rb +0 -6
  32. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/default_parser.rb +0 -0
  33. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/engine.rb +0 -0
  34. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/generic_parser.rb +0 -0
  35. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/tag_list.rb +0 -0
  36. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/related.rb +0 -0
  37. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/tag_list_type.rb +0 -0
  38. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/tagged_with_query/all_tags_query.rb +0 -0
  39. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/tagged_with_query/any_tags_query.rb +0 -0
  40. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/tagged_with_query/exclude_tags_query.rb +0 -0
  41. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/tagged_with_query/query_base.rb +0 -0
  42. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/taggable/tagged_with_query.rb +0 -0
  43. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/tagging.rb +0 -0
  44. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/tags_helper.rb +0 -0
  45. /data/lib/{acts_as_taggable_on → acts-as-taggable-on}/utils.rb +0 -0
  46. /data/lib/tasks/example/{acts_as_taggable_on.rb.example → acts-as-taggable-on.rb.example} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a72bfb5bb88aea5ec247738610ca9010077e75742abbc6ae28b0fecb441a01e
4
- data.tar.gz: 1772385e3921e9b85bbcb0d4407b5dea817f22a62dad50a268375819885541e2
3
+ metadata.gz: ab3dc3f7295e510515332b81d62b0cc3098a26d364b6eaf1cae1831f3275b228
4
+ data.tar.gz: d8e5ddda21eacb986be4e636adbbadabf6cdc8931f229a0a3faebf388fe30f58
5
5
  SHA512:
6
- metadata.gz: 72de9a02773b616bc6a55fb4b21879aa104c5100dd9f3b6538334c08bccef904a4e680796c46699e51cafab205301be0288ca831ef26e59c011cd37ab0f9210d
7
- data.tar.gz: 74a5235a9c37a7c3793bcb8a3b4c5e2a2a6fe2a74a499a5b1fb2ef208e9c8b1f778c2b120f6921019eb7961a9020f0b05bede0aab97234612039b67171a1f7a7
6
+ metadata.gz: e903a0632765032594251734d43dfc8392a319ef37f7be80c03940afc923d3afc812bc9c4960d0c68c47d3a6babd230b642eb77fadc093ee22b39fdb7f37835d
7
+ data.tar.gz: 1d16b52d2d6c6795509e5e94d65fd837fab427fdeffafa26293bc3b894776f4ce47b0a44a4517d0999d6d15ffa93a902fa33632436c00d96e48e32e1b25b3c3c
@@ -13,14 +13,12 @@ jobs:
13
13
  fail-fast: false
14
14
  matrix:
15
15
  ruby:
16
+ - 3.3
16
17
  - 3.2
17
- - 3.1
18
- - "3.0"
19
- - 2.7
20
18
  gemfile:
19
+ - gemfiles/activerecord_8.0.gemfile
20
+ - gemfiles/activerecord_7.2.gemfile
21
21
  - gemfiles/activerecord_7.1.gemfile
22
- - gemfiles/activerecord_7.0.gemfile
23
- - gemfiles/activerecord_6.1.gemfile
24
22
  db:
25
23
  - mysql
26
24
  - postgresql
@@ -28,13 +26,13 @@ jobs:
28
26
  include:
29
27
  - ruby: truffleruby-head
30
28
  db: postgresql
31
- gemfile: gemfiles/activerecord_6.1.gemfile
29
+ gemfile: gemfiles/activerecord_8.0.gemfile
32
30
  - ruby: truffleruby-head
33
31
  db: postgresql
34
- gemfile: gemfiles/activerecord_7.0.gemfile
35
- exclude:
36
- - ruby: 3.2
37
- gemfile: gemfiles/activerecord_6.0.gemfile
32
+ gemfile: gemfiles/activerecord_7.1.gemfile
33
+ - ruby: truffleruby-head
34
+ db: postgresql
35
+ gemfile: gemfiles/activerecord_7.2.gemfile
38
36
 
39
37
  services:
40
38
  postgres:
data/Appraisals CHANGED
@@ -1,19 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'activerecord-6.1' do
4
- gem 'activerecord', '~> 6.1.0'
3
+ appraise 'activerecord-7.1' do
4
+ gem 'activerecord', '~> 7.1.0'
5
5
  gem 'pg'
6
+ gem 'sqlite3', '~> 1.4'
6
7
  gem 'mysql2', '~> 0.5'
7
8
  end
8
9
 
9
- appraise 'activerecord-7.0' do
10
- gem 'activerecord', '~> 7.0.1'
10
+ appraise 'activerecord-7.2' do
11
+ gem 'activerecord', '~> 7.2.0'
11
12
  gem 'pg'
13
+ gem 'sqlite3', '~> 2.2'
12
14
  gem 'mysql2', '~> 0.5'
13
15
  end
14
16
 
15
- appraise 'activerecord-7.1' do
16
- gem 'activerecord', '~> 7.1.0'
17
+ appraise 'activerecord-8.0' do
18
+ gem 'activerecord', '~> 8.0.0.beta1'
19
+ gem 'railties', '~> 8.0.0.beta1'
17
20
  gem 'pg'
21
+ gem 'sqlite3', '~> 2.2'
18
22
  gem 'mysql2', '~> 0.5'
19
23
  end
data/CHANGELOG.md CHANGED
@@ -10,7 +10,16 @@ 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
- ### [v10.0.0) / unreleased](https://github.com/mbleigh/acts-as-taggable-on/compare/v9.0.1...master)
13
+ ### [v11.0.0) / 2024-08-23](https://github.com/mbleigh/acts-as-taggable-on/compare/v10.0.0...v11.0.0)
14
+ - Removed support for Ruby 2.7
15
+ - Removed support for Rails 6.1
16
+ - Added support for Ruby 3.2 and 3.3
17
+ - Added support for Rails 7.2
18
+ - Remove legacy code
19
+ - Renamed gem folder from acts_as_taggable_on to acts-as-taggable-on
20
+ - Removed legacy autoloading and replaced it with zeitwerk
21
+
22
+ ### [v10.0.0) / 2023-10-15](https://github.com/mbleigh/acts-as-taggable-on/compare/v9.0.1...v10.0.0)
14
23
  * Features
15
24
  * [@glampr Add support for prefix and suffix searches alongside previously supported containment (wildcard) searches](https://github.com/mbleigh/acts-as-taggable-on/pull/1082)
16
25
  * [@donquxiote Add support for horizontally sharded databases](https://github.com/mbleigh/acts-as-taggable-on/pull/1079)
@@ -121,7 +130,7 @@ As such, _Breaking Changes_ are major. _Features_ would map to either major or m
121
130
 
122
131
  * Fixes
123
132
  * [@rikettsie #623 collation parameter is ignored if it generates an exception](https://github.com/mbleigh/acts-as-taggable-on/pull/650)
124
- * [@bwvoss References working parser in deprectation warning](https://github.com/mbleigh/acts-as-taggable-on/pull/659)
133
+ * [@bwvoss References working parser in deprecation warning](https://github.com/mbleigh/acts-as-taggable-on/pull/659)
125
134
  * [@jh125486 Updated tagging_contexts to include dynamic contexts](https://github.com/mbleigh/acts-as-taggable-on/pull/660)
126
135
  * [@jh125486 Fixed wildcard test (postgres returning rows with unexpected order)](https://github.com/mbleigh/acts-as-taggable-on/pull/660)
127
136
  * [@FlowerWrong Add rails 5.0.0 alpha support, not hack rails <5](https://github.com/mbleigh/acts-as-taggable-on/pull/673)
@@ -142,7 +151,7 @@ As such, _Breaking Changes_ are major. _Features_ would map to either major or m
142
151
  * [@seuros Remove more deprecations](https://github.com/mbleigh/acts-as-taggable-on/commit/05794170f64f8bf250b34d2d594e368721009278)
143
152
  * [@lukeasrodgers Bugfix `TagList#concat` with non-duplicates.](https://github.com/mbleigh/acts-as-taggable-on/commit/2c6214f0ddf8c6440ab81eec04d1fbf9d97c8826)
144
153
  * [@seuros clean! should return self.](https://github.com/mbleigh/acts-as-taggable-on/commit/c739422f56f8ff37e3f321235e74997422a1c980)
145
- * [@rbritom renable appraisals](https://github.com/mbleigh/acts-as-taggable-on/commit/0ca1f1c5b059699c683a28b522e86a3d5cd7639e)
154
+ * [@rbritom re-enable appraisals](https://github.com/mbleigh/acts-as-taggable-on/commit/0ca1f1c5b059699c683a28b522e86a3d5cd7639e)
146
155
  * [@rbritom remove index conditionally on up method.](https://github.com/mbleigh/acts-as-taggable-on/commit/9cc580e7f88164634eb10c8826e5b30ea0e00544)
147
156
  * [@rbritom add index on down method . ](https://github.com/mbleigh/acts-as-taggable-on/pull/767)
148
157
  * [@rbritom remove index conditionally on up method](https://github.com/mbleigh/acts-as-taggable-on/commit/9cc580e7f88164634eb10c8826e5b30ea0e00544)
data/Gemfile CHANGED
@@ -7,6 +7,5 @@ group :local_development do
7
7
  gem 'guard-rspec'
8
8
  gem 'appraisal'
9
9
  gem 'rake'
10
- gem 'sqlite3'
11
10
  gem 'byebug', platforms: [:mri]
12
11
  end
data/README.md CHANGED
@@ -22,7 +22,6 @@
22
22
  - [Upgrading](#upgrading)
23
23
  - [Contributors](#contributors)
24
24
  - [Compatibility](#compatibility)
25
- - [TODO](#todo)
26
25
  - [Testing](#testing)
27
26
  - [License](#license)
28
27
 
@@ -57,7 +56,7 @@ was used.
57
56
  To use it, add it to your Gemfile:
58
57
 
59
58
  ```ruby
60
- gem 'acts-as-taggable-on', '~> 9.0'
59
+ gem 'acts-as-taggable-on'
61
60
  ```
62
61
 
63
62
  and bundle:
@@ -377,7 +376,7 @@ Note that `tag_list` only returns tags whose taggings do not have an owner. Cont
377
376
  To retrieve all tags of an object (regardless of ownership) or if only one owner can tag the object, use `all_tags_list`.
378
377
 
379
378
  ##### Adding owned tags
380
- Note that **owned tags** are added all at once, in the form of ***comma seperated tags*** in string.
379
+ Note that **owned tags** are added all at once, in the form of ***comma separated tags*** in string.
381
380
  Also, when you try to add **owned tags** again, it simply overwrites the previous set of **owned tags**.
382
381
  So to append tags in previously existing **owned tags** list, go as follows:
383
382
  ```ruby
@@ -570,7 +569,11 @@ Versions >= 7.x are compatible with Ruby 2.3.7+ and Rails 5 and 6.
570
569
 
571
570
  Versions >= 8.x are compatible with Ruby 2.3.7+ and Rails 5 and 6.
572
571
 
573
- Versions >= 9.x are compatible with Ruby 2.5.0 and Rails 6 and 7.
572
+ Versions >= 9.x are compatible with Ruby 2.5.0 and Rails 6 and 7.0.
573
+
574
+ Versions >= 11.x are compatible with Ruby 3.1.0 and Rails 7.0 and 7.1.
575
+
576
+ Versions >= 12.x are compatible with Ruby 3.2.0 and Rails 7.1, 7.2 and 8.0.
574
577
 
575
578
  For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/milestones
576
579
 
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require_relative 'lib/acts_as_taggable_on/version'
3
+ require_relative 'lib/acts-as-taggable-on/version'
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'acts-as-taggable-on'
@@ -15,13 +15,14 @@ Gem::Specification.new do |gem|
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.test_files = gem.files.grep(%r{^spec/})
17
17
  gem.require_paths = ['lib']
18
- gem.required_ruby_version = '>= 2.7.0'
18
+ gem.required_ruby_version = '>= 3.2.0'
19
19
 
20
20
  if File.exist?('UPGRADING.md')
21
21
  gem.post_install_message = File.read('UPGRADING.md')
22
22
  end
23
23
 
24
- gem.add_runtime_dependency 'activerecord', '>= 6.1', '< 7.2'
24
+ gem.add_runtime_dependency 'activerecord', '>= 7.1', '< 8.1'
25
+ gem.add_runtime_dependency 'zeitwerk', '>= 2.4', '< 3.0'
25
26
 
26
27
  gem.add_development_dependency 'rspec-rails'
27
28
  gem.add_development_dependency 'rspec-its'
@@ -4,6 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 7.1.0"
6
6
  gem "pg"
7
+ gem "sqlite3", "~> 1.4"
7
8
  gem "mysql2", "~> 0.5"
8
9
 
9
10
  group :local_development do
@@ -11,7 +12,6 @@ group :local_development do
11
12
  gem "guard-rspec"
12
13
  gem "appraisal"
13
14
  gem "rake"
14
- gem "sqlite3"
15
15
  gem "byebug", platforms: [:mri]
16
16
  end
17
17
 
@@ -2,8 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 6.0.0"
5
+ gem "activerecord", "~> 7.2.0"
6
6
  gem "pg"
7
+ gem "sqlite3", "~> 2.1"
7
8
  gem "mysql2", "~> 0.5"
8
9
 
9
10
  group :local_development do
@@ -11,7 +12,6 @@ group :local_development do
11
12
  gem "guard-rspec"
12
13
  gem "appraisal"
13
14
  gem "rake"
14
- gem "sqlite3"
15
15
  gem "byebug", platforms: [:mri]
16
16
  end
17
17
 
@@ -2,8 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 6.1.0"
5
+ gem "activerecord", "~> 8.0.0.beta1"
6
+ gem "railties", "~> 8.0.0.beta1"
6
7
  gem "pg"
8
+ gem "sqlite3", "~> 2.1"
7
9
  gem "mysql2", "~> 0.5"
8
10
 
9
11
  group :local_development do
@@ -11,7 +13,6 @@ group :local_development do
11
13
  gem "guard-rspec"
12
14
  gem "appraisal"
13
15
  gem "rake"
14
- gem "sqlite3"
15
16
  gem "byebug", platforms: [:mri]
16
17
  end
17
18
 
@@ -33,7 +33,7 @@ module ActsAsTaggableOn
33
33
 
34
34
  def self.named_any(list)
35
35
  clause = list.map do |tag|
36
- sanitize_sql_for_named_any(tag).force_encoding('BINARY')
36
+ sanitize_sql_for_named_any(tag)
37
37
  end.join(' OR ')
38
38
  where(clause)
39
39
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActsAsTaggableOn
4
+ module Taggable
5
+ module Caching
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ initialize_tags_cache
10
+ before_save :save_cached_tag_list
11
+ end
12
+
13
+ class_methods do
14
+ def initialize_tags_cache
15
+ tag_types.map(&:to_s).each do |tag_type|
16
+ define_singleton_method("caching_#{tag_type.singularize}_list?") do
17
+ caching_tag_list_on?(tag_type)
18
+ end
19
+ end
20
+ end
21
+
22
+ def acts_as_taggable_on(*args)
23
+ super(*args)
24
+ initialize_tags_cache
25
+ end
26
+
27
+ def caching_tag_list_on?(context)
28
+ column_names.include?("cached_#{context.to_s.singularize}_list")
29
+ end
30
+ end
31
+
32
+ def save_cached_tag_list
33
+ tag_types.map(&:to_s).each do |tag_type|
34
+ next unless self.class.respond_to?("caching_#{tag_type.singularize}_list?")
35
+ if self.class.send("caching_#{tag_type.singularize}_list?") && tag_list_cache_set_on(tag_type)
36
+ list = tag_list_cache_on(tag_type).to_a.flatten.compact.join("#{ActsAsTaggableOn.delimiter} ")
37
+ self["cached_#{tag_type.singularize}_list"] = list
38
+ end
39
+ end
40
+
41
+ true
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -3,12 +3,13 @@
3
3
  module ActsAsTaggableOn
4
4
  module Taggable
5
5
  module Collection
6
- def self.included(base)
7
- base.extend ActsAsTaggableOn::Taggable::Collection::ClassMethods
8
- base.initialize_acts_as_taggable_on_collection
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ initialize_acts_as_taggable_on_collection
9
10
  end
10
11
 
11
- module ClassMethods
12
+ class_methods do
12
13
  def initialize_acts_as_taggable_on_collection
13
14
  tag_types.map(&:to_s).each do |tag_type|
14
15
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
@@ -6,19 +6,17 @@ require_relative 'tag_list_type'
6
6
  module ActsAsTaggableOn
7
7
  module Taggable
8
8
  module Core
9
- def self.included(base)
10
- base.extend ActsAsTaggableOn::Taggable::Core::ClassMethods
9
+ extend ActiveSupport::Concern
11
10
 
12
- base.class_eval do
11
+ included do
13
12
  attr_writer :custom_contexts
14
13
 
15
14
  after_save :save_tags
16
- end
17
15
 
18
- base.initialize_acts_as_taggable_on_core
16
+ initialize_acts_as_taggable_on_core
19
17
  end
20
18
 
21
- module ClassMethods
19
+ class_methods do
22
20
  def initialize_acts_as_taggable_on_core
23
21
  include taggable_mixin
24
22
  tag_types.map(&:to_s).each do |tags_type|
@@ -3,17 +3,15 @@
3
3
  module ActsAsTaggableOn
4
4
  module Taggable
5
5
  module Ownership
6
- def self.included(base)
7
- base.extend ActsAsTaggableOn::Taggable::Ownership::ClassMethods
6
+ extend ActiveSupport::Concern
8
7
 
9
- base.class_eval do
10
- after_save :save_owned_tags
11
- end
8
+ included do
9
+ after_save :save_owned_tags
12
10
 
13
- base.initialize_acts_as_taggable_on_ownership
11
+ initialize_acts_as_taggable_on_ownership
14
12
  end
15
13
 
16
- module ClassMethods
14
+ class_methods do
17
15
  def acts_as_taggable_on(*args)
18
16
  initialize_acts_as_taggable_on_ownership
19
17
  super(*args)
@@ -66,7 +66,7 @@ module ActsAsTaggableOn
66
66
  # called on each call of taggable_on
67
67
  include Core
68
68
  include Collection
69
- include Cache
69
+ include Caching
70
70
  include Ownership
71
71
  include Related
72
72
  end
@@ -91,13 +91,13 @@ module ActsAsTaggableOn
91
91
  self.tag_types = (self.tag_types + tag_types).uniq
92
92
  self.preserve_tag_order = preserve_tag_order
93
93
  else
94
- class_attribute :tag_types
95
- self.tag_types = tag_types
96
- class_attribute :preserve_tag_order
97
- self.preserve_tag_order = preserve_tag_order
98
- class_attribute :tenant_column
99
-
100
94
  class_eval do
95
+ class_attribute :tag_types
96
+ class_attribute :preserve_tag_order
97
+ class_attribute :tenant_column
98
+ self.tag_types = tag_types
99
+ self.preserve_tag_order = preserve_tag_order
100
+
101
101
  has_many :taggings, as: :taggable, dependent: :destroy, class_name: '::ActsAsTaggableOn::Tagging'
102
102
  has_many :base_tags, through: :taggings, source: :tag, class_name: '::ActsAsTaggableOn::Tag'
103
103
 
@@ -111,7 +111,7 @@ module ActsAsTaggableOn
111
111
  # called on each call of taggable_on
112
112
  include Core
113
113
  include Collection
114
- include Cache
114
+ include Caching
115
115
  include Ownership
116
116
  include Related
117
117
  end
@@ -2,11 +2,9 @@
2
2
 
3
3
  module ActsAsTaggableOn
4
4
  module Tagger
5
- def self.included(base)
6
- base.extend ClassMethods
7
- end
5
+ extend ActiveSupport::Concern
8
6
 
9
- module ClassMethods
7
+ class_methods do
10
8
  ##
11
9
  # Make a model a tagger. This allows an instance of a model to claim ownership
12
10
  # of tags.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsTaggableOn
4
- VERSION = '10.0.0'
4
+ VERSION = '12.0.0'
5
5
  end
@@ -1,43 +1,21 @@
1
1
  require 'active_record'
2
2
  require 'active_record/version'
3
3
  require 'active_support/core_ext/module'
4
+ require 'zeitwerk'
5
+
6
+ loader = Zeitwerk::Loader.for_gem
7
+ loader.inflector.inflect "acts-as-taggable-on" => "ActsAsTaggableOn"
8
+ loader.setup
4
9
 
5
10
  begin
6
11
  require 'rails/engine'
7
- require 'acts_as_taggable_on/engine'
12
+ require 'acts-as-taggable-on/engine'
8
13
  rescue LoadError
9
-
10
14
  end
11
15
 
12
16
  require 'digest/sha1'
13
17
 
14
18
  module ActsAsTaggableOn
15
- extend ActiveSupport::Autoload
16
-
17
- autoload :Tag
18
- autoload :TagList
19
- autoload :GenericParser
20
- autoload :DefaultParser
21
- autoload :Taggable
22
- autoload :Tagger
23
- autoload :Tagging
24
- autoload :TagsHelper
25
- autoload :VERSION
26
-
27
- autoload_under 'taggable' do
28
- autoload :Cache
29
- autoload :Collection
30
- autoload :Core
31
- autoload :Dirty
32
- autoload :Ownership
33
- autoload :Related
34
- autoload :TagListType
35
- end
36
-
37
- autoload :Utils
38
- autoload :Compatibility
39
-
40
-
41
19
  class DuplicateTagError < StandardError
42
20
  end
43
21
 
@@ -134,6 +112,7 @@ ActiveSupport.on_load(:active_record) do
134
112
  extend ActsAsTaggableOn::Taggable
135
113
  include ActsAsTaggableOn::Tagger
136
114
  end
115
+
137
116
  ActiveSupport.on_load(:action_view) do
138
117
  include ActsAsTaggableOn::TagsHelper
139
118
  end
@@ -9,10 +9,10 @@ namespace :acts_as_taggable_on do
9
9
  "lib",
10
10
  "tasks",
11
11
  "examples",
12
- "acts_as_taggable_on.rb.example"
12
+ "acts-as-taggable-on.rb.example"
13
13
  )
14
14
 
15
- destination = "config/initializers/acts_as_taggable_on.rb"
15
+ destination = "config/initializers/acts-as-taggable-on.rb"
16
16
 
17
17
  cp source, destination
18
18
  end
@@ -197,7 +197,7 @@ describe 'Acts As Taggable On' do
197
197
 
198
198
  its(:language_list) { should == ['ruby', '.net']}
199
199
  its(:cached_language_list) { should == 'ruby, .net' } # passes
200
- its(:instance_variables) { should include((RUBY_VERSION < '1.9' ? '@language_list' : :@language_list)) }
200
+ its(:instance_variables) { should include(:@language_list) }
201
201
  end
202
202
 
203
203
  context 'status taggings cache after update' do
@@ -207,8 +207,8 @@ describe 'Acts As Taggable On' do
207
207
  its(:status_list) { should == ['happy', 'married'] }
208
208
  its(:cached_status_list) { should == 'happy, married' } # fails
209
209
  its(:cached_status_list) { should_not == '' } # fails, is blank
210
- its(:instance_variables) { should include((RUBY_VERSION < '1.9' ? '@status_list' : :@status_list)) }
211
- its(:instance_variables) { should_not include((RUBY_VERSION < '1.9' ? '@statu_list' : :@statu_list)) } # fails, note: one "s"
210
+ its(:instance_variables) { should include(:@status_list) }
211
+ its(:instance_variables) { should_not include(:@statu_list) } # fails, note: one "s"
212
212
 
213
213
  end
214
214
 
@@ -221,13 +221,8 @@ describe 'Acts As Taggable On' do
221
221
  its(:glass_list) { should == ['rectangle', 'aviator'] }
222
222
  its(:cached_glass_list) { should == 'rectangle, aviator' } # fails
223
223
  its(:cached_glass_list) { should_not == '' } # fails, is blank
224
- if RUBY_VERSION < '1.9'
225
- its(:instance_variables) { should include('@glass_list') }
226
- its(:instance_variables) { should_not include('@glas_list') } # fails, note: one "s"
227
- else
228
- its(:instance_variables) { should include(:@glass_list) }
229
- its(:instance_variables) { should_not include(:@glas_list) } # fails, note: one "s"
230
- end
224
+ its(:instance_variables) { should include(:@glass_list) }
225
+ its(:instance_variables) { should_not include(:@glas_list) } # fails, note: one "s"
231
226
 
232
227
  end
233
228
  end
@@ -16,10 +16,6 @@ describe 'Acts As Taggable On' do
16
16
  expect(@taggable).to respond_to(:save_tags)
17
17
  end
18
18
 
19
- it 'should add cached tag lists to the instance if cached column is not present' do
20
- expect(TaggableModel.new(name: 'Art Kram')).to_not respond_to(:save_cached_tag_list)
21
- end
22
-
23
19
  it 'should generate a cached column checker for each tag type' do
24
20
  expect(CachedModel).to respond_to(:caching_tag_list?)
25
21
  expect(OtherCachedModel).to respond_to(:caching_language_list?)
@@ -161,7 +161,7 @@ describe ActsAsTaggableOn::TagList do
161
161
  expect(parser).to have_received(:parse)
162
162
  end
163
163
 
164
- it 'should use the parser setted as attribute' do
164
+ it 'should use the parser set as attribute' do
165
165
  allow(parser_class).to receive(:new).with('new, tag').and_return(parser)
166
166
 
167
167
  tag_list = ActsAsTaggableOn::TagList.new('example')
@@ -389,7 +389,7 @@ describe ActsAsTaggableOn::Tag do
389
389
 
390
390
  ActsAsTaggableOn.base_class = 'Foo'
391
391
  hide_const("ActsAsTaggableOn::Tag")
392
- load("lib/acts_as_taggable_on/tag.rb")
392
+ load("lib/acts-as-taggable-on/tag.rb")
393
393
 
394
394
  expect(ActsAsTaggableOn::Tag.ancestors).to include(Foo)
395
395
  end
@@ -761,7 +761,7 @@ describe 'Taggable' do
761
761
  end
762
762
 
763
763
  # See https://github.com/mbleigh/acts-as-taggable-on/pull/457 for details
764
- context 'tag_counts and aggreating scopes, compatability with MySQL ' do
764
+ context 'tag_counts and aggreating scopes, compatibility with MySQL ' do
765
765
  before(:each) do
766
766
  TaggableModel.new(:name => 'Barb Jones').tap { |t| t.tag_list = %w(awesome fun) }.save
767
767
  TaggableModel.new(:name => 'John Doe').tap { |t| t.tag_list = %w(cool fun hella) }.save
@@ -159,7 +159,7 @@ describe ActsAsTaggableOn::Tagging do
159
159
 
160
160
  ActsAsTaggableOn.base_class = 'Foo'
161
161
  hide_const("ActsAsTaggableOn::Tagging")
162
- load("lib/acts_as_taggable_on/tagging.rb")
162
+ load("lib/acts-as-taggable-on/tagging.rb")
163
163
 
164
164
  expect(ActsAsTaggableOn::Tagging.ancestors).to include(Foo)
165
165
  end
@@ -13,11 +13,7 @@ ActiveRecord::Base.configurations = YAML.load_file(database_yml)
13
13
  ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), '../debug.log'))
14
14
  ActiveRecord::Base.logger.level = ENV['CI'] ? ::Logger::ERROR : ::Logger::DEBUG
15
15
  ActiveRecord::Migration.verbose = false
16
- if ActiveRecord.version >= Gem::Version.new('7.0.0.alpha2')
17
- ActiveRecord.default_timezone = :utc
18
- else
19
- ActiveRecord::Base.default_timezone = :utc
20
- end
16
+ ActiveRecord.default_timezone = :utc
21
17
  config = ActiveRecord::Base.configurations.configs_for(env_name: db_name)
22
18
 
23
19
  begin
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-taggable-on
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 12.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
8
8
  - Joost Baaij
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-15 00:00:00.000000000 Z
12
+ date: 2024-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -17,20 +17,40 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '6.1'
20
+ version: '7.1'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '7.2'
23
+ version: '8.1'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: '6.1'
30
+ version: '7.1'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '7.2'
33
+ version: '8.1'
34
+ - !ruby/object:Gem::Dependency
35
+ name: zeitwerk
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '2.4'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
34
54
  - !ruby/object:Gem::Dependency
35
55
  name: rspec-rails
36
56
  requirement: !ruby/object:Gem::Requirement
@@ -130,35 +150,33 @@ files:
130
150
  - db/migrate/6_add_missing_indexes_on_taggings.rb
131
151
  - db/migrate/7_add_tenant_to_taggings.rb
132
152
  - docker-compose.yml
133
- - gemfiles/activerecord_6.0.gemfile
134
- - gemfiles/activerecord_6.1.gemfile
135
- - gemfiles/activerecord_7.0.gemfile
136
153
  - gemfiles/activerecord_7.1.gemfile
154
+ - gemfiles/activerecord_7.2.gemfile
155
+ - gemfiles/activerecord_8.0.gemfile
137
156
  - lib/acts-as-taggable-on.rb
138
- - lib/acts_as_taggable_on.rb
139
- - lib/acts_as_taggable_on/default_parser.rb
140
- - lib/acts_as_taggable_on/engine.rb
141
- - lib/acts_as_taggable_on/generic_parser.rb
142
- - lib/acts_as_taggable_on/tag.rb
143
- - lib/acts_as_taggable_on/tag_list.rb
144
- - lib/acts_as_taggable_on/taggable.rb
145
- - lib/acts_as_taggable_on/taggable/cache.rb
146
- - lib/acts_as_taggable_on/taggable/collection.rb
147
- - lib/acts_as_taggable_on/taggable/core.rb
148
- - lib/acts_as_taggable_on/taggable/ownership.rb
149
- - lib/acts_as_taggable_on/taggable/related.rb
150
- - lib/acts_as_taggable_on/taggable/tag_list_type.rb
151
- - lib/acts_as_taggable_on/taggable/tagged_with_query.rb
152
- - lib/acts_as_taggable_on/taggable/tagged_with_query/all_tags_query.rb
153
- - lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb
154
- - lib/acts_as_taggable_on/taggable/tagged_with_query/exclude_tags_query.rb
155
- - lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb
156
- - lib/acts_as_taggable_on/tagger.rb
157
- - lib/acts_as_taggable_on/tagging.rb
158
- - lib/acts_as_taggable_on/tags_helper.rb
159
- - lib/acts_as_taggable_on/utils.rb
160
- - lib/acts_as_taggable_on/version.rb
161
- - lib/tasks/example/acts_as_taggable_on.rb.example
157
+ - lib/acts-as-taggable-on/default_parser.rb
158
+ - lib/acts-as-taggable-on/engine.rb
159
+ - lib/acts-as-taggable-on/generic_parser.rb
160
+ - lib/acts-as-taggable-on/tag.rb
161
+ - lib/acts-as-taggable-on/tag_list.rb
162
+ - lib/acts-as-taggable-on/taggable.rb
163
+ - lib/acts-as-taggable-on/taggable/caching.rb
164
+ - lib/acts-as-taggable-on/taggable/collection.rb
165
+ - lib/acts-as-taggable-on/taggable/core.rb
166
+ - lib/acts-as-taggable-on/taggable/ownership.rb
167
+ - lib/acts-as-taggable-on/taggable/related.rb
168
+ - lib/acts-as-taggable-on/taggable/tag_list_type.rb
169
+ - lib/acts-as-taggable-on/taggable/tagged_with_query.rb
170
+ - lib/acts-as-taggable-on/taggable/tagged_with_query/all_tags_query.rb
171
+ - lib/acts-as-taggable-on/taggable/tagged_with_query/any_tags_query.rb
172
+ - lib/acts-as-taggable-on/taggable/tagged_with_query/exclude_tags_query.rb
173
+ - lib/acts-as-taggable-on/taggable/tagged_with_query/query_base.rb
174
+ - lib/acts-as-taggable-on/tagger.rb
175
+ - lib/acts-as-taggable-on/tagging.rb
176
+ - lib/acts-as-taggable-on/tags_helper.rb
177
+ - lib/acts-as-taggable-on/utils.rb
178
+ - lib/acts-as-taggable-on/version.rb
179
+ - lib/tasks/example/acts-as-taggable-on.rb.example
162
180
  - lib/tasks/install_initializer.rake
163
181
  - lib/tasks/tags_collate_utf8.rake
164
182
  - spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
@@ -202,7 +220,7 @@ homepage: https://github.com/mbleigh/acts-as-taggable-on
202
220
  licenses:
203
221
  - MIT
204
222
  metadata: {}
205
- post_install_message:
223
+ post_install_message:
206
224
  rdoc_options: []
207
225
  require_paths:
208
226
  - lib
@@ -210,15 +228,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
228
  requirements:
211
229
  - - ">="
212
230
  - !ruby/object:Gem::Version
213
- version: 2.7.0
231
+ version: 3.2.0
214
232
  required_rubygems_version: !ruby/object:Gem::Requirement
215
233
  requirements:
216
234
  - - ">="
217
235
  - !ruby/object:Gem::Version
218
236
  version: '0'
219
237
  requirements: []
220
- rubygems_version: 3.4.12
221
- signing_key:
238
+ rubygems_version: 3.5.6
239
+ signing_key:
222
240
  specification_version: 4
223
241
  summary: Advanced tagging for Rails.
224
242
  test_files:
@@ -1,18 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 7.0.1"
6
- gem "pg"
7
- gem "mysql2", "~> 0.5"
8
-
9
- group :local_development do
10
- gem "guard"
11
- gem "guard-rspec"
12
- gem "appraisal"
13
- gem "rake"
14
- gem "sqlite3"
15
- gem "byebug", platforms: [:mri]
16
- end
17
-
18
- gemspec path: "../"
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActsAsTaggableOn
4
- module Taggable
5
- module Cache
6
- def self.included(base)
7
- # When included, conditionally adds tag caching methods when the model
8
- # has any "cached_#{tag_type}_list" column
9
- base.extend Columns
10
- end
11
-
12
- module Columns
13
- # ActiveRecord::Base.columns makes a database connection and caches the
14
- # calculated columns hash for the record as @columns. Since we don't
15
- # want to add caching methods until we confirm the presence of a
16
- # caching column, and we don't want to force opening a database
17
- # connection when the class is loaded, here we intercept and cache
18
- # the call to :columns as @acts_as_taggable_on_cache_columns
19
- # to mimic the underlying behavior. While processing this first
20
- # call to columns, we do the caching column check and dynamically add
21
- # the class and instance methods
22
- # FIXME: this method cannot compile in rubinius
23
- def columns
24
- @acts_as_taggable_on_cache_columns ||= begin
25
- db_columns = super
26
- _add_tags_caching_methods if _has_tags_cache_columns?(db_columns)
27
- db_columns
28
- end
29
- end
30
-
31
- def reset_column_information
32
- super
33
- @acts_as_taggable_on_cache_columns = nil
34
- end
35
-
36
- private
37
-
38
- # @private
39
- def _has_tags_cache_columns?(db_columns)
40
- db_column_names = db_columns.map(&:name)
41
- tag_types.any? do |context|
42
- db_column_names.include?("cached_#{context.to_s.singularize}_list")
43
- end
44
- end
45
-
46
- # @private
47
- def _add_tags_caching_methods
48
- send :include, ActsAsTaggableOn::Taggable::Cache::InstanceMethods
49
- extend ActsAsTaggableOn::Taggable::Cache::ClassMethods
50
-
51
- before_save :save_cached_tag_list
52
-
53
- initialize_tags_cache
54
- end
55
- end
56
-
57
- module ClassMethods
58
- def initialize_tags_cache
59
- tag_types.map(&:to_s).each do |tag_type|
60
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
61
- def self.caching_#{tag_type.singularize}_list?
62
- caching_tag_list_on?("#{tag_type}")
63
- end
64
- RUBY
65
- end
66
- end
67
-
68
- def acts_as_taggable_on(*args)
69
- super(*args)
70
- initialize_tags_cache
71
- end
72
-
73
- def caching_tag_list_on?(context)
74
- column_names.include?("cached_#{context.to_s.singularize}_list")
75
- end
76
- end
77
-
78
- module InstanceMethods
79
- def save_cached_tag_list
80
- tag_types.map(&:to_s).each do |tag_type|
81
- if self.class.send("caching_#{tag_type.singularize}_list?") && tag_list_cache_set_on(tag_type)
82
- list = tag_list_cache_on(tag_type).to_a.flatten.compact.join("#{ActsAsTaggableOn.delimiter} ")
83
- self["cached_#{tag_type.singularize}_list"] = list
84
- end
85
- end
86
-
87
- true
88
- end
89
- end
90
- end
91
- end
92
- end
@@ -1,6 +0,0 @@
1
- $stderr.puts <<EOF
2
- You are requiring 'acts_as_taggable_on' in the 'acts-as-taggable-on' gem.
3
-
4
- Please change your require to 'acts-as-taggable-on'.
5
- EOF
6
- require_relative 'acts-as-taggable-on'