mulder 0.0.2 → 0.0.3

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: 41372bd6e9e04c7254193716768f028c5b283e69
4
- data.tar.gz: 3675e34ac91a2b15ed36b835541de1838a929db4
3
+ metadata.gz: fde0e9bde59fcc1ca2c09d4b539c7247500f35d1
4
+ data.tar.gz: f0f281e98da7eb020a33e6178ac46e91d307afed
5
5
  SHA512:
6
- metadata.gz: 23f37ad65d666809ffee635f29f2745234bb6975ab49f4330b5a178d48def4ff40d0cccd4cad4adb54023fc5bd708fe260c66315590cb0f05827672296543d7f
7
- data.tar.gz: 77b2478db6c7f190fdfef18db902cdb806729ebeb4617d1aa808a20fcc8d6743f9ce4bb55a18e69ad8848faa64226c5f9bb567a53e0c92a5dd38186fc88392b6
6
+ metadata.gz: 0a0f75eaf98fc1d52a093da22cdff7a6a5365ce0d194385020dc7cf888ebbfd9be3ab793cc0a06cdda9badab02d44bd97fce19ce37bfcb4e8de8679f8cfb8b52
7
+ data.tar.gz: c11732ede3ee8f3634b9a9dd2c05c5dec2e6642c63ded0e965495af8746aff92120d8f1423f90de7db1009cc09c47234b41d030b5f16fb53bd8bb7b3efbb9422
data/README.markdown CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A deploy-time helper for your AWS AutoScaling groups, and servers. Discover the IP addresses of your instances by AutoScalingGroup.
4
4
 
