once 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dde9027d041ec8bc455dfb29b458fed3666da33e
4
- data.tar.gz: 1bb7239b043139e3da69164c09bf9a50ac075aad
3
+ metadata.gz: fe6ea9a8339f436782e75748211b744c3c046fb8
4
+ data.tar.gz: 36774c058a79d7af701bdf7bfe9a154618c264f5
5
5
  SHA512:
6
- metadata.gz: 2a0691f67c45f58704d86663a0a8bff8ae2230a2f0d009babdb6f8adb4ba9879d94dd879ac0565dd4c31fb88a94d48e4fa6285d409cf28c7bd7046bfa9e36378
7
- data.tar.gz: 45afe0ac8fbdfc7166330f8263c990ddb358def0174956392345d96d5f2fe2457a1832258d0a2b3d8483c350b41b5568448c7f404862b0698fcf452bab61b809
6
+ metadata.gz: 8403391dc262b6bcc752783d78d8e8497169bb374fd64d058883df165d27e1c9c8eed3a7031d4e83a3ffb912d3bb0dac415d8589de5cfccc77b50ce5874ad95a
7
+ data.tar.gz: 6c371fec3539393c4844eb2db382fa6ef7012e40c07ff47d3a34660b0494f1d69918d8bd82acf878bd040d1ddf7cec09b4fbb3398b17f5b2543137cc51c12862
@@ -1 +1 @@
1
- ruby-2.2
1
+ ruby-2.2.2
@@ -38,7 +38,12 @@ module Once
38
38
  redis_key = "uniquecheck:#{name}:#{hash}"
39
39
 
40
40
  if redis.set(redis_key, true, ex: within, nx: true)
41
- block.call
41
+ begin
42
+ block.call
43
+ rescue
44
+ redis.expire(redis_key, 0)
45
+ raise
46
+ end
42
47
  end
43
48
  end
44
49
  end
@@ -1,3 +1,3 @@
1
1
  module Once
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -90,4 +90,18 @@ describe Once do
90
90
 
91
91
  thing_to_execute.should have_received(:execute).twice
92
92
  end
93
+
94
+ it "expires the key immediately if an exception is raised" do
95
+ 2.times do
96
+ begin
97
+ described_class.do(name: "mycheck", params: {foo: "bar"}) do
98
+ thing_to_execute.execute
99
+ raise "BOOM"
100
+ end
101
+ rescue
102
+ end
103
+ end
104
+
105
+ thing_to_execute.should have_received(:execute).twice
106
+ end
93
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: once
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yan Pritzker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.4.8
123
+ rubygems_version: 2.4.5
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Execute commands only once within a specified period of time