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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a26cb66caf12d398610c04fd395478ad28b1274d
4
- data.tar.gz: 14ee875c010f87bb3f2fafe5e4bc4076210ae7a8
2
+ SHA256:
3
+ metadata.gz: f9b93bd8fe90a4f54a92e36f45bce11a65cbb1098e966522ca5c31f0f00caab4
4
+ data.tar.gz: c72b9b7e3bc96d6baf90a8301c2436ae8cad364990f3dedab3f498977de2e8f4
5
5
  SHA512:
6
- metadata.gz: 8b6c6f02542b419644cdc30e07d776227a98aef5479528d7aa80be05fa45757fc7f6eaeacd298a64df20d72cae62b63bd9e3846d1e460a13a871faabe8c9007a
7
- data.tar.gz: 6d58adf70948425b4dacb24284392bbd9faf8b84c5108fffb15b042e2edd0277cfb77d78675c4c23aefa624dc3d7e401405862534d8d6f8ab34d160c8c62ce58
6
+ metadata.gz: 3ba282659b71f3d3444a579ecded444bb37023355789c5567985491c2ca12ec613dacdc7f22dd6e29186252f01a11967e67be2aa0ece5334c213c9537494f63d
7
+ data.tar.gz: 8e2d0b6526f36d163aa926d9999f0054a9b030efee14d9c101960aaa265447bb4dd602fe7330889f2ad3e6dfd2a6fc0255860cd5a57a407871f6ff39af25bb3e
data/.travis.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  script: bundle exec appraisal rake
3
3
  rvm:
4
- - 2.2.8
5
- - 2.3.5
6
- - 2.4.2
4
+ - 2.2.9
5
+ - 2.3.6
6
+ - 2.4.3
7
+ - 2.5.0
7
8
  - jruby-9.1.13.0
8
9
  before_install:
9
10
  - gem install bundler
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, and 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. If you want to know more, read [this blog post](http://freelancing-gods.com/posts/gutentag_simple_rails_tagging).
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', '~> 1.1.0'
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
- If you want to use Gutentag outside of Rails, you can. However, this means you lose the migration import rake task. As a workaround, here's the expected schema (as of 0.7.0):
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
- ### 1.1.0
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
 
@@ -11,8 +11,6 @@ class Gutentag::Tag < ActiveRecord::Base
11
11
 
12
12
  scope :by_weight, lambda { order("gutentag_tags.taggings_count DESC") }
13
13
 
14
- Gutentag.tag_validations.call self
15
-
16
14
  before_validation :normalise_name
17
15
 
18
16
  def self.find_by_name(name)
data/gutentag.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "gutentag"
6
- s.version = "1.1.0"
6
+ s.version = "2.0.0"
7
7
  s.authors = ["Pat Allan"]
8
8
  s.email = ["pat@freelancing-gods.com"]
9
9
  s.homepage = "https://github.com/pat/gutentag"
@@ -2,4 +2,8 @@
2
2
 
3
3
  class Gutentag::Engine < Rails::Engine
4
4
  engine_name :gutentag
5
+
6
+ config.after_initialize do
7
+ ActiveSupport.run_load_hooks :gutentag
8
+ end
5
9
  end
@@ -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
@@ -5,6 +5,7 @@ require "bundler/setup"
5
5
  Bundler.require :default, :development
6
6
 
7
7
  Combustion.initialize! :active_record
8
+ ActiveSupport.run_load_hooks :gutentag unless defined?(Gutentag::Engine)
8
9
 
9
10
  require "rspec/rails"
10
11
 
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: 1.1.0
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-16 00:00:00.000000000 Z
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.6.14
178
+ rubygems_version: 2.7.3
178
179
  signing_key:
179
180
  specification_version: 4
180
181
  summary: Good Tags