ec2-host 0.3.1 → 0.4.0

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: fae889d5827d0ad70013e335f5f3785a941bbcb5
4
- data.tar.gz: 5456aabec1ed98dc10b84010d9a15af736437f39
3
+ metadata.gz: ab82e2af1189495aec002dcbce61337e9a0f0af5
4
+ data.tar.gz: 3c464dd9a3c42773f4acfa2e385d58152e9e15de
5
5
  SHA512:
6
- metadata.gz: 52a2fb57dc940b14fb0672977d240d089bccfb414b824c676a40b3a0a30465a0418e0cd2848a4d4362d7f737deb7d8076600a51b806bebee72fe79481d832b37
7
- data.tar.gz: 56a30d8efa33b0643cf962be73db44e96b1bdae74686abddff19c6a765fc4312043e4c31371befa4baac8b331fa7f483fe480edc8df58d04941753b9aed7f937
6
+ metadata.gz: ebb7e3cb363e5d04a827bf9a89b46baa155e8b4e1a766c476dc2b74a95d03d1de9aeafb54e68a4a9588ae6189e8cc93e06403443191b49997071ba2e854b8c76
7
+ data.tar.gz: c1cc99a1c363d9f8568050fb458fd0ff1c0617d11501bd1d4d0357050063342c2e5c50d995a471d3aef73716d6fd74e7d725885d3f9a0dc49b2c5fe26f52d9c9
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ vendor
15
15
  *.swp
16
16
  pkg/
17
17
  .env
18
+ *tfstate
19
+ *tfstate.backup
@@ -0,0 +1,6 @@
1
+ --no-private
2
+ --protected
3
+ --output-dir docs
4
+ -
5
+ README.md
6
+ LICENSE
@@ -1,3 +1,11 @@
1
+ # 0.4.0 (2016/11/24)
2
+
3
+ Enhancements:
4
+
5
+ * Refactoring
6
+ * Add instance_type to to_hash (or -j option)
7
+ * Support new standard environment variables of AWS CLI such as AWS_DEFAULT_REGION, AWS_DEFAULT_PROFILE, AWS_CREDENTIAL_FILE.
8
+
1
9
  # 0.3.1 (2016/04/21)
2
10
 
3
11
  Enhancements:
data/README.md CHANGED
@@ -8,17 +8,24 @@ Search hosts on AWS EC2
8
8
  gem install ec2-host
9
9
  ```
10
10
 
11
+ ## How it works
12
+
13
+ This gems uses [tagging of EC2 resources](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html).
14
+ You can configure, but basically use `Name` tag for hostname (this is default of EC2) and `Roles` tag for roles.
15
+
16
+ You can manage roles of a host, and search hosts having a specified role using thease tags with this gem.
17
+
11
18
  ## Configuration
12
19
 
13
20
  You can write a configuration file located at `/etc/sysconfig/ec2-host` (You can configure this path by `EC2_HOST_CONFIG_FILE` environment variable), or as environment variables:
14
21
 
15
22
  AWS SDK (CLI) parameters:
16
23
 
17
- * **AWS_REGION**; AWS SDK (CLI) region such as `ap-northeast-1`, `us-east-1`.
18
24
  * **AWS_ACCESS_KEY_ID**: AWS SDK (CLI) crendentials. Default loads a credentials file
19
25
  * **AWS_SECRET_ACCESS_KEY**: AWS SDK (CLI) credentials. Default load a credentials file
20
- * **AWS_PROFILE**: The profile key of the AWS SDK (CLI) credentails file. Default is `default`
21
- * **AWS_CREDENTIALS_FILE**: Path of the AWS SDK (CLI) credentails file. Default is `$HOME/.aws/credentials`. See [Configuring the AWS Command Line Interface](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files) for details.
26
+ * **AWS_DEFAULT_REGION** (**AWS_REGION**); AWS SDK (CLI) region such as `ap-northeast-1`, `us-east-1`.
27
+ * **AWS_DEFAULT_PROFILE** (**AWS_PROFILE**): The profile key of the AWS SDK (CLI) credentails file. Default is `default`
28
+ * **AWS_CREDENTIAL_FILE** (**AWS_CREDENTIALS_FILE**): Path of the AWS SDK (CLI) credentails file. Default is `$HOME/.aws/credentials`. See [Configuring the AWS Command Line Interface](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files) for details.
22
29
 
23
30
  ec2-host parameters:
24
31
 
@@ -33,7 +40,7 @@ ec2-host parameters:
33
40
  * **ARRAY_TAG_DELIMITER (optional)**: A delimiter to express array. Default is `,`
34
41
  * **LOG_LEVEL (optional)**: Log level such as `info`, `debug`, `error`. The default is `info`.
35
42
 
36
- See [sample.conf](./sample.conf)
43
+ See [example.conf](./example/example.conf)
37
44
 
38
45
  ## Tag Example
39
46
 
@@ -140,7 +147,7 @@ end
140
147
 
141
148
  ### Library Reference
142
149
 
143
- See http://sonots.github.io/ec2-host/doc/frames.html.
150
+ See http://sonots.github.io/ec2-host/frames.html.
144
151
 
145
152
  ## ChangeLog
146
153
 
@@ -156,7 +163,34 @@ See [CHANGELOG.md](CHANGELOG.md) for details.
156
163
 
157
164
  ### How to Run test
158
165
 
159
- See [spec/README.md](spec/README.md)
166
+ NOTE: Currently, mock is not supported yet. So, you have to create your own AWS account, and instances.
167
+
168
+ Configure .env file as
169
+
170
+ ```
171
+ AWS_ACCESS_KEY_ID=
172
+ AWS_SECRET_ACCESS_KEY=
173
+ AWS_DEFAULT_REGION=
174
+ EC2_HOST_CONFIG_FILE=.env
175
+ OPTIONAL_ARRAY_TAGS=Tags
176
+ OPTIONAL_STRING_TAGS=Service,Status
177
+ ```
178
+
179
+ Install terraform and run to create instances for tests
180
+
181
+ ```
182
+ $ brew install terraform
183
+ $ env $(cat .env) terraform plan
184
+ $ env ($cat .env) terraform apply
185
+ ```
186
+
187
+ Run test
188
+
189
+ ```
190
+ $ bundle exec rspec
191
+ ```
192
+
193
+ After working, destory instances by commenting out `terraform.tf` and apply.
160
194
 
161
195
  ### How to Release Gem
162
196
 
@@ -167,8 +201,8 @@ See [spec/README.md](spec/README.md)
167
201
 
168
202
  ### How to Update doc
169
203
 
170
- 1. Run `./doc.sh`
171
- 2. git commit && git push (to gh-pages branch)
204
+ 1. Run `bundle exec yard`
205
+ 2. git commit && git push
172
206
 
173
207
  ### Licenses
174
208
 
@@ -0,0 +1,132 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: EC2
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!EC2.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (E)</a> &raquo;
35
+
36
+
37
+ <span class="title">EC2</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: EC2
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName">Object</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">EC2</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ <dt class="r2 last">Defined in:</dt>
97
+ <dd class="r2 last">lib/ec2/host.rb<span class="defines">,<br />
98
+ lib/ec2/host/cli.rb,<br /> lib/ec2/host/config.rb,<br /> lib/ec2/host/hash_util.rb,<br /> lib/ec2/host/host_data.rb,<br /> lib/ec2/host/role_data.rb,<br /> lib/ec2/host/ec2_client.rb,<br /> lib/ec2/host/string_util.rb</span>
99
+ </dd>
100
+
101
+ </dl>
102
+ <div class="clear"></div>
103
+
104
+ <h2>Defined Under Namespace</h2>
105
+ <p class="children">
106
+
107
+
108
+
109
+
110
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="EC2/Host.html" title="EC2::Host (class)">Host</a></span>
111
+
112
+
113
+ </p>
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ </div>
124
+
125
+ <div id="footer">
126
+ Generated on Thu Nov 24 10:25:36 2016 by
127
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
128
+ 0.8.7.6 (ruby-2.3.2).
129
+ </div>
130
+
131
+ </body>
132
+ </html>
@@ -0,0 +1,889 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: EC2::Host
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!EC2/Host.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (H)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../EC2.html" title="EC2 (class)">EC2</a></span></span>
36
+ &raquo;
37
+ <span class="title">Host</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: EC2::Host
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName">Object</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">EC2::Host</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+
92
+
93
+ <dt class="r2">Includes:</dt>
94
+ <dd class="r2">Enumerable</dd>
95
+
96
+
97
+
98
+
99
+
100
+ <dt class="r1 last">Defined in:</dt>
101
+ <dd class="r1 last">lib/ec2/host.rb<span class="defines">,<br />
102
+ lib/ec2/host/cli.rb,<br /> lib/ec2/host/config.rb,<br /> lib/ec2/host/hash_util.rb,<br /> lib/ec2/host/host_data.rb,<br /> lib/ec2/host/role_data.rb,<br /> lib/ec2/host/ec2_client.rb,<br /> lib/ec2/host/string_util.rb</span>
103
+ </dd>
104
+
105
+ </dl>
106
+ <div class="clear"></div>
107
+
108
+ <h2>Overview</h2><div class="docstring">
109
+ <div class="discussion">
110
+
111
+ <p>Search EC2 hosts from tags</p>
112
+
113
+ <pre class="code ruby"><code class="ruby">require &#39;ec2-host&#39;
114
+ # Search by `Name` tag
115
+ EC2::Host.new(hostname: &#39;test&#39;).first # =&gt; test
116
+
117
+ # Search by `Roles` tag
118
+ EC2::Host.new(
119
+ role: &#39;admin:haikanko&#39;,
120
+ ).each do |host|
121
+ # ...
122
+ end
123
+
124
+ or
125
+
126
+ EC2::Host.new(
127
+ role1: &#39;admin&#39;,
128
+ role2: &#39;haikanko&#39;,
129
+ ).each do |host|
130
+ # ...
131
+ end
132
+
133
+ # Or search
134
+ EC2::Host.new(
135
+ {
136
+ role1: &#39;db&#39;,
137
+ role2: &#39;master&#39;,
138
+ },
139
+ {
140
+ role1: &#39;web&#39;,
141
+ }
142
+ ).each do |host|
143
+ # ...
144
+ end
145
+
146
+ EC2::Host.me.hostname # =&gt; &#39;test&#39;</code></pre>
147
+
148
+
149
+ </div>
150
+ </div>
151
+ <div class="tags">
152
+
153
+
154
+ </div><h2>Defined Under Namespace</h2>
155
+ <p class="children">
156
+
157
+
158
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Host/HashUtil.html" title="EC2::Host::HashUtil (module)">HashUtil</a></span>, <span class='object_link'><a href="Host/StringUtil.html" title="EC2::Host::StringUtil (module)">StringUtil</a></span>
159
+
160
+
161
+
162
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Host/CLI.html" title="EC2::Host::CLI (class)">CLI</a></span>, <span class='object_link'><a href="Host/Config.html" title="EC2::Host::Config (class)">Config</a></span>, <span class='object_link'><a href="Host/EC2Client.html" title="EC2::Host::EC2Client (class)">EC2Client</a></span>, <span class='object_link'><a href="Host/HostData.html" title="EC2::Host::HostData (class)">HostData</a></span>, <span class='object_link'><a href="Host/RoleData.html" title="EC2::Host::RoleData (class)">RoleData</a></span>
163
+
164
+
165
+ </p>
166
+
167
+
168
+
169
+
170
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
171
+ <ul class="summary">
172
+
173
+ <li class="public ">
174
+ <span class="summary_signature">
175
+
176
+ <a href="#conditions-instance_method" title="#conditions (instance method)">- (Object) <strong>conditions</strong> </a>
177
+
178
+
179
+
180
+ </span>
181
+
182
+
183
+
184
+
185
+ <span class="note title readonly">readonly</span>
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+ <span class="summary_desc"><div class='inline'>
196
+ <p>Returns the value of attribute conditions.</p>
197
+ </div></span>
198
+
199
+ </li>
200
+
201
+
202
+ <li class="public ">
203
+ <span class="summary_signature">
204
+
205
+ <a href="#options-instance_method" title="#options (instance method)">- (Object) <strong>options</strong> </a>
206
+
207
+
208
+
209
+ </span>
210
+
211
+
212
+
213
+
214
+ <span class="note title readonly">readonly</span>
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+ <span class="summary_desc"><div class='inline'>
225
+ <p>Returns the value of attribute options.</p>
226
+ </div></span>
227
+
228
+ </li>
229
+
230
+
231
+ </ul>
232
+
233
+
234
+
235
+
236
+
237
+ <h2>
238
+ Class Method Summary
239
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
240
+ </h2>
241
+
242
+ <ul class="summary">
243
+
244
+ <li class="public ">
245
+ <span class="summary_signature">
246
+
247
+ <a href="#configure-class_method" title="configure (class method)">+ (Object) <strong>configure</strong>(params = {}) </a>
248
+
249
+
250
+
251
+ </span>
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ <span class="summary_desc"><div class='inline'>
262
+ <p>Configure EC2::Host.</p>
263
+ </div></span>
264
+
265
+ </li>
266
+
267
+
268
+ <li class="public ">
269
+ <span class="summary_signature">
270
+
271
+ <a href="#ec2_client-class_method" title="ec2_client (class method)">+ (Object) <strong>ec2_client</strong> </a>
272
+
273
+
274
+
275
+ </span>
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+ <span class="summary_desc"><div class='inline'></div></span>
286
+
287
+ </li>
288
+
289
+
290
+ <li class="public ">
291
+ <span class="summary_signature">
292
+
293
+ <a href="#me-class_method" title="me (class method)">+ (Host::Data) <strong>me</strong> </a>
294
+
295
+
296
+
297
+ </span>
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+ <span class="summary_desc"><div class='inline'>
308
+ <p>Representing myself.</p>
309
+ </div></span>
310
+
311
+ </li>
312
+
313
+
314
+ </ul>
315
+
316
+ <h2>
317
+ Instance Method Summary
318
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
319
+ </h2>
320
+
321
+ <ul class="summary">
322
+
323
+ <li class="public ">
324
+ <span class="summary_signature">
325
+
326
+ <a href="#each-instance_method" title="#each (instance method)">- (Object) <strong>each</strong> {|data| ... }</a>
327
+
328
+
329
+
330
+ </span>
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+ <span class="summary_desc"><div class='inline'></div></span>
341
+
342
+ </li>
343
+
344
+
345
+ <li class="public ">
346
+ <span class="summary_signature">
347
+
348
+ <a href="#ec2_client-instance_method" title="#ec2_client (instance method)">- (Object) <strong>ec2_client</strong> </a>
349
+
350
+
351
+
352
+ </span>
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+ <span class="summary_desc"><div class='inline'></div></span>
363
+
364
+ </li>
365
+
366
+
367
+ <li class="public ">
368
+ <span class="summary_signature">
369
+
370
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Host) <strong>initialize</strong>(*conditions) </a>
371
+
372
+
373
+
374
+ </span>
375
+
376
+
377
+ <span class="note title constructor">constructor</span>
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+ <span class="summary_desc"><div class='inline'>
387
+ <p>A new instance of Host.</p>
388
+ </div></span>
389
+
390
+ </li>
391
+
392
+
393
+ </ul>
394
+
395
+
396
+
397
+ <div id="constructor_details" class="method_details_list">
398
+ <h2>Constructor Details</h2>
399
+
400
+ <div class="method_details first">
401
+ <h3 class="signature first" id="initialize-instance_method">
402
+
403
+ - (<tt><span class='object_link'><a href="" title="EC2::Host (class)">Host</a></span></tt>) <strong>initialize</strong>(*conditions)
404
+
405
+
406
+
407
+
408
+
409
+ </h3><div class="docstring">
410
+ <div class="discussion">
411
+
412
+ <p>Returns a new instance of Host</p>
413
+
414
+
415
+ </div>
416
+ </div>
417
+ <div class="tags">
418
+ <p class="tag_title">Parameters:</p>
419
+ <ul class="param">
420
+
421
+ <li>
422
+
423
+ <span class='name'>conditions</span>
424
+
425
+
426
+ <span class='type'>(<tt>Array of Hash</tt>, <tt>or Hash</tt>)</span>
427
+
428
+
429
+
430
+ &mdash;
431
+ <div class='inline'>
432
+ <p>(and options)</p>
433
+
434
+ <p>EC2::Host.new(</p>
435
+
436
+ <pre class="code ruby"><code class="ruby">hostname: &#39;test&#39;,
437
+ options: {a: &#39;b&#39;}</code></pre>
438
+
439
+ <p>)</p>
440
+
441
+ <p>EC2::Host.new(</p>
442
+
443
+ <pre class="code ruby"><code class="ruby">{
444
+ hostname: &#39;foo&#39;,
445
+ },
446
+ {
447
+ hostname: &#39;bar&#39;,
448
+ },
449
+ options: {a: &#39;b&#39;}</code></pre>
450
+
451
+ <p>)</p>
452
+ </div>
453
+
454
+ </li>
455
+
456
+ </ul>
457
+
458
+ <p class="tag_title">Raises:</p>
459
+ <ul class="raise">
460
+
461
+ <li>
462
+
463
+
464
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
465
+
466
+
467
+
468
+ </li>
469
+
470
+ </ul>
471
+
472
+ </div><table class="source_code">
473
+ <tr>
474
+ <td>
475
+ <pre class="lines">
476
+
477
+
478
+ 82
479
+ 83
480
+ 84
481
+ 85
482
+ 86
483
+ 87
484
+ 88
485
+ 89
486
+ 90
487
+ 91
488
+ 92
489
+ 93
490
+ 94
491
+ 95
492
+ 96
493
+ 97
494
+ 98</pre>
495
+ </td>
496
+ <td>
497
+ <pre class="code"><span class="info file"># File 'lib/ec2/host.rb', line 82</span>
498
+
499
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_conditions'>conditions</span><span class='rparen'>)</span>
500
+ <span class='id identifier rubyid_conditions'>conditions</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
501
+ <span class='id identifier rubyid_conditions'>conditions</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_conditions'>conditions</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_kind_of?'>kind_of?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
502
+ <span class='ivar'>@options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
503
+ <span class='kw'>if</span> <span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>1</span>
504
+ <span class='ivar'>@options</span> <span class='op'>=</span> <span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:options</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
505
+ <span class='kw'>else</span>
506
+ <span class='id identifier rubyid_index'>index</span> <span class='op'>=</span> <span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_find_index'>find_index</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_condition'>condition</span><span class='op'>|</span> <span class='id identifier rubyid_condition'>condition</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='symbol'>:options</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
507
+ <span class='ivar'>@options</span> <span class='op'>=</span> <span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_delete_at'>delete_at</span><span class='lparen'>(</span><span class='id identifier rubyid_index'>index</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:options</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_index'>index</span>
508
+ <span class='kw'>end</span>
509
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Hash expected (options)</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='ivar'>@options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
510
+ <span class='ivar'>@conditions</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
511
+ <span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_condition'>condition</span><span class='op'>|</span>
512
+ <span class='ivar'>@conditions</span> <span class='op'>&lt;&lt;</span> <span class='const'>Hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_condition'>condition</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_s</span><span class='rparen'>)</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rbracket'>]</span>
513
+ <span class='kw'>end</span>
514
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Array of Hash, or Hash expected (conditions)</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='ivar'>@conditions</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_h'>h</span><span class='op'>|</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_kind_of?'>kind_of?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span><span class='rbrace'>}</span>
515
+ <span class='kw'>end</span></pre>
516
+ </td>
517
+ </tr>
518
+ </table>
519
+ </div>
520
+
521
+ </div>
522
+
523
+ <div id="instance_attr_details" class="attr_details">
524
+ <h2>Instance Attribute Details</h2>
525
+
526
+
527
+ <span id=""></span>
528
+ <div class="method_details first">
529
+ <h3 class="signature first" id="conditions-instance_method">
530
+
531
+ - (<tt>Object</tt>) <strong>conditions</strong> <span class="extras">(readonly)</span>
532
+
533
+
534
+
535
+
536
+
537
+ </h3><div class="docstring">
538
+ <div class="discussion">
539
+
540
+ <p>Returns the value of attribute conditions</p>
541
+
542
+
543
+ </div>
544
+ </div>
545
+ <div class="tags">
546
+
547
+
548
+ </div><table class="source_code">
549
+ <tr>
550
+ <td>
551
+ <pre class="lines">
552
+
553
+
554
+ 64
555
+ 65
556
+ 66</pre>
557
+ </td>
558
+ <td>
559
+ <pre class="code"><span class="info file"># File 'lib/ec2/host.rb', line 64</span>
560
+
561
+ <span class='kw'>def</span> <span class='id identifier rubyid_conditions'>conditions</span>
562
+ <span class='ivar'>@conditions</span>
563
+ <span class='kw'>end</span></pre>
564
+ </td>
565
+ </tr>
566
+ </table>
567
+ </div>
568
+
569
+
570
+ <span id=""></span>
571
+ <div class="method_details ">
572
+ <h3 class="signature " id="options-instance_method">
573
+
574
+ - (<tt>Object</tt>) <strong>options</strong> <span class="extras">(readonly)</span>
575
+
576
+
577
+
578
+
579
+
580
+ </h3><div class="docstring">
581
+ <div class="discussion">
582
+
583
+ <p>Returns the value of attribute options</p>
584
+
585
+
586
+ </div>
587
+ </div>
588
+ <div class="tags">
589
+
590
+
591
+ </div><table class="source_code">
592
+ <tr>
593
+ <td>
594
+ <pre class="lines">
595
+
596
+
597
+ 64
598
+ 65
599
+ 66</pre>
600
+ </td>
601
+ <td>
602
+ <pre class="code"><span class="info file"># File 'lib/ec2/host.rb', line 64</span>
603
+
604
+ <span class='kw'>def</span> <span class='id identifier rubyid_options'>options</span>
605
+ <span class='ivar'>@options</span>
606
+ <span class='kw'>end</span></pre>
607
+ </td>
608
+ </tr>
609
+ </table>
610
+ </div>
611
+
612
+ </div>
613
+
614
+
615
+ <div id="class_method_details" class="method_details_list">
616
+ <h2>Class Method Details</h2>
617
+
618
+
619
+ <div class="method_details first">
620
+ <h3 class="signature first" id="configure-class_method">
621
+
622
+ + (<tt>Object</tt>) <strong>configure</strong>(params = {})
623
+
624
+
625
+
626
+
627
+
628
+ </h3><div class="docstring">
629
+ <div class="discussion">
630
+
631
+ <p>Configure EC2::Host</p>
632
+
633
+
634
+ </div>
635
+ </div>
636
+ <div class="tags">
637
+ <p class="tag_title">Parameters:</p>
638
+ <ul class="param">
639
+
640
+ <li>
641
+
642
+ <span class='name'>params</span>
643
+
644
+
645
+ <span class='type'>(<tt>Hash</tt>)</span>
646
+
647
+
648
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
649
+
650
+
651
+ &mdash;
652
+ <div class='inline'>
653
+ <p>see EC2::Host::Config for configurable parameters</p>
654
+ </div>
655
+
656
+ </li>
657
+
658
+ </ul>
659
+
660
+
661
+ </div><table class="source_code">
662
+ <tr>
663
+ <td>
664
+ <pre class="lines">
665
+
666
+
667
+ 52
668
+ 53
669
+ 54</pre>
670
+ </td>
671
+ <td>
672
+ <pre class="code"><span class="info file"># File 'lib/ec2/host.rb', line 52</span>
673
+
674
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
675
+ <span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
676
+ <span class='kw'>end</span></pre>
677
+ </td>
678
+ </tr>
679
+ </table>
680
+ </div>
681
+
682
+ <div class="method_details ">
683
+ <h3 class="signature " id="ec2_client-class_method">
684
+
685
+ + (<tt>Object</tt>) <strong>ec2_client</strong>
686
+
687
+
688
+
689
+
690
+
691
+ </h3><table class="source_code">
692
+ <tr>
693
+ <td>
694
+ <pre class="lines">
695
+
696
+
697
+ 56
698
+ 57
699
+ 58</pre>
700
+ </td>
701
+ <td>
702
+ <pre class="code"><span class="info file"># File 'lib/ec2/host.rb', line 56</span>
703
+
704
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ec2_client'>ec2_client</span>
705
+ <span class='ivar'>@ec2_client</span> <span class='op'>||=</span> <span class='const'>EC2Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
706
+ <span class='kw'>end</span></pre>
707
+ </td>
708
+ </tr>
709
+ </table>
710
+ </div>
711
+
712
+ <div class="method_details ">
713
+ <h3 class="signature " id="me-class_method">
714
+
715
+ + (<tt>Host::Data</tt>) <strong>me</strong>
716
+
717
+
718
+
719
+
720
+
721
+ </h3><div class="docstring">
722
+ <div class="discussion">
723
+
724
+ <p>Returns representing myself</p>
725
+
726
+
727
+ </div>
728
+ </div>
729
+ <div class="tags">
730
+
731
+ <p class="tag_title">Returns:</p>
732
+ <ul class="return">
733
+
734
+ <li>
735
+
736
+
737
+ <span class='type'>(<tt>Host::Data</tt>)</span>
738
+
739
+
740
+
741
+ &mdash;
742
+ <div class='inline'>
743
+ <p>representing myself</p>
744
+ </div>
745
+
746
+ </li>
747
+
748
+ </ul>
749
+
750
+ </div><table class="source_code">
751
+ <tr>
752
+ <td>
753
+ <pre class="lines">
754
+
755
+
756
+ 42
757
+ 43
758
+ 44
759
+ 45
760
+ 46
761
+ 47</pre>
762
+ </td>
763
+ <td>
764
+ <pre class="code"><span class="info file"># File 'lib/ec2/host.rb', line 42</span>
765
+
766
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_me'>me</span>
767
+ <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>instance_id:</span> <span class='id identifier rubyid_ec2_client'>ec2_client</span><span class='period'>.</span><span class='id identifier rubyid_instance_id'>instance_id</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_d'>d</span><span class='op'>|</span>
768
+ <span class='kw'>return</span> <span class='id identifier rubyid_d'>d</span>
769
+ <span class='kw'>end</span>
770
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Not Found</span><span class='tstring_end'>&#39;</span></span>
771
+ <span class='kw'>end</span></pre>
772
+ </td>
773
+ </tr>
774
+ </table>
775
+ </div>
776
+
777
+ </div>
778
+
779
+ <div id="instance_method_details" class="method_details_list">
780
+ <h2>Instance Method Details</h2>
781
+
782
+
783
+ <div class="method_details first">
784
+ <h3 class="signature first" id="each-instance_method">
785
+
786
+ - (<tt>Object</tt>) <strong>each</strong> {|data| ... }
787
+
788
+
789
+
790
+
791
+
792
+ </h3><div class="docstring">
793
+ <div class="discussion">
794
+
795
+
796
+ </div>
797
+ </div>
798
+ <div class="tags">
799
+
800
+ <p class="tag_title">Yield Parameters:</p>
801
+ <ul class="yieldparam">
802
+
803
+ <li>
804
+
805
+ <span class='name'>data</span>
806
+
807
+
808
+ <span class='type'>(<tt>Host::Data</tt>)</span>
809
+
810
+
811
+
812
+ &mdash;
813
+ <div class='inline'>
814
+ <p>entry</p>
815
+ </div>
816
+
817
+ </li>
818
+
819
+ </ul>
820
+
821
+ </div><table class="source_code">
822
+ <tr>
823
+ <td>
824
+ <pre class="lines">
825
+
826
+
827
+ 101
828
+ 102
829
+ 103
830
+ 104
831
+ 105
832
+ 106</pre>
833
+ </td>
834
+ <td>
835
+ <pre class="code"><span class="info file"># File 'lib/ec2/host.rb', line 101</span>
836
+
837
+ <span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
838
+ <span class='ivar'>@conditions</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_condition'>condition</span><span class='op'>|</span>
839
+ <span class='id identifier rubyid_search'>search</span><span class='lparen'>(</span><span class='id identifier rubyid_ec2_client'>ec2_client</span><span class='period'>.</span><span class='id identifier rubyid_instances'>instances</span><span class='lparen'>(</span><span class='id identifier rubyid_condition'>condition</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_condition'>condition</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
840
+ <span class='kw'>end</span>
841
+ <span class='kw'>return</span> <span class='kw'>self</span>
842
+ <span class='kw'>end</span></pre>
843
+ </td>
844
+ </tr>
845
+ </table>
846
+ </div>
847
+
848
+ <div class="method_details ">
849
+ <h3 class="signature " id="ec2_client-instance_method">
850
+
851
+ - (<tt>Object</tt>) <strong>ec2_client</strong>
852
+
853
+
854
+
855
+
856
+
857
+ </h3><table class="source_code">
858
+ <tr>
859
+ <td>
860
+ <pre class="lines">
861
+
862
+
863
+ 60
864
+ 61
865
+ 62</pre>
866
+ </td>
867
+ <td>
868
+ <pre class="code"><span class="info file"># File 'lib/ec2/host.rb', line 60</span>
869
+
870
+ <span class='kw'>def</span> <span class='id identifier rubyid_ec2_client'>ec2_client</span>
871
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_ec2_client'>ec2_client</span>
872
+ <span class='kw'>end</span></pre>
873
+ </td>
874
+ </tr>
875
+ </table>
876
+ </div>
877
+
878
+ </div>
879
+
880
+ </div>
881
+
882
+ <div id="footer">
883
+ Generated on Thu Nov 24 10:25:36 2016 by
884
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
885
+ 0.8.7.6 (ruby-2.3.2).
886
+ </div>
887
+
888
+ </body>
889
+ </html>