5
+ [![Build Status](https://travis-ci.org/shopkeep/mulder.png?branch=master)](https://travis-ci.org/shopkeep/mulder)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -18,6 +20,28 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
23
+ ### CLI
24
+
25
+ To see the web servers for an app, and environment:
26
+
27
+ mulder search banana_sandwich production WebServerGroup
28
+
29
+ Example output:
30
+
31
+ [
32
+ {
33
+ :id => "i-ididid",
34
+ :dns_name => "web.prod.example.com",
35
+ :public_ip_address => "1.0.1.0",
36
+ :private_ip_address => "0.1.0.1",
37
+ :created_at => 2013-08-08 18:21:05 UTC
38
+ }
39
+ ]
40
+
41
+ To change the configration file:
42
+
43
+ mulder search banana_sandwich production WebServerGroup human foo.yml
44
+
21
45
  ### Capistrano
22
46
 
23
47
  At the top of your `deploy.rb` file, add:
data/bin/mulder ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mulder'
4
+
5
+ Mulder::CLI.start(ARGV)
data/lib/mulder.rb CHANGED
@@ -1,9 +1,20 @@
1
1
  module Mulder
2
2
 
3
+ require_relative 'mulder/cli'
3
4
  require_relative 'mulder/client'
4
5
  require_relative 'mulder/config'
5
6
  require_relative 'mulder/connection'
7
+ require_relative 'mulder/formatter'
6
8
  require_relative 'mulder/instance'
7
9
  require_relative 'mulder/version'
8
10
 
11
+ def self.search(app, env, role, format, config_file)
12
+ config = Mulder::Config.from(:yaml, file: config_file)
13
+ connection = Mulder::Connection.new(config)
14
+ client = Mulder::Client.new(connection, app, env, role)
15
+ instances = client.instances
16
+ formatter = Mulder::Formatter.new(instances, format)
17
+
18
+ formatter.output
19
+ end
9
20
  end
data/lib/mulder/cli.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'thor'
2
+
3
+ module Mulder
4
+ class CLI < Thor
5
+
6
+ desc "search APP ENV ROLE FORMAT CONFIG_FILE", "Search AutoScaling Groups for APP, ENV, ROLE, FORMAT and CONFIG_FILE"
7
+ def search(app, env, role, format = 'human', config_file = 'config/aws.yml')
8
+ Mulder.search(app, env, role, format, config_file)
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module Mulder
2
+ module Formats
3
+ class Base
4
+
5
+ attr_reader :instances
6
+
7
+ def initialize(instances)
8
+ @instances = instances
9
+ end
10
+
11
+ def output
12
+ raise NotImplementedError
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ require 'awesome_print'
2
+
3
+ module Mulder
4
+ module Formats
5
+ class Human < Base
6
+
7
+ def output
8
+ ap instances.collect(&:as_hash), { index: false, sort: true }
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'formats/base'
2
+ require_relative 'formats/human'
3
+
4
+ module Mulder
5
+ class Formatter
6
+
7
+ VALID_FORMATS = {
8
+ 'human' => Formats::Human
9
+ }
10
+
11
+ def initialize(instances, format)
12
+ unless VALID_FORMATS.keys.include?(format)
13
+ raise NotImplementedError.new("Formatting as #{format} has not been implemented!")
14
+ end
15
+
16
+ @instances = instances
17
+ @format = VALID_FORMATS[format]
18
+ end
19
+
20
+ def output
21
+ @format.new(@instances).output
22
+ end
23
+ end
24
+
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Mulder
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/mulder.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency 'fog', '~> 1.15.0'
28
28
  spec.add_dependency 'isomer', '~> 0.1.3'
29
29
  spec.add_dependency 'thor', '~> 0.18.1'
30
+ spec.add_dependency 'awesome_print', '~> 1.1.0'
30
31
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mulder::Formats::Base do
4
+ describe '.new' do
5
+ it 'stores the instances' do
6
+ described_class.new(['foo']).instances.should == ['foo']
7
+ end
8
+ end
9
+
10
+ describe '#output' do
11
+ it 'raises a NotImplementedError' do
12
+ expect {
13
+ described_class.new(['foo']).output
14
+ }.to raise_error(NotImplementedError)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mulder::Formats::Human do
4
+
5
+ describe '#output' do
6
+ it 'calls ap with the correct stuff' do
7
+ mocked_instances = mock(collect: [{ foo: :bar }])
8
+ formatter = described_class.new(mocked_instances)
9
+ formatter.expects(:ap).with([{ foo: :bar }], { index: false, sort: true })
10
+ formatter.output
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mulder::Formatter do
4
+ describe '.initialize' do
5
+ it 'raises an error of the format is not implemented' do
6
+ expect {
7
+ described_class.new([], 'foo')
8
+ }.to raise_error(NotImplementedError, 'Formatting as foo has not been implemented!')
9
+ end
10
+ end
11
+
12
+ describe "#output" do
13
+ it 'sends the correct formatter the instances' do
14
+ mock_instances = mock
15
+ Mulder::Formats::Human.expects(:new).with(mock_instances).returns(mock(output: 'foo'))
16
+ Mulder::Formatter.new(mock_instances, 'human').output
17
+ end
18
+ end
19
+ end
@@ -2,4 +2,26 @@ require 'spec_helper'
2
2
 
3
3
  describe Mulder do
4
4
 
5
+ describe '.search' do
6
+ it 'uses the human formatter for the given params' do
7
+ mock_config = mock
8
+ Mulder::Config.expects(:from).with(:yaml, file: 'config/aws.yml').returns(mock_config)
9
+
10
+ mock_connection = stub
11
+ Mulder::Connection.expects(:new).with(mock_config).returns(mock_connection)
12
+
13
+ mock_client = stub
14
+ Mulder::Client.expects(:new).with(mock_connection, 'foo-app', 'production', 'WebServerGroup').returns(mock_client)
15
+
16
+ mock_instances = stub
17
+ mock_client.expects(:instances).returns(['foo'])
18
+
19
+ mocked_formatter = stub
20
+ Mulder::Formatter.expects(:new).with(['foo'], 'human').returns(mocked_formatter)
21
+
22
+ mocked_formatter.expects(:output).once
23
+ described_class.search('foo-app', 'production', 'WebServerGroup', 'human', 'config/aws.yml')
24
+ end
25
+ end
26
+
5
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mulder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duncan Grazier
@@ -122,11 +122,26 @@ dependencies:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.18.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: awesome_print
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 1.1.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 1.1.0
125
139
  description: Discover information about AWS Autoscaling Groups
126
140
  email:
127
141
  - itsmeduncan@gmail.com
128
142
  executables:
129
143
  - .gitkeep
144
+ - mulder
130
145
  extensions: []
131
146
  extra_rdoc_files: []
132
147
  files:
@@ -140,18 +155,26 @@ files:
140
155
  - README.markdown
141
156
  - Rakefile
142
157
  - bin/.gitkeep
158
+ - bin/mulder
143
159
  - config/aws.example.yml
144
160
  - lib/mulder.rb
145
161
  - lib/mulder/capistrano.rb
162
+ - lib/mulder/cli.rb
146
163
  - lib/mulder/client.rb
147
164
  - lib/mulder/config.rb
148
165
  - lib/mulder/connection.rb
166
+ - lib/mulder/formats/base.rb
167
+ - lib/mulder/formats/human.rb
168
+ - lib/mulder/formatter.rb
149
169
  - lib/mulder/instance.rb
150
170
  - lib/mulder/version.rb
151
171
  - mulder.gemspec
152
172
  - spec/lib/mulder/capistrano_spec.rb
153
173
  - spec/lib/mulder/client_spec.rb
154
174
  - spec/lib/mulder/connection_spec.rb
175
+ - spec/lib/mulder/formats/base_spec.rb
176
+ - spec/lib/mulder/formats/human_spec.rb
177
+ - spec/lib/mulder/formatter_spec.rb
155
178
  - spec/lib/mulder/instance_spec.rb
156
179
  - spec/lib/mulder_spec.rb
157
180
  - spec/spec_helper.rb
@@ -183,6 +206,9 @@ test_files:
183
206
  - spec/lib/mulder/capistrano_spec.rb
184
207
  - spec/lib/mulder/client_spec.rb
185
208
  - spec/lib/mulder/connection_spec.rb
209
+ - spec/lib/mulder/formats/base_spec.rb
210
+ - spec/lib/mulder/formats/human_spec.rb
211
+ - spec/lib/mulder/formatter_spec.rb
186
212
  - spec/lib/mulder/instance_spec.rb
187
213
  - spec/lib/mulder_spec.rb
188
214
  - spec/spec_helper.rb