gutentag 2.4.1 → 2.5.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
- SHA256:
3
- metadata.gz: 53b60a0cb99836a7c475d6fee7b431f99e38c16976f914e3591e86530c1d5b7b
4
- data.tar.gz: 564c325549cf3f51ceb24a5986a06d5ad66b81f1a07b948a1875b4e1d8ebead5
2
+ SHA1:
3
+ metadata.gz: fe6d98b81a4c392bb7591418821697ceb622e80e
4
+ data.tar.gz: 5299b1efed9975a5bb902d704617c41dc0a1dd38
5
5
  SHA512:
6
- metadata.gz: dcb6dba995fc07e770dbd605d667501dba90ed153c6c40ff825e53276890a2a7fb2e5d4f13cef3573a094d0b25fb1645baa956aeccdf3e1bfad8e6b0f8ade58e
7
- data.tar.gz: df7591b2ed083abb732c447ecf1b916d540edc168b4542bca99fe41e03e8135f2cee6745b2a43d2e68cc9466da411e578db4bac40264123d3cf88ee5da84b502
6
+ metadata.gz: 1ae92f80e7bd6b60bd7623a976b910ba4a9a43e97aac6b2dab3b0f2d72ee76bce9d1eaddc6a70c2bbbe4500c36cfa9ea2f055635f4e6a0b0182dd6842b43af83
7
+ data.tar.gz: 2a07b209873183a7ed92d47bd2c6cecf153af767d14c2fe6e664272c6ee22032134ce4a0b194d5a0837206716cd5f99388b1c5a325c60d7c5c4bdd79aa9d0396
@@ -2,13 +2,10 @@ inherit_from:
2
2
  - https://gist.githubusercontent.com/pat/ba3b8ffb1901bfe5439b460943b6b019/raw/.rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.2
5
+ TargetRubyVersion: 2.3
6
6
  Exclude:
