gutentag 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +12 -5
- data/Appraisals +21 -11
- data/CHANGELOG.md +11 -0
- data/Gemfile +7 -7
- data/README.md +14 -20
- data/gutentag.gemspec +4 -5
- data/lib/gutentag/active_record/instance_methods.rb +1 -1
- data/spec/acceptance/dirty_state_spec.rb +9 -1
- data/spec/internal/app/models/thinkpiece.rb +0 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/support/mysql.rb +27 -0
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53b60a0cb99836a7c475d6fee7b431f99e38c16976f914e3591e86530c1d5b7b
|
4
|
+
data.tar.gz: 564c325549cf3f51ceb24a5986a06d5ad66b81f1a07b948a1875b4e1d8ebead5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcb6dba995fc07e770dbd605d667501dba90ed153c6c40ff825e53276890a2a7fb2e5d4f13cef3573a094d0b25fb1645baa956aeccdf3e1bfad8e6b0f8ade58e
|
7
|
+
data.tar.gz: df7591b2ed083abb732c447ecf1b916d540edc168b4542bca99fe41e03e8135f2cee6745b2a43d2e68cc9466da411e578db4bac40264123d3cf88ee5da84b502
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
language: ruby
|
2
|
+
dist: xenial
|
2
3
|
script: bundle exec appraisal rake
|
3
4
|
rvm:
|
4
5
|
- 2.2.10
|
5
|
-
- 2.3.
|
6
|
-
- 2.4.
|
7
|
-
- 2.5.
|
8
|
-
-
|
6
|
+
- 2.3.8
|
7
|
+
- 2.4.5
|
8
|
+
- 2.5.3
|
9
|
+
- 2.6.1
|
10
|
+
- jruby-9.2.5.0
|
9
11
|
before_install:
|
10
|
-
- gem install bundler
|
12
|
+
- gem install bundler --version 1.17.3
|
13
|
+
install:
|
14
|
+
- bundle _1.17.3_ install --jobs=3 --retry=3
|
11
15
|
before_script:
|
12
16
|
- bundle exec appraisal install
|
13
17
|
env:
|
14
18
|
- DATABASE=postgres
|
15
19
|
- DATABASE=mysql
|
16
20
|
- DATABASE=sqlite
|
21
|
+
services:
|
22
|
+
- mysql
|
23
|
+
- postgresql
|
data/Appraisals
CHANGED
@@ -1,37 +1,47 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
appraise "rails_3_2" do
|
4
|
-
gem "rails",
|
5
|
-
gem "mysql2",
|
4
|
+
gem "rails", "~> 3.2.22.5"
|
5
|
+
gem "mysql2", "~> 0.3.10", :platform => :ruby
|
6
6
|
end if RUBY_VERSION.to_f <= 2.2
|
7
7
|
|
8
8
|
appraise "rails_4_0" do
|
9
|
-
gem "rails",
|
10
|
-
gem "mysql2",
|
9
|
+
gem "rails", "~> 4.0.13"
|
10
|
+
gem "mysql2", "~> 0.3.10", :platform => :ruby
|
11
11
|
end if RUBY_VERSION.to_f < 2.4
|
12
12
|
|
13
13
|
appraise "rails_4_1" do
|
14
|
-
gem "rails",
|
15
|
-
gem "mysql2",
|
14
|
+
gem "rails", "~> 4.1.16"
|
15
|
+
gem "mysql2", "~> 0.3.13", :platform => :ruby
|
16
16
|
end if RUBY_VERSION.to_f < 2.4
|
17
17
|
|
18
18
|
appraise "rails_4_2" do
|
19
|
-
gem "rails",
|
20
|
-
gem "mysql2",
|
19
|
+
gem "rails", "~> 4.2.8"
|
20
|
+
gem "mysql2", "~> 0.4.0", :platform => :ruby
|
21
|
+
|
22
|
+
gem "activerecord-jdbcmysql-adapter", "~> 1.3.23", :platform => :jruby
|
23
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.23", :platform => :jruby
|
24
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.23", :platform => :jruby
|
21
25
|
end
|
22
26
|
|
23
27
|
appraise "rails_5_0" do
|
24
28
|
gem "rails", "~> 5.0.3"
|
25
29
|
gem "mysql2", "~> 0.4.0", :platform => :ruby
|
26
|
-
end if RUBY_VERSION.to_f >= 2.2
|
30
|
+
end if RUBY_VERSION.to_f >= 2.2
|
27
31
|
|
28
32
|
appraise "rails_5_1" do
|
29
33
|
gem "rails", "~> 5.1.1"
|
30
34
|
gem "mysql2", "~> 0.4.0", :platform => :ruby
|
31
|
-
end if RUBY_VERSION.to_f >= 2.2
|
35
|
+
end if RUBY_VERSION.to_f >= 2.2
|
32
36
|
|
33
37
|
appraise "rails_5_2" do
|
34
38
|
gem "rails", "~> 5.2.0"
|
35
39
|
gem "pg", "~> 1.0", :platform => :ruby
|
36
40
|
gem "mysql2", "~> 0.5.0", :platform => :ruby
|
37
|
-
end if RUBY_VERSION.to_f >= 2.2
|
41
|
+
end if RUBY_VERSION.to_f >= 2.2
|
42
|
+
|
43
|
+
appraise "rails_6_0" do
|
44
|
+
gem "rails", "~> 6.0.0.beta1"
|
45
|
+
gem "pg", "~> 1.0", :platform => :ruby
|
46
|
+
gem "mysql2", "~> 0.5.0", :platform => :ruby
|
47
|
+
end if RUBY_VERSION.to_f >= 2.5 && RUBY_PLATFORM != "java"
|
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
|
+
## 2.4.1 - 2019-02-22
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
* Tests are now run against Rails 6.0, MRI 2.6, JRuby 9.2.5.
|
10
|
+
* The README documents a simpler migration ([seelensonne](https://github.com/seelensonne) in [#55](https://github.com/pat/gutentag/pull/55)).
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
* Do not record changes when tag_names did not change ([Stephen Oberther](https://github.com/smo921) in [#60](https://github.com/pat/gutentag/pull/60)).
|
15
|
+
|
5
16
|
## 2.4.0 - 2018-05-18
|
6
17
|
|
7
18
|
### Changed
|
data/Gemfile
CHANGED
@@ -6,12 +6,12 @@ gemspec
|
|
6
6
|
|
7
7
|
gem "test-unit", :platform => :ruby_22
|
8
8
|
|
9
|
-
gem "mysql2", "~> 0.3",
|
10
|
-
gem "pg", "~> 0.18",
|
11
|
-
gem "sqlite3", "~> 1.3",
|
9
|
+
gem "mysql2", "~> 0.3", :platform => :ruby
|
10
|
+
gem "pg", "~> 0.18", :platform => :ruby
|
11
|
+
gem "sqlite3", "~> 1.3.13", :platform => :ruby
|
12
12
|
|
13
|
-
gem "activerecord-jdbcmysql-adapter", "
|
14
|
-
gem "activerecord-jdbcpostgresql-adapter", "
|
15
|
-
gem "activerecord-jdbcsqlite3-adapter", "
|
13
|
+
gem "activerecord-jdbcmysql-adapter", ">= 1.3.23", :platform => :jruby
|
14
|
+
gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.23", :platform => :jruby
|
15
|
+
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.23", :platform => :jruby
|
16
16
|
|
17
|
-
gem "activerecord", [">= 3.2.22"
|
17
|
+
gem "activerecord", [">= 3.2.22"] if RUBY_PLATFORM == "java"
|
data/README.md
CHANGED
@@ -72,8 +72,8 @@ Article.tagged_with(:ids => [tag_a.id, tag_b.id], :match => :all)
|
|
72
72
|
|
73
73
|
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.
|
74
74
|
|
75
|
-
* Ruby: MRI v2.2-v2.
|
76
|
-
* Rails/ActiveRecord: v3.2-
|
75
|
+
* Ruby: MRI v2.2-v2.6, JRuby v9.2.5
|
76
|
+
* Rails/ActiveRecord: v3.2-v6.0
|
77
77
|
|
78
78
|
### Installing
|
79
79
|
|
@@ -90,31 +90,25 @@ rake gutentag:install:migrations
|
|
90
90
|
rake db:migrate
|
91
91
|
```
|
92
92
|
|
93
|
+
If you're using UUID primary keys, make sure you alter the migration files before running `db:migrate` to use UUIDs for the `taggable_id` foreign key column (as noted in [issue 57](https://github.com/pat/gutentag/issues/57).)
|
94
|
+
|
93
95
|
### Without Rails
|
94
96
|
|
95
97
|
If you want to use Gutentag outside of Rails, you can. However, there is one caveat: You'll want to set up your database with the same schema (as importing in the migrations isn't possible without Rails). The schema from 0.7.0 onwards is below:
|
96
98
|
|
97
|
-
```
|
98
|
-
create_table :gutentag_taggings do |t|
|
99
|
-
t.integer :tag_id, null: false
|
100
|
-
t.integer :taggable_id, null: false
|
101
|
-
t.string :taggable_type, null: false
|
102
|
-
t.timestamps null: false
|
103
|
-
end
|
104
|
-
|
105
|
-
add_index :gutentag_taggings, :tag_id
|
106
|
-
add_index :gutentag_taggings, [:taggable_type, :taggable_id]
|
107
|
-
add_index :gutentag_taggings, [:taggable_type, :taggable_id, :tag_id],
|
108
|
-
unique: true, name: 'unique_taggings'
|
109
|
-
|
99
|
+
```ruby
|
110
100
|
create_table :gutentag_tags do |t|
|
111
|
-
t.string
|
112
|
-
t.
|
113
|
-
t.timestamps
|
101
|
+
t.string :name, null: false, index: {unique: true}
|
102
|
+
t.bigint :taggings_count, null: false, index: true, default: 0
|
103
|
+
t.timestamps null: false
|
114
104
|
end
|
115
105
|
|
116
|
-
|
117
|
-
|
106
|
+
create_table :gutentag_taggings do |t|
|
107
|
+
t.references :tag, null: false, index: true, foreign_key: {to_table: :gutentag_tags}
|
108
|
+
t.references :taggable, null: false, index: true, polymorphic: true
|
109
|
+
t.timestamps null: false
|
110
|
+
end
|
111
|
+
add_index :gutentag_taggings, [:taggable_type, :taggable_id, :tag_id], unique: true, name: "gutentag_taggings_uniqueness"
|
118
112
|
```
|
119
113
|
|
120
114
|
<h2 id="upgrading">Upgrading</h2>
|
data/gutentag.gemspec
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# -*- encoding: utf-8 -*-
|
3
2
|
|
4
3
|
Gem::Specification.new do |s|
|
5
4
|
s.name = "gutentag"
|
6
|
-
s.version = "2.4.
|
5
|
+
s.version = "2.4.1"
|
7
6
|
s.authors = ["Pat Allan"]
|
8
7
|
s.email = ["pat@freelancing-gods.com"]
|
9
8
|
s.homepage = "https://github.com/pat/gutentag"
|
@@ -18,10 +17,10 @@ Gem::Specification.new do |s|
|
|
18
17
|
s.add_runtime_dependency "activerecord", ">= 3.2.0"
|
19
18
|
|
20
19
|
s.add_development_dependency "appraisal", "~> 2.1.0"
|
21
|
-
s.add_development_dependency "bundler", "
|
22
|
-
s.add_development_dependency "combustion", "
|
20
|
+
s.add_development_dependency "bundler", "~> 1.17"
|
21
|
+
s.add_development_dependency "combustion", "~> 1.1"
|
23
22
|
s.add_development_dependency "database_cleaner", "~> 1.6"
|
24
23
|
s.add_development_dependency "rails"
|
25
24
|
s.add_development_dependency "rspec-rails", "~> 3.1"
|
26
|
-
s.add_development_dependency "rubocop", "~> 0.
|
25
|
+
s.add_development_dependency "rubocop", "~> 0.64.0"
|
27
26
|
end
|
@@ -28,7 +28,7 @@ module Gutentag::ActiveRecord::InstanceMethods
|
|
28
28
|
def tag_names=(names)
|
29
29
|
# This value is about to be overwritten, but we want to make sure the change
|
30
30
|
# tracking doesn't think the original value was nil.
|
31
|
-
@attributes.write_from_database "tag_names",
|
31
|
+
@attributes.write_from_database "tag_names", tags.pluck(:name)
|
32
32
|
|
33
33
|
super Gutentag::TagNames.call(names)
|
34
34
|
end
|
@@ -27,7 +27,7 @@ RSpec.describe "Dirty state of tag names" do
|
|
27
27
|
|
28
28
|
it "knows what tag names have changed" do
|
29
29
|
article.tag_names = ["pancakes"]
|
30
|
-
article.save
|
30
|
+
article.save!
|
31
31
|
|
32
32
|
expect(article.tag_names).to eq(["pancakes"])
|
33
33
|
|
@@ -49,4 +49,12 @@ RSpec.describe "Dirty state of tag names" do
|
|
49
49
|
expect(article.tag_names_in_database).to eq(["pancakes"])
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
it "knows when tags have not changed" do
|
54
|
+
article.tag_names = ["pancakes"]
|
55
|
+
article.save!
|
56
|
+
|
57
|
+
article.tag_names = ["pancakes"]
|
58
|
+
expect(article.changes).to eq({})
|
59
|
+
end
|
52
60
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record"
|
4
|
+
|
5
|
+
# New versions of MySQL don't allow NULL values for primary keys, but old
|
6
|
+
# versions of Rails do. To use both at the same time, we need to update Rails'
|
7
|
+
# default primary key type to no longer have a default NULL value.
|
8
|
+
#
|
9
|
+
class PatchAdapter
|
10
|
+
def call
|
11
|
+
return unless using_mysql? && using_rails_pre_4_1?
|
12
|
+
|
13
|
+
require "active_record/connection_adapters/abstract_mysql_adapter"
|
14
|
+
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::
|
15
|
+
NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
|
16
|
+
end
|
17
|
+
|
18
|
+
def using_mysql?
|
19
|
+
ENV.fetch("DATABASE", "sqlite") == "mysql"
|
20
|
+
end
|
21
|
+
|
22
|
+
def using_rails_pre_4_1?
|
23
|
+
ActiveRecord::VERSION::STRING.to_f < 4.1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
PatchAdapter.new.call
|
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.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -42,30 +42,30 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: '1.17'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: '1.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: combustion
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '1.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '1.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: database_cleaner
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.64.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.64.0
|
125
125
|
description: A good, simple, solid tagging extension for ActiveRecord
|
126
126
|
email:
|
127
127
|
- pat@freelancing-gods.com
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- spec/models/gutentag/tag_spec.rb
|
176
176
|
- spec/models/gutentag/tagging_spec.rb
|
177
177
|
- spec/spec_helper.rb
|
178
|
+
- spec/support/mysql.rb
|
178
179
|
homepage: https://github.com/pat/gutentag
|
179
180
|
licenses:
|
180
181
|
- MIT
|