gutentag 2.5.0 → 2.5.1

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
- SHA1:
3
- metadata.gz: fe6d98b81a4c392bb7591418821697ceb622e80e
4
- data.tar.gz: 5299b1efed9975a5bb902d704617c41dc0a1dd38
2
+ SHA256:
3
+ metadata.gz: 2220c5448de91dad49288b5d2370588e09a08bf863f3398b1ef0eb07e54691ef
4
+ data.tar.gz: 42b8046acab85218e0e3ecea86ae5d1fb27e2ca69895567b66d66227b3070ffe
5
5
  SHA512:
6
- metadata.gz: 1ae92f80e7bd6b60bd7623a976b910ba4a9a43e97aac6b2dab3b0f2d72ee76bce9d1eaddc6a70c2bbbe4500c36cfa9ea2f055635f4e6a0b0182dd6842b43af83
7
- data.tar.gz: 2a07b209873183a7ed92d47bd2c6cecf153af767d14c2fe6e664272c6ee22032134ce4a0b194d5a0837206716cd5f99388b1c5a325c60d7c5c4bdd79aa9d0396
6
+ metadata.gz: a151247791c559ff523ebb8af939ed28a0d55932b1d99d0476fa77a6ae9bafe724526ed1f21a3eb38d05ea0a371540e15c659f69e062abfe90f33f337b7ee71d
7
+ data.tar.gz: fd7f8db5ee16bd1fb854e9d2ad3bf18dc5b48de866e307bc750a4ff525ab303981e3eddef1ac562bbe0918fdd32e088543fba7025d09a4ff2af7e87d2694c8dc
@@ -1,6 +1,8 @@
1
1
  inherit_from:
2
2
  - https://gist.githubusercontent.com/pat/ba3b8ffb1901bfe5439b460943b6b019/raw/.rubocop.yml
3
3
 
4
+ require: rubocop-performance
5
+
4
6
  AllCops:
5
7
  TargetRubyVersion: 2.3
6
8
  Exclude:
@@ -3,10 +3,10 @@ dist: xenial
3
3
  script: bundle exec appraisal rake
4
4
  rvm:
5
5
  - 2.3.8
6
- - 2.4.5
7
- - 2.5.3
8
- - 2.6.1
9
- - jruby-9.2.5.0
6
+ - 2.4.6
7
+ - 2.5.5
8
+ - 2.6.3
9
+ - jruby-9.2.7.0
10
10
  before_install:
11
11
  - gem install bundler --version 1.17.3
12
12
  install:
data/Appraisals CHANGED
@@ -36,7 +36,8 @@ appraise "rails_5_2" do
36
36
  end if RUBY_VERSION.to_f >= 2.2
37
37
 
38
38
  appraise "rails_6_0" do
39
- gem "rails", "~> 6.0.0.beta1"
40
- gem "pg", "~> 1.0", :platform => :ruby
41
- gem "mysql2", "~> 0.5.0", :platform => :ruby
39
+ gem "rails", "~> 6.0.0.beta1"
40
+ gem "pg", "~> 1.0", :platform => :ruby
41
+ gem "mysql2", "~> 0.5.0", :platform => :ruby
42
+ gem "sqlite3", "~> 1.4", :platform => :ruby
42
43
  end if RUBY_VERSION.to_f >= 2.5 && RUBY_PLATFORM != "java"
