kiosk 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,8 +31,7 @@ module Kiosk
31
31
  # +cache_expire_by_pattern+.
32
32
  #
33
33
  def cache_key_matcher
34
- case Rails.cache
35
- when ActiveSupport::Cache::RedisStore
34
+ if defined?(ActiveSupport::Cache::RedisStore) && Rails.cache.is_a?(ActiveSupport::Cache::RedisStore)
36
35
  :glob
37
36
  else
38
37
  :regexp
@@ -73,11 +72,11 @@ module Kiosk
73
72
  # fresh result is returned.
74
73
  #
75
74
  def cache_read_write(key)
76
- if result = cache(:read, cache_key(key))
77
- result = JSON.parse(result)
75
+ if cached_object = cache(:read, cache_key(key))
76
+ result = cached_object
78
77
  elsif result = yield
79
78
  options = (expiry = cache_expiry_of(result)) ? {:expires_in => expiry} : {}
80
- cache(:write, cache_key(key), result.to_json, options) if result
79
+ cache(:write, cache_key(key), result, options) if result
81
80
  end
82
81
  result
83
82
  end
@@ -100,12 +100,10 @@ module Kiosk
100
100
  end
101
101
  end
102
102
 
103
- module InstanceMethods
104
- # Expire the resource from the cache.
105
- #
106
- def expire
107
- self.class.expire_resource(self)
108
- end
103
+ # Expire the resource from the cache.
104
+ #
105
+ def expire
106
+ self.class.expire_resource(self)
109
107
  end
110
108
  end
111
109
  end
@@ -6,56 +6,54 @@ module Kiosk
6
6
  module Controller
7
7
  extend ActiveSupport::Concern
8
8
 
9
- module InstanceMethods
10
- # Declares a rewrite of content nodes that sets the host portion of
11
- # each node's URI attribute (href or src) to target the configured CDN
12
- # host.
13
- #
14
- def rewrite_cdn_paths_for(resource_model)
15
- Kiosk.rewriter.add_rewrite(Rewrite.new(:cdn, resource_model))
16
- end
9
+ # Declares a rewrite of content nodes that sets the host portion of
10
+ # each node's URI attribute (href or src) to target the configured CDN
11
+ # host.
12
+ #
13
+ def rewrite_cdn_paths_for(resource_model)
14
+ Kiosk.rewriter.add_rewrite(Rewrite.new(:cdn, resource_model))
15
+ end
17
16
 
18
- # Declares a rewrite of content nodes.
19
- #
20
- # Example:
21
- #
22
- # class PostsController
23
- # include Kiosk::Controller
24
- #
25
- # before_filter do
26
- # rewrite_content_for(Attachment) do |attachment,node|
27
- # case node.name
28
- # when 'a'
29
- # node['title'] = 'Some photo'
30
- # when 'img'
31
- # node['src'] = attachment_path(attachment.filename)
32
- # end
33
- # end
34
- # end
35
- # end
36
- #
37
- def rewrite_content_for(resource_model, &blk)
38
- Kiosk.rewriter.add_rewrite(Rewrite.new(:node, resource_model, &blk))
39
- end
17
+ # Declares a rewrite of content nodes.
18
+ #
19
+ # Example:
20
+ #
21
+ # class PostsController
22
+ # include Kiosk::Controller
23
+ #
24
+ # before_filter do
25
+ # rewrite_content_for(Attachment) do |attachment,node|
26
+ # case node.name
27
+ # when 'a'
28
+ # node['title'] = 'Some photo'
29
+ # when 'img'
30
+ # node['src'] = attachment_path(attachment.filename)
31
+ # end
32
+ # end
33
+ # end
34
+ # end
35
+ #
36
+ def rewrite_content_for(resource_model, &blk)
37
+ Kiosk.rewriter.add_rewrite(Rewrite.new(:node, resource_model, &blk))
38
+ end
40
39
 
41
- # Declares a rewrite of content nodes that sets a new URL any href or src
42
- # attributes (the first one found, it that order). The given block is
43
- # passed the instantiated resource and node as its arguments and should
44
- # return the new value for the node attribute.
45
- #
46
- # Example:
47
- #
48
- # class PostsController
49
- # include Kiosk::Controller
50
- #
51
- # before_filter do
52
- # rewrite_paths_for(Post) { |post| post_path(post.slug) }
53
- # end
54
- # end
55
- #
56
- def rewrite_paths_for(resource_model, &blk)
57
- Kiosk.rewriter.add_rewrite(Rewrite.new(:path, resource_model, &blk))
58
- end
40
+ # Declares a rewrite of content nodes that sets a new URL any href or src
41
+ # attributes (the first one found, it that order). The given block is
42
+ # passed the instantiated resource and node as its arguments and should
43
+ # return the new value for the node attribute.
44
+ #
45
+ # Example:
46
+ #
47
+ # class PostsController
48
+ # include Kiosk::Controller
49
+ #
50
+ # before_filter do
51
+ # rewrite_paths_for(Post) { |post| post_path(post.slug) }
52
+ # end
53
+ # end
54
+ #
55
+ def rewrite_paths_for(resource_model, &blk)
56
+ Kiosk.rewriter.add_rewrite(Rewrite.new(:path, resource_model, &blk))
59
57
  end
60
58
  end
61
59
  end
data/lib/kiosk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kiosk
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kiosk
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Duvall
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-05-12 00:00:00 Z
13
+ date: 2012-05-15 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: 3.1.4
34
+ version: 3.2.3
35
35
  type: :runtime
36
36
  version_requirements: *id002
37
37
  - !ruby/object:Gem::Dependency
@@ -46,16 +46,27 @@ dependencies:
46
46
  type: :development
47
47
  version_requirements: *id003
48
48
  - !ruby/object:Gem::Dependency
49
- name: shoulda
49
+ name: shoulda-matchers
50
50
  prerelease: false
51
51
  requirement: &id004 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
- - - ">="
54
+ - - ~>
55
55
  - !ruby/object:Gem::Version
56
- version: "0"
56
+ version: "1.1"
57
57
  type: :development
58
58
  version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: thinking-sphinx
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 2.0.3
68
+ type: :development
69
+ version_requirements: *id005
59
70
  description: "Kiosk provides APIs for integrating WordPress content into a Ruby application: a base REST model for retrieving content, a caching layer, and a rewriting engine for canonicalizing and contextualizing content elements."
60
71
  email:
61
72
  - dan@mutual.io