hitnmiss 2.1.0 → 2.2.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16113a952ba4f6e13da3988202b5293f7b29883e
4
- data.tar.gz: e47681d3d3de77dc028ace05d8ca89c6c44d4cc0
3
+ metadata.gz: ff75002585412d720fd263df2de46c40a938b6e8
4
+ data.tar.gz: 0f32bfbe940cb194497f8fc7fe9ec07f1ff61faf
5
5
  SHA512:
6
- metadata.gz: 063cac92539361cd38cbf1cf6defd69d83ab9406c5e0f65e3639b7ad708f3ecee452cd6b2313383c6e0658baaaec4cf71ffc9eeddd79d61ec2fa65c0d4cb2828
7
- data.tar.gz: f2495525eb2431776aaf631766e61d17f0ff712a7e98b9e9ad71c216eedeb8df4f542a76c14ccb24b203af5b8d3bbd702782fc1ee0e843e0a65630570e011303
6
+ metadata.gz: b30dd65528003dfb525ad21ef9019cad6e7f9919ae377b5262d8e5886471a07508c1405603ac023303187ee75615a39f346e6aa25f03285c002505daa657efc6
7
+ data.tar.gz: bd865b3b46ab573a274a4205bf956ffeb5e4557b969da4fcf4fc1b92d1c770fc17e6f251d1be4e6d470a3b30550c9bfbaa08ad97fd157745b665af88c9a48cae
@@ -6,6 +6,8 @@ versions, as well as provide a rough history.
6
6
 
7
7
  #### Next Release
8
8
 
9
+ * Added logging support to BackgroundRefreshRepository and Repository
10
+
9
11
  #### v2.1.0
10
12
 
