soror 0.1.0 → 0.2.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: 4bff2dc21e2da2264062e8b5df495aa0d6de4a07
4
- data.tar.gz: 1929169d3c2f4062dcc9b37c2f6e53e0bb296106
3
+ metadata.gz: ab8b39b3eccef7a690c16da4975c4a9dd59632b7
4
+ data.tar.gz: 0356f90edb7ba6d14c788e66fe058cb39fb7378b
5
5
  SHA512:
6
- metadata.gz: 3986d1d96c69b3de84749185b37f14e6b2d95e41b38a4833aadc002cc316c7311965e36a167bfb78193daa2ac712bc28ca0be27198d25dbf88705e0ab6d0b1b8
7
- data.tar.gz: 3f1fcb90291200f467b253d60a12b80d57d7491f8f2207e6b09b4974ecc19bdf4468c44afe169e03a8025c48f1a7b615eb9aed2d9c99a766945434befe9163be
6
+ metadata.gz: 109c87056a530122720b520f07a2576bc93382a39678bd610b66f285cb149fc92ff685b4397f1f4e087d763dc15925a7ba4c1a7dcecdfb8a64783553f0e870d3
7
+ data.tar.gz: 4b389288e835f0daa08ef2caf9c74c481bc3a61c15dda009a85db6efd74bdf3c903b01a347abdb525cacccdf3d626aa363b5b213dc473b90ba8e0ddaf77c258d
data/README.md CHANGED
@@ -12,11 +12,15 @@ gem 'soror'
12
12
 
13
13
  And then execute:
14
14
 
15
- $ bundle
15
+ ```
16
+ $ bundle
17
+ ```
16
18
 
17
19
  Or install it yourself as:
18
20
 
19
- $ gem install soror
21
+ ```
22
+ $ gem install soror
23
+ ```
20
24
 
21
25
  ## Usage
22
26
 
@@ -42,7 +46,7 @@ In addition, Soror supports [a new and standardized way to manage credentials](h
42
46
  ```
43
47
  $ soror --help
44
48
  Usage: soror [options]
45
- --tags='KEY=VAL,KEY=VAL,...'
49
+ -t, --tags='KEY=VAL,KEY=VAL,...'
46
50
  -a, --attributes=ATTR,ATTR,...
47
51
  --[no-]header
48
52
  --profile-name=NAME
data/bin/soror CHANGED
@@ -7,11 +7,6 @@ Version = Soror::VERSION
7
7
 
8
8
  options = { header: true, attributes: [], config: {}, credentials: {}, tag: {} }
9
9
  OptionParser.new do |opt|
10
- opt.on('-t', '--tag=\'KEY=VALUE\'', /\A[^=]+=[^=]+\z/) do |v|
11
- warn '[DEPRECATION] The option `--tag` will be removed, and `-t` will be assigned to `--tags`. Please use `--tags` instead.'
12
- key, val = v.split('=')
13
- options[:tag][key] = val
14
- end
15
10
  opt.on(%q{--tags='KEY=VAL,KEY=VAL,...'}, Array) do |a|
16
11
  a.map{ |s| s.split('=') }.each{ |k, v| options[:tag][k] = v }
17
12
  end
@@ -1,13 +1,34 @@
1
- require 'aws-sdk'
1
+ require 'aws-sdk-ec2'
2
2
  require 'forwardable'
3
- require 'soror/ec2'
4
3
  require 'soror/version'
5
- require 'yaml'
6
4
 
7
- module Soror
5
+ class Soror
8
6
  class << self
9
7
  extend Forwardable
8
+
10
9
  def_delegators Aws, :config, :config=
11
- def_delegators Soror::EC2::Instance, :search_by
10
+ def_delegators new, :search_by
11
+ end
12
+
13
+ def initialize
14
+ @ec2 = Aws::EC2::Client.new
15
+ end
16
+
17
+ def search_by(tags)
18
+ filters = [{ name: 'instance-state-name', values: ['running'] }]
19
+ tags.each do |k, v|
20
+ filters << { name: "tag:#{k}", values: [v] }
21
+ end
22
+
23
+ @ec2.describe_instances(filters: filters).reservations.map(&:instances).flatten
24
+ end
25
+
26
+ module EC2
27
+ class Instance
28
+ # Deprecated
29
+ def self.search_by(tags)
30
+ Soror.search_by(tags)
31
+ end
32
+ end
12
33
  end
13
34
  end
@@ -1,3 +1,3 @@
1
1
  module Soror
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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", '~> 2'
24
+ spec.add_runtime_dependency "aws-sdk-ec2"
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kirikiriyamama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-27 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,19 +39,19 @@ 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-ec2
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '2'
47
+ version: '0'
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: '2'
54
+ version: '0'
55
55
  description: Search for EC2 instances by tags
56
56
  email:
57
57
  - kirikiriyamama@icloud.com
@@ -67,8 +67,6 @@ files:
67
67
  - Rakefile
68
68
  - bin/soror
69
69
  - lib/soror.rb
70
- - lib/soror/ec2.rb
71
- - lib/soror/ec2/instance.rb
72
70
  - lib/soror/version.rb
73
71
  - soror.gemspec
74
72
  homepage: https://github.com/kirikiriyamama/soror
@@ -91,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
89
  version: '0'
92
90
  requirements: []
93
91
  rubyforge_project:
94
- rubygems_version: 2.4.5
92
+ rubygems_version: 2.6.13
95
93
  signing_key:
96
94
  specification_version: 4
97
95
  summary: Search for EC2 instances by tags
@@ -1,13 +0,0 @@
1
- require 'soror/ec2/instance'
2
-
3
- module Soror
4
- module EC2
5
- def client
6
- @@client ||= Aws::EC2::Client.new
7
- end
8
-
9
- def resource
10
- @@resource ||= Aws::EC2::Resource.new(client: client)
11
- end
12
- end
13
- end
@@ -1,19 +0,0 @@
1
- module Soror
2
- module EC2
3
- class Instance
4
- class << self
5
- include Soror::EC2
6
-
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
15
- end
16
- end
17
- end
18
- end
19
- end