readthis 1.0.0.pre.rc.1 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c641f0b14297f5f65cc9e2a36dc525c92e2f4a48
4
- data.tar.gz: cf5625a9a3b874f5f715979c615ee0db5c27daad
3
+ metadata.gz: 985ab4cb70b6ff45de0b279fe4d3ca90690cb206
4
+ data.tar.gz: d3c0519b74366c12278dc2a554d0a33c2914e7ac
5
5
  SHA512:
6
- metadata.gz: 3774c714c24caa36cdb07b8ce5b39f1694ed2e9b9b116b2b3c463fc516e2b2bfebf68e1481c5181502fddd76e3690ae3af7bfcf7ef3210c5ae8ca634ad3f16c9
7
- data.tar.gz: 274020a823960b9f4b7efdf101d02b3cc6a08074c508a6b32d4c990de0ccacf47571d98a1e74796f2d12d417971c297dffdc81abc1e24b3a770a74c64874810a
6
+ metadata.gz: e0cec4bef654487ed5f99c46f27d05572993a823239d1993b6e0b534f0b699f170c773ef191cddf468e1b05936c588d23ac6716ddf7659c89a86710306f13c5b
7
+ data.tar.gz: 5f8ac666204946a58135953c5e4b23d64a12f412019d578b28c8b8b1a7c351c1004775c0470a812038b12d2577b87eec5df8a4e09f628e5fbb1bed3fc008517a
data/README.md CHANGED
@@ -52,7 +52,11 @@ cache = Readthis::Cache.new(
52
52
  )
53
53
  ```
54
54
 
55
+ You can also specify `host`, `port`, `db` or any other valid Redis options. For
56
+ more details about connection options see in [redis gem documentation][redisrb]
57
+
55
58
  [store]: http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html
59
+ [redisrb]: https://github.com/redis/redis-rb#getting-started
56
60
 
57
61
  ### Instances & Databases
58
62
 
@@ -1,24 +1,19 @@
1
1
  require 'readthis/entity'
2
2
  require 'readthis/expanders'
3
- require 'readthis/notifications'
4
3
  require 'readthis/passthrough'
5
4
  require 'redis'
6
5
  require 'connection_pool'
7
6
 
8
7
  module Readthis
9
8
  class Cache
10
- attr_reader :entity, :options, :pool
9
+ attr_reader :entity, :notifications, :options, :pool
11
10
 
12
11
  # Provide a class level lookup of the proper notifications module.
13
12
  # Instrumention is expected to occur within applications that have
14
13
  # ActiveSupport::Notifications available, but needs to work even when it
15
14
  # isn't.
16
15
  def self.notifications
17
- if defined?(ActiveSupport::Notifications)
18
- ActiveSupport::Notifications
19
- else
20
- Readthis::Notifications
21
- end
16
+ ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
22
17
  end
23
18
 
24
19
  # Creates a new Readthis::Cache object with the given options.
@@ -334,11 +329,15 @@ module Readthis
334
329
  delta
335
330
  end
336
331
 
337
- def instrument(operation, key)
338
- name = "cache_#{operation}.active_support"
339
- payload = { key: key }
332
+ def instrument(name, key)
333
+ if self.class.notifications
334
+ name = "cache_#{name}.active_support"
335
+ payload = { key: key, name: name }
340
336
 
341
- self.class.notifications.instrument(name, payload) { yield(payload) }
337
+ self.class.notifications.instrument(name, payload) { yield(payload) }
338
+ else
339
+ yield
340
+ end
342
341
  end
343
342
 
344
343
  def invoke(operation, key, &block)
@@ -1,3 +1,3 @@
1
1
  module Readthis
2
- VERSION = '1.0.0-rc.1'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -291,4 +291,27 @@ RSpec.describe Readthis::Cache do
291
291
  expect(cache.decrement('unknown')).to eq(-1)
292
292
  end
293
293
  end
294
+
295
+ describe 'instrumentation' do
296
+ it 'instruments cache invokations' do
297
+ require 'active_support/notifications'
298
+
299
+ notes = ActiveSupport::Notifications
300
+ cache = Readthis::Cache.new
301
+ events = []
302
+
303
+ notes.subscribe(/cache_*/) do |*args|
304
+ events << ActiveSupport::Notifications::Event.new(*args)
305
+ end
306
+
307
+ cache.write('a', 'a')
308
+ cache.read('a')
309
+
310
+ expect(events.length).to eq(2)
311
+ expect(events.map(&:name)).to eq(%w[
312
+ cache_write.active_support
313
+ cache_read.active_support
314
+ ])
315
+ end
316
+ end
294
317
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readthis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.rc.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Selbert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2015-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -107,14 +121,12 @@ files:
107
121
  - lib/readthis/cache.rb
108
122
  - lib/readthis/entity.rb
109
123
  - lib/readthis/expanders.rb
110
- - lib/readthis/notifications.rb
111
124
  - lib/readthis/passthrough.rb
112
125
  - lib/readthis/serializers.rb
113
126
  - lib/readthis/version.rb
114
127
  - spec/readthis/cache_spec.rb
115
128
  - spec/readthis/entity_spec.rb
116
129
  - spec/readthis/expanders_spec.rb
117
- - spec/readthis/notifications_spec.rb
118
130
  - spec/readthis/passthrough_spec.rb
119
131
  - spec/readthis/serializers_spec.rb
120
132
  - spec/readthis_spec.rb
@@ -134,9 +146,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
146
  version: '0'
135
147
  required_rubygems_version: !ruby/object:Gem::Requirement
136
148
  requirements:
137
- - - ">"
149
+ - - ">="
138
150
  - !ruby/object:Gem::Version
139
- version: 1.3.1
151
+ version: '0'
140
152
  requirements: []
141
153
  rubyforge_project:
142
154
  rubygems_version: 2.4.5.1
@@ -147,7 +159,6 @@ test_files:
147
159
  - spec/readthis/cache_spec.rb
148
160
  - spec/readthis/entity_spec.rb
149
161
  - spec/readthis/expanders_spec.rb
150
- - spec/readthis/notifications_spec.rb
151
162
  - spec/readthis/passthrough_spec.rb
152
163
  - spec/readthis/serializers_spec.rb
153
164
  - spec/readthis_spec.rb
@@ -1,7 +0,0 @@
1
- module Readthis
2
- module Notifications
3
- def self.instrument(_name, payload)
4
- yield(payload)
5
- end
6
- end
7
- end
@@ -1,15 +0,0 @@
1
- require 'readthis/notifications'
2
-
3
- RSpec.describe Readthis::Notifications do
4
- describe '#instrument' do
5
- it 'yields the provided block' do
6
- inner = double(:inner)
7
-
8
- expect(inner).to receive(:call)
9
-
10
- Readthis::Notifications.instrument('operation', key: 'key') do
11
- inner.call
12
- end
13
- end
14
- end
15
- end