gutentag 2.3.2 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b31660115c80a0a86d70ab6b0e77896e33b8dd81b51b4d841461a692f69b808
4
- data.tar.gz: 4b3bcc20917350af7a07ec5186df2c23c6b6adee1f02700a9fcfc9c46ef9978c
3
+ metadata.gz: ab338132cb66484c650c46037b6c5133b4ee72c90e7397fbf045cb909029bc3c
4
+ data.tar.gz: 7f4d9166ed7d9ef6a0b44a677f0a182434abcc1ceecfe26ea0ab137714b2c6c3
5
5
  SHA512:
6
- metadata.gz: 304828039b887d1f505e4ce68fbe6d0b8d3c5b70a5fa8f3cff4e26154c2a5fa278a3c3cd3a9cc3298f5609cb1b545da1ff001ddc8aa4f4af21566959562e1135
7
- data.tar.gz: 68a753b3495279474106363deec171d8ba96d97621e1d131360cbb46f4d0e4d341b483b627d90f841c0b9bf44d66c84f75f5a42b7d5ea9d1e6d2a80dfa364c13
6
+ metadata.gz: 57eaa6e0442287f4a07dfb612cbb2c18dda900fe8cf7b274f12eecd299b70355711ff786ab20bf0616716e0ba7b1dc8520458d90a779c3cc715fa78e7842304a
7
+ data.tar.gz: 067b316bba0642bfedd777ff8cf7d0d85a08f326fd4959466ca3b831be3496fe9aad93872e16a7c3830f29b2ef8aafba8194628188784aed4d60413951d38c6e
@@ -2,6 +2,14 @@
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.4.0 - 2018-05-18
6
+
7
+ ### Changed
8
+
9
+ * Tag validation is now added only when the tag model is loaded, rather than when the app boots. This especially simplifies setup for non-Rails apps ([Michael Grosser](https://github.com/grosser) in [#54](https://github.com/pat/gutentag/pull/54)).
10
+ * A warning is displayed if the tag model is referenced without a database being present.
11
+ * Models are now lazily autoloaded for non-Rails apps (when `Rails::Engine` isn't present).
12
+
5
13
  ## 2.3.2 - 2018-04-27
6
14
 
7
15
  ### 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.3'
83
+ gem 'gutentag', '~> 2.4'
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:
@@ -92,15 +92,7 @@ rake db:migrate
92
92
 
93
93
  ### Without Rails
94
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:
95
+ If you want to use Gutentag outside of Rails, you can. However, there is one caveat: 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:
104
96
 
105
97
  ```Ruby
106
98
  create_table :gutentag_taggings do |t|
@@ -23,3 +23,6 @@ class Gutentag::Tag < ActiveRecord::Base
23
23
  super(Gutentag.normaliser.call(value))
24
24
  end
25
25
  end
26
+
27
+ require "gutentag/tag_validations"
28
+ Gutentag.tag_validations.call Gutentag::Tag
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "gutentag"
6
- s.version = "2.3.2"
6
+ s.version = "2.4.0"
7
7
  s.authors = ["Pat Allan"]
8
8
  s.email = ["pat@freelancing-gods.com"]
9
9
  s.homepage = "https://github.com/pat/gutentag"
@@ -38,17 +38,13 @@ require "gutentag/tagged_with"
38
38
 
39
39
  Gutentag.dirtier = Gutentag::Dirty if ActiveRecord::VERSION::STRING.to_f < 4.2
40
40
 
41
- require "active_support/lazy_load_hooks"
42
- ActiveSupport.on_load(:gutentag) do
43
- require "gutentag/tag_validations"
44
-
45
- Gutentag.tag_validations.call Gutentag::Tag
46
- end
47
-
48
41
  if defined?(Rails::Engine)
49
42
  require "gutentag/engine"
50
43
  else
51
44
  require "active_record"
52
- require_relative "../app/models/gutentag/tag"
53
- require_relative "../app/models/gutentag/tagging"
45
+
46
+ Gutentag.autoload :Tag,
47
+ File.expand_path("../app/models/gutentag/tag", __dir__)
48
+ Gutentag.autoload :Tagging,
49
+ File.expand_path("../app/models/gutentag/tagging", __dir__)
54
50
  end
@@ -2,8 +2,4 @@
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
9
5
  end
@@ -37,6 +37,11 @@ class Gutentag::TagValidations
37
37
  def add_length_validation?
38
38
  klass.table_exists? && limit.present?
39
39
  rescue *DATABASE_ERROR_CLASSES
40
+ warn <<-MESSAGE
41
+ The database is not currently available, and so Gutentag was not able to set
42
+ up tag validations completely (in particular: adding a length limit to match
43
+ database constraints).
44
+ MESSAGE
40
45
  false
41
46
  end
42
47
 
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.3.2
4
+ version: 2.4.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-04-27 00:00:00.000000000 Z
11
+ date: 2018-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord