gutentag 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +21 -0
  4. data/.travis.yml +6 -5
  5. data/Appraisals +20 -26
  6. data/Gemfile +13 -8
  7. data/README.md +5 -1
  8. data/Rakefile +9 -5
  9. data/app/models/gutentag/tag.rb +7 -4
  10. data/app/models/gutentag/tagging.rb +5 -3
  11. data/bin/literals +9 -0
  12. data/db/migrate/1_gutentag_tables.rb +5 -3
  13. data/db/migrate/2_gutentag_cache_counter.rb +2 -0
  14. data/db/migrate/3_no_null_counters.rb +8 -4
  15. data/gutentag.gemspec +18 -18
  16. data/lib/gutentag.rb +13 -13
  17. data/lib/gutentag/active_record.rb +11 -6
  18. data/lib/gutentag/active_record/class_methods.rb +4 -16
  19. data/lib/gutentag/active_record/instance_methods.rb +3 -1
  20. data/lib/gutentag/change_state.rb +32 -0
  21. data/lib/gutentag/dirty.rb +4 -1
  22. data/lib/gutentag/engine.rb +2 -4
  23. data/lib/gutentag/persistence.rb +13 -16
  24. data/lib/gutentag/tag_validations.rb +4 -1
  25. data/lib/gutentag/tagged_with.rb +5 -3
  26. data/lib/gutentag/tagged_with/id_query.rb +2 -0
  27. data/lib/gutentag/tagged_with/name_query.rb +2 -0
  28. data/lib/gutentag/tagged_with/query.rb +2 -0
  29. data/spec/acceptance/tag_names_spec.rb +40 -38
  30. data/spec/acceptance/tags_spec.rb +8 -6
  31. data/spec/gutentag/active_record_spec.rb +69 -112
  32. data/spec/gutentag_spec.rb +5 -3
  33. data/spec/internal/app/models/article.rb +2 -0
  34. data/spec/internal/db/schema.rb +2 -0
  35. data/spec/models/gutentag/tag_spec.rb +24 -22
  36. data/spec/models/gutentag/tagging_spec.rb +5 -3
  37. data/spec/spec_helper.rb +4 -2
  38. metadata +11 -43
  39. data/gemfiles/rails_3_2.gemfile +0 -11
  40. data/gemfiles/rails_4_0.gemfile +0 -11
  41. data/gemfiles/rails_4_1.gemfile +0 -11
  42. data/gemfiles/rails_4_2.gemfile +0 -10
  43. data/gemfiles/rails_5_0.gemfile +0 -8
  44. data/gemfiles/rails_5_1.gemfile +0 -8
  45. data/lib/gutentag/has_many_tags.rb +0 -10
@@ -1,9 +1,11 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
2
4
 
3
5
  describe Gutentag do
4
- describe '.normalizer' do
6
+ describe ".normalizer" do
5
7
  it "downcases the provided name" do
6
- expect(Gutentag.normaliser.call('Tasty Pancakes')).to eq('tasty pancakes')
8
+ expect(Gutentag.normaliser.call("Tasty Pancakes")).to eq("tasty pancakes")
7
9
  end
8
10
  end
9
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Article < ActiveRecord::Base
2
4
  Gutentag::ActiveRecord.call self
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveRecord::Schema.define do
2
4
  create_table :articles, :force => true do |t|
3
5
  t.string :title
@@ -1,64 +1,66 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
2
4
 
3
5
  describe Gutentag::Tag, :type => :model do
4
- describe '.find_by_name' do
6
+ describe ".find_by_name" do
5
7
  it "returns a tag with the same name" do
6
- existing = Gutentag::Tag.create! :name => 'pancakes'
8
+ existing = Gutentag::Tag.create! :name => "pancakes"
7
9
 
8
- expect(Gutentag::Tag.find_by_name('pancakes')).to eq(existing)
10
+ expect(Gutentag::Tag.find_by_name("pancakes")).to eq(existing)
9
11
  end
10
12
 
11
13
  it "returns a tag with the same normalised name" do
12
- existing = Gutentag::Tag.create! :name => 'pancakes'
14
+ existing = Gutentag::Tag.create! :name => "pancakes"
13
15
 
14
- expect(Gutentag::Tag.find_by_name('Pancakes')).to eq(existing)
16
+ expect(Gutentag::Tag.find_by_name("Pancakes")).to eq(existing)
15
17
  end
16
18
 
17
19
  it "otherwise returns nil" do
18
- expect(Gutentag::Tag.find_by_name('pancakes')).to be_nil
20
+ expect(Gutentag::Tag.find_by_name("pancakes")).to be_nil
19
21
  end
