izanami 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2IxY2E3OWY5ZWE5N2UzNTNkN2JmMDRlNjVhZmE0NThkZTQ5ZmU0Ng==
4
+ ZmQ0ODM0MjA1MzFiNWRhNDI3MDA2MjUwZTE0ZGM5ZmYyN2EyZjFiMg==
5
5
  data.tar.gz: !binary |-
6
- ZGE1MjM5NDI1ZjE1MDE1OGM2NzcyYjIzMWVmYTUxN2NhMmVlNDBlMA==
6
+ OWI2OGIyY2IyYmY1ZmYzMDU2ODgwY2I0OTJlYWUzYjJiN2RlZDA3Nw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWZlNDgwYTZhOGFiMWQwNzlkMTYyOTIxMjk0MzQ0ZWU4MzcxZWQ0YWE1MDAw
10
- OTFiMTNjMGI3MDg0ZTZhMTA2NjkyMDZkODY0ZTQ2NjE5YzE0NTA5YmQyMDVk
11
- ZDI2MjU2ZWNlODM0MjQxNDg0YzI3N2QwODc1Y2U2NTIyYmNkZWQ=
9
+ YmQwNTFmMjVmZjFkMWRiYTI5ZTg5M2I1MDNkM2VjZmI0YTA5OWUwZjJkYjFh
10
+ YTNlZGU5ZTBmYjZhMjZkZmJjZjI2Y2VjNjdjZTk1MzdlYTZhNGEyYTUwZDRl
11
+ MjQxMzc2NjA0MmFlMjdlMTVlOTU0Y2I0N2ZmZTAzMzA0OGQxYjY=
12
12
  data.tar.gz: !binary |-
13
- ZDBjNzlmOTU4Y2FhOTRhZGQ3M2MwYWVkMjM3YmFkOTA2NzcxMjUyODEzYzky
14
- YWE4MGM4ZTVjZmU4NWQ2ODIxNDkwNmRlYjA1ZTlhNzdmZTgzMTJiMDQwY2M2
15
- MDYwYmE5MTYxN2NjMDIyNjA3ZDYyMWM4ZjBlN2VhNWY2ODFmZjg=
13
+ YThiMmJjOWQ3N2YxYzk2NDQ4ZTYzYjNhNTEzYTc4ZGJhNWU3OGYwMTMzNWY1
14
+ NjQzYjY3YzVmZTU2ZjAwOTM0MWZmNGU0YWQ3YTllYjA1ODcxYmYzYWExOTYx
15
+ YzY4ZTkwZjFkZWZhODI2YjczNDNmM2ViYzI0MDFlZmY4ZDgzNDA=
@@ -50,7 +50,7 @@ module Izanami
50
50
  # @return [Array] all the commands found.
51
51
  def take(number)
52
52
  options = { order: 'DESC', limit: [0, number] }
53
- client.sort('ids', options).map { |id| find(id) }
53
+ client.sort('ids', options).map { |id| find(id) }.compact
54
54
  end
55
55
 
56
56
  # Delete the specified commands
@@ -58,14 +58,37 @@ module Izanami
58
58
  # @param [Array] ids the commands' ids.
59
59
  def delete(ids)
60
60
  client.multi do
61
- client.del(ids)
62
- client.srem('ids', ids)
61
+ delete_commands ids
62
+ delete_ids ids
63
63
  end
64
64
  end
65
65
 
66
+ # Delete the commands' attributes.
67
+ #
68
+ # @param [Array] ids the commands' ids.
69
+ def delete_commands(ids)
70
+ client.del(ids)
71
+ end
72
+
73
+ # Delete the commands' ids from the global IDs set.
74
+ #
75
+ # @param [Array] ids the commands' ids.
76
+ def delete_ids(ids)
77
+ client.srem('ids', ids)
78
+ end
79
+
66
80
  # Delete all commands
81
+ #
82
+ # @see {#delete}
67
83
  def delete_all
68
- delete client.smembers('ids')
84
+ delete stored_ids
85
+ end
86
+
87
+ # Retrieve all stored IDs
88
+ #
89
+ # @return [Array] all the ids as Strings.
90
+ def stored_ids
91
+ client.smembers('ids')
69
92
  end
70
93
 
71
94
  # Save the hash as a command.
@@ -1,3 +1,3 @@
1
1
  module Izanami
2
- VERSION = "0.19.0"
2
+ VERSION = "0.20.0"
3
3
  end
@@ -84,6 +84,19 @@ describe Izanami::Mappers do
84
84
  it 'takes the elements sorted by their ids' do
85
85
  subject.take(3).should == commands.take(3)
86
86
  end
87
+
88
+ context 'when the IDs are inconsistent' do
89
+ before do
90
+ # remove the commands' data, but not their IDs,
91
+ # like they have been expired by redis
92
+ ids = commands.map { |c| c['id'] }
93
+ subject.send(:delete_commands, ids)
94
+ end
95
+
96
+ it 'takes zero commands' do
97
+ subject.take(3).should be_empty
98
+ end
99
+ end
87
100
  end
88
101
 
89
102
  describe '#count' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: izanami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Hernández
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-28 00:00:00.000000000 Z
11
+ date: 2013-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler