villein 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/villein/tags.rb +12 -0
- data/lib/villein/version.rb +1 -1
- data/spec/tags_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df2731fb88973b484824361021f7e95383f6642c
|
4
|
+
data.tar.gz: 9b68ffc3464ee705d645446fdf017819da130340
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a375d7bc0d40dc65b5fe94bc5b80ed0074a1efd53c48b5ced070d7bb4ed8cab085ecad3cea4994c3a79bf7512338995db5b65b9e7f093f3dcd46fcd8596d056a
|
7
|
+
data.tar.gz: 4eadcdd42d2619e7d77c5ee1ece33029fb5218f437ed9c4b10a80a0b06a1edcc278f357ac1c195475120f14e3516090f025b2cfe7cbbcf41b56ef80123c37980
|
data/README.md
CHANGED
@@ -79,7 +79,7 @@ client.members
|
|
79
79
|
# =>
|
80
80
|
# [
|
81
81
|
# {
|
82
|
-
# "name"=>"testnode", "addr"=>"
|
82
|
+
# "name"=>"testnode", "addr"=>"x.x.x.x:7946", "port"=>7946,
|
83
83
|
# "tags"=>{}, "status"=>"alive",
|
84
84
|
# "protocol"=>{"max"=>4, "min"=>2, "version"=>4}
|
85
85
|
# }
|
data/lib/villein/tags.rb
CHANGED
@@ -7,6 +7,7 @@ module Villein
|
|
7
7
|
|
8
8
|
##
|
9
9
|
# Set tag of the agent.
|
10
|
+
# When a value is nil, this will remove tag of key.
|
10
11
|
def []=(key, value)
|
11
12
|
if value
|
12
13
|
key = key.to_s
|
@@ -18,6 +19,17 @@ module Villein
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
22
|
+
##
|
23
|
+
# Update multiple tags at once.
|
24
|
+
# When a value is nil, this will remove tag with key of a value.
|
25
|
+
def update(tags={})
|
26
|
+
tags.each do |key, val|
|
27
|
+
self[key] = val
|
28
|
+
end
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
21
33
|
##
|
22
34
|
# Returns tag of the agent.
|
23
35
|
# Note that this method is cached, you have to call +reload+ method to flush them.
|
data/lib/villein/version.rb
CHANGED
data/spec/tags_spec.rb
CHANGED
@@ -40,6 +40,24 @@ describe Villein::Tags do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
describe "#update(hash)" do
|
44
|
+
it "sets multiple tags at once" do
|
45
|
+
expect(parent).to receive(:set_tag).with('a', '1').and_return('1')
|
46
|
+
expect(parent).to receive(:set_tag).with('b', '2').and_return('2')
|
47
|
+
|
48
|
+
tags.update(a: 1, b: 2)
|
49
|
+
end
|
50
|
+
|
51
|
+
context "with nil" do
|
52
|
+
it "removes tags at once" do
|
53
|
+
expect(parent).to receive(:delete_tag).with('a')
|
54
|
+
expect(parent).to receive(:delete_tag).with('b')
|
55
|
+
|
56
|
+
tags.update(a: nil, b: nil)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
43
61
|
describe "#delete" do
|
44
62
|
it "deletes key, using parent#delete_tag" do
|
45
63
|
expect(parent).to receive(:delete_tag).with('a')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: villein
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shota Fukumori (sora_h)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|