@@ -2,6 +2,12 @@
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.5.1 - 2019-05-10
6
+
7
+ ### Fixed
8
+
9
+ * Ensuring consistent behaviour for tag_names array - names are not duplicated, and are normalised prior to saving (as discussed in [issue #66](https://github.com/pat/gutentag/issues/66)).
10
+
5
11
  ## 2.5.0 - 2019-03-15
6
12
 
7
13
  **Pleease note this release ends official support of Rails 3.2 and Ruby (MRI) 2.2.** The code currently still works on Ruby 2.2, and all features except for the new `Gutentag::Tag.names_for_scope` method work in Rails 3.2, but they're no longer tested against, and cannot be guaranteed to work in future releases.
data/README.md CHANGED
@@ -16,6 +16,7 @@ If you want to know more, read [this blog post](http://freelancing-gods.com/post
16
16
  * [Installation](#installation)
17
17
  * [Upgrading](#upgrading)
18
18
  * [Configuration](#configuration)
19
+ * [Extending](#extending)
19
20
  * [Contribution](#contribution)
20
21
  * [Licence](#licence)
21
22
 
@@ -151,6 +152,19 @@ Gutentag.normaliser = lambda { |value| value.to_s.upcase }
151
152
 
152
153
  Gutentag ignores case by default, but can be customised to be case-sensitive by supplying your own validations and normaliser, as outlined by [Robin Mehner](https://github.com/rmehner) in [issue 42](https://github.com/pat/gutentag/issues/42). Further changes may be required for your schema though, depending on your database.
153
154
 
155
+ <h2 id="extending">Extending</h2>
156
+
157
+ If you need to extend Gutentag's models, you will need to wrap the `include` inside a `to_prepare` hook to ensure it's loaded consistently in all Rails environments:
158
+
159
+ ```ruby
160
+ # config/initializers/gutentag.rb or equivalent
161
+ Rails.application.config.to_prepare do
162
+ Gutentag::Tag.include TagExtensions
163
+ end
164
+ ```
165
+
166
+ Further discussion and examples of this can be found in [issue 65](https://github.com/pat/gutentag/issues/65).
167
+
154
168
  <h2 id="contribution">Contribution</h2>
155
169
 
156
170
  Please note that this project now has a [Contributor Code of Conduct](http://contributor-covenant.org/version/1/0/0/). By participating in this project you agree to abide by its terms.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "gutentag"
5
- s.version = "2.5.0"
5
+ s.version = "2.5.1"
6
6
  s.authors = ["Pat Allan"]
7
7
  s.email = ["pat@freelancing-gods.com"]
8
8
  s.homepage = "https://github.com/pat/gutentag"
@@ -16,11 +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.1.0"
20
- s.add_development_dependency "bundler", "~> 1.17"
21
- s.add_development_dependency "combustion", "~> 1.1"
22
- s.add_development_dependency "database_cleaner", "~> 1.6"
19
+ s.add_development_dependency "appraisal", "~> 2.1.0"
20
+ s.add_development_dependency "bundler", "~> 1.17"
21
+ s.add_development_dependency "combustion", "~> 1.1"
22
+ s.add_development_dependency "database_cleaner", "~> 1.6"
23
23
  s.add_development_dependency "rails"
24
- s.add_development_dependency "rspec-rails", "~> 3.1"
25
- s.add_development_dependency "rubocop", "~> 0.64.0"
24
+ s.add_development_dependency "rspec-rails", "~> 3.1"
25
+ s.add_development_dependency "rubocop", "~> 0.68.1"
26
+ s.add_development_dependency "rubocop-performance", "~> 1"
26
27
  end
@@ -4,6 +4,8 @@ class Gutentag::TagNames
4
4
  def self.call(names)
5
5
  return nil if names.nil?
6
6
 
7
- names.reject(&:blank?)
7
+ names.reject(&:blank?).uniq.collect do |name|
8
+ Gutentag.normaliser.call(name)
9
+ end
8
10
  end
9
11
  end
@@ -36,7 +36,7 @@ class Gutentag::TagValidations
36
36
 
37
37
  def add_length_validation?
38
38
  klass.table_exists? && limit.present?
39
- rescue *DATABASE_ERROR_CLASSES
39
+ rescue *DATABASE_ERROR_CLASSES => _error
40
40
  warn <<-MESSAGE
41
41
  The database is not currently available, and so Gutentag was not able to set
42
42
  up tag validations completely (in particular: adding a length limit to match
@@ -70,6 +70,13 @@ describe "Managing tags via names" do
70
70
  expect(article.tags.collect(&:name)).to eq(%w[ portland oregon ruby ])
71
71
  end
72
72
 
73
+ it "does not repeat appended names that exist in the array of strings" do
74
+ article.tag_names = %w[ portland oregon ]
75
+ article.tag_names += %w[ oregon ruby ]
76
+
77
+ expect(article.tag_names).to match(%w[ portland oregon ruby ])
78
+ end
79
+
73
80
  it "removes a single tag name" do
74
81
  article.tag_names = %w[ portland oregon ]
75
82
  article.tag_names.delete "oregon"
@@ -99,6 +106,11 @@ describe "Managing tags via names" do
99
106
  expect(article.tags.collect(&:name)).to eq(%w[ portland ])
100
107
  end
101
108
 
109
+ it "normalises tag names" do
110
+ article.tag_names = %w[ Perth ]
111
+ expect(article.tag_names).to eq(%w[ perth ])
112
+ end
113
+
102
114
  it "allows setting of tag names on unpersisted objects" do
103
115
  article = Article.new :tag_names => %w[ melbourne pancakes ]
104
116
  article.save!
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.5.0
4
+ version: 2.5.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: 2019-03-15 00:00:00.000000000 Z
11
+ date: 2019-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -114,14 +114,28 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.64.0
117
+ version: 0.68.1
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.64.0
124
+ version: 0.68.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-performance
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1'
125
139
  description: A good, simple, solid tagging extension for ActiveRecord
126
140
  email:
127
141
  - pat@freelancing-gods.com
@@ -196,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
210
  - !ruby/object:Gem::Version
197
211
  version: '0'
198
212
  requirements: []
199
- rubyforge_project:
200
- rubygems_version: 2.4.5.5
213
+ rubygems_version: 3.0.3
201
214
  signing_key:
202
215
  specification_version: 4
203
216
  summary: Good Tags