easy_tags 0.2.3 → 0.2.4

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: 7dc33730db127f2b295d1965a40d3f1a26398a15298eed3f737c75c78d5b2d89
4
- data.tar.gz: 6242af5c9b8e2fbeece7924c8a3296f9a0493237b2474bc53dbdc0b8167e2177
3
+ metadata.gz: 8287fdecc7f7ef46be4d02d25db0781471ce1bd039a4e6f0ed357d4ff9ba0a46
4
+ data.tar.gz: 2d3e23375449f4c229948825e6aadf8194a76bd47d00a480050140124db0fa10
5
5
  SHA512:
6
- metadata.gz: 596d6f43a3afc179d5ad929f96a225de792ac3994091de2c148cd669343b0bdf361a6dcff2333a15d3740d087f85687620b933a2558a2b95629d857374f6589b
7
- data.tar.gz: 0e86be8f5ff60cf8cb6d40aa364225ac90aab6147f448e73a27e4fbff74a846199409d2b8a770151abe0ed00f8e8f960fe4dc15e2cd49056e122d23f002e895b
6
+ metadata.gz: eef88df3c81e4f130f1a59aaad9c6c7ea74752bc8e4bdc6279f8ee716be7fd27d7f576c7c132aca38a3d3e93aa3052dc2b838a3e9f505be08a41225cbe7636da
7
+ data.tar.gz: 1302a9207d12f0980cca36d93f01595d1293456f4d2a8a28427a63857a236ad78aae83daffd4b8881c28dc2c856eadc999808cb7a2b2e0641521609f3e0651ff
data/Appraisals CHANGED
@@ -1,8 +1,3 @@
1
- appraise 'activerecord-5.0' do
2
- gem 'activerecord', '~> 5.0.0'
3
- gem 'activesupport', '~> 5.0.0'
4
- end
5
-
6
1
  appraise 'activerecord-5.1' do
7
2
  gem 'activerecord', '~> 5.1.0'
8
3
  gem 'activesupport', '~> 5.1.0'
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.4] - 2020-06-09
10
+ ### Fixed
11
+ - Fixed tags eager loading
12
+
13
+ ## [0.2.3] - 2020-01-15
14
+ ### Added
15
+ - Rails 6.0 support
16
+
9
17
  ## [0.2.2] - 2019-10-24
10
18
  ### Fixed
11
19
  - Fixed inspect and compare for context objects (delegate to tags list) that may have affected debug and testing
@@ -21,8 +29,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
29
  ## [0.1.0] - 2019-07-15
22
30
  Initial release
23
31
 
24
- [Unreleased]: https://github.com/iiwo/easy_tagscompare/v0.2.0...HEAD
25
- [0.2.1]: https://github.com/iiwo/easy_tags/compare/v0.2.1...v0.2.2
32
+ [Unreleased]: https://github.com/iiwo/easy_tagscompare/v0.2.4...HEAD
33
+ [0.2.4]: https://github.com/iiwo/easy_tags/compare/v0.2.3...v0.2.4
34
+ [0.2.3]: https://github.com/iiwo/easy_tags/compare/v0.2.2...v0.2.3
35
+ [0.2.2]: https://github.com/iiwo/easy_tags/compare/v0.2.1...v0.2.2
26
36
  [0.2.1]: https://github.com/iiwo/easy_tags/compare/v0.2.0...v0.2.1
27
37
  [0.2.0]: https://github.com/iiwo/easy_tags/compare/v0.1.0...v0.2.0
28
38
  [0.1.0]: https://github.com/iiwo/easy_tags/releases/tag/v0.1.0
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_development_dependency 'appraisal'
34
34
  spec.add_development_dependency 'database_cleaner'
35
+ spec.add_development_dependency 'db-query-matchers'
35
36
  spec.add_development_dependency 'rspec'
36
37
  spec.add_development_dependency 'rspec-rails'
37
38
  spec.add_development_dependency 'simplecov'
@@ -2,11 +2,11 @@ module EasyTags
2
2
  # Handles tag context manipulation
3
3
  class TaggableContext
4
4
  # @param [String, Symbol] context
5
- # @param [Proc] refresh_persisted_tags
5
+ # @param [ActiveRecord::Relation] tags_association
6
6
  # @param [Proc] on_change
7
- def initialize(context:, refresh_persisted_tags:, on_change:)
7
+ def initialize(context:, tags_association:, on_change:)
8
8
  self.context = context
9
- self.refresh_persisted_tags = refresh_persisted_tags
9
+ self.tags_association = tags_association
10
10
  self.on_change = on_change
11
11
  end
12
12
 
@@ -22,7 +22,7 @@ module EasyTags
22
22
 
23
23
  # @return [TagList]
24
24
  def persisted_tags
25
- @persisted_tags ||= TagList.new(refresh_persisted_tags.call)
25
+ @persisted_tags ||= preloaded_persisted_tags
26
26
  end
27
27
 
28
28
  # @param [String, Symbol] value
@@ -73,7 +73,7 @@ module EasyTags
73
73
 
74
74
  private
75
75
 
76
- attr_accessor :context, :refresh_persisted_tags, :on_change
76
+ attr_accessor :context, :tags_association, :on_change
77
77
 
78
78
  def respond_to_missing?(name, _include_private = false)
79
79
  tags.respond_to?(name)
@@ -88,5 +88,12 @@ module EasyTags
88
88
  def notify_change
89
89
  on_change.call(self) if changed?
90
90
  end
91
+
92
+ def preloaded_persisted_tags
93
+ return TagList.new(tags_association.reload.map(&:name)) if @preloaded
94
+
95
+ @preloaded = true
96
+ TagList.new(tags_association.map(&:name))
97
+ end
91
98
  end
92
99
  end
@@ -14,14 +14,6 @@ module EasyTags
14
14
  inverse_of: :taggable
15
15
  )
16
16
 
17
- has_many(
18
- :base_tags,
19
- through: :taggings,
20
- source: :tag,
21
- class_name: '::EasyTags::Tag',
22
- inverse_of: :tag
23
- )
24
-
25
17
  after_save :_update_taggings, :_refresh_tagging
26
18
  after_find :_refresh_tagging
27
19
 
@@ -70,9 +62,7 @@ module EasyTags
70
62
  def _taggable_context(context)
71
63
  _taggable_contexts[context] ||= TaggableContext.new(
72
64
  context: context,
73
- refresh_persisted_tags: lambda {
74
- taggings.joins(:tag).where(context: context).pluck(:name)
75
- },
65
+ tags_association: public_send("#{context}_tags"),
76
66
  on_change: lambda { |tag_context|
77
67
  _mark_dirty(context: context, taggable_context: tag_context)
78
68
  }
@@ -1,3 +1,3 @@
1
1
  module EasyTags
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iwo Dziechciarow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -78,6 +78,20 @@ dependencies:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: db-query-matchers
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
81
95
  - !ruby/object:Gem::Dependency
82
96
  name: rspec
83
97
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
228
  - !ruby/object:Gem::Version
215
229
  version: '0'
216
230
  requirements: []
217
- rubygems_version: 3.1.2
231
+ rubygems_version: 3.0.8
218
232
  signing_key:
219
233
  specification_version: 4
220
234
  summary: EasyTags allows you to tag a single model on several contexts