docs/Triglav/Agent/StorageFile.html in triglav-agent-1.0.0.rc1 vs docs/Triglav/Agent/StorageFile.html in triglav-agent-1.0.0.rc2
- old
+ new
@@ -265,10 +265,34 @@
<li class="public ">
<span class="summary_signature">
+ <a href="#select%21-class_method" title="select! (class method)">.<strong>select!</strong>(path, parents = [], keys) ⇒ Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Keep specified keys, and remove others.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
<a href="#set-class_method" title="set (class method)">.<strong>set</strong>(path, key, val) ⇒ Object </a>
</span>
@@ -402,16 +426,16 @@
<tr>
<td>
<pre class="lines">
-13
14
-15</pre>
+15
+16</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 13</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 14</span>
<span class='kw'>def</span> <span class='id identifier rubyid_fp'>fp</span>
<span class='ivar'>@fp</span>
<span class='kw'>end</span></pre>
</td>
@@ -480,17 +504,17 @@
<tr>
<td>
<pre class="lines">
-121
122
123
-124</pre>
+124
+125</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 121</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 122</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_fp'>fp</span><span class='op'>|</span> <span class='id identifier rubyid_fp'>fp</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
@@ -584,25 +608,25 @@
<tr>
<td>
<pre class="lines">
-101
102
103
104
105
106
107
108
109
110
111
-112</pre>
+112
+113</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 101</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 102</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_getsetnx'>getsetnx</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
<span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_fp'>fp</span><span class='op'>|</span>
<span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='id identifier rubyid_fp'>fp</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span>
@@ -674,16 +698,16 @@
<tr>
<td>
<pre class="lines">
-25
26
-27</pre>
+27
+28</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 25</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 26</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
<span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_fp'>fp</span><span class='op'>|</span> <span class='id identifier rubyid_fp'>fp</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
</td>
@@ -748,11 +772,10 @@
<tr>
<td>
<pre class="lines">
-39
40
41
42
43
44
@@ -760,14 +783,15 @@
46
47
48
49
50
-51</pre>
+51
+52</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 39</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 40</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_fp'>fp</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='const'>File</span><span class='op'>::</span><span class='const'>RDONLY</span> <span class='op'>|</span> <span class='const'>File</span><span class='op'>::</span><span class='const'>CREAT</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='kw'>until</span> <span class='id identifier rubyid_fp'>fp</span><span class='period'>.</span><span class='id identifier rubyid_flock'>flock</span><span class='lparen'>(</span><span class='const'>File</span><span class='op'>::</span><span class='const'>LOCK_EX</span> <span class='op'>|</span> <span class='const'>File</span><span class='op'>::</span><span class='const'>LOCK_NB</span><span class='rparen'>)</span>
<span class='gvar'>$logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span> <span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Somebody else is locking the storage file </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
@@ -784,10 +808,113 @@
</tr>
</table>
</div>
<div class="method_details ">
+ <h3 class="signature " id="select!-class_method">
+
+ .<strong>select!</strong>(path, parents = [], keys) ⇒ <tt>Object</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Keep specified keys, and remove others</p>
+
+
+ </div>
+</div>
+<div class="tags">
+ <p class="tag_title">Parameters:</p>
+<ul class="param">
+
+ <li>
+
+ <span class='name'>path</span>
+
+
+ <span class='type'>(<tt>String</tt>)</span>
+
+
+
+ </li>
+
+ <li>
+
+ <span class='name'>parent</span>
+
+
+ <span class='type'>(<tt>Array</tt>)</span>
+
+
+
+ —
+ <div class='inline'>
+<p>keys of hash</p>
+</div>
+
+ </li>
+
+ <li>
+
+ <span class='name'>keys</span>
+
+
+ <span class='type'>(<tt>Array</tt>)</span>
+
+
+
+ </li>
+
+</ul>
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 150</span>
+
+<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_select!'>select!</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_parents'>parents</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_fp'>fp</span><span class='op'>|</span>
+ <span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='id identifier rubyid_fp'>fp</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span>
+ <span class='kw'>if</span> <span class='id identifier rubyid_dig'>dig</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_parents'>parents</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='id identifier rubyid_params'>params</span> <span class='op'>:</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_parents'>parents</span><span class='rparen'>)</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_removes'>removes</span> <span class='op'>=</span> <span class='id identifier rubyid_dig'>dig</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_keys'>keys</span>
+ <span class='kw'>unless</span> <span class='id identifier rubyid_removes'>removes</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
+ <span class='gvar'>$logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span> <span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Remove from status: </span><span class='embexpr_beg'>#{</span><span class='lbrace'>{</span><span class='label'>parent_keys:</span> <span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='label'>keys:</span> <span class='id identifier rubyid_removes'>removes</span><span class='rbrace'>}</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
+ <span class='id identifier rubyid_removes'>removes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='id identifier rubyid_dig'>dig</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_k'>k</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
+ <span class='kw'>end</span>
+ <span class='kw'>end</span>
+ <span class='id identifier rubyid_fp'>fp</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
+ <span class='kw'>end</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
<h3 class="signature " id="set-class_method">
.<strong>set</strong>(path, key, val) ⇒ <tt>Object</tt>
@@ -850,21 +977,21 @@
<tr>
<td>
<pre class="lines">
-61
62
63
64
65
66
67
-68</pre>
+68
+69</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 61</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 62</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
<span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_fp'>fp</span><span class='op'>|</span>
<span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='id identifier rubyid_fp'>fp</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span>
@@ -960,23 +1087,23 @@
<tr>
<td>
<pre class="lines">
-79
80
81
82
83
84
85
86
87
-88</pre>
+88
+89</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 79</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 80</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setnx'>setnx</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
<span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_fp'>fp</span><span class='op'>|</span>
<span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='id identifier rubyid_fp'>fp</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span>
@@ -1036,16 +1163,16 @@
<tr>
<td>
<pre class="lines">
-140
141
-142</pre>
+142
+143</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 140</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 141</span>
<span class='kw'>def</span> <span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='ivar'>@fp</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
@@ -1090,20 +1217,20 @@
<tr>
<td>
<pre class="lines">
-129
130
131
132
133
134
-135</pre>
+135
+136</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 129</span>
+ <pre class="code"><span class="info file"># File 'lib/triglav/agent/storage_file.rb', line 130</span>
<span class='kw'>def</span> <span class='id identifier rubyid_load'>load</span>
<span class='kw'>if</span> <span class='op'>!</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='ivar'>@fp</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='rparen'>)</span> <span class='comment'># all keys must be symbols
</span> <span class='kw'>else</span>
@@ -1118,10 +1245,10 @@
</div>
</div>
<div id="footer">
- Generated on Wed Mar 8 23:12:39 2017 by
+ Generated on Tue Mar 14 19:09:27 2017 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.5 (ruby-2.3.2).
</div>
</div>
\ No newline at end of file