11
13
  * Changed: Documentation for open sourcing
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- [![Build Status](https://travis-ci.com/Acornsgrow/hitnmiss.svg?token=GGEgqzL4zt7sa3zVgspU&branch=master)](https://travis-ci.com/Acornsgrow/hitnmiss)
2
- [![Code Climate](https://codeclimate.com/repos/567a3c30bd3f3b63510017dd/badges/e979a32e79ec12d35896/gpa.svg)](https://codeclimate.com/repos/567a3c30bd3f3b63510017dd/feed)
3
- [![Test Coverage](https://codeclimate.com/repos/567a3c30bd3f3b63510017dd/badges/e979a32e79ec12d35896/coverage.svg)](https://codeclimate.com/repos/567a3c30bd3f3b63510017dd/coverage)
4
- [![Issue Count](https://codeclimate.com/repos/567a3c30bd3f3b63510017dd/badges/e979a32e79ec12d35896/issue_count.svg)](https://codeclimate.com/repos/567a3c30bd3f3b63510017dd/feed)
1
+ [![Build Status](https://travis-ci.org/Acornsgrow/hitnmiss.svg?branch=master)](https://travis-ci.org/Acornsgrow/hitnmiss)
2
+ [![Code Climate](https://codeclimate.com/github/Acornsgrow/hitnmiss/badges/gpa.svg)](https://codeclimate.com/github/Acornsgrow/hitnmiss)
3
+ [![Test Coverage](https://codeclimate.com/github/Acornsgrow/hitnmiss/badges/coverage.svg)](https://codeclimate.com/github/Acornsgrow/hitnmiss/coverage)
4
+ [![Issue Count](https://codeclimate.com/github/Acornsgrow/hitnmiss/badges/issue_count.svg)](https://codeclimate.com/github/Acornsgrow/hitnmiss)
5
5
 
6
6
  # Hitnmiss
7
7
 
@@ -179,6 +179,24 @@ end
179
179
 
180
180
  This works exactly the same with the `Hitnmiss::BackgroundRefreshRepository`.
181
181
 
182
+ ### Set a Logger
183
+
184
+ Hitnmiss defaults to not logging. However, if you would like to get detailed
185
+ logging from Hitnmiss you can do so by passing your application controlled
186
+ logger instance to the Hitnmiss repository. An example of this can be seen
187
+ below.
188
+
189
+ ```ruby
190
+ class MostRecentPrice
191
+ include Hitnmiss::Repository
192
+
193
+ logger Logger.new(STDOUT)
194
+ end
195
+ ```
196
+
197
+ **Note:** The above works exactly the same way for `Hitnmiss::Repository` and
198
+ `Hitnmiss::BackgroundRefreshRepository`.
199
+
182
200
  ### Define Fetcher Methods
183
201
 
184
202
  You may be asking yourself, "How does the cache value get set?" Well,
@@ -6,8 +6,8 @@ require 'hitnmiss/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "hitnmiss"
8
8
  spec.version = Hitnmiss::VERSION
9
- spec.authors = ["Andrew De Ponte"]
10
- spec.email = ["cyphactor@gmail.com"]
9
+ spec.authors = ["Andrew De Ponte", "Brian Miller", "Kyle Chong"]
10
+ spec.email = ["cyphactor@gmail.com", "brimil01@gmail.com", "me@kylechong.com"]
11
11
 
12
12
  spec.summary = %q{Ruby read-through, write-behind caching using POROs}
13
13
  spec.description = %q{Ruby gem to support using the Repository pattern for read-through, write-behind caching using POROs}
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.add_dependency "optional_logger", "~> 2.0"
22
23
  spec.add_development_dependency "bundler", "~> 1.11"
23
24
  spec.add_development_dependency "rake", "~> 10.0"
24
25
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -1,3 +1,4 @@
1
+ require "optional_logger"
1
2
  require "hitnmiss/version"
2
3
  require "hitnmiss/errors"
3
4
  require "hitnmiss/repository"
@@ -6,6 +6,7 @@ module Hitnmiss
6
6
  class RefreshIntervalRequired < StandardError; end
7
7
 
8
8
  def self.included(mod)
9
+ mod.extend(OptionalLogger::LoggerManagement)
9
10
  mod.include(Repository::CacheManagement)
10
11
  mod.extend(ClassMethods)
11
12
  mod.include(InstanceMethods)
@@ -33,28 +34,39 @@ module Hitnmiss
33
34
  end
34
35
 
35
36
  def refresh(*args, swallow_exceptions: [])
37
+ self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) called")
36
38
  if swallow_exceptions.empty?
39
+ self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) about to check stale?")
37
40
  if stale?(*args)
41
+ self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) is stale, about to prime")
38
42
  prime(*args)
39
43
  end
40
44
  else
41
45
  begin
46
+ self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) about to check stale?")
42
47
  if stale?(*args)
48
+ self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) is stale, about to prime")
43
49
  prime(*args)
44
50
  end
45
- rescue *swallow_exceptions
51
+ rescue *swallow_exceptions => e
52
+ self.class.logger.error("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) swallowed exception: #{e.inspect}")
53
+ self.class.logger.error(e.backtrace.join("\n"))
46
54
  end
47
55
  end
48
56
  end
49
57
 
50
58
  def background_refresh(*args, swallow_exceptions: [])
59
+ self.class.logger.debug("hitnmiss: background_refresh(#{args.inspect}) called")
51
60
  @refresh_thread = Thread.new(self, args) do |repository, args|
52
61
  while(true) do
62
+ repository.class.logger.debug("hitnmiss: background_refresh(#{args.inspect}): about to call refresh()")
53
63
  refresh(*args, swallow_exceptions: swallow_exceptions)
64
+ repository.class.logger.debug("hitnmiss: background_refresh(#{args.inspect}): about to sleep for #{repository.class.refresh_interval}")
54
65
  sleep repository.class.refresh_interval
55
66
  end
56
67
  end
57
68
  @refresh_thread.abort_on_exception = true
69
+ self.class.logger.debug("hitnmiss: background_refresh(#{args.inspect}) enabled abort on exception")
58
70
  end
59
71
 
60
72
  private
@@ -3,6 +3,7 @@ require 'hitnmiss/repository/cache_management'
3
3
  module Hitnmiss
4
4
  module Repository
5
5
  def self.included(mod)
6
+ mod.extend(OptionalLogger::LoggerManagement)
6
7
  mod.include(CacheManagement)
7
8
  mod.extend(ClassMethods)
8
9
  mod.include(InstanceMethods)
@@ -1,3 +1,3 @@
1
1
  module Hitnmiss
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0.pre.rc.1"
3
3
  end
metadata CHANGED
@@ -1,15 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hitnmiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0.pre.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew De Ponte
8
+ - Brian Miller
9
+ - Kyle Chong
8
10
  autorequire:
9
11
  bindir: exe
10
12
  cert_chain: []
11
- date: 2016-07-03 00:00:00.000000000 Z
13
+ date: 2016-10-27 00:00:00.000000000 Z
12
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: optional_logger
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.0'
13
29
  - !ruby/object:Gem::Dependency
14
30
  name: bundler
15
31
  requirement: !ruby/object:Gem::Requirement
@@ -98,6 +114,8 @@ description: Ruby gem to support using the Repository pattern for read-through,
98
114
  caching using POROs
99
115
  email:
100
116
  - cyphactor@gmail.com
117
+ - brimil01@gmail.com
118
+ - me@kylechong.com
101
119
  executables: []
102
120
  extensions: []
103
121
  extra_rdoc_files: []
@@ -145,9 +163,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
163
  version: '0'
146
164
  required_rubygems_version: !ruby/object:Gem::Requirement
147
165
  requirements:
148
- - - ">="
166
+ - - ">"
149
167
  - !ruby/object:Gem::Version
150
- version: '0'
168
+ version: 1.3.1
151
169
  requirements: []
152
170
  rubyforge_project:
153
171
  rubygems_version: 2.5.1