soror 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -11
- data/bin/soror +0 -1
- data/lib/soror/ec2/instance.rb +10 -7
- data/lib/soror/ec2.rb +6 -2
- data/lib/soror/version.rb +1 -1
- data/lib/soror.rb +25 -3
- data/soror.gemspec +2 -2
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 034997ba85838ff60db49c955ea8b4f4405f5c33
|
4
|
+
data.tar.gz: 56411d4aa19bb9b7b8ee338f3ad7d2c986b39998
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 668a7efefa9faaed4c4382d1f832f84ac7bc3f83ff8052f9a2660fa8119399c3cfcf4980b6acc7afa07036f800f5d781a8da146072e9ad549fb4bd785bbc0902
|
7
|
+
data.tar.gz: 500a4bc5dfabb60a656e30773c3a2c4449899c4dc5b134ae57f0ad3c920f868745b9ff7547b082aed2002f152f586fa2000743c1e47bf0f0125d8d2f8d2d3047
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Soror
|
2
2
|
|
3
|
-
|
3
|
+
Search for EC2 instances by tags :mag_right:
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -22,15 +22,15 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
# Search for EC2 instances which have the tag `{ "Key": "name", "Value": "soror" }`
|
25
|
-
# You can use methods of
|
26
|
-
# See http://docs.aws.amazon.com/
|
27
|
-
Soror::EC2::Instance.search_by(name: 'soror') #=> [<
|
25
|
+
# You can use methods of Aws::EC2::Instance to an element of return value
|
26
|
+
# See http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Instance.html
|
27
|
+
Soror::EC2::Instance.search_by(name: 'soror') #=> [<Aws::EC2::Instance>, ...]
|
28
28
|
```
|
29
29
|
|
30
30
|
### Configuration
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
Soror.config
|
33
|
+
Soror.config = { access_key_id: 'xxxxx', secret_access_key: 'xxxxx', region: 'ap-northeast-1' }
|
34
34
|
```
|
35
35
|
|
36
36
|
Or put the configuration file on your home directory as:
|
@@ -43,12 +43,6 @@ region: 'ap-northeast-1'
|
|
43
43
|
EOS
|
44
44
|
```
|
45
45
|
|
46
|
-
### Memoization
|
47
|
-
|
48
|
-
```ruby
|
49
|
-
Soror.start_memoizing
|
50
|
-
```
|
51
|
-
|
52
46
|
## CLI
|
53
47
|
|
54
48
|
```
|
data/bin/soror
CHANGED
@@ -22,7 +22,6 @@ fail OptionParser::MissingArgument, '--attributes' if options[:attributes].nil?
|
|
22
22
|
fail OptionParser::InvalidArgument, '--attributes' if options[:attributes].empty?
|
23
23
|
|
24
24
|
Soror.config(options[:config])
|
25
|
-
Soror.start_memoizing
|
26
25
|
|
27
26
|
instances = Soror::EC2::Instance.search_by(options[:tag])
|
28
27
|
exit! if instances.empty?
|
data/lib/soror/ec2/instance.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
module Soror
|
2
2
|
module EC2
|
3
3
|
class Instance
|
4
|
-
|
4
|
+
class << self
|
5
|
+
include Soror::EC2
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
def search_by(tags)
|
8
|
+
filters = [].tap do |array|
|
9
|
+
array << { name: 'instance-state-name', values: ['running'] }
|
10
|
+
tags.each do |k, v|
|
11
|
+
array << { name: "tag:#{k}", values: [v] }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
resource.instances(filters: filters).to_a
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
data/lib/soror/ec2.rb
CHANGED
data/lib/soror/version.rb
CHANGED
data/lib/soror.rb
CHANGED
@@ -1,16 +1,38 @@
|
|
1
|
-
require 'aws-sdk
|
1
|
+
require 'aws-sdk'
|
2
2
|
require 'forwardable'
|
3
3
|
require 'soror/ec2'
|
4
4
|
require 'soror/version'
|
5
5
|
require 'yaml'
|
6
6
|
|
7
|
+
unless {}.respond_to?(:symbolize_keys)
|
8
|
+
class Hash
|
9
|
+
def symbolize_keys
|
10
|
+
dup.symbolize_keys!
|
11
|
+
end
|
12
|
+
|
13
|
+
def symbolize_keys!
|
14
|
+
keys.each do |key|
|
15
|
+
self[(key.to_sym rescue key) || key] = delete(key)
|
16
|
+
end
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
7
22
|
module Soror
|
8
23
|
class << self
|
9
24
|
extend Forwardable
|
10
|
-
def_delegators
|
25
|
+
def_delegators Aws, :config=
|
26
|
+
|
27
|
+
def config(hash)
|
28
|
+
warn '[DEPRECATION] `Soror.config` will be removed. Please use `Soror.config=` instead.'
|
29
|
+
hash.symbolize_keys.each{ |k, v| Aws.config[k] = v }
|
30
|
+
end
|
11
31
|
end
|
12
32
|
end
|
13
33
|
|
14
34
|
File.expand_path('~/.soror').tap do |path|
|
15
|
-
File.exists?(path)
|
35
|
+
if File.exists?(path)
|
36
|
+
Soror.config = YAML.load_file(path).symbolize_keys
|
37
|
+
end
|
16
38
|
end
|
data/soror.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Soror::VERSION
|
9
9
|
spec.authors = ["kirikiriyamama"]
|
10
10
|
spec.email = ["kirikiriyamama@icloud.com"]
|
11
|
-
spec.summary = %q{
|
11
|
+
spec.summary = %q{Search for EC2 instances by tags}
|
12
12
|
spec.description = spec.summary
|
13
13
|
spec.homepage = "https://github.com/kirikiriyamama/soror"
|
14
14
|
spec.license = "MIT"
|
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
|
24
|
-
spec.add_runtime_dependency "aws-sdk
|
24
|
+
spec.add_runtime_dependency "aws-sdk", '~> 2'
|
25
25
|
end
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kirikiriyamama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,20 +39,20 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: aws-sdk
|
42
|
+
name: aws-sdk
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description:
|
54
|
+
version: '2'
|
55
|
+
description: Search for EC2 instances by tags
|
56
56
|
email:
|
57
57
|
- kirikiriyamama@icloud.com
|
58
58
|
executables:
|
@@ -94,5 +94,5 @@ rubyforge_project:
|
|
94
94
|
rubygems_version: 2.2.2
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
|
-
summary:
|
97
|
+
summary: Search for EC2 instances by tags
|
98
98
|
test_files: []
|