forever-alone 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b052ede07b7ad7b53c3e94df548f0b037fcdd6de
4
- data.tar.gz: d376c64a2b1bf946d113320f2b2195bb8316491c
3
+ metadata.gz: 8154e566aa2d643903b97ea2526e0b0060767390
4
+ data.tar.gz: eefd5eafeab89175dc6ad6877911a6708ce0762d
5
5
  SHA512:
6
- metadata.gz: 494cd2f686bfdb9925d38eb84a38b9f9caf8fcd99789cb1546e9c98183c925fc189518b0ba0e2fe108b999a261c3fb16103b6f94728d3814c596d831e66af276
7
- data.tar.gz: 25d7a78b4fe7eddf6d0cffa359efdd747319fcbb97b0eaa1d14f8fb29c3674750973c61886be1efc4a9a73af57e4537df18e019b5d08b66e1047e2133e5f31f7
6
+ metadata.gz: 1bf6709af9cd3bcbc5f4341c3c659f8b470bad05b057a637fd1345840a454ec9e469e18e78826b46bca374df3239f986881b1c9f917dc2dbea04701e682f08ce
7
+ data.tar.gz: 0fd0173d11c39a7de3bf50be114c57c4b82f218921eb92e1714c161694f6e340a86653cdd092205a03017def453f90e6da1a31318bb975009a3f7adca07c664a
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # ForeverAlone
2
+
3
+ ![forever alone](http://cdn.alltheragefaces.com/img/faces/svg/sad-forever-alone-face-only.svg)
4
+
2
5
  [![Build Status](https://travis-ci.org/Spalmalo/forever-alone.svg)](https://travis-ci.org/Spalmalo/forever-alone)
3
6
 
4
7
  This gem uses Redis to keep a list of recent text messages. ForeverAlone calculates hex digests of message and stores them into the Redis with a given expiration period.
@@ -35,6 +38,9 @@ Or install it yourself as:
35
38
 
36
39
  # OR just ensure that message is unique and raise ForeverAlone::MessageIsNotUnique error otherwise
37
40
  forever_alone.ensure
41
+
42
+ # if you want to flush all locks
43
+ forever_alone.flush_locks
38
44
  ```
39
45
 
40
46
  ## Configuration
@@ -51,6 +57,15 @@ end
51
57
 
52
58
  You can configure redis connection with `REDIS_URL` environment variable.
53
59
 
60
+
61
+ ## Testing
62
+
63
+ You can add [fakeredis](https://github.com/guilleiguaran/fakeredis) to your Gemfile to prevent ForeverAlone from making requests to your Redis server.
64
+ ```
65
+ gem "fakeredis", require: "fakeredis/rspec", group: :test
66
+ ```
67
+
68
+
54
69
  ## Contributing
55
70
 
56
71
  1. Fork it ( https://github.com/[my-github-username]/forever-alone/fork )
@@ -12,6 +12,11 @@ module ForeverAlone
12
12
  ForeverAlone.redis.get(key).nil?
13
13
  end
14
14
 
15
+ def flush_locks
16
+ keys = ForeverAlone.redis.keys "#{ ForeverAlone.configuration.namespace }:*"
17
+ ForeverAlone.redis.del keys if keys.any?
18
+ end
19
+
15
20
  def remember
16
21
  ForeverAlone.redis.setex key, timeout, 'foo'
17
22
  end
@@ -1,3 +1,3 @@
1
1
  module ForeverAlone
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,15 @@
1
+ describe ForeverAlone::Validator, "#flush_locks" do
2
+ subject { validator.flush_locks }
3
+
4
+ let!(:validator) { described_class.new "some message", 10 }
5
+
6
+ before do
7
+ allow(ForeverAlone.configuration).to receive(:namespace).and_return("locks")
8
+ validator.remember
9
+ end
10
+
11
+ it "should flush locks" do
12
+ subject
13
+ expect(ForeverAlone.redis.keys("locks:*")).to eq []
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forever-alone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Sharshenov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -105,6 +105,7 @@ files:
105
105
  - spec/forever-alone/new_spec.rb
106
106
  - spec/forever-alone/redis_spec.rb
107
107
  - spec/forever-alone/validator/ensure_spec.rb
108
+ - spec/forever-alone/validator/flush_locks_spec.rb
108
109
  - spec/forever-alone/validator/key_spec.rb
109
110
  - spec/forever-alone/validator/remember_spec.rb
110
111
  - spec/forever-alone/validator/unique_spec.rb
@@ -138,6 +139,7 @@ test_files:
138
139
  - spec/forever-alone/new_spec.rb
139
140
  - spec/forever-alone/redis_spec.rb
140
141
  - spec/forever-alone/validator/ensure_spec.rb
142
+ - spec/forever-alone/validator/flush_locks_spec.rb
141
143
  - spec/forever-alone/validator/key_spec.rb
142
144
  - spec/forever-alone/validator/remember_spec.rb
143
145
  - spec/forever-alone/validator/unique_spec.rb