gutentag 2.6.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98f15b646e502b6b79038023b1e36b4b1d148cb99744134254165ad0997733ff
4
- data.tar.gz: d5f73cf67e7c0992a01730506a63567ecb62bf27bd934036c04c2fa80383eff6
3
+ metadata.gz: adb59cbc5cd83581ef775e99cb94b81f45cb5ecc9ba75f2e6fe961cdcd955eb2
4
+ data.tar.gz: 0cce71108169f9801466f7448aada0b90c37f548d43b7d0b4a2f1aca1e71b090
5
5
  SHA512:
6
- metadata.gz: 3fcff8de1bf31f8c7c31183c868445e68e4ea22b836c55512b8b423efeaee1cc72f2b6b40cf5e7d3749371a87a3e8627318aa831ceb8b6a2aaeb6b30f30237fb
7
- data.tar.gz: 538d5d06ce5ddad20ea227cc6ea090d6b2cead6afe97259fa7d01f6c7f80863c86ca13a66e9c8ab39f56d22ea6f34106e3cc1f32a5ce2a92d15021d3a055a0ef
6
+ metadata.gz: c1287091c8fc104f9e0aeef3475c1ff8c02414cc7aa27f0d9b8dd578214e3d9b2b4549e284bf56beb3f1c8438984f823542b362cf2fc86602c3e581a2dcab066
7
+ data.tar.gz: c3756b774873e7e0342d1371b6473566dfa136cdbf60994ccc82fbb89d8f5c2c0c70d7ec5a4faeb0c08f832c9275e4e17700cae3a54ea98218e8ac88b639f65a
@@ -1,34 +1,20 @@
1
1
  name: CI
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  test:
7
- runs-on: ubuntu-18.04
7
+ runs-on: ubuntu-22.04
8
8
 
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.1' ]
13
- bundler: [ '1.17.3', '2.1.4' ]
12
+ ruby: [ '3.0', '3.1', '3.2', '3.3', '3.4' ]
14
13
  database: [ 'mysql', 'postgresql', 'sqlite' ]
15
- exclude:
16
- - ruby: '2.4'
17
- bundler: '2.1.4'
18
- - ruby: '2.5'
19
- bundler: '2.1.4'
20
- - ruby: '2.6'
21
- bundler: '2.1.4'
22
- - ruby: '2.7'
23
- bundler: '1.17.3'
24
- - ruby: '3.0'
25
- bundler: '1.17.3'
26
- - ruby: '3.1'
27
- bundler: '1.17.3'
28
14
 
29
15
  services:
30
16
  postgres:
31
- image: postgres:13.5
17
+ image: postgres:16
32
18
  env:
33
19
  POSTGRES_USER: root
34
20
  POSTGRES_PASSWORD: gutentag
@@ -47,26 +33,16 @@ jobs:
47
33
 
48
34
  steps:
49
35
  - name: Check out code
50
- uses: actions/checkout@v2
36
+ uses: actions/checkout@v4
51
37
  - name: Set up ruby
52
38
  uses: ruby/setup-ruby@v1
53
39
  with:
54
40
  ruby-version: ${{ matrix.ruby }}
55
- bundler: ${{ matrix.bundler }}
56
41
  bundler-cache: true
57
-
58
- - name: Set up Bundler
59
- run: |
60
- export BUNDLER_VERSION=${{ matrix.bundler }}
61
- export BUNDLE_PATH=$PWD/vendor/bundle
62
-
63
- gem update --system
64
-
65
- bundle _${{ matrix.bundler }}_ config set path $PWD/$BUNDLE_PATH
66
- bundle _${{ matrix.bundler }}_ install --jobs=4 --retry=3
67
- bundle _${{ matrix.bundler }}_ update
68
- - name: Set up Appraisal
69
- run: bundle exec appraisal update
42
+ - name: Generate Appraisal gemfiles
43
+ run: bundle exec appraisal generate
44
+ - name: Install gems for each appraisal
45
+ run: bundle exec appraisal install
70
46
  - name: Test
71
47
  env:
72
48
  CI: "true"
@@ -77,16 +53,15 @@ jobs:
77
53
  run: bundle exec appraisal rspec
78
54
 
79
55
  rubocop:
80
- runs-on: ubuntu-18.04
56
+ runs-on: ubuntu-latest
81
57
 
82
58
  steps:
83
59
  - name: Check out code
84
- uses: actions/checkout@v2
60
+ uses: actions/checkout@v4
85
61
  - name: Set up ruby
86
62
  uses: ruby/setup-ruby@v1
87
63
  with:
88
64
  ruby-version: 2.7
89
- bundler: 2.1.4
90
65
  bundler-cache: true
91
66
  - name: Rubocop
92
67
  run: bundle exec rubocop
data/Appraisals CHANGED
@@ -1,59 +1,51 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise "rails_4_0" do
4
- gem "rails", "~> 4.0.13"
5
- gem "mysql2", "~> 0.3.10", :platform => :ruby
6
- end if RUBY_VERSION.to_f < 2.4
7
-
8
- appraise "rails_4_1" do
9
- gem "rails", "~> 4.1.16"
10
- gem "mysql2", "~> 0.3.13", :platform => :ruby
11
- end if RUBY_VERSION.to_f < 2.4
12
-
13
- appraise "rails_4_2" do
14
- gem "rails", "~> 4.2.8"
15
- gem "mysql2", "~> 0.4.0", :platform => :ruby
16
-
17
- gem "activerecord-jdbcmysql-adapter", "~> 1.3.23", :platform => :jruby
18
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.23", :platform => :jruby
19
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.23", :platform => :jruby
20
- end if RUBY_VERSION.to_f < 2.7
21
-
22
- appraise "rails_5_0" do
23
- gem "rails", "~> 5.0.3"
24
- gem "mysql2", "~> 0.4.0", :platform => :ruby
25
- end if RUBY_VERSION.to_f >= 2.2 && RUBY_VERSION.to_f <= 2.7
26
-
27
- appraise "rails_5_1" do
28
- gem "rails", "~> 5.1.1"
29
- gem "mysql2", "~> 0.4.0", :platform => :ruby
30
- end if RUBY_VERSION.to_f >= 2.2 && RUBY_VERSION.to_f <= 2.7
31
-
32
- appraise "rails_5_2" do
33
- gem "rails", "~> 5.2.0"
34
- gem "pg", "~> 1.0", :platform => :ruby
35
- gem "mysql2", "~> 0.5.0", :platform => :ruby
36
- end if RUBY_VERSION.to_f >= 2.2 && RUBY_VERSION.to_f <= 2.7
37
-
38
3
  if RUBY_PLATFORM != "java"
39
- appraise "rails_6_0" do
40
- gem "rails", "~> 6.0.0"
41
- gem "pg", "~> 1.0", :platform => :ruby
42
- gem "mysql2", "~> 0.5.0", :platform => :ruby
43
- gem "sqlite3", "~> 1.4", :platform => :ruby
44
- end if RUBY_VERSION.to_f >= 2.5 && RUBY_VERSION.to_f <= 3.0
45
-
46
4
  appraise "rails_6_1" do
47
- gem "rails", "~> 6.1.0"
48
- gem "pg", "~> 1.0", :platform => :ruby
49
- gem "mysql2", "~> 0.5.0", :platform => :ruby
50
- gem "sqlite3", "~> 1.4", :platform => :ruby
51
- end if RUBY_VERSION.to_f >= 2.5
5
+ gem "rails", "~> 6.1.0"
6
+ gem "rspec-rails", "~> 6.1"
7
+ gem "pg", "~> 1.0", :platform => :ruby
8
+ gem "mysql2", "~> 0.5.0", :platform => :ruby
9
+ gem "sqlite3", "~> 1.4", :platform => :ruby
10
+ end
52
11
 
53
12
  appraise "rails_7_0" do
54
- gem "rails", "~> 7.0.1"
55
- gem "pg", "~> 1.0", :platform => :ruby
56
- gem "mysql2", "~> 0.5.0", :platform => :ruby
57
- gem "sqlite3", "~> 1.4", :platform => :ruby
58
- end if RUBY_VERSION.to_f >= 2.7
13
+ gem "rails", "~> 7.0.8.6"
14
+ gem "rspec-rails", "~> 7.1"
15
+ gem "pg", "~> 1.0", :platform => :ruby
16
+ gem "mysql2", "~> 0.5.0", :platform => :ruby
17
+ gem "sqlite3", "~> 1.4", :platform => :ruby
18
+ end
19
+
20
+ appraise "rails_7_1" do
21
+ gem "rails", "~> 7.1.5"
22
+ gem "rspec-rails", "~> 7.1"
23
+ gem "pg", "~> 1.0", :platform => :ruby
24
+ gem "mysql2", "~> 0.5.0", :platform => :ruby
25
+ gem "sqlite3", "~> 2.0", :platform => :ruby
26
+ end if RUBY_VERSION.to_f >= 3.1
27
+
28
+ appraise "rails_7_2" do
29
+ gem "rails", "~> 7.2.2"
30
+ gem "rspec-rails", "~> 7.1"
31
+ gem "pg", "~> 1.0", :platform => :ruby
32
+ gem "mysql2", "~> 0.5.0", :platform => :ruby
33
+ gem "sqlite3", "~> 2.0", :platform => :ruby
34
+ end if RUBY_VERSION.to_f >= 3.1
35
+
36
+ appraise "rails_8_0" do
37
+ gem "rails", "~> 8.0.0"
38
+ gem "rspec-rails", "~> 8.0"
39
+ gem "pg", "~> 1.0", :platform => :ruby
40
+ gem "mysql2", "~> 0.5.0", :platform => :ruby
41
+ gem "sqlite3", "~> 2.3", :platform => :ruby
42
+ end if RUBY_VERSION.to_f >= 3.2
43
+
44
+ appraise "rails_8_1" do
45
+ gem "rails", "~> 8.1.0"
46
+ gem "rspec-rails", "~> 8.0"
47
+ gem "pg", "~> 1.0", :platform => :ruby
48
+ gem "mysql2", "~> 0.5.0", :platform => :ruby
49
+ gem "sqlite3", "~> 2.3", :platform => :ruby
50
+ end if RUBY_VERSION.to_f >= 3.2
59
51
  end
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project (at least, from v0.5.0 onwards) will be documented in this file.
4
4
 
