gutentag 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -3
- data/Appraisals +4 -0
- data/CHANGELOG.md +63 -0
- data/README.md +25 -42
- data/app/models/gutentag/tag.rb +0 -2
- data/gutentag.gemspec +1 -1
- data/lib/gutentag/engine.rb +4 -0
- data/lib/gutentag/tag_validations.rb +20 -6
- data/lib/gutentag.rb +5 -0
- data/spec/spec_helper.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f9b93bd8fe90a4f54a92e36f45bce11a65cbb1098e966522ca5c31f0f00caab4
|
4
|
+
data.tar.gz: c72b9b7e3bc96d6baf90a8301c2436ae8cad364990f3dedab3f498977de2e8f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ba282659b71f3d3444a579ecded444bb37023355789c5567985491c2ca12ec613dacdc7f22dd6e29186252f01a11967e67be2aa0ece5334c213c9537494f63d
|
7
|
+
data.tar.gz: 8e2d0b6526f36d163aa926d9999f0054a9b030efee14d9c101960aaa265447bb4dd602fe7330889f2ad3e6dfd2a6fc0255860cd5a57a407871f6ff39af25bb3e
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -26,3 +26,7 @@ end if RUBY_VERSION.to_f >= 2.2 && RUBY_PLATFORM != "java"
|
|
26
26
|
appraise "rails_5_1" do
|
27
27
|
gem "rails", "~> 5.1.1"
|
28
28
|
end if RUBY_VERSION.to_f >= 2.2 && RUBY_PLATFORM != "java"
|
29
|
+
|
30
|
+
appraise "rails_5_2" do
|
31
|
+
gem "rails", "~> 5.2.0.beta2"
|
32
|
+
end if RUBY_VERSION.to_f >= 2.2 && RUBY_PLATFORM != "java"
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project (at least, from v0.5.0 onwards) will be documented in this file.
|
4
|
+
|
5
|
+
## 2.0.0
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
This is **a breaking change** if you're using Gutentag without Rails: To ensure database-reliant code isn't invoked before it should be, `ActiveSupport.run_load_hooks :gutentag` should be called after your database is connected.
|
10
|
+
|
11
|
+
## 1.1.0 - 2017-12-16
|
12
|
+
|
13
|
+
No breaking changes.
|
14
|
+
|
15
|
+
Thanks to [Robin](https://github.com/rmehner), Gutentag::Tag#name will now validate default database column lengths ([#41](https://github.com/pat/gutentag/pull/41)).
|
16
|
+
|
17
|
+
## 1.0.0 - 2017-10-29
|
18
|
+
|
19
|
+
Behaviour that was deprecated in 0.9.0 (`has_many_tags`, `tagged_with` arguments) have now been removed.
|
20
|
+
|
21
|
+
## 0.9.0 - 2017-06-02
|
22
|
+
|
23
|
+
* In your models with tags, change `has_many_tags` to `Gutentag::ActiveRecord.call self`.
|
24
|
+
* Any calls to `tagged_with` should change from `Model.tagged_with('ruby', 'pancakes')` to `Model.tagged_with(:names => ['ruby', 'pancakes'])`.
|
25
|
+
|
26
|
+
In both of the above cases, the old behaviour will continue to work for 0.9.x releases, but with a deprecation warning.
|
27
|
+
|
28
|
+
## 0.8.0 - 2017-01-19
|
29
|
+
|
30
|
+
No breaking changes.
|
31
|
+
|
32
|
+
## 0.7.0 - 2015-08-27
|
33
|
+
|
34
|
+
No breaking changes.
|
35
|
+
|
36
|
+
## 0.6.0 - 2015-01-24
|
37
|
+
|
38
|
+
Rails 4.2 is supported as of Gutentag 0.6.0 - but please note that due to internal changes in ActiveRecord, changes to tag_names will no longer be tracked by your model's dirty state. This feature will continue to work in Rails 3.2 through to 4.1 though.
|
39
|
+
|
40
|
+
## 0.5.1 - 2014-07-29
|
41
|
+
|
42
|
+
## 0.5.0 - 2013-09-10
|
43
|
+
|
44
|
+
Between 0.4.0 and 0.5.0, Gutentag switched table names from `tags` and `taggings` to `gutentag_tags` and `gutentag_taggings`. This has been done to avoid conflicting with the more generic table names that may exist in Rails apps already.
|
45
|
+
|
46
|
+
If you were using Gutentag 0.4.0 (or older) and now want to upgrade, you'll need to create a migration manually that renames these tables:
|
47
|
+
|
48
|
+
```Ruby
|
49
|
+
rename_table :tags, :gutentag_tags
|
50
|
+
rename_table :taggings, :gutentag_taggings
|
51
|
+
```
|
52
|
+
|
53
|
+
## 0.4.0 - 2013-09-03
|
54
|
+
|
55
|
+
## 0.3.0 - 2013-08-07
|
56
|
+
|
57
|
+
## 0.2.2 - 2013-07-25
|
58
|
+
|
59
|
+
## 0.2.1 - 2013-07-25
|
60
|
+
|
61
|
+
## 0.2.0 - 2013-07-15
|
62
|
+
|
63
|
+
## 0.1.0 - 2013-07-11
|
data/README.md
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
|
7
7
|
A good, simple, solid tagging extension for ActiveRecord.
|
8
8
|
|
9
|
-
This was built partly as a proof-of-concept,
|
9
|
+
This was initially built partly as a proof-of-concept, partly to see how a tagging gem could work when it's not all stuffed within models, and partly just because I wanted a simpler tagging library. It's now a solid little tagging Rails engine.
|
10
|
+
|
11
|
+
If you want to know more, read [this blog post](http://freelancing-gods.com/posts/gutentag_simple_rails_tagging).
|
10
12
|
|
11
13
|
## Contents
|
12
14
|
|
@@ -66,10 +68,19 @@ Article.tagged_with(:ids => [tag_a.id, tag_b.id], :match => :all)
|
|
66
68
|
|
67
69
|
<h2 id="installation">Installation</h2>
|
68
70
|
|
71
|
+
### Dependencies
|
72
|
+
|
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
|
+
|
75
|
+
* Ruby: MRI v2.2-v2.5, JRuby v9.1
|
76
|
+
* Rails/ActiveRecord: v3.2-v5.2
|
77
|
+
|
78
|
+
### Installing
|
79
|
+
|
69
80
|
Get it into your Gemfile - and don't forget the version constraint!
|
70
81
|
|
71
82
|
```Ruby
|
72
|
-
gem 'gutentag', '~>
|
83
|
+
gem 'gutentag', '~> 2.0.0'
|
73
84
|
```
|
74
85
|
|
75
86
|
Next: your tags get persisted to your database, so let's import and run the migrations to get the tables set up:
|
@@ -79,7 +90,17 @@ rake gutentag:install:migrations
|
|
79
90
|
rake db:migrate
|
80
91
|
```
|
81
92
|
|
82
|
-
|
93
|
+
### Without Rails
|
94
|
+
|
95
|
+
If you want to use Gutentag outside of Rails, you can. However, there are two caveats:
|
96
|
+
|
97
|
+
* You'll want to invoke this code once ActiveRecord's connected to the database:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
ActiveSupport.run_load_hooks :gutentag
|
101
|
+
```
|
102
|
+
|
103
|
+
* And 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:
|
83
104
|
|
84
105
|
```Ruby
|
85
106
|
create_table :gutentag_taggings do |t|
|
@@ -106,45 +127,7 @@ add_index :gutentag_tags, :taggings_count
|
|
106
127
|
|
107
128
|
<h2 id="upgrading">Upgrading</h2>
|
108
129
|
|
109
|
-
|
110
|
-
|
111
|
-
No breaking changes.
|
112
|
-
|
113
|
-
Thanks to [Robin](https://github.com/rmehner), Gutentag::Tag#name will now validate default database column lengths ([#41](https://github.com/pat/gutentag/pull/41)).
|
114
|
-
|
115
|
-
### 1.0.0
|
116
|
-
|
117
|
-
Behaviour that was deprecated in 0.9.0 (`has_many_tags`, `tagged_with` arguments) have now been removed.
|
118
|
-
|
119
|
-
### 0.9.0
|
120
|
-
|
121
|
-
* In your models with tags, change `has_many_tags` to `Gutentag::ActiveRecord.call self`.
|
122
|
-
* Any calls to `tagged_with` should change from `Model.tagged_with('ruby', 'pancakes')` to `Model.tagged_with(:names => ['ruby', 'pancakes'])`.
|
123
|
-
|
124
|
-
In both of the above cases, the old behaviour will continue to work for 0.9.x releases, but with a deprecation warning.
|
125
|
-
|
126
|
-
### 0.8.0
|
127
|
-
|
128
|
-
No breaking changes.
|
129
|
-
|
130
|
-
### 0.7.0
|
131
|
-
|
132
|
-
No breaking changes.
|
133
|
-
|
134
|
-
### 0.6.0
|
135
|
-
|
136
|
-
Rails 4.2 is supported as of Gutentag 0.6.0 - but please note that due to internal changes in ActiveRecord, changes to tag_names will no longer be tracked by your model's dirty state. This feature will continue to work in Rails 3.2 through to 4.1 though.
|
137
|
-
|
138
|
-
### 0.5.0
|
139
|
-
|
140
|
-
Between 0.4.0 and 0.5.0, Gutentag switched table names from `tags` and `taggings` to `gutentag_tags` and `gutentag_taggings`. This has been done to avoid conflicting with the more generic table names that may exist in Rails apps already.
|
141
|
-
|
142
|
-
If you were using Gutentag 0.4.0 (or older) and now want to upgrade, you'll need to create a migration manually that renames these tables:
|
143
|
-
|
144
|
-
```Ruby
|
145
|
-
rename_table :tags, :gutentag_tags
|
146
|
-
rename_table :taggings, :gutentag_taggings
|
147
|
-
```
|
130
|
+
Please refer to the [CHANGELOG](CHANGELOG.md), which covers significant and breaking changes between versions.
|
148
131
|
|
149
132
|
<h2 id="configuration">Configuration</h2>
|
150
133
|
|
data/app/models/gutentag/tag.rb
CHANGED
data/gutentag.gemspec
CHANGED
data/lib/gutentag/engine.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Gutentag::TagValidations
|
4
|
+
DEFAULTS = {
|
5
|
+
:presence => true,
|
6
|
+
:uniqueness => {:case_sensitive => false}
|
7
|
+
}.freeze
|
8
|
+
|
4
9
|
def self.call(klass)
|
5
10
|
new(klass).call
|
6
11
|
end
|
@@ -10,15 +15,24 @@ class Gutentag::TagValidations
|
|
10
15
|
end
|
11
16
|
|
12
17
|
def call
|
13
|
-
klass.validates :name,
|
14
|
-
:presence => true,
|
15
|
-
:uniqueness => {:case_sensitive => false}
|
16
|
-
|
17
|
-
limit = klass.columns_hash["name"].limit
|
18
|
-
klass.validates_length_of :name, :maximum => limit if limit.present?
|
18
|
+
klass.validates :name, validation_options
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
23
|
attr_reader :klass
|
24
|
+
|
25
|
+
def add_length_validation?
|
26
|
+
klass.table_exists? && limit.present?
|
27
|
+
end
|
28
|
+
|
29
|
+
def limit
|
30
|
+
@limit ||= klass.columns_hash["name"].limit
|
31
|
+
end
|
32
|
+
|
33
|
+
def validation_options
|
34
|
+
return DEFAULTS unless add_length_validation?
|
35
|
+
|
36
|
+
DEFAULTS.merge :length => {:maximum => limit}
|
37
|
+
end
|
24
38
|
end
|
data/lib/gutentag.rb
CHANGED
@@ -41,6 +41,11 @@ elsif ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR < 2
|
|
41
41
|
Gutentag.dirtier = Gutentag::Dirty
|
42
42
|
end
|
43
43
|
|
44
|
+
require "active_support/lazy_load_hooks"
|
45
|
+
ActiveSupport.on_load(:gutentag) do
|
46
|
+
Gutentag.tag_validations.call Gutentag::Tag
|
47
|
+
end
|
48
|
+
|
44
49
|
if defined?(Rails::Engine)
|
45
50
|
require "gutentag/engine"
|
46
51
|
else
|
data/spec/spec_helper.rb
CHANGED
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:
|
4
|
+
version: 2.0.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: 2017-12-
|
11
|
+
date: 2017-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".rubocop.yml"
|
120
120
|
- ".travis.yml"
|
121
121
|
- Appraisals
|
122
|
+
- CHANGELOG.md
|
122
123
|
- Gemfile
|
123
124
|
- LICENCE
|
124
125
|
- README.md
|
@@ -174,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
175
|
version: '0'
|
175
176
|
requirements: []
|
176
177
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.7.3
|
178
179
|
signing_key:
|
179
180
|
specification_version: 4
|
180
181
|
summary: Good Tags
|