outliers 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/outliers/evaluation.rb +3 -1
- data/lib/outliers/provider.rb +23 -4
- data/lib/outliers/resource.rb +12 -0
- data/lib/outliers/resources.rb +7 -2
- data/lib/outliers/version.rb +1 -1
- data/spec/collection_spec.rb +1 -1
- data/spec/evaluation_spec.rb +5 -0
- data/spec/info_spec.rb +1 -1
- data/spec/provider_spec.rb +35 -0
- data/spec/resource_spec.rb +17 -0
- data/spec/resources_spec.rb +11 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 834ef0a08d61f1df2366395da4695af04c034eb1
|
4
|
+
data.tar.gz: b958631f09f5e25bbc9ffa84562fda4961ce3ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7786919daab3cc5062f27ef73ede084d6263164d319d9669908cf0c47581fed6d916b7f3d1f27ac3187113b457a6403a65668a3c1baa376d68e0ba3d598a09b
|
7
|
+
data.tar.gz: 1777fb497e933c4a3de1ca63606d5e1619e71193354cea342a40fb6325f92d4104427babc923805168102e4bf0561a596f86ea3666ffaec2b983622f31830104
|
data/CHANGELOG.md
CHANGED
data/lib/outliers/evaluation.rb
CHANGED
@@ -105,7 +105,9 @@ module Outliers
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def account(name)
|
108
|
-
@run.account.fetch name
|
108
|
+
account = @run.account.fetch name, nil
|
109
|
+
raise Outliers::Exceptions::UnknownAccount.new "Unkown account '#{name}'." unless account
|
110
|
+
account
|
109
111
|
end
|
110
112
|
|
111
113
|
def merged_account(name, options)
|
data/lib/outliers/provider.rb
CHANGED
@@ -3,17 +3,36 @@ module Outliers
|
|
3
3
|
|
4
4
|
attr_reader :account
|
5
5
|
|
6
|
+
def self.find_by_name(name)
|
7
|
+
Outliers::Providers.name_map.fetch name, nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.exists?(name)
|
11
|
+
find_by_name(name) != nil
|
12
|
+
end
|
13
|
+
|
6
14
|
def self.connect_to(account)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
15
|
+
provider_name = account.fetch 'provider'
|
16
|
+
|
17
|
+
if exists? provider_name
|
18
|
+
find_by_name(provider_name).new account
|
19
|
+
else
|
20
|
+
raise Outliers::Exceptions::UnknownProvider.new "Invalid provider '#{provider_name}'."
|
21
|
+
end
|
11
22
|
end
|
12
23
|
|
13
24
|
def self.to_human
|
14
25
|
(self.to_s.split('::') - ['Outliers', 'Providers']).map { |p| p.underscore }.join('_').downcase
|
15
26
|
end
|
16
27
|
|
28
|
+
def self.resources
|
29
|
+
Outliers::Resources.resources.select {|r| r.to_human =~ /^#{to_human}/}
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.collections
|
33
|
+
Outliers::Resources.collections.select {|r| r.to_human =~ /^#{to_human}/}
|
34
|
+
end
|
35
|
+
|
17
36
|
def initialize(account)
|
18
37
|
@account = account
|
19
38
|
@logger = Outliers.logger
|
data/lib/outliers/resource.rb
CHANGED
@@ -7,10 +7,22 @@ module Outliers
|
|
7
7
|
'name'
|
8
8
|
end
|
9
9
|
|
10
|
+
def self.to_human
|
11
|
+
(self.to_s.split('::') - ['Outliers', 'Resources']).map { |p| p.underscore }.join('_').downcase
|
12
|
+
end
|
13
|
+
|
10
14
|
def self.verifications
|
11
15
|
[]
|
12
16
|
end
|
13
17
|
|
18
|
+
def self.find_by_name(name)
|
19
|
+
Outliers::Resources.find_by_name name
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.list
|
23
|
+
Outliers::Resources.resources
|
24
|
+
end
|
25
|
+
|
14
26
|
def initialize(source)
|
15
27
|
@source = source
|
16
28
|
@logger = Outliers.logger
|
data/lib/outliers/resources.rb
CHANGED
@@ -4,12 +4,17 @@ module Outliers
|
|
4
4
|
module Resources
|
5
5
|
module_function
|
6
6
|
|
7
|
-
def
|
8
|
-
|
7
|
+
def find_by_name(name)
|
8
|
+
l = resources.select {|m| m.to_human == name }
|
9
|
+
l.any? ? l.first : nil
|
9
10
|
end
|
10
11
|
|
11
12
|
def collections
|
12
13
|
all_the_modules.select {|m| (m.is_a? Class) && (m.to_s =~ /Collection$/)}
|
13
14
|
end
|
15
|
+
|
16
|
+
def resources
|
17
|
+
all_the_modules.select {|m| (m.is_a? Class) && !(m.to_s =~ /Collection$/)}
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
data/lib/outliers/version.rb
CHANGED
data/spec/collection_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe Outliers::Collection do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
context "#to_human" do
|
20
|
-
it "should return the human name for
|
20
|
+
it "should return the human name for the resource of the collection" do
|
21
21
|
expect(Outliers::Resources::Aws::Ec2::SecurityGroupCollection.to_human).to eq('aws_ec2_security_group')
|
22
22
|
expect(Outliers::Resources::Aws::S3::BucketCollection.to_human).to eq('aws_s3_bucket')
|
23
23
|
end
|
data/spec/evaluation_spec.rb
CHANGED
@@ -31,6 +31,11 @@ describe Outliers::Evaluation do
|
|
31
31
|
subject.connect('test_account_1', { 'provider' => 'aws_ec2' })
|
32
32
|
expect(subject.provider_name_array).to eq(['Aws', 'Ec2'])
|
33
33
|
end
|
34
|
+
|
35
|
+
it "should throw an error if the account is unknown" do
|
36
|
+
expect { subject.connect('bad_account') }.
|
37
|
+
to raise_error(Outliers::Exceptions::UnknownAccount)
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
|
data/spec/info_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Outliers::Info do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should verify each resource method has a entry in reference.yaml" do
|
23
|
-
expect((@resources - ['all_shared']).sort).to eq(Outliers::
|
23
|
+
expect((@resources - ['all_shared']).sort).to eq(Outliers::Resource.list.map {|r| r.to_human}.sort)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should validate each resource has a verification list, filter list and description" do
|
data/spec/provider_spec.rb
CHANGED
@@ -3,6 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe Outliers::Provider do
|
4
4
|
subject { Outliers::Provider }
|
5
5
|
|
6
|
+
context "#find_by_name" do
|
7
|
+
it "should return the provider by the given name" do
|
8
|
+
expect(subject.find_by_name 'aws_ec2').to eq(Outliers::Providers::Aws::Ec2)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return nil if name not found" do
|
12
|
+
expect(subject.find_by_name 'blah').to be_false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
6
16
|
context "#connect_to" do
|
7
17
|
let(:account) { ( { :name => "test_account_1",
|
8
18
|
"provider" => "aws_ec2",
|
@@ -20,6 +30,31 @@ describe Outliers::Provider do
|
|
20
30
|
"secret_access_key" => "abc",
|
21
31
|
"access_key_id" => "123" })
|
22
32
|
end
|
33
|
+
|
34
|
+
it "should raise an error if the provider does not exist" do
|
35
|
+
expect(subject.connect_to(account).class).to eq(Outliers::Providers::Aws::Ec2)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should raise an error if the provider is invalid" do
|
39
|
+
expect(subject.connect_to(account).class).to eq(Outliers::Providers::Aws::Ec2)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
context "#collections" do
|
45
|
+
it "should return the collections for the provider" do
|
46
|
+
expect(Outliers::Providers::Aws::Rds.collections).
|
47
|
+
to eq([Outliers::Resources::Aws::Rds::DbInstanceCollection,
|
48
|
+
Outliers::Resources::Aws::Rds::DbSnapshotCollection])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "#resources" do
|
53
|
+
it "should return the resources for the provider" do
|
54
|
+
expect(Outliers::Providers::Aws::Rds.resources).
|
55
|
+
to eq([Outliers::Resources::Aws::Rds::DbInstance,
|
56
|
+
Outliers::Resources::Aws::Rds::DbSnapshot])
|
57
|
+
end
|
23
58
|
end
|
24
59
|
|
25
60
|
context "#to_human" do
|
data/spec/resource_spec.rb
CHANGED
@@ -16,4 +16,21 @@ describe Outliers::Resource do
|
|
16
16
|
expect(Outliers::Resource.key).to eq('name')
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
context "#to_human" do
|
21
|
+
it "should return the human name for this resource" do
|
22
|
+
expect(Outliers::Resources::Aws::Ec2::SecurityGroupCollection.to_human).to eq('aws_ec2_security_group')
|
23
|
+
expect(Outliers::Resources::Aws::S3::BucketCollection.to_human).to eq('aws_s3_bucket')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "#self.find_by_name" do
|
28
|
+
it "should find the resource by name" do
|
29
|
+
expect(Outliers::Resource.find_by_name('aws_ec2_instance')).to eq(Outliers::Resources::Aws::Ec2::Instance)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return nil if the resource can't be found" do
|
33
|
+
expect(Outliers::Resource.find_by_name('blah')).to be_nil
|
34
|
+
end
|
35
|
+
end
|
19
36
|
end
|
data/spec/resources_spec.rb
CHANGED
@@ -2,14 +2,22 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Outliers::Resources do
|
4
4
|
subject { Outliers::Resources }
|
5
|
-
|
6
|
-
context "#collections" do
|
7
|
-
it "should return all the collections" do
|
5
|
+
before do
|
8
6
|
Outliers::Resources.stub :all_the_modules => [Outliers::Resources::Aws::Ec2,
|
9
7
|
Outliers::Resources::Aws::Ec2::SecurityGroup,
|
10
8
|
Outliers::Resources::Aws::Ec2::SecurityGroupCollection]
|
9
|
+
end
|
10
|
+
|
11
|
+
context "#collection" do
|
12
|
+
it "should return all the collections" do
|
11
13
|
expect(subject.collections).to eq([Outliers::Resources::Aws::Ec2::SecurityGroupCollection])
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
17
|
+
context "#resources" do
|
18
|
+
it "should return all the resources" do
|
19
|
+
expect(subject.resources).to eq([Outliers::Resources::Aws::Ec2::SecurityGroup])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
15
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outliers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Weaver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|