5
+ ## 3.0.0 - 2025-11-21
6
+
7
+ ### Breaking
8
+
9
+ This release is all about which versions of Ruby and Rails are supported.
10
+
11
+ * Removing official support for Ruby 2.4-2.7 (2.7 may continue to work, but is not covered by CI).
12
+ * Removing official support for Rails 4.0-6.0 (5.2 and 6.0 may continue to work, but are not covered by CI).
13
+ * Adding official support for Ruby 3.2-3.4 (though no code changes were required for this).
14
+ * Adding official support for Rails 7.1-8.1 (one change from [Urban Hafner](https://github.com/ujh) in [#87](https://github.com/pat/gutentag/pull/87) assisted with this for Rails 8.0).
15
+
5
16
  ## 2.6.2 - 2022-11-05
6
17
 
7
18
  ### Fixed
data/Gemfile CHANGED
@@ -4,22 +4,24 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "test-unit", :platform => :ruby_22
8
-
9
- gem "mysql2", "~> 0.3", :platform => :ruby
10
- gem "pg", "~> 0.18", :platform => :ruby
7
+ gem "mysql2", "~> 0.5", :platform => :ruby
8
+ gem "pg", "~> 1.0", :platform => :ruby
11
9
 
12
10
  if RUBY_VERSION.to_f < 3.0
13
11
  gem "sqlite3", "~> 1.3.13"
14
12
  else
15
- gem "sqlite3", "~> 1.4"
13
+ gem "sqlite3", ">= 1.4"
16
14
  end
17
15
 
18
16
  gem "activerecord-jdbcmysql-adapter", ">= 1.3.23", :platform => :jruby
19
17
  gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.23", :platform => :jruby
20
18
  gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.23", :platform => :jruby
21
19
 
22
- gem "activerecord", [">= 3.2.22"] if RUBY_PLATFORM == "java"
20
+ gem "activerecord", [">= 5.2"] if RUBY_PLATFORM == "java"
23
21
 
24
22
  # Required for testing Rails 6.1 on MRI 3.1+
25
23
  gem "net-smtp" if RUBY_VERSION.to_f > 3.0
24
+ # mutex_m is no longer a default gem in MRI 3.4, warnings in 3.3
25
+ gem "mutex_m" if RUBY_VERSION.to_f > 3.2
26
+ # drb is no longer a default gem in MRI 4.0, warnings in 3.4
27
+ gem "drb" if RUBY_VERSION.to_f > 3.3
data/README.md CHANGED
@@ -93,19 +93,21 @@ Gutentag::Tag.names_for_scope(Article.order(created_at: :desc).limit(2))
93
93
 
94
94
  ### Dependencies
95
95
 
96
- These are the versions the test suite runs against. It's possible it may work on older versions of Ruby, but it definitely won't work on older versions of Rails.
96
+ These are the versions the current test suite runs against. It's possible that the gem may work on slightly older versions (Ruby 2.7, Rails 5.2).
97
97
 
98
- * Ruby: MRI v2.3-v3.1, JRuby v9.2.5
99
- * Rails/ActiveRecord: v4.0-v7.0
98
+ * Ruby: MRI v3.0-v3.4
99
+ * Rails/ActiveRecord: v6.1-v8.1
100
100
 
101
- If you're using MRI v2.2 and/or ActiveRecord v3.2, the last version of Gutentag that fully supported those versions is v2.4.1.
101
+ If you're using Ruby v2.4-2.7 and/or ActiveRecord v4.0-6.0, the last release of Gutentag that officially supported those versions is v2.6.2, though the v3.0.0 release may be fine.
102
+
103
+ If you're using Ruby v2.2 and/or ActiveRecord v3.2, the last release of Gutentag that fully supported those versions is v2.4.1.
102
104
 
103
105
  ### Installing
104
106
 
105
107
  Get it into your Gemfile - and don't forget the version constraint!
106
108
 
107
109
  ```Ruby
108
- gem 'gutentag', '~> 2.6'
110
+ gem 'gutentag', '~> 3.0'
109
111
  ```
110
112
 
111
113
  Next: your tags get persisted to your database, so let's import the migrations, update them to your current version of Rails, and then migrate:
@@ -194,4 +196,4 @@ Please note that this project now has a [Contributor Code of Conduct](http://con
194
196
 
195
197
  <h2 id="licence">Licence</h2>
196
198
 
197
- Copyright (c) 2013-2022, Gutentag is developed and maintained by Pat Allan, and is released under the open MIT Licence.
199
+ Copyright (c) 2013-2025, Gutentag is developed and maintained by Pat Allan, and is released under the open MIT Licence.
@@ -33,7 +33,7 @@ class Gutentag::Tag < ActiveRecord::Base
33
33
  end
34
34
 
35
35
  def name=(value)
36
- super(Gutentag.normaliser.call(value))
36
+ write_attribute(:name, Gutentag.normaliser.call(value))
37
37
  end
38
38
  end
39
39
 
data/gutentag.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "gutentag"
5
- s.version = "2.6.2"
5
+ s.version = "3.0.0"
6
6
  s.authors = ["Pat Allan"]
7
7
  s.email = ["pat@freelancing-gods.com"]
8
8
  s.homepage = "https://github.com/pat/gutentag"
@@ -16,12 +16,12 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_runtime_dependency "activerecord", ">= 3.2.0"
18
18
 
19
- s.add_development_dependency "appraisal", "~> 2.4.1"
19
+ s.add_development_dependency "appraisal", "~> 2.5.0"
20
20
  s.add_development_dependency "bundler", ">= 1.17"
21
21
  s.add_development_dependency "combustion", "~> 1.1"
22
- s.add_development_dependency "database_cleaner", "~> 1.6"
22
+ s.add_development_dependency "database_cleaner", "~> 2.1"
23
23
  s.add_development_dependency "rails"
24
- s.add_development_dependency "rspec-rails", "~> 3.1"
24
+ s.add_development_dependency "rspec-rails", ">= 5.1.2"
25
25
  s.add_development_dependency "rubocop", "~> 0.81.0"
26
26
  s.add_development_dependency "rubocop-performance", "~> 1"
27
27
  end
@@ -4,20 +4,4 @@ module Gutentag::ActiveRecord::ClassMethods
4
4
  def tagged_with(options)
5
5
  Gutentag::TaggedWith.call self, options
6
6
  end
7
-
8
- if ActiveRecord::VERSION::STRING.to_f < 4.2
9
- def skip_time_zone_conversion_for_attributes
10
- super + [:tag_names]
11
- end
12
- end
13
-
14
- if ActiveRecord::VERSION::STRING.to_f < 4.0
15
- def create_time_zone_conversion_attribute?(attr_name, column)
16
- attr_name != "tag_names" && super
17
- end
18
-
19
- def attribute_cast_code(attr_name)
20
- attr_name == "tag_names" ? "v" : super
21
- end
22
- end
23
7
  end
@@ -11,12 +11,7 @@ module Gutentag::ActiveRecord::InstanceMethods
11
11
  # the instance directly (e.g. article.tags << tag), which invokes the save
12
12
  # callbacks, but the old tag_names value is stored but not updated.
13
13
  def reset_tag_names
14
- # Rails 5.1 introduces major changes to how ActiveModel::Dirty works:
15
- # https://github.com/pat/gutentag/pull/70#issuecomment-524605448
16
- # For Rails <5.1 we'll use *_previously_changed?
17
- # and for 5.1+ we'll use saved_change_to_*?
18
- return if AR_VERSION < 5.1 && tag_names_previously_changed?
19
- return if AR_VERSION >= 5.1 && saved_change_to_tag_names?
14
+ return if saved_change_to_tag_names?
20
15
 
21
16
  # Update the underlying value rather than going through the setter, to
22
17
  # ensure this update doesn't get marked as a 'change'.
@@ -31,45 +31,20 @@ class Gutentag::ActiveRecord
31
31
  end
32
32
 
33
33
  def add_attribute
34
- if ActiveRecord::VERSION::STRING.to_f <= 4.2
35
- model.define_attribute_method "tag_names"
36
- else
37
- model.attribute "tag_names", ActiveRecord::Type::Value.new,
38
- :default => default_tag_names
39
- end
34
+ model.attribute "tag_names", ActiveRecord::Type::Value.new,
35
+ :default => nil
40
36
  end
41
37
 
42
38
  def add_callbacks
43
39
  model.after_save :persist_tags
44
-
45
- if legacy?
46
- model.after_save :reset_tag_names
47
- else
48
- model.after_commit :reset_tag_names, :on => %i[ create update ]
49
- end
40
+ model.after_commit :reset_tag_names, :on => %i[ create update ]
50
41
  end
51
42
 
52
43
  def add_methods
53
- case ActiveRecord::VERSION::STRING.to_f
54
- when 3.2..4.1
55
- require "gutentag/active_record/instance_methods_3_2"
56
- when 4.2
57
- require "gutentag/active_record/instance_methods_4_2"
58
- else
59
- require "gutentag/active_record/instance_methods"
60
- end
61
-
62
44
  model.send :extend, Gutentag::ActiveRecord::ClassMethods
63
45
  model.send :include, Gutentag::ActiveRecord::InstanceMethods
64
46
  end
65
-
66
- def default_tag_names
67
- ActiveRecord::VERSION::STRING.to_f <= 4.2 ? [] : nil
68
- end
69
-
70
- def legacy?
71
- ActiveRecord::VERSION::STRING.to_f < 4.2
72
- end
73
47
  end
74
48
 
75
49
  require "gutentag/active_record/class_methods"
50
+ require "gutentag/active_record/instance_methods"
@@ -10,10 +10,6 @@ module Gutentag
10
10
  def update_migration_versions
11
11
  superclass = "ActiveRecord::Migration[#{rails_version}]"
12
12
 
13
- if ::ActiveRecord::VERSION::MAJOR < 5
14
- superclass = "ActiveRecord::Migration"
15
- end
16
-
17
13
  migration_files.each do |file|
18
14
  gsub_file file,
19
15
  /< ActiveRecord::Migration\[4\.2\]$/,
@@ -9,10 +9,7 @@ class Gutentag::TagValidations
9
9
  :uniqueness => {:case_sensitive => false}
10
10
  }.freeze
11
11
  DATABASE_ERROR_CLASSES = lambda {
12
- classes = []
13
- if ActiveRecord::VERSION::STRING.to_f > 4.0
14
- classes << ActiveRecord::NoDatabaseError
15
- end
12
+ classes = [ActiveRecord::NoDatabaseError]
16
13
  classes << ActiveRecord::ConnectionNotEstablished
17
14
  classes << Mysql2::Error if defined?(::Mysql2)
18
15
  classes << PG::ConnectionBad if defined?(::PG)
data/lib/gutentag.rb CHANGED
@@ -3,14 +3,6 @@
3
3
  require "active_record/version"
4
4
 
5
5
  module Gutentag
6
- def self.dirtier
7
- @dirtier
8
- end
9
-
10
- def self.dirtier=(dirtier)
11
- @dirtier = dirtier
12
- end
13
-
14
6
  def self.normaliser
15
7
  @normaliser ||= lambda { |tag_name| tag_name.to_s.downcase }
16
8
  end
@@ -30,14 +22,11 @@ end
30
22
 
31
23
  require "gutentag/active_record"
32
24
  require "gutentag/change_state"
33
- require "gutentag/dirty"
34
25
  require "gutentag/persistence"
35
26
  require "gutentag/remove_unused"
36
27
  require "gutentag/tag_names"
37
28
  require "gutentag/tagged_with"
38
29
 
39
- Gutentag.dirtier = Gutentag::Dirty if ActiveRecord::VERSION::STRING.to_f < 4.2
40
-
41
30
  if defined?(Rails::Engine)
42
31
  require "gutentag/engine"
43
32
  else
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/setup"
4
+ require "logger"
4
5
 
5
6
  Bundler.require :default, :development
6
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gutentag
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-05 00:00:00.000000000 Z
11
+ date: 2025-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.4.1
33
+ version: 2.5.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.4.1
40
+ version: 2.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.6'
75
+ version: '2.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.6'
82
+ version: '2.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rails
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '3.1'
103
+ version: 5.1.2
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '3.1'
110
+ version: 5.1.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -164,10 +164,7 @@ files:
164
164
  - lib/gutentag/active_record.rb
165
165
  - lib/gutentag/active_record/class_methods.rb
166
166
  - lib/gutentag/active_record/instance_methods.rb
167
- - lib/gutentag/active_record/instance_methods_3_2.rb
168
- - lib/gutentag/active_record/instance_methods_4_2.rb
169
167
  - lib/gutentag/change_state.rb
170
- - lib/gutentag/dirty.rb
171
168
  - lib/gutentag/engine.rb
172
169
  - lib/gutentag/generators/migration_versions_generator.rb
173
170
  - lib/gutentag/persistence.rb
@@ -215,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
212
  - !ruby/object:Gem::Version
216
213
  version: '0'
217
214
  requirements: []
218
- rubygems_version: 3.3.3
215
+ rubygems_version: 3.5.22
219
216
  signing_key:
220
217
  specification_version: 4
221
218
  summary: Good Tags
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # For Rails <= 4.1
4
- module Gutentag::ActiveRecord::InstanceMethods
5
- # The reason we overwrite the stored value is because new tags may be added to
6
- # the instance directly (e.g. article.tags << tag), which invokes the save
7
- # callbacks, but the old tag_names value is stored but not updated.
8
- def reset_tag_names
9
- @tag_names = nil
10
- end
11
-
12
- def tag_names
13
- @tag_names ||= tags.pluck(:name)
14
- end
15
-
16
- def tag_names=(names)
17
- names = Gutentag::TagNames.call(names)
18
-
19
- Gutentag.dirtier.call self, names if Gutentag.dirtier.present?
20
-
21
- @tag_names = names
22
- end
23
-
24
- private
25
-
26
- def persist_tags
27
- Gutentag::Persistence.new(Gutentag::ChangeState.new(self)).persist
28
- end
29
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # For Rails 4.2 only.
4
- module Gutentag::ActiveRecord::InstanceMethods
5
- # The reason we overwrite the stored value is because new tags may be added to
6
- # the instance directly (e.g. article.tags << tag), which invokes the save
7
- # callbacks, but the old tag_names value is stored but not updated.
8
- def reset_tag_names
9
- # Update the underlying value rather than going through the setter, to
10
- # ensure this update doesn't get marked as a 'change'.
11
- @tag_names = nil
12
- end
13
-
14
- def tag_names
15
- @tag_names ||= begin
16
- raw = tags.pluck(:name)
17
- raw_write_attribute "tag_names", raw
18
- raw
19
- end
20
- end
21
-
22
- def tag_names=(names)
23
- new_names = Gutentag::TagNames.call names
24
- return if new_names.sort == tag_names.sort
25
-
26
- tag_names_will_change!
27
-
28
- write_attribute "tag_names", new_names
29
- @tag_names = new_names
30
- end
31
-
32
- private
33
-
34
- def persist_tags
35
- Gutentag::Persistence.new(Gutentag::ChangeState.new(self)).persist
36
- end
37
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Gutentag::Dirty
4
- def self.call(instance, tag_names)
5
- new(instance, tag_names).call
6
- end
7
-
8
- def initialize(instance, tag_names)
9
- @instance = instance
10
- @tag_names = tag_names
11
- end
12
-
13
- def call
14
- return unless changes.present?
15
-
16
- instance.tag_names_will_change!
17
- instance.changed_attributes[:tag_names] = existing
18
- end
19
-
20
- private
21
-
22
- attr_reader :instance, :tag_names
23
-
24
- def changes
25
- (existing + tag_names).uniq - (existing & tag_names)
26
- end
27
-
28
- def existing
29
- instance.tag_names
30
- end
31
- end