slideshowpro 0.0.3 → 0.0.4
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/README.md +2 -2
- data/lib/slideshowpro/director.rb +6 -5
- data/lib/slideshowpro/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -42,12 +42,12 @@ Get an Album:
|
|
42
42
|
Caching
|
43
43
|
--------
|
44
44
|
|
45
|
-
This gem will cache the API responses if you
|
45
|
+
This gem will cache the API responses if you pass in a cache object from your app. Only tested with memcachd but should work with anything that responds to 'get' and 'set' methods.
|
46
46
|
|
47
47
|
Example:
|
48
48
|
|
49
49
|
require 'memcached'
|
50
|
-
|
50
|
+
@ssp.cache = Memcached.new
|
51
51
|
|
52
52
|
Enjoy!
|
53
53
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Slideshowpro
|
2
2
|
class Director
|
3
|
-
attr_accessor :api_key, :url
|
4
|
-
def initialize(url, api_key,
|
3
|
+
attr_accessor :api_key, :url, :cache
|
4
|
+
def initialize(url, api_key, cache=nil)
|
5
5
|
self.url = url
|
6
6
|
self.api_key = api_key
|
7
|
+
self.cache = cache
|
7
8
|
end
|
8
9
|
def post(method, options)
|
9
10
|
params = {
|
@@ -14,14 +15,14 @@ module Slideshowpro
|
|
14
15
|
params.merge!(options)
|
15
16
|
data = URI.escape(params.map {|k,v| "#{URI.escape(k)}=#{URI.escape(v.to_s)}"}.join("&"))
|
16
17
|
|
17
|
-
if defined?(
|
18
|
+
if defined?(self.cache) && self.cache.respond_to?(:get)
|
18
19
|
require 'digest/md5'
|
19
20
|
data_key = Digest::MD5.hexdigest(method + "|" + data)
|
20
21
|
begin
|
21
|
-
json=
|
22
|
+
json=self.cache.get(data_key)
|
22
23
|
rescue Memcached::NotFound
|
23
24
|
json = get_json(url, method, data)
|
24
|
-
|
25
|
+
self.cache.set(data_key, json)
|
25
26
|
rescue Memcached::ServerIsMarkedDead
|
26
27
|
puts "Memcache Down!"
|
27
28
|
#fall back to get data directly
|
data/lib/slideshowpro/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slideshowpro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Hixon
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-09 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|