20
22
  end
21
23
 
22
- describe '.find_or_create' do
24
+ describe ".find_or_create" do
23
25
  it "returns a tag with the same name" do
24
- existing = Gutentag::Tag.create! :name => 'pancakes'
26
+ existing = Gutentag::Tag.create! :name => "pancakes"
25
27
 
26
- expect(Gutentag::Tag.find_or_create('pancakes')).to eq(existing)
28
+ expect(Gutentag::Tag.find_or_create("pancakes")).to eq(existing)
27
29
  end
28
30
 
29
31
  it "returns a tag with the same normalised name" do
30
- existing = Gutentag::Tag.create! :name => 'pancakes'
32
+ existing = Gutentag::Tag.create! :name => "pancakes"
31
33
 
32
- expect(Gutentag::Tag.find_or_create('Pancakes')).to eq(existing)
34
+ expect(Gutentag::Tag.find_or_create("Pancakes")).to eq(existing)
33
35
  end
34
36
 
35
37
  it "creates a new tag if no matches exist" do
36
- expect(Gutentag::Tag.find_or_create('pancakes')).to be_persisted
38
+ expect(Gutentag::Tag.find_or_create("pancakes")).to be_persisted
37
39
  end
38
40
  end
39
41
 
40
- describe '#name' do
42
+ describe "#name" do
41
43
  before :each do
42
- allow(Gutentag.normaliser).to receive(:call).and_return('waffles')
44
+ allow(Gutentag.normaliser).to receive(:call).and_return("waffles")
43
45
  end
44
46
 
45
47
  it "normalises the provided name" do
46
- allow(Gutentag.normaliser).to receive(:call).with('Pancakes').
47
- and_return('waffles')
48
+ allow(Gutentag.normaliser).to receive(:call).with("Pancakes").
49
+ and_return("waffles")
48
50
 
49
- Gutentag::Tag.create!(:name => 'Pancakes')
51
+ Gutentag::Tag.create!(:name => "Pancakes")
50
52
  end
51
53
 
52
54
  it "saves the normalised name" do
53
- expect(Gutentag::Tag.create!(:name => 'Pancakes').name).to eq('waffles')
55
+ expect(Gutentag::Tag.create!(:name => "Pancakes").name).to eq("waffles")
54
56
  end
55
57
  end
56
58
 
57
- describe '#valid?' do
59
+ describe "#valid?" do
58
60
  it "ignores case when enforcing uniqueness" do
59
- Gutentag::Tag.create! :name => 'pancakes'
61
+ Gutentag::Tag.create! :name => "pancakes"
60
62
 
61
- tag = Gutentag::Tag.create(:name => 'Pancakes')
63
+ tag = Gutentag::Tag.create(:name => "Pancakes")
62
64
  expect(tag.errors[:name].length).to eq(1)
63
65
  end
64
66
  end
@@ -1,8 +1,10 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
2
4
 
3
5
  describe Gutentag::Tagging, :type => :model do
4
- describe '#valid?' do
5
- let(:tag) { Gutentag::Tag.create! :name => 'pancakes' }
6
+ describe "#valid?" do
7
+ let(:tag) { Gutentag::Tag.create! :name => "pancakes" }
6
8
  let(:taggable) { Article.create! }
7
9
 
8
10
  it "ensures tags are unique for any given taggable" do
@@ -1,10 +1,12 @@
1
- require 'bundler/setup'
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
2
4
 
3
5
  Bundler.require :default, :development
4
6
 
5
7
  Combustion.initialize! :active_record
6
8
 
7
- require 'rspec/rails'
9
+ require "rspec/rails"
8
10
 
9
11
  RSpec.configure do |config|
10
12
  if config.respond_to?(:use_transactional_tests)
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: 0.9.0
4
+ version: 1.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-06-02 00:00:00.000000000 Z
11
+ date: 2017-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -58,42 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.5.5
61
+ version: 0.7.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.5.5
69
- - !ruby/object:Gem::Dependency
70
- name: mysql2
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: pg
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
68
+ version: 0.7.0
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: rails
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -123,19 +95,19 @@ dependencies:
123
95
  - !ruby/object:Gem::Version
124
96
  version: '3.1'
125
97
  - !ruby/object:Gem::Dependency
126
- name: sqlite3
98
+ name: rubocop
127
99
  requirement: !ruby/object:Gem::Requirement
128
100
  requirements:
129
101
  - - "~>"
130
102
  - !ruby/object:Gem::Version
131
- version: 1.3.7
103
+ version: 0.51.0
132
104
  type: :development
133
105
  prerelease: false
134
106
  version_requirements: !ruby/object:Gem::Requirement
135
107
  requirements:
136
108
  - - "~>"
137
109
  - !ruby/object:Gem::Version
138
- version: 1.3.7
110
+ version: 0.51.0
139
111
  description: A good, simple, solid tagging extension for ActiveRecord
140
112
  email:
141
113
  - pat@freelancing-gods.com
@@ -144,6 +116,7 @@ extensions: []
144
116
  extra_rdoc_files: []
145
117
  files:
146
118
  - ".gitignore"
119
+ - ".rubocop.yml"
147
120
  - ".travis.yml"
148
121
  - Appraisals
149
122
  - Gemfile
@@ -152,23 +125,18 @@ files:
152
125
  - Rakefile
153
126
  - app/models/gutentag/tag.rb
154
127
  - app/models/gutentag/tagging.rb
128
+ - bin/literals
155
129
  - db/migrate/1_gutentag_tables.rb
156
130
  - db/migrate/2_gutentag_cache_counter.rb
157
131
  - db/migrate/3_no_null_counters.rb
158
- - gemfiles/rails_3_2.gemfile
159
- - gemfiles/rails_4_0.gemfile
160
- - gemfiles/rails_4_1.gemfile
161
- - gemfiles/rails_4_2.gemfile
162
- - gemfiles/rails_5_0.gemfile
163
- - gemfiles/rails_5_1.gemfile
164
132
  - gutentag.gemspec
165
133
  - lib/gutentag.rb
166
134
  - lib/gutentag/active_record.rb
167
135
  - lib/gutentag/active_record/class_methods.rb
168
136
  - lib/gutentag/active_record/instance_methods.rb
137
+ - lib/gutentag/change_state.rb
169
138
  - lib/gutentag/dirty.rb
170
139
  - lib/gutentag/engine.rb
171
- - lib/gutentag/has_many_tags.rb
172
140
  - lib/gutentag/persistence.rb
173
141
  - lib/gutentag/tag_validations.rb
174
142
  - lib/gutentag/tagged_with.rb
@@ -206,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
174
  version: '0'
207
175
  requirements: []
208
176
  rubyforge_project:
209
- rubygems_version: 2.6.11
177
+ rubygems_version: 2.6.13
210
178
  signing_key:
211
179
  specification_version: 4
212
180
  summary: Good Tags
@@ -1,11 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "test-unit", :platform => :ruby_22
6
- gem "rack", "~> 1.0", :platforms => [:ruby_20, :ruby_21]
7
- gem "rails", "~> 3.2.22.5"
8
- gem "nokogiri", "~> 1.6.0", :platforms => [:ruby_20]
9
- gem "mysql2", "~> 0.3.10"
10
-
11
- gemspec :path => "../"
@@ -1,11 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "test-unit", :platform => :ruby_22
6
- gem "rails", "~> 4.0.13"
7
- gem "rack", "~> 1.0", :platforms => [:ruby_20, :ruby_21]
8
- gem "nokogiri", "~> 1.6.0", :platforms => [:ruby_20]
9
- gem "mysql2", "~> 0.3.10"
10
-
11
- gemspec :path => "../"
@@ -1,11 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "test-unit", :platform => :ruby_22
6
- gem "rails", "~> 4.1.16"
7
- gem "rack", "~> 1.0", :platforms => [:ruby_20, :ruby_21]
8
- gem "nokogiri", "~> 1.6.0", :platforms => [:ruby_20]
9
- gem "mysql2", "~> 0.3.13"
10
-
11
- gemspec :path => "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "test-unit", :platform => :ruby_22
6
- gem "rails", "~> 4.2.7"
7
- gem "rack", "~> 1.0", :platforms => [:ruby_20, :ruby_21]
8
- gem "nokogiri", "~> 1.6.0", :platforms => [:ruby_20]
9
-
10
- gemspec :path => "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "test-unit", :platform => :ruby_22
6
- gem "rails", "~> 5.0.1"
7
-
8
- gemspec :path => "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "test-unit", :platform => :ruby_22
6
- gem "rails", "~> 5.1.0"
7
-
8
- gemspec :path => "../"
@@ -1,10 +0,0 @@
1
- module Gutentag::HasManyTags
2
- def has_many_tags
3
- ActiveSupport::Deprecation.warn <<-TXT
4
- has_many_tags is now deprecated, and will be removed in Gutentag v1.0.0.
5
- Replace it with Gutentag::ActiveRecord.call(self), and everything will continue
6
- to work as expected.
7
- TXT
8
- Gutentag::ActiveRecord.call self
9
- end
10
- end