markbates-rack_page_caching 0.1.2 → 0.1.3

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.
@@ -1,6 +1,7 @@
1
1
  require 'rack'
2
2
  require 'cachetastic'
3
3
  require 'configatron'
4
+ require 'hoptoad_notifier'
4
5
 
5
6
  # configatron.rack.caching.set_default(:use_page_caching, true)
6
7
 
@@ -1,7 +1,7 @@
1
1
  unless ActionController.const_defined?('CONFIGURED_PAGE_CACHING_EXTENSIONS')
2
2
  module ActionController
3
3
  class Base
4
-
4
+ include HoptoadNotifier::Catcher
5
5
  class << self
6
6
  alias_method :__caches_page, :caches_page
7
7
 
@@ -20,14 +20,19 @@ unless ActionController.const_defined?('CONFIGURED_PAGE_CACHING_EXTENSIONS')
20
20
 
21
21
  private
22
22
  def read_from_rack_page_cache
23
- if request.get? && configatron.rack.caching.use_page_caching
24
- cpage = Cachetastic::Caches::PageCache.get(request.url)
25
- if cpage
26
- response.headers["Content-Type"] = cpage.content_type
27
- render(:text => cpage.body, :layout => false)
28
- return false
23
+ begin
24
+ if request.get? && configatron.rack.caching.use_page_caching
25
+ cpage = Cachetastic::Caches::PageCache.get(request.url)
26
+ if cpage
27
+ response.headers["Content-Type"] = cpage.content_type
28
+ render(:text => cpage.body, :layout => false)
29
+ return false
30
+ end
29
31
  end
32
+ rescue Exception => e
33
+ notify_hoptoad(e)
30
34
  end
35
+
31
36
  return true
32
37
  end
33
38
 
@@ -1,6 +1,7 @@
1
1
  module Rack
2
2
  module PageCaching
3
3
  class Middleware
4
+ include HoptoadNotifier::Catcher
4
5
 
5
6
  def initialize(app) # :nodoc:
6
7
  @app = app
@@ -10,13 +11,18 @@ module Rack
10
11
  if configatron.rack.caching.use_page_caching
11
12
  request = Rack::Request.new(env)
12
13
  if request.get?
13
- page = Cachetastic::Caches::PageCache.get(request.fullpath)
14
- if page
15
- response = Rack::Response.new
16
- response["Content-Type"] = page.content_type
17
- response.write(page.body)
18
- return response.finish
14
+ begin
15
+ page = Cachetastic::Caches::PageCache.get(request.fullpath)
16
+ if page
17
+ response = Rack::Response.new
18
+ response["Content-Type"] = page.content_type
19
+ response.write(page.body)
20
+ return response.finish
21
+ end
22
+ rescue Exception => e
23
+ HoptoadNotifier::Catcher.notify_hoptoad(e)
19
24
  end
25
+
20
26
  end
21
27
  ret = @app.call(env)
22
28
  unless ret[2].is_a?(Rack::File)
@@ -56,6 +62,7 @@ module Rack
56
62
  end # Page
57
63
 
58
64
  class << self
65
+ include HoptoadNotifier::Catcher
59
66
 
60
67
  def cache_controls(headers)
61
68
  cc_header = headers['Cache-Control'] || 'private'
@@ -76,8 +83,13 @@ module Rack
76
83
  end
77
84
 
78
85
  def set_into_cache(url, body, content_type, expiry = configatron.cachetastic_caches_page_cache_options.default_expiry)
79
- Cachetastic::Caches::PageCache.set(url, Rack::PageCaching::Middleware::Page.new(body, content_type),
80
- expiry.to_i)
86
+ begin
87
+ Cachetastic::Caches::PageCache.set(url,
88
+ Rack::PageCaching::Middleware::Page.new(body, content_type),
89
+ expiry.to_i)
90
+ rescue Exception => e
91
+ notify_hoptoad(e)
92
+ end
81
93
  end
82
94
 
83
95
  end # class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markbates-rack_page_caching
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-16 00:00:00 -07:00
12
+ date: 2009-03-26 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,16 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: "0"
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: markbates-hoptoad_notifier
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ version: "1.2"
44
+ version:
35
45
  description: "rack_page_caching was developed by: markbates"
36
46
  email: ""
37
47
  executables: []