rack-cache-tags 0.0.5 → 0.0.6

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.
@@ -10,7 +10,8 @@ module Rack
10
10
  end
11
11
 
12
12
  def store(url, tags)
13
- tags.each { |tag| Tagging.find_or_create_by_url_and_tag(url, tag) }
13
+ tags -= taggings_by_url_and_tags(url, tags).map(&:tag)
14
+ tags.each { |tag| Tagging.create(:url => url, :tag => tag) }
14
15
  end
15
16
 
16
17
  def purge(tags)
@@ -18,13 +19,17 @@ module Rack
18
19
  end
19
20
 
20
21
  def urls_by_tags(tags)
21
- taggings_by_tags(tags).map(&:url)
22
+ taggings_by_tags(tags).map(&:url).uniq
22
23
  end
23
24
 
24
25
  def taggings_by_tags(tags)
25
26
  sql = "tag IN (?) #{[' OR tag LIKE ?'] * tags.size}"
26
27
  Tagging.where(sql, tags, *tags.map { |tag| "#{tag.split(':').first}%" })
27
28
  end
29
+
30
+ def taggings_by_url_and_tags(url, tags)
31
+ Tagging.where("url = ? AND tag IN (?)", url, tags)
32
+ end
28
33
  end
29
34
  end
30
35
  end
@@ -1,3 +1,3 @@
1
1
  module RackCacheTags
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cache-tags
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-03 00:00:00 +02:00
18
+ date: 2010-10-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21