booking_locations 0.5.0 → 0.6.0

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: 539fd819b4941dcbd0027147abf45d8e6061550b
4
- data.tar.gz: c060eacb91f9da6b514f88f328154b4e387e897a
3
+ metadata.gz: 32a99d8cdce3cdfedc42e876dc225d3db5de2637
4
+ data.tar.gz: 2a3a1f730d693206b0ed4440f7c03af15ddf1e51
5
5
  SHA512:
6
- metadata.gz: 3cc408330e0afcb341a3bde19f809b9ef7b0c6f93a61251f0e0081e7f99963b977fe41e2c3b471d7f498ed0409ebb966aecc6ea931728a567846d123554c39ff
7
- data.tar.gz: 952de21a2d951e62ffbc68fc47cd1b036d5b385b0240f024adaeb9d093847755d02b5568c1cb3975b6ce9b7447e729ff16daf699dc0efa128cbe4e180cf8d5c6
6
+ metadata.gz: 283e4901d9174e1f49ff5b063bb9ee441c5a67c60d44c217130de227f26a7bfe01b46e5d25cddb9fe7e1ea0a5e036da17c6df699d89599c085a5097768dae69e
7
+ data.tar.gz: 528103ba0d79e97af6785a535532283abc42be87664353b0fa2a22af0c9e0e425feecd34cdf3955e157062d75f5be075a584f5f97dd32f3cbd7978707b83c770
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.6.0
2
+
3
+ * Adds configurable caching for location responses
4
+
1
5
  ## 0.5.0
2
6
 
3
7
  * Return guider's name by ID
@@ -2,19 +2,29 @@ require 'booking_locations/version'
2
2
  require 'booking_locations/api'
3
3
  require 'booking_locations/slot'
4
4
  require 'booking_locations/location'
5
+ require 'booking_locations/null_cache'
5
6
 
6
7
  require 'active_support/core_ext/module/attribute_accessors'
7
8
 
8
9
  module BookingLocations
10
+ DEFAULT_TTL = 2 * 60 * 60 # 2 hours
11
+
9
12
  mattr_writer :api
13
+ mattr_writer :cache
10
14
 
11
15
  def self.api
12
16
  @@api ||= BookingLocations::Api.new
13
17
  end
14
18
 
15
- def self.find(id)
16
- api.get(id) do |response_hash|
17
- Location.new(response_hash)
19
+ def self.cache
20
+ @@cache ||= BookingLocations::NullCache.new
21
+ end
22
+
23
+ def self.find(id, expires = DEFAULT_TTL)
24
+ cache.fetch(id, expires: expires) do
25
+ api.get(id) do |response_hash|
26
+ Location.new(response_hash)
27
+ end
18
28
  end
19
29
  end
20
30
  end
@@ -0,0 +1,7 @@
1
+ module BookingLocations
2
+ class NullCache
3
+ def fetch(*)
4
+ yield
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module BookingLocations
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: booking_locations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Lovell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -135,6 +135,7 @@ files:
135
135
  - lib/booking_locations.rb
136
136
  - lib/booking_locations/api.rb
137
137
  - lib/booking_locations/location.rb
138
+ - lib/booking_locations/null_cache.rb
138
139
  - lib/booking_locations/slot.rb
139
140
  - lib/booking_locations/stub_api.json
140
141
  - lib/booking_locations/stub_api.rb