flickr-objects 0.4.1 → 0.5.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: 7de03cf589dcbc788d7f5379898849697d77727a
4
- data.tar.gz: 6e5ecd527db406c9d5c04b32941f16f74c05a925
3
+ metadata.gz: 804fe3b3024d5bfa5273c6b6ffbb65fd091e85e8
4
+ data.tar.gz: 3f80d880bbb6f2cfacaa0e11e144eb962ffe3f18
5
5
  SHA512:
6
- metadata.gz: aaf84c71ca0dd4ec410f392d39982e4a6a69eca500acd225cde9378bfbdb26223151a733783301ef39b74eca6aaf518a7ac80b913d6bf8aa6bb9811fce4b528e
7
- data.tar.gz: 391211fca29b2f3a713cc6e8fa343d76b8d067830300be0c9040fcadd8f8769f56a7c7254aaf8af80fc4d72ff5b24715bbc522551df172657cad8095ee89126e
6
+ metadata.gz: 2c98b7affe1fe3deba5842e135d2640cdf9404c4f36035e0c26e23ef3626590e9725a6a1e2d01ad4228a2a8853e082efdb83f7fb1fa1a3e4245d6979b384fc59
7
+ data.tar.gz: c25d0c5f1570a5299c54ba64e30230c3eb2c6f59b23081fe8bf1889aac6d86260ab4303813c58593cf4ed0b372b11c5f742aa44171cd15ed379734bce4760f70
data/README.md CHANGED
@@ -175,6 +175,25 @@ Flickr gives you pagination on almost every request that returns a collection of
175
175
  This gem supports both [WillPaginate](https://github.com/mislav/will_paginate) (`:will_paginate`)
176
176
  and [Kaminari](https://github.com/amatsuda/kaminari) (`:kaminari`).
177
177
 
178
+ ## Caching
179
+
180
+ To enable caching responses, just pass in a cache object (an object that responds
181
+ to `#read`, `#write` and `#fetch`) in the configuration.
182
+
183
+ ```ruby
184
+ require "active_support/cache"
185
+ require "active_support/core_ext/numeric/time"
186
+
187
+ Flickr.configure do |config|
188
+ config.cache = ActiveSupport::Cache::MemoryStore(expires_in: 1.week)
189
+ end
190
+ ```
191
+
192
+ ```ruby
193
+ Flickr.photos.recent # Makes an API call
194
+ Flickr.photos.recent # Uses the cache
195
+ ```
196
+
178
197
  ## Few words
179
198
 
180
199
  Many of the API methods are not covered yet (because they are so many).
data/lib/flickr/client.rb CHANGED
@@ -33,6 +33,7 @@ module Flickr
33
33
  @connection = Faraday.new(url, connection_options) do |builder|
34
34
  builder.use Flickr::Middleware::CatchTimeout
35
35
  yield builder if block_given?
36
+ builder.use FaradayMiddleware::Caching, Flickr.cache if Flickr.cache
36
37
 
37
38
  builder.adapter :net_http
38
39
  end
@@ -91,6 +91,14 @@ module Flickr
91
91
  #
92
92
  attr_accessor :pagination
93
93
 
94
+ ##
95
+ # Enables caching responses. An object that is passed must respond to
96
+ # `#read`, `#write` and `#fetch`.
97
+ #
98
+ # config.cache = ActiveSupport::Cache::MemoryStore.new(expires_in: 1.hour)
99
+ #
100
+ attr_accessor :cache
101
+
94
102
  end
95
103
 
96
104
  end
@@ -1,5 +1,5 @@
1
1
  module Flickr
2
2
 
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.0"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickr-objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday