mulder 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93e9573ee32a8b984d09b107c87de3d01a20e6ef
4
- data.tar.gz: 47388be2f11a80a774023890d5842d41d832beaa
3
+ metadata.gz: c74bd78ed1a5b5cf346c11d3c2e40c96b3415139
4
+ data.tar.gz: 86b32162edd9de13059ffbc0f52d67bf59f65447
5
5
  SHA512:
6
- metadata.gz: 05651cc95b366d7b3f6046fd4eccf2f917481f96c154215d0428e643905a18c2bbcc20d536625caeca62482047d4d09b559053d6ec3d213eee21819431bff786
7
- data.tar.gz: 04146bf12d17206d0ec905f66a1a688b6fae6d9fe109ee2e794b7853fa5debee1710e8d0cee687e51e12bdf9473c9b00095ec5c110f5191f9c7af4f1e6152311
6
+ metadata.gz: 70ee6aaaebc866db3d6f7a148b8a9b3d515e5749c5ea18974573255687f3097cacd65dfe997b73c5da799362074fcc331eb5daf2e14913b0e88c213db8df2df7
7
+ data.tar.gz: af7678ac094b8256d5be5e57dc3e47aeeb19b0ab7c084450578f790f292f1b13e03a89bfdfcf332b33fcbeba4e7c564d149c868b33eabc62d689e51a579e2f1c
@@ -2,7 +2,7 @@
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)
5
+ [![Build Status](https://travis-ci.org/shopkeep/mulder.png?branch=master)](https://travis-ci.org/shopkeep/mulder) [![Code Climate](https://codeclimate.com/github/shopkeep/mulder/badges/gpa.svg)](https://codeclimate.com/github/shopkeep/mulder)
6
6
 
7
7
  ## Installation
8
8
 
@@ -0,0 +1,18 @@
1
+ require 'json'
2
+
3
+ module Mulder
4
+ module Formats
5
+ class JSON < Base
6
+ attr_writer :stream
7
+
8
+ def stream
9
+ @stream || STDOUT
10
+ end
11
+
12
+ def output
13
+ stream.write(instances.collect(&:as_hash).to_json)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -1,11 +1,13 @@
1
1
  require_relative 'formats/base'
2
2
  require_relative 'formats/human'
3
+ require_relative 'formats/json'
3
4
 
4
5
  module Mulder
5
6
  class Formatter
6
7
 
7
8
  VALID_FORMATS = {
8
- 'human' => Formats::Human
9
+ 'human' => Formats::Human,
10
+ 'json' => Formats::JSON
9
11
  }
10
12
 
11
13
  def initialize(instances, format)
@@ -22,4 +24,4 @@ module Mulder
22
24
  end
23
25
  end
24
26
 
25
- end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Mulder
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mulder::Formats::JSON do
4
+
5
+ describe '#stream' do
6
+ it 'defaults to STDOUT' do
7
+ formatter = described_class.new(anything)
8
+ expect(formatter.stream).to eq(STDOUT)
9
+ end
10
+
11
+ it 'returns the given stream' do
12
+ io = mock()
13
+ formatter = described_class.new(anything)
14
+ formatter.stream = io
15
+
16
+ expect(formatter.stream).to eq(io)
17
+ end
18
+ end
19
+
20
+ describe '#output' do
21
+ it 'prints json encoded output to the stream' do
22
+ instances = [{ foo: :bar }]
23
+ mocked_instances = mock(collect: instances)
24
+
25
+ io = StringIO.new()
26
+ formatter = described_class.new(mocked_instances)
27
+ formatter.stream = io
28
+
29
+ formatter.output
30
+ expect(io.string).to eq('[{"foo":"bar"}]')
31
+ end
32
+ end
33
+
34
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mulder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duncan Grazier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -179,6 +179,7 @@ files:
179
179
  - lib/mulder/connection.rb
180
180
  - lib/mulder/formats/base.rb
181
181
  - lib/mulder/formats/human.rb
182
+ - lib/mulder/formats/json.rb
182
183
  - lib/mulder/formatter.rb
183
184
  - lib/mulder/instance.rb
184
185
  - lib/mulder/version.rb
@@ -188,6 +189,7 @@ files:
188
189
  - spec/lib/mulder/connection_spec.rb
189
190
  - spec/lib/mulder/formats/base_spec.rb
190
191
  - spec/lib/mulder/formats/human_spec.rb
192
+ - spec/lib/mulder/formats/json_spec.rb
191
193
  - spec/lib/mulder/formatter_spec.rb
192
194
  - spec/lib/mulder/instance_spec.rb
193
195
  - spec/lib/mulder_spec.rb
@@ -222,6 +224,7 @@ test_files:
222
224
  - spec/lib/mulder/connection_spec.rb
223
225
  - spec/lib/mulder/formats/base_spec.rb
224
226
  - spec/lib/mulder/formats/human_spec.rb
227
+ - spec/lib/mulder/formats/json_spec.rb
225
228
  - spec/lib/mulder/formatter_spec.rb
226
229
  - spec/lib/mulder/instance_spec.rb
227
230
  - spec/lib/mulder_spec.rb