gutentag 2.6.1 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a57320061f9e3181385744a38c797564a7ce45c2fceb6e51ba3bc7a5e7a4d68
4
- data.tar.gz: 86d6f5d761a18434e20919b1996234896f33f5764ed2f6032cca5dbe82164e2a
3
+ metadata.gz: 98f15b646e502b6b79038023b1e36b4b1d148cb99744134254165ad0997733ff
4
+ data.tar.gz: d5f73cf67e7c0992a01730506a63567ecb62bf27bd934036c04c2fa80383eff6
5
5
  SHA512:
6
- metadata.gz: 45e211fdef9849824571e960dfe21d68eaa77ca2244375952e823e031bc112d797f55513aa7adf25c6469d399ba9f7e045c7714cf875c13a754823e91cea3f17
7
- data.tar.gz: 86f48f5be03702882c074ff36d055ca735ca97ef0ae9befa1fd95e750cbcea7c44b0f00e52a4df19f8007fb361816661e7415035a083ed288fd01e4f003884b8
6
+ metadata.gz: 3fcff8de1bf31f8c7c31183c868445e68e4ea22b836c55512b8b423efeaee1cc72f2b6b40cf5e7d3749371a87a3e8627318aa831ceb8b6a2aaeb6b30f30237fb
7
+ data.tar.gz: 538d5d06ce5ddad20ea227cc6ea090d6b2cead6afe97259fa7d01f6c7f80863c86ca13a66e9c8ab39f56d22ea6f34106e3cc1f32a5ce2a92d15021d3a055a0ef
@@ -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:10
31
+ image: postgres:13.5
30
32
  env:
31
33
  POSTGRES_USER: root
32
34
  POSTGRES_PASSWORD: gutentag
33
- POSTGRES_DB: test
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: test
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
@@ -1,6 +1,10 @@
1
1
  *.lock
2
+ data
2
3
  gemfiles
3
4
  pkg/*
4
5
  spec/internal/db/*.sqlite
5
6
  spec/internal/db/migrate/
7
+ .overmind.env
8
+ .rspec
6
9
  .rubocop-*-yml
10
+ .tool-versions
data/.rubocop.yml CHANGED
@@ -7,6 +7,7 @@ AllCops:
7
7
  TargetRubyVersion: 2.3
8
8
  Exclude:
9
9
  - gemfiles/*.gemfile
10
+ - spec/internal/db/migrate/*
10
11
  - vendor/**/*
11
12
 
12
13
  Bundler/DuplicatedGem:
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
- appraise "rails_6_0" do
39
- gem "rails", "~> 6.0.0"
40
- gem "pg", "~> 1.0", :platform => :ruby
41
- gem "mysql2", "~> 0.5.0", :platform => :ruby
42
- gem "sqlite3", "~> 1.4", :platform => :ruby
43
- end if RUBY_VERSION.to_f >= 2.5 && RUBY_PLATFORM != "java"
44
-
45
- appraise "rails_6_1" do
46
- gem "rails", "~> 6.1.0"
47
- gem "pg", "~> 1.0", :platform => :ruby
48
- gem "mysql2", "~> 0.5.0", :platform => :ruby
49
- gem "sqlite3", "~> 1.4", :platform => :ruby
50
- end if RUBY_VERSION.to_f >= 2.5 && RUBY_PLATFORM != "java"
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,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.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
+
5
16
  ## 2.6.1 - 2021-09-18
6
17
 
7
18
  ### Fixed
data/Gemfile CHANGED
@@ -20,3 +20,6 @@ gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.23", :platform => :jruby
20
20
  gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.23", :platform => :jruby
21
21
 
22
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
@@ -0,0 +1,2 @@
1
+ postgres: postgres -D data/postgres -p ${POSTGRES_PORT:-5432}
2
+ mysql: $(brew --prefix mysql@5.7)/bin/mysqld --datadir=$(PWD)/data/mysql --port ${MYSQL_PORT:-3306} --socket=mysql.sock
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://travis-ci.org/pat/gutentag.svg?branch=master)](https://travis-ci.org/pat/gutentag)
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-v2.6, JRuby v9.2.5
84
- * Rails/ActiveRecord: v4.0-v6.1
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
 
@@ -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-2021, Gutentag is developed and maintained by Pat Allan, and is released under the open MIT Licence.
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
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.1"
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"
@@ -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", nil
23
+ @attributes.write_from_database "tag_names", []
24
+ @prepared_tag_names = false
24
25
  end
25
26
 
26
27
  def tag_names
27
- # If the underlying value is nil, we've not requested this from the
28
- # database yet.
29
- self.tag_names = tags.pluck(:name) if super.nil?
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
- @attributes.write_from_database "tag_names", tags.pluck(:name)
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
@@ -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.1
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: 2021-09-18 00:00:00.000000000 Z
11
+ date: 2022-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -150,10 +150,12 @@ files:
150
150
  - CHANGELOG.md
151
151
  - Gemfile
152
152
  - LICENCE
153
+ - Procfile.support
153
154
  - README.md
154
155
  - Rakefile
155
156
  - app/models/gutentag/tag.rb
156
157
  - app/models/gutentag/tagging.rb
158
+ - bin/test
157
159
  - db/migrate/1_gutentag_tables.rb
158
160
  - db/migrate/2_gutentag_cache_counter.rb
159
161
  - db/migrate/3_no_null_counters.rb
@@ -198,7 +200,7 @@ homepage: https://github.com/pat/gutentag
198
200
  licenses:
199
201
  - MIT
200
202
  metadata: {}
201
- post_install_message:
203
+ post_install_message:
202
204
  rdoc_options: []
203
205
  require_paths:
204
206
  - lib
@@ -213,8 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
215
  - !ruby/object:Gem::Version
214
216
  version: '0'
215
217
  requirements: []
216
- rubygems_version: 3.1.2
217
- signing_key:
218
+ rubygems_version: 3.3.3
219
+ signing_key:
218
220
  specification_version: 4
219
221
  summary: Good Tags
220
222
  test_files: []