gutentag 2.2.1 → 2.3.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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/gutentag.gemspec +1 -1
- data/lib/gutentag.rb +1 -0
- data/lib/gutentag/active_record/instance_methods.rb +1 -1
- data/lib/gutentag/active_record/instance_methods_3_2.rb +2 -0
- data/lib/gutentag/active_record/instance_methods_4_2.rb +4 -0
- data/lib/gutentag/tag_names.rb +9 -0
- data/lib/gutentag/tag_validations.rb +14 -2
- data/spec/acceptance/tag_names_spec.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06163432b93d4590113c493220800afa305a1f982aaa52384648aad8f1646213
|
4
|
+
data.tar.gz: 4cec16fcaa7b11d5a47e45533c956f42762c65235f11819bdae36d5b485181c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c08959b80eddd4cbaad7587a0aed5e5942089aa1107a800e62fab91d81099f6801c0b8a89f8627507fe0489907441f0d92b2c7e45d3f8d30b02456f4d8fc942
|
7
|
+
data.tar.gz: d38bfaef36f64adbaa59049b8cac7a5d4183a119dd496a92aceaaffbad059af1f7e5a74d6597273756d307b798555d95bbdb79785e178089fb52e3396c368d69
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
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.3.0 - 2018-03-19
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
* Filter out blank tag names when provided via `tag_names=` (as discussed in [#51](https://github.com/pat/gutentag/issues/51)).
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
* Tag validations logic fails gracefully when the database server cannot be reached.
|
14
|
+
|
5
15
|
## 2.2.1 - 2018-03-06
|
6
16
|
|
7
17
|
### Fixed
|
data/README.md
CHANGED
@@ -80,7 +80,7 @@ These are the versions the test suite runs against. It's possible it may work on
|
|
80
80
|
Get it into your Gemfile - and don't forget the version constraint!
|
81
81
|
|
82
82
|
```Ruby
|
83
|
-
gem 'gutentag', '~> 2.
|
83
|
+
gem 'gutentag', '~> 2.3'
|
84
84
|
```
|
85
85
|
|
86
86
|
Next: your tags get persisted to your database, so let's import and run the migrations to get the tables set up:
|
data/gutentag.gemspec
CHANGED
data/lib/gutentag.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_model/errors"
|
4
|
+
require "active_record/errors"
|
5
|
+
|
3
6
|
class Gutentag::TagValidations
|
4
7
|
DEFAULTS = {
|
5
8
|
:presence => true,
|
6
9
|
:uniqueness => {:case_sensitive => false}
|
7
10
|
}.freeze
|
11
|
+
DATABASE_ERROR_CLASSES = lambda {
|
12
|
+
classes = []
|
13
|
+
if ActiveRecord::VERSION::STRING.to_f > 4.0
|
14
|
+
classes << ActiveRecord::NoDatabaseError
|
15
|
+
end
|
16
|
+
classes << Mysql2::Error if defined?(::Mysql2)
|
17
|
+
classes << PG::ConnectionBad if defined?(::PG)
|
18
|
+
classes
|
19
|
+
}.call.freeze
|
8
20
|
|
9
21
|
def self.call(klass)
|
10
22
|
new(klass).call
|
@@ -15,7 +27,7 @@ class Gutentag::TagValidations
|
|
15
27
|
end
|
16
28
|
|
17
29
|
def call
|
18
|
-
klass.validates :name, validation_options
|
30
|
+
klass.validates :name, validation_options.dup
|
19
31
|
end
|
20
32
|
|
21
33
|
private
|
@@ -24,7 +36,7 @@ class Gutentag::TagValidations
|
|
24
36
|
|
25
37
|
def add_length_validation?
|
26
38
|
klass.table_exists? && limit.present?
|
27
|
-
rescue
|
39
|
+
rescue *DATABASE_ERROR_CLASSES
|
28
40
|
false
|
29
41
|
end
|
30
42
|
|
@@ -116,4 +116,11 @@ describe "Managing tags via names" do
|
|
116
116
|
|
117
117
|
expect(Article.find(article.id).tag_names).to eq(["melbourne"])
|
118
118
|
end
|
119
|
+
|
120
|
+
it "ignores blank tags" do
|
121
|
+
article = Article.new :tag_names => ["", "melbourne"]
|
122
|
+
article.save!
|
123
|
+
|
124
|
+
expect(article.tag_names).to eq(%w[ melbourne ])
|
125
|
+
end
|
119
126
|
end
|
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
|
+
version: 2.3.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: 2018-03-
|
11
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/gutentag/engine.rb
|
156
156
|
- lib/gutentag/persistence.rb
|
157
157
|
- lib/gutentag/remove_unused.rb
|
158
|
+
- lib/gutentag/tag_names.rb
|
158
159
|
- lib/gutentag/tag_validations.rb
|
159
160
|
- lib/gutentag/tagged_with.rb
|
160
161
|
- lib/gutentag/tagged_with/id_query.rb
|