gutentag 2.0.0 → 2.1.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
2
  SHA256:
3
- metadata.gz: f9b93bd8fe90a4f54a92e36f45bce11a65cbb1098e966522ca5c31f0f00caab4
4
- data.tar.gz: c72b9b7e3bc96d6baf90a8301c2436ae8cad364990f3dedab3f498977de2e8f4
3
+ metadata.gz: 22821eb031cd1b00ea0f167035e557971b5c3c073ce56964394b96f05b364d5b
4
+ data.tar.gz: d523b07744aa3159028c765284b91e4d83bfebff3ad5fdaab27383bfee76e1d7
5
5
  SHA512:
6
- metadata.gz: 3ba282659b71f3d3444a579ecded444bb37023355789c5567985491c2ca12ec613dacdc7f22dd6e29186252f01a11967e67be2aa0ece5334c213c9537494f63d
7
- data.tar.gz: 8e2d0b6526f36d163aa926d9999f0054a9b030efee14d9c101960aaa265447bb4dd602fe7330889f2ad3e6dfd2a6fc0255860cd5a57a407871f6ff39af25bb3e
6
+ metadata.gz: 04f2eb02cfd53bac7b394f07e0c2d035b79978b96388f7ea8c083adfb2bc5cbe59a2ae4a4535863455d3cdc62260c8927879ef987cd1596567c3402006b954e8
7
+ data.tar.gz: fc75caec7d7a1b03f42136087c78f8cd5c0319595afca6e76b2977b8c7f11b2b75a456434342040f2c8b78a4e9f9091181a327785eae551a52adcbc2ebb3f496
data/.travis.yml CHANGED
@@ -10,7 +10,6 @@ before_install:
10
10
  - gem install bundler
11
11
  before_script:
12
12
  - bundle exec appraisal install
13
- - ./bin/literals
14
13
  env:
15
14
  - DATABASE=postgres
16
15
  - DATABASE=mysql
data/Appraisals CHANGED
@@ -28,5 +28,6 @@ appraise "rails_5_1" do
28
28
  end if RUBY_VERSION.to_f >= 2.2 && RUBY_PLATFORM != "java"
29
29
 
30
30
  appraise "rails_5_2" do
31
- gem "rails", "~> 5.2.0.beta2"
31
+ gem "rails", "~> 5.2.0.rc1"
32
+ gem "pg", "~> 1.0"
32
33
  end if RUBY_VERSION.to_f >= 2.2 && RUBY_PLATFORM != "java"
