sleepy 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/sleepy.rb +6 -5
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/lib/sleepy.rb CHANGED
@@ -29,6 +29,7 @@ module Weary
29
29
  def perform_sleepily(timeout=60*60*1000, &block)
30
30
  @on_complete = block if block_given?
31
31
  if HAS_MEMCACHE
32
+ timeout = ENV["SLEEPY_TIMEOUT"] if defined?(ENV["SLEEPY_TIMEOUT"])
32
33
  response = perform_sleepily!(timeout)
33
34
  else
34
35
  response = perform
@@ -37,13 +38,11 @@ module Weary
37
38
  end
38
39
 
39
40
  # Redefine the perform method
40
- def perform_sleepily!(timeout=60*60*1000, &block)
41
+ def perform_sleepily!(timeout, &block)
41
42
  @on_complete = block if block_given?
42
43
  Thread.new {
43
- STDERR.puts "Before send: #{uri}"
44
44
  before_send.call(self) if before_send
45
45
 
46
- STDERR.puts "try nap"
47
46
  nap = sleepy.get("#{round_time(Time.new.to_i, timeout)}:#{uri}") rescue nil
48
47
 
49
48
  unless nap.blank?
@@ -60,8 +59,10 @@ module Weary
60
59
  on_complete.call(response) if on_complete
61
60
  response
62
61
  end
63
- sleepy.set("#{round_time(Time.new.to_i, timeout)}:#{uri}", response)
64
- sleepy.set("0:#{uri}", response)
62
+ if response.code && response.code == 200
63
+ sleepy.set("#{round_time(Time.new.to_i, timeout)}:#{uri}", response)
64
+ sleepy.set("0:#{uri}", response)
65
+ end
65
66
  rescue
66
67
  sleepy.get("0:#{uri}") rescue nil
67
68
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sleepy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - steflewandowski
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-26 00:00:00 +01:00
18
+ date: 2010-09-17 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency