block_cache 0.0.2 → 0.1.0

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.
data/lib/block_cache.rb CHANGED
@@ -1,25 +1,21 @@
1
- =begin
2
-
3
- block_cache methods for caching single block responses in mongo
4
- planned to support mongoid in the future. :D -blake
5
-
6
- attributes:
7
- * block_key: basic key passed to the cache_overwrite_by method that
8
- will store and overwrite by that valid. could easily use
9
- the request.uri for content cached as json or something as
10
- such.
11
- * block_response: basic block of content that is returned by the block call.
12
-
13
- WARNING: BLOCKS THAT RETURN NIL WILL OVERWRITE THE DATA. TO BE SURE RAISE ERRORS
14
- WHEN EXITING BLOCKS WITH NIL DATA. THIS LIBRARY CURRENTLY DOSESNT PREVENT
15
- THIS EXCEPTION.
16
-
17
- =end
18
-
1
+ # block_cache methods for caching single block responses in mongo
2
+ # planned to support mongoid in the future. :D -blake
3
+ #
4
+ # attributes:
5
+ # * block_key: basic key passed to the cache_overwrite_by method that
6
+ # will store and overwrite by that valid. could easily use
7
+ # the request.uri for content cached as json or something as
8
+ # such.
9
+ # * block_response: basic block of content that is returned by the block call.
10
+ #
11
+ # WARNING: BLOCKS THAT RETURN NIL WILL OVERWRITE THE DATA. TO BE SURE RAISE ERRORS
12
+ # WHEN EXITING BLOCKS WITH NIL DATA. THIS LIBRARY CURRENTLY DOSESNT PREVENT
13
+ # THIS EXCEPTION.
19
14
  module BlockCache
20
15
  CACHE_NIL_RESPONSES = true
21
- HOPTOAD_SUPPORTED=begin
22
- require 'hoptoad_notifier' ;; true
16
+ AIRBRAKE_SUPPORTED=begin
17
+ require 'airbrake' ;; true
18
+ Airbrake
23
19
  rescue
24
20
  false
25
21
  end
@@ -30,6 +26,7 @@ module BlockCache
30
26
 
31
27
  module ControllerMethods
32
28
  class NilResponseError < Exception ;; end
29
+
33
30
  def cache_overwrite_by(key, &block)
34
31
  raise ArgumentError, "needs a key and block" unless key && block
35
32
 
@@ -42,7 +39,7 @@ module BlockCache
42
39
  rescue => exception
43
40
  logger.info "block cache error(#{exception.to_s}) returned, rendering from mongo."
44
41
  logger.debug "Backtrace:\n\n#{exception.backtrace}\n\n"
45
- HoptoadNotifier.notify(exception) if RAILS_ENV["production"] and HOPTOAD_SUPPORTED
42
+ Airbrake.notify(exception) if RAILS_ENV["production"] and AIRBRAKE_SUPPORTED
46
43
 
47
44
  return BlockCache::Record.find_by_block_key(key).try(:block_response)
48
45
  end
@@ -1,3 +1,3 @@
1
1
  module BlockCache
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -2,12 +2,12 @@
2
2
  name: block_cache
3
3
  version: !ruby/object:Gem::Version
4
4
  hash: 27
5
- prerelease: false
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 2
10
- version: 0.0.2
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Blake Chambers
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-17 00:00:00 -05:00
19
- default_executable:
18
+ date: 2012-01-13 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: mongo_mapper
@@ -32,20 +31,6 @@ dependencies:
32
31
  version: "0"
33
32
  type: :runtime
34
33
  version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rspec
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
47
- type: :development
48
- version_requirements: *id002
49
34
  description: "uses mongo_mapper to cache block response strings. Use case: wrap your twitter api call with a block, if twitter bugs out, raise an error and the last value will be returned"
50
35
  email:
51
36
  - chambb1@gmail.com
@@ -65,7 +50,6 @@ files:
65
50
  - lib/block_cache.rb
66
51
  - lib/block_cache/version.rb
67
52
  - spec/block_cache_spec.rb
68
- has_rdoc: true
69
53
  homepage: http://rubygems.org/gems/block_cache
70
54
  licenses: []
71
55
 
@@ -95,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
79
  requirements: []
96
80
 
97
81
  rubyforge_project:
98
- rubygems_version: 1.3.7
82
+ rubygems_version: 1.8.10
99
83
  signing_key:
100
84
  specification_version: 3
101
85
  summary: uses mongo_mapper to cache block response strings.