triglav-agent 1.0.0.rc1 → 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -102,7 +102,7 @@
102
102
  </div>
103
103
 
104
104
  <div id="footer">
105
- Generated on Wed Mar 8 23:12:38 2017 by
105
+ Generated on Tue Mar 14 19:09:26 2017 by
106
106
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
107
  0.9.5 (ruby-2.3.2).
108
108
  </div>
@@ -26,6 +26,19 @@ module Triglav::Agent
26
26
  StorageFile.set(path, [*@parents, *keys], val)
27
27
  end
28
28
 
29
+ # Merge Hash value with existing Hash value.
30
+ #
31
+ # merge!(val)
32
+ # merge!(key, val)
33
+ # merge!(key1, key2, val)
34
+ # merge!([key], val)
35
+ # merge!([key1, key2], val)
36
+ def merge!(*args)
37
+ val = args.pop
38
+ keys = args.flatten
39
+ StorageFile.merge!(path, [*@parents, *keys], val)
40
+ end
41
+
29
42
  # setnx(val)
30
43
  # setnx(key, val)
31
44
  # setnx(key1, key2, val)
@@ -68,6 +68,24 @@ module Triglav::Agent
68
68
  end
69
69
  end
70
70
 
71
+ # Merge Hash value with existing Hash value.
72
+ #
73
+ # @param [String] path
74
+ # @param [Object] key
75
+ # @param [Hash] val
76
+ # @return [Object] holded value
77
+ def self.merge!(path, key, val)
78
+ keys = Array(key)
79
+ open(path) do |fp|
80
+ params = fp.load
81
+ _val = params.dig(*keys) || {}
82
+ _val.merge!(val)
83
+ HashUtil.setdig(params, keys, _val)
84
+ fp.dump(params)
85
+ return true
86
+ end
87
+ end
88
+
71
89
  # Set key to hold val if key does not exist
72
90
  #
73
91
  # StorageFile.setnx($setting.status_file, 'foo', 'bar') # like h['foo'] = 'bar'
@@ -1,5 +1,5 @@
1
1
  module Triglav
2
2
  module Agent
3
- VERSION = "1.0.0.rc1"
3
+ VERSION = "1.0.0.rc2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: triglav-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Triglav Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serverengine
@@ -187,6 +187,7 @@ files:
187
187
  - docs/Triglav/Agent/HashUtil.html
188
188
  - docs/Triglav/Agent/LogFormatter.html
189
189
  - docs/Triglav/Agent/Logger.html
190
+ - docs/Triglav/Agent/Status.html
190
191
  - docs/Triglav/Agent/StorageFile.html
191
192
  - docs/Triglav/Agent/Timer.html
192
193
  - docs/Triglav/Agent/TooManyError.html