social_current 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/social_current/service.rb +4 -4
- data/lib/social_current/version.rb +1 -1
- data/lib/social_current.rb +1 -0
- metadata +1 -1
@@ -5,8 +5,8 @@ module SocialCurrent
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def fetch(remote, local)
|
8
|
-
@contents = if cache_valid?(
|
9
|
-
JSON.parse(
|
8
|
+
@contents = if cache_valid?(local)
|
9
|
+
JSON.parse(Tempfile.read(local))
|
10
10
|
else
|
11
11
|
write_cache(local, JSON.parse(self.class.get(remote).body))
|
12
12
|
end
|
@@ -15,14 +15,14 @@ module SocialCurrent
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def write_cache(local, contents)
|
18
|
-
|
18
|
+
Tempfile.new(local) do |f|
|
19
19
|
f.write(contents.to_json)
|
20
20
|
end
|
21
21
|
contents
|
22
22
|
end
|
23
23
|
|
24
24
|
def cache_valid?(cache)
|
25
|
-
|
25
|
+
Tempfile.open(cache) && Tempfile.open(cache).mtime > Time.now - 3000
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/social_current.rb
CHANGED