7
7
  - gemfiles/*.gemfile
8
8
 
9
- Layout/AlignHash:
10
- EnforcedHashRocketStyle: table
11
-
12
9
  Metrics/MethodLength:
13
10
  Exclude:
14
11
  - db/migrate/1_gutentag_tables.rb
@@ -21,6 +18,3 @@ Style/MultilineIfModifier:
21
18
  Style/MultilineTernaryOperator:
22
19
  Exclude:
23
20
  - db/migrate/*.rb
24
-
25
- Style/SafeNavigation:
26
- Enabled: false
@@ -2,7 +2,6 @@ language: ruby
2
2
  dist: xenial
3
3
  script: bundle exec appraisal rake
4
4
  rvm:
5
- - 2.2.10
6
5
  - 2.3.8
7
6
  - 2.4.5
8
7
  - 2.5.3
data/Appraisals CHANGED
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise "rails_3_2" do
4
- gem "rails", "~> 3.2.22.5"
5
- gem "mysql2", "~> 0.3.10", :platform => :ruby
6
- end if RUBY_VERSION.to_f <= 2.2
7
-
8
3
  appraise "rails_4_0" do
9
4
  gem "rails", "~> 4.0.13"
10
5
  gem "mysql2", "~> 0.3.10", :platform => :ruby
@@ -2,6 +2,18 @@
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.5.0 - 2019-03-15
6
+
7
+ **Pleease note this release ends official support of Rails 3.2 and Ruby (MRI) 2.2.** The code currently still works on Ruby 2.2, and all features except for the new `Gutentag::Tag.names_for_scope` method work in Rails 3.2, but they're no longer tested against, and cannot be guaranteed to work in future releases.
8
+
9
+ ### Added
10
+
11
+ * Added the `Gutentag::Tag.names_for_scope(scope)` method, which accepts an ActiveRecord model or a relation, and returns all tag names associated to that model/relation.
12
+
13
+ ### Changed
14
+
15
+ * Removing support for MRI 2.2 and Rails 3.2.
16
+
5
17
  ## 2.4.1 - 2019-02-22
6
18
 
7
19
  ### Changed
data/README.md CHANGED
@@ -72,15 +72,17 @@ Article.tagged_with(:ids => [tag_a.id, tag_b.id], :match => :all)
72
72
 
73
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
74
 
75
- * Ruby: MRI v2.2-v2.6, JRuby v9.2.5
76
- * Rails/ActiveRecord: v3.2-v6.0
75
+ * Ruby: MRI v2.3-v2.6, JRuby v9.2.5
76
+ * Rails/ActiveRecord: v4.0-v6.0
77
+
78
+ If you're using MRI v2.2 and/or ActiveRecord v3.2, the last version of Gutentag that fully supported those versions is v2.4.1.
77
79
 
78
80
  ### Installing
79
81
 
80
82
  Get it into your Gemfile - and don't forget the version constraint!
81
83
 
82
84
  ```Ruby
83
- gem 'gutentag', '~> 2.4'
85
+ gem 'gutentag', '~> 2.5'
84
86
  ```
85
87
 
86
88
  Next: your tags get persisted to your database, so let's import and run the migrations to get the tables set up:
@@ -19,6 +19,17 @@ class Gutentag::Tag < ActiveRecord::Base
19
19
  find_by_name(name) || create(:name => name)
20
20
  end
21
21
 
22
+ def self.names_for_scope(scope)
23
+ join_conditions = {:taggable_type => scope.name}
24
+ if scope.current_scope.present?
25
+ join_conditions[:taggable_id] = scope.select(:id)
26
+ end
27
+
28
+ joins(:taggings).where(
29
+ Gutentag::Tagging.table_name => join_conditions
30
+ ).distinct.pluck(:name)
31
+ end
32
+
22
33
  def name=(value)
23
34
  super(Gutentag.normaliser.call(value))
24
35
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "gutentag"
5
- s.version = "2.4.1"
5
+ s.version = "2.5.0"
6
6
  s.authors = ["Pat Allan"]
7
7
  s.email = ["pat@freelancing-gods.com"]
8
8
  s.homepage = "https://github.com/pat/gutentag"
@@ -16,7 +16,7 @@ module Gutentag::ActiveRecord::InstanceMethods
16
16
  def tag_names=(names)
17
17
  names = Gutentag::TagNames.call(names)
18
18
 
19
- Gutentag.dirtier.call self, names if Gutentag.dirtier
19
+ Gutentag.dirtier.call self, names if Gutentag.dirtier.present?
20
20
 
21
21
  @tag_names = names
22
22
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe "Tag names for scopes" do
6
+ it "returns tag names for a given model" do
7
+ Article.create :tag_names => %w[ koala wombat ]
8
+ Article.create :tag_names => %w[ cassowary ]
9
+
10
+ expect(Gutentag::Tag.names_for_scope(Article)).
11
+ to match_array(%w[ koala wombat cassowary ])
12
+ end
13
+
14
+ it "returns tag names for a given scope" do
15
+ Article.create :title => "mammals", :tag_names => %w[ koala wombat ]
16
+ Article.create :title => "birds", :tag_names => %w[ cassowary ]
17
+
18
+ expect(Gutentag::Tag.names_for_scope(Article.where(:title => "mammals"))).
19
+ to match_array(%w[ koala wombat ])
20
+ end
21
+
22
+ it "does not duplicate tag names for a given model/scope" do
23
+ Article.create :tag_names => %w[ koala wombat ]
24
+ Article.create :tag_names => %w[ cassowary ]
25
+ Article.create :tag_names => %w[ cassowary wombat ]
26
+
27
+ expect(Gutentag::Tag.names_for_scope(Article)).
28
+ to match_array(%w[ koala wombat cassowary ])
29
+ end
30
+ 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.4.1
4
+ version: 2.5.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: 2019-02-22 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -163,6 +163,7 @@ files:
163
163
  - lib/gutentag/tagged_with/query.rb
164
164
  - spec/acceptance/dirty_state_spec.rb
165
165
  - spec/acceptance/removing_unused_spec.rb
166
+ - spec/acceptance/tag_names_for_scope_spec.rb
166
167
  - spec/acceptance/tag_names_spec.rb
167
168
  - spec/acceptance/tags_spec.rb
168
169
  - spec/gutentag/active_record_spec.rb
@@ -196,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
197
  version: '0'
197
198
  requirements: []
198
199
  rubyforge_project:
199
- rubygems_version: 2.7.6
200
+ rubygems_version: 2.4.5.5
200
201
  signing_key:
201
202
  specification_version: 4
202
203
  summary: Good Tags