data/CHANGELOG.md CHANGED
@@ -2,7 +2,17 @@
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.0.0
5
+ ## 2.1.0 - 2018-02-01
6
+
7
+ ### Added
8
+
9
+ * `Gutentag::RemoveUnused` is now present, and can be invoked with the `call` method. It will remove all unused tags (i.e. tags that aren't connected to any taggable objects). Related to [#19](https://github.com/pat/gutentag/issues/19).
10
+
11
+ ### Fixed
12
+
13
+ * Tag validations logic fails gracefully when no database exists (Nishutosh Sharma in [#46](https://github.com/pat/gutentag/pull/46)).
14
+
15
+ ## 2.0.0 - 2017-12-27
6
16
 
7
17
  ### Changed
8
18
 
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.0.0'
83
+ gem 'gutentag', '~> 2.1.0'
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
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "gutentag"
6
- s.version = "2.0.0"
6
+ s.version = "2.1.0"
7
7
  s.authors = ["Pat Allan"]
8
8
  s.email = ["pat@freelancing-gods.com"]
9
9
  s.homepage = "https://github.com/pat/gutentag"
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_development_dependency "appraisal", "~> 2.1.0"
21
21
  s.add_development_dependency "bundler", ">= 1.7.12"
22
- s.add_development_dependency "combustion", "0.7.0"
22
+ s.add_development_dependency "combustion", "0.8.0"
23
23
  s.add_development_dependency "rails"
24
24
  s.add_development_dependency "rspec-rails", "~> 3.1"
25
- s.add_development_dependency "rubocop", "~> 0.51.0"
25
+ s.add_development_dependency "rubocop", "~> 0.52.1"
26
26
  end
data/lib/gutentag.rb CHANGED
@@ -32,6 +32,7 @@ require "gutentag/active_record"
32
32
  require "gutentag/change_state"
33
33
  require "gutentag/dirty"
34
34
  require "gutentag/persistence"
35
+ require "gutentag/remove_unused"
35
36
  require "gutentag/tag_validations"
36
37
  require "gutentag/tagged_with"
37
38
 
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gutentag::RemoveUnused
4
+ def self.call
5
+ Gutentag::Tag.connection.execute <<-SQL
6
+ DELETE FROM gutentag_tags
7
+ WHERE id NOT IN (SELECT DISTINCT tag_id FROM gutentag_taggings)
8
+ SQL
9
+ end
10
+ end
@@ -24,6 +24,8 @@ class Gutentag::TagValidations
24
24
 
25
25
  def add_length_validation?
26
26
  klass.table_exists? && limit.present?
27
+ rescue ActiveRecord::NoDatabaseError
28
+ false
27
29
  end
28
30
 
29
31
  def limit
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe "Removing unused" do
6
+ let(:article) { Article.create }
7
+
8
+ it "deletes only unused tags" do
9
+ pancakes = Gutentag::Tag.create :name => "pancakes"
10
+ Gutentag::Tag.create :name => "waffles"
11
+
12
+ Gutentag::Tagging.create :tag => pancakes, :taggable => article
13
+
14
+ expect(Gutentag::Tag.pluck(:name)).to match_array(%w[ pancakes waffles ])
15
+
16
+ Gutentag::RemoveUnused.call
17
+
18
+ expect(Gutentag::Tag.pluck(:name)).to match_array(%w[ pancakes ])
19
+ end
20
+ 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.0.0
4
+ version: 2.1.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-27 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.7.0
61
+ version: 0.8.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.7.0
68
+ version: 0.8.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rails
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.51.0
103
+ version: 0.52.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.51.0
110
+ version: 0.52.1
111
111
  description: A good, simple, solid tagging extension for ActiveRecord
112
112
  email:
113
113
  - pat@freelancing-gods.com
@@ -126,7 +126,6 @@ files:
126
126
  - Rakefile
127
127
  - app/models/gutentag/tag.rb
128
128
  - app/models/gutentag/tagging.rb
129
- - bin/literals
130
129
  - db/migrate/1_gutentag_tables.rb
131
130
  - db/migrate/2_gutentag_cache_counter.rb
132
131
  - db/migrate/3_no_null_counters.rb
@@ -139,11 +138,13 @@ files:
139
138
  - lib/gutentag/dirty.rb
140
139
  - lib/gutentag/engine.rb
141
140
  - lib/gutentag/persistence.rb
141
+ - lib/gutentag/remove_unused.rb
142
142
  - lib/gutentag/tag_validations.rb
143
143
  - lib/gutentag/tagged_with.rb
144
144
  - lib/gutentag/tagged_with/id_query.rb
145
145
  - lib/gutentag/tagged_with/name_query.rb
146
146
  - lib/gutentag/tagged_with/query.rb
147
+ - spec/acceptance/removing_unused_spec.rb
147
148
  - spec/acceptance/tag_names_spec.rb
148
149
  - spec/acceptance/tags_spec.rb
149
150
  - spec/gutentag/active_record_spec.rb
data/bin/literals DELETED
@@ -1,9 +0,0 @@
1
- if (ruby -e "exit RUBY_VERSION.to_f >= 2.4")
2
- then
3
- echo "Automatic frozen string literals are supported"
4
- gem install pragmater -v 4.0.0
5
- pragmater --add lib --comments "# frozen_string_literal: true" --whitelist "**/*.rb"
6
- pragmater --add spec --comments "# frozen_string_literal: true" --whitelist "**/*.rb"
7
- else
8
- echo "Automatic frozen string literals are not supported."
9
- fi