soror 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -1
- data/bin/soror +34 -0
- data/lib/soror.rb +9 -2
- data/lib/soror/ec2/instance.rb +1 -0
- data/lib/soror/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42d441c4bd3902be3e288411d4cc568e9e8a1988
|
4
|
+
data.tar.gz: 31f9696ef46faf3d88dc5dcd3e8a73300c62ee25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeee8b20d3f49371f18cbc1b6231181138b9d6b0a0a1cd3fdeed4ee44a24c48e669d2a734431c1c865b74ce400049285250ef01a2d9e14ab13b949fc9285371c
|
7
|
+
data.tar.gz: 323ee560c02571ffdc90c8cae872fdcdf8c0e1f6f99e02ad8121ac9b63300e36151790aedf0ffd2828f5f2c3ccb889872571412dad04a65a7fd3a5437e6d2157
|
data/README.md
CHANGED
@@ -33,6 +33,34 @@ Soror::EC2::Instance.search_by(name: 'soror') #=> [<AWS::EC2::Instance>, ...]
|
|
33
33
|
Soror.config(access_key_id: 'xxxxx', secret_access_key: 'xxxxx', region: 'ap-northeast-1')
|
34
34
|
```
|
35
35
|
|
36
|
+
Or put the configuration file on your home directory as:
|
37
|
+
|
38
|
+
```sh
|
39
|
+
cat <<EOS >$HOME/.soror
|
40
|
+
access_key_id: 'xxxxx'
|
41
|
+
secret_access_key: 'xxxxx'
|
42
|
+
region: 'ap-northeast-1'
|
43
|
+
EOS
|
44
|
+
```
|
45
|
+
|
46
|
+
### Memoization
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
Soror.start_memoizing
|
50
|
+
```
|
51
|
+
|
52
|
+
## CLI
|
53
|
+
|
54
|
+
```
|
55
|
+
Usage: soror [options]
|
56
|
+
-t, --tag='KEY=VALUE'
|
57
|
+
-a, --attributes=ATTR,ATTR,...
|
58
|
+
--[no-]header
|
59
|
+
--access-key=KEY
|
60
|
+
--secret-key=KEY
|
61
|
+
--region=REGION
|
62
|
+
```
|
63
|
+
|
36
64
|
## Required permissions
|
37
65
|
|
38
66
|
```js
|
@@ -43,7 +71,7 @@ Soror.config(access_key_id: 'xxxxx', secret_access_key: 'xxxxx', region: 'ap-nor
|
|
43
71
|
"Action": "ec2:Describe*",
|
44
72
|
"Resource": "*"
|
45
73
|
}
|
46
|
-
|
74
|
+
]
|
47
75
|
}
|
48
76
|
```
|
49
77
|
|
data/bin/soror
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'soror'
|
5
|
+
|
6
|
+
options = { header: true, tag: {}, config: {} }
|
7
|
+
|
8
|
+
OptionParser.new do |opt|
|
9
|
+
opt.on('-t', '--tag=\'KEY=VALUE\'', /\A[^=]+=[^=]+\z/) do |v|
|
10
|
+
key, val = v.split('=')
|
11
|
+
options[:tag][key] = val
|
12
|
+
end
|
13
|
+
opt.on('-a', '--attributes=ATTR,ATTR,...', Array) { |v| options[:attributes] = v }
|
14
|
+
opt.on('--[no-]header') { |v| options[:header] = v }
|
15
|
+
opt.on('--access-key=KEY') { |v| options[:config][:access_key_id] = v }
|
16
|
+
opt.on('--secret-key=KEY') { |v| options[:config][:secret_access_key] = v }
|
17
|
+
opt.on('--region=REGION') { |v| options[:config][:region] = v }
|
18
|
+
opt.parse!(ARGV)
|
19
|
+
end
|
20
|
+
fail OptionParser::MissingArgument, '--tag' if options[:tag].empty?
|
21
|
+
fail OptionParser::MissingArgument, '--attributes' if options[:attributes].nil?
|
22
|
+
fail OptionParser::InvalidArgument, '--attributes' if options[:attributes].empty?
|
23
|
+
|
24
|
+
Soror.config(options[:config])
|
25
|
+
Soror.start_memoizing
|
26
|
+
|
27
|
+
instances = Soror::EC2::Instance.search_by(options[:tag])
|
28
|
+
exit! if instances.empty?
|
29
|
+
|
30
|
+
result = instances.map{ |i| options[:attributes].map{ |a| i.send(a.intern) || '' } }
|
31
|
+
result.unshift(options[:attributes]) if options[:header]
|
32
|
+
|
33
|
+
width = result.transpose.map{ |row| row.map(&:length).max }
|
34
|
+
result.each{ |line| puts line.zip(width).map{ |a, w| a.ljust(w) }.join(' ') }
|
data/lib/soror.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
require 'aws-sdk-v1'
|
2
|
+
require 'forwardable'
|
2
3
|
require 'soror/ec2'
|
3
4
|
require 'soror/version'
|
5
|
+
require 'yaml'
|
4
6
|
|
5
7
|
module Soror
|
6
|
-
|
7
|
-
|
8
|
+
class << self
|
9
|
+
extend Forwardable
|
10
|
+
def_delegators AWS, :config, :start_memoizing, :stop_memoizing
|
8
11
|
end
|
9
12
|
end
|
13
|
+
|
14
|
+
File.expand_path('~/.soror').tap do |path|
|
15
|
+
File.exists?(path) && Soror.config(YAML.load_file(path))
|
16
|
+
end
|
data/lib/soror/ec2/instance.rb
CHANGED
@@ -4,6 +4,7 @@ module Soror
|
|
4
4
|
extend Soror::EC2
|
5
5
|
|
6
6
|
def self.search_by(tags)
|
7
|
+
warn %q{[DEPRECATION] `Soror::EC2::Instance.search_by` won't be memoized. If you want to memoize, use `Soror.start_memoizing`.}
|
7
8
|
AWS.memoize do
|
8
9
|
ec2.instances.
|
9
10
|
filter('instance-state-name', 'running').
|
data/lib/soror/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soror
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kirikiriyamama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -55,7 +55,8 @@ dependencies:
|
|
55
55
|
description: Soror is EC2 instances seacher
|
56
56
|
email:
|
57
57
|
- kirikiriyamama@icloud.com
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- soror
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
@@ -64,6 +65,7 @@ files:
|
|
64
65
|
- LICENSE.txt
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
68
|
+
- bin/soror
|
67
69
|
- lib/soror.rb
|
68
70
|
- lib/soror/ec2.rb
|
69
71
|
- lib/soror/ec2/instance.rb
|