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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b6d36799ad957920fbb7b42d62b6e1bf148c70b
4
- data.tar.gz: 375feb1e4a3da4b2febac8f08e3980a86916be03
3
+ metadata.gz: df2731fb88973b484824361021f7e95383f6642c
4
+ data.tar.gz: 9b68ffc3464ee705d645446fdf017819da130340
5
5
  SHA512:
6
- metadata.gz: c24bfe7a7a228c061a27d2beb0d2a9ad7b218a0e63d0d28d21cd2a57a00a60b39932976898ee962e690bdf554c656140131aaddd75016c923e711dafdefe990a
7
- data.tar.gz: c85805cc00f7f680fc75c674bf537a2b35552301c5bc631bd26058e0d39458dd096b5b83c9879ad379fbbd5241112292f4dace6f706f80cc1b595d9d298d16ca
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"=>"192.168.101.157:7946", "port"=>7946,
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.
@@ -1,3 +1,3 @@
1
1
  module Villein
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-16 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec