gutentag 2.6.0 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +6 -4
- data/.gitignore +4 -0
- data/.rubocop.yml +1 -0
- data/Appraisals +22 -13
- data/CHANGELOG.md +17 -0
- data/Gemfile +3 -4
- data/Procfile.support +2 -0
- data/README.md +20 -5
- data/bin/test +9 -0
- data/db/migrate/1_gutentag_tables.rb +1 -1
- data/db/migrate/2_gutentag_cache_counter.rb +1 -1
- data/db/migrate/3_no_null_counters.rb +1 -1
- data/gutentag.gemspec +2 -2
- data/lib/gutentag/active_record/instance_methods.rb +25 -5
- data/lib/gutentag/generators/migration_versions_generator.rb +9 -7
- data/spec/internal/config/database.yml +6 -0
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98f15b646e502b6b79038023b1e36b4b1d148cb99744134254165ad0997733ff
|
4
|
+
data.tar.gz: d5f73cf67e7c0992a01730506a63567ecb62bf27bd934036c04c2fa80383eff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fcff8de1bf31f8c7c31183c868445e68e4ea22b836c55512b8b423efeaee1cc72f2b6b40cf5e7d3749371a87a3e8627318aa831ceb8b6a2aaeb6b30f30237fb
|
7
|
+
data.tar.gz: 538d5d06ce5ddad20ea227cc6ea090d6b2cead6afe97259fa7d01f6c7f80863c86ca13a66e9c8ab39f56d22ea6f34106e3cc1f32a5ce2a92d15021d3a055a0ef
|
data/.github/workflows/ci.yml
CHANGED
@@ -9,7 +9,7 @@ jobs:
|
|
9
9
|
strategy:
|
10
10
|
fail-fast: false
|
11
11
|
matrix:
|
12
|
-
ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0' ]
|
12
|
+
ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.1' ]
|
13
13
|
bundler: [ '1.17.3', '2.1.4' ]
|
14
14
|
database: [ 'mysql', 'postgresql', 'sqlite' ]
|
15
15
|
exclude:
|
@@ -23,14 +23,16 @@ jobs:
|
|
23
23
|
bundler: '1.17.3'
|
24
24
|
- ruby: '3.0'
|
25
25
|
bundler: '1.17.3'
|
26
|
+
- ruby: '3.1'
|
27
|
+
bundler: '1.17.3'
|
26
28
|
|
27
29
|
services:
|
28
30
|
postgres:
|
29
|
-
image: postgres:
|
31
|
+
image: postgres:13.5
|
30
32
|
env:
|
31
33
|
POSTGRES_USER: root
|
32
34
|
POSTGRES_PASSWORD: gutentag
|
33
|
-
POSTGRES_DB:
|
35
|
+
POSTGRES_DB: gutentag
|
34
36
|
ports: ['5432:5432']
|
35
37
|
# needed because the postgres container does not provide a healthcheck
|
36
38
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
@@ -39,7 +41,7 @@ jobs:
|
|
39
41
|
image: mysql:5.7
|
40
42
|
env:
|
41
43
|
MYSQL_ROOT_PASSWORD: gutentag
|
42
|
-
MYSQL_DATABASE:
|
44
|
+
MYSQL_DATABASE: gutentag
|
43
45
|
ports: ['3306:3306']
|
44
46
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
45
47
|
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Appraisals
CHANGED
@@ -35,16 +35,25 @@ appraise "rails_5_2" do
|
|
35
35
|
gem "mysql2", "~> 0.5.0", :platform => :ruby
|
36
36
|
end if RUBY_VERSION.to_f >= 2.2 && RUBY_VERSION.to_f <= 2.7
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
38
|
+
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
|
+
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
|
52
|
+
|
53
|
+
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
|
59
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,23 @@
|
|
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.6.2 - 2022-11-05
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
* Documenting the `Gutentag::Tag.names_for_scope` method. ([Ryan Romanchuk](https://github.com/rromanchuk) in [#83](https://github.com/pat/gutentag/pull/83)).
|
10
|
+
* Avoid double-querying of tag_names from the database. See discussion in [#84](https://github.com/pat/gutentag/issues/84).
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
* Added Ruby 3.1 to the test matrix.
|
15
|
+
|
16
|
+
## 2.6.1 - 2021-09-18
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
* The initially-generated migrations now work out of the box with Rails 5.0+, using the 4.2 version. The generator will now update that version to the latest, or remove it for Rails 4.2. See later discussion in [#80](https://github.com/pat/gutentag/issues/80).
|
21
|
+
|
5
22
|
## 2.6.0 - 2021-07-10
|
6
23
|
|
7
24
|
### Added
|
data/Gemfile
CHANGED
@@ -4,10 +4,6 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem "appraisal",
|
8
|
-
:git => "https://github.com/marcotc/appraisal.git",
|
9
|
-
:branch => "explicit-require-set"
|
10
|
-
|
11
7
|
gem "test-unit", :platform => :ruby_22
|
12
8
|
|
13
9
|
gem "mysql2", "~> 0.3", :platform => :ruby
|
@@ -24,3 +20,6 @@ gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.23", :platform => :jruby
|
|
24
20
|
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.23", :platform => :jruby
|
25
21
|
|
26
22
|
gem "activerecord", [">= 3.2.22"] if RUBY_PLATFORM == "java"
|
23
|
+
|
24
|
+
# Required for testing Rails 6.1 on MRI 3.1+
|
25
|
+
gem "net-smtp" if RUBY_VERSION.to_f > 3.0
|
data/Procfile.support
ADDED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Gutentag
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/gutentag.svg)](http://badge.fury.io/rb/gutentag)
|
4
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/pat/gutentag/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/pat/gutentag/actions/)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/pat/gutentag.svg)](https://codeclimate.com/github/pat/gutentag)
|
6
6
|
|
7
7
|
A good, simple, solid tagging extension for ActiveRecord.
|
@@ -74,14 +74,29 @@ To return records that have _none_ of the specified tags, use `:match => :none`:
|
|
74
74
|
Article.tagged_with(:ids => [tag_a.id, tag_b.id], :match => :none)
|
75
75
|
```
|
76
76
|
|
77
|
+
To return all tag names used by an instance of a model or relation
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
# Returns array of tag names
|
81
|
+
Gutentag::Tag.names_for_scope(Article)
|
82
|
+
# => ['tag1', 'tag2', 'tag3']
|
83
|
+
|
84
|
+
Gutentag::Tag.names_for_scope(Article.where(:created_at => 1.week.ago..1.second.ago))
|
85
|
+
# => ['tag3']
|
86
|
+
|
87
|
+
# Return array of the tag names used from the two most recent articles
|
88
|
+
Gutentag::Tag.names_for_scope(Article.order(created_at: :desc).limit(2))
|
89
|
+
# => []
|
90
|
+
```
|
91
|
+
|
77
92
|
<h2 id="installation">Installation</h2>
|
78
93
|
|
79
94
|
### Dependencies
|
80
95
|
|
81
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.
|
82
97
|
|
83
|
-
* Ruby: MRI v2.3-
|
84
|
-
* Rails/ActiveRecord: v4.0-
|
98
|
+
* Ruby: MRI v2.3-v3.1, JRuby v9.2.5
|
99
|
+
* Rails/ActiveRecord: v4.0-v7.0
|
85
100
|
|
86
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.
|
87
102
|
|
@@ -90,7 +105,7 @@ If you're using MRI v2.2 and/or ActiveRecord v3.2, the last version of Gutentag
|
|
90
105
|
Get it into your Gemfile - and don't forget the version constraint!
|
91
106
|
|
92
107
|
```Ruby
|
93
|
-
gem 'gutentag', '~> 2.
|
108
|
+
gem 'gutentag', '~> 2.6'
|
94
109
|
```
|
95
110
|
|
96
111
|
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:
|
@@ -179,4 +194,4 @@ Please note that this project now has a [Contributor Code of Conduct](http://con
|
|
179
194
|
|
180
195
|
<h2 id="licence">Licence</h2>
|
181
196
|
|
182
|
-
Copyright (c) 2013-
|
197
|
+
Copyright (c) 2013-2022, Gutentag is developed and maintained by Pat Allan, and is released under the open MIT Licence.
|
data/bin/test
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -o allexport
|
4
|
+
source .overmind.env
|
5
|
+
set +o allexport
|
6
|
+
|
7
|
+
DATABASE=postgresql DB_HOST=127.0.0.1 DB_PORT=${POSTGRES_PORT} bundle exec appraisal rspec
|
8
|
+
DATABASE=mysql DB_USERNAME=${MYSQL_USERNAME} DB_PASSWORD=${MYSQL_PASSWORD} DB_HOST=127.0.0.1 DB_PORT=${MYSQL_PORT} bundle exec appraisal rspec
|
9
|
+
DATABASE=sqlite bundle exec appraisal rspec
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class GutentagCacheCounter < ActiveRecord::Migration
|
3
|
+
class GutentagCacheCounter < ActiveRecord::Migration[4.2]
|
4
4
|
def up
|
5
5
|
add_column :gutentag_tags, :taggings_count, :integer, :default => 0
|
6
6
|
add_index :gutentag_tags, :taggings_count
|
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.
|
5
|
+
s.version = "2.6.2"
|
6
6
|
s.authors = ["Pat Allan"]
|
7
7
|
s.email = ["pat@freelancing-gods.com"]
|
8
8
|
s.homepage = "https://github.com/pat/gutentag"
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_runtime_dependency "activerecord", ">= 3.2.0"
|
18
18
|
|
19
|
-
|
19
|
+
s.add_development_dependency "appraisal", "~> 2.4.1"
|
20
20
|
s.add_development_dependency "bundler", ">= 1.17"
|
21
21
|
s.add_development_dependency "combustion", "~> 1.1"
|
22
22
|
s.add_development_dependency "database_cleaner", "~> 1.6"
|
@@ -20,13 +20,20 @@ module Gutentag::ActiveRecord::InstanceMethods
|
|
20
20
|
|
21
21
|
# Update the underlying value rather than going through the setter, to
|
22
22
|
# ensure this update doesn't get marked as a 'change'.
|
23
|
-
@attributes.write_from_database "tag_names",
|
23
|
+
@attributes.write_from_database "tag_names", []
|
24
|
+
@prepared_tag_names = false
|
24
25
|
end
|
25
26
|
|
26
27
|
def tag_names
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
if super.nil? || !prepared_tag_names?
|
29
|
+
# If the underlying value is nil, we've not requested this from the
|
30
|
+
# database yet. But we also don't want to make the query twice. So, grab
|
31
|
+
# the names, prepare as needed, and make sure we also invoke the setter.
|
32
|
+
names = tags.pluck(:name)
|
33
|
+
|
34
|
+
prepare_tag_names(names)
|
35
|
+
self.tag_names = names
|
36
|
+
end
|
30
37
|
|
31
38
|
# Use ActiveRecord's underlying implementation with change tracking.
|
32
39
|
super
|
@@ -35,7 +42,7 @@ module Gutentag::ActiveRecord::InstanceMethods
|
|
35
42
|
def tag_names=(names)
|
36
43
|
# This value is about to be overwritten, but we want to make sure the change
|
37
44
|
# tracking doesn't think the original value was nil.
|
38
|
-
|
45
|
+
prepare_tag_names
|
39
46
|
|
40
47
|
super Gutentag::TagNames.call(names)
|
41
48
|
end
|
@@ -45,4 +52,17 @@ module Gutentag::ActiveRecord::InstanceMethods
|
|
45
52
|
def persist_tags
|
46
53
|
Gutentag::Persistence.new(Gutentag::ChangeState.new(self)).persist
|
47
54
|
end
|
55
|
+
|
56
|
+
def prepare_tag_names(names = nil)
|
57
|
+
return if prepared_tag_names?
|
58
|
+
|
59
|
+
names ||= tags.pluck(:name)
|
60
|
+
@attributes.write_from_database("tag_names", names)
|
61
|
+
|
62
|
+
@prepared_tag_names = true
|
63
|
+
end
|
64
|
+
|
65
|
+
def prepared_tag_names?
|
66
|
+
@prepared_tag_names ||= false
|
67
|
+
end
|
48
68
|
end
|
@@ -8,14 +8,16 @@ module Gutentag
|
|
8
8
|
desc "Update the ActiveRecord version in Gutentag migrations"
|
9
9
|
|
10
10
|
def update_migration_versions
|
11
|
+
superclass = "ActiveRecord::Migration[#{rails_version}]"
|
12
|
+
|
11
13
|
if ::ActiveRecord::VERSION::MAJOR < 5
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
superclass = "ActiveRecord::Migration"
|
15
|
+
end
|
16
|
+
|
17
|
+
migration_files.each do |file|
|
18
|
+
gsub_file file,
|
19
|
+
/< ActiveRecord::Migration\[4\.2\]$/,
|
20
|
+
"< #{superclass}"
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -9,6 +9,9 @@ test:
|
|
9
9
|
<% if ENV["DB_PASSWORD"] %>
|
10
10
|
password: <%= ENV["DB_PASSWORD"] %>
|
11
11
|
<% end %>
|
12
|
+
<% if ENV["DB_PORT"] %>
|
13
|
+
port: <%= ENV["DB_PORT"] %>
|
14
|
+
<% end %>
|
12
15
|
<% elsif ENV["DATABASE"] == "postgres" %>
|
13
16
|
test:
|
14
17
|
adapter: postgresql
|
@@ -22,6 +25,9 @@ test:
|
|
22
25
|
<% if ENV["DB_PASSWORD"] %>
|
23
26
|
password: <%= ENV["DB_PASSWORD"] %>
|
24
27
|
<% end %>
|
28
|
+
<% if ENV["DB_PORT"] %>
|
29
|
+
port: <%= ENV["DB_PORT"] %>
|
30
|
+
<% end %>
|
25
31
|
<% else %>
|
26
32
|
test:
|
27
33
|
adapter: sqlite3
|
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.
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: appraisal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.4.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.4.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,10 +150,12 @@ files:
|
|
136
150
|
- CHANGELOG.md
|
137
151
|
- Gemfile
|
138
152
|
- LICENCE
|
153
|
+
- Procfile.support
|
139
154
|
- README.md
|
140
155
|
- Rakefile
|
141
156
|
- app/models/gutentag/tag.rb
|
142
157
|
- app/models/gutentag/tagging.rb
|
158
|
+
- bin/test
|
143
159
|
- db/migrate/1_gutentag_tables.rb
|
144
160
|
- db/migrate/2_gutentag_cache_counter.rb
|
145
161
|
- db/migrate/3_no_null_counters.rb
|
@@ -184,7 +200,7 @@ homepage: https://github.com/pat/gutentag
|
|
184
200
|
licenses:
|
185
201
|
- MIT
|
186
202
|
metadata: {}
|
187
|
-
post_install_message:
|
203
|
+
post_install_message:
|
188
204
|
rdoc_options: []
|
189
205
|
require_paths:
|
190
206
|
- lib
|
@@ -199,8 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
215
|
- !ruby/object:Gem::Version
|
200
216
|
version: '0'
|
201
217
|
requirements: []
|
202
|
-
rubygems_version: 3.
|
203
|
-
signing_key:
|
218
|
+
rubygems_version: 3.3.3
|
219
|
+
signing_key:
|
204
220
|
specification_version: 4
|
205
221
|
summary: Good Tags
|
206
222
|
test_files: []
|