social_current 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  require "httparty"
2
2
  require "json"
3
- require "tempfile"
3
+ require "tmpdir"
4
4
 
5
5
  require "social_current/version"
6
6
  require "social_current/service"
@@ -5,8 +5,8 @@ module SocialCurrent
5
5
  end
6
6
 
7
7
  def fetch(remote, local)
8
- @contents = if cache_valid?(local)
9
- JSON.parse(Tempfile.read(local))
8
+ @contents = if cache_valid?("#{Dir.tmpdir}/#{local}")
9
+ JSON.parse(File.read("#{Dir.tmpdir}/#{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
- Tempfile.new(local) do |f|
18
+ File.open("#{Dir.tmpdir}/#{local}", "w") 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
- Tempfile.open(cache) && Tempfile.open(cache).mtime > Time.now - 3000
25
+ File.exists?(cache) && File.new(cache).mtime > Time.now - 3000
26
26
  end
27
27
  end
28
28
  end
@@ -1,4 +1,4 @@
1
1
  module SocialCurrent
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  SUPPORTED_INTEGRATIONS = [:github, :twitter]
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_current
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: