Skip to content

Commit

Permalink
Update Isomer
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Guelpa committed Jun 22, 2015
1 parent 9778555 commit 1efb80d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/mulder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ module Mulder
require_relative 'mulder/version'

def self.search(app, env, role, format, config_file)
config = Mulder::Config.from(:yaml, file: config_file)
config = Isomer::Configuration.hydrate(Mulder::CONFIG, Isomer::Sources::Yaml.new(config_file))
connection = Mulder::Connection.new(config)
client = Mulder::Client.new(connection, app, env, role)
instances = client.instances
formatter = Mulder::Formatter.new(instances, format)

formatter.output
end
end
end
4 changes: 2 additions & 2 deletions lib/mulder/capistrano.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Mulder
class Capistrano

def initialize(config_file, application, environment)
config = ::Mulder::Config.from(:yaml, file: config_file)
config = Isomer::Configuration.hydrate(Mulder::CONFIG, Isomer::Sources::Yaml.new(config_file))
@connection = ::Mulder::Connection.new(config)
@application = application
@environment = environment
Expand All @@ -20,4 +20,4 @@ def ips(role, use_private = false)
client(role).instances.collect(&type_of_ips).compact
end
end
end
end
8 changes: 4 additions & 4 deletions lib/mulder/config.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'isomer'

module Mulder
class Config < Isomer::Base
parameter :aws_access_key_id
parameter :aws_secret_access_key
CONFIG = Isomer::Nucleus.new do |n|
n.parameter :aws_access_key_id
n.parameter :aws_secret_access_key
end
end
end
2 changes: 1 addition & 1 deletion mulder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'simplecov', '~> 0.7.1'

spec.add_dependency 'fog', '~> 1.20.0'
spec.add_dependency 'isomer', '~> 0.1.3'
spec.add_dependency 'isomer', '~> 0.2', '>= 0.2.2' # Ensure we have the 0.2.2 bug fix
spec.add_dependency 'thor', '~> 0.19.1'
spec.add_dependency 'awesome_print', '~> 1.1.0'
spec.add_dependency 'unf', '~> 0.1.4'
Expand Down
20 changes: 13 additions & 7 deletions spec/lib/mulder/capistrano_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

describe '#client' do
it 'instantiates a new client with the correct role' do
mocked_connection = mock
mocked_config = mock
Mulder::Config.expects(:from).returns(mocked_config)
Isomer::Sources::Yaml.expects(:new)
Isomer::Configuration.expects(:hydrate).returns(mocked_config)

mocked_connection = mock
Mulder::Connection.expects(:new).returns(mocked_connection)

capistrano = described_class.new('foo', 'bar', 'widget')
Expand All @@ -19,9 +21,11 @@

describe '.ips' do
it 'it returns the public ips for the client' do
mocked_connection = mock
mocked_config = mock
Mulder::Config.expects(:from).returns(mocked_config)
Isomer::Sources::Yaml.expects(:new)
Isomer::Configuration.expects(:hydrate).returns(mocked_config)

mocked_connection = mock
Mulder::Connection.expects(:new).returns(mocked_connection)

capistrano = described_class.new('foo', 'bar', 'widget')
Expand All @@ -31,9 +35,11 @@
end

it 'returns the private ips for the client' do
mocked_connection = mock
mocked_config = mock
Mulder::Config.expects(:from).returns(mocked_config)
Isomer::Sources::Yaml.expects(:new)
Isomer::Configuration.expects(:hydrate).returns(mocked_config)

mocked_connection = mock
Mulder::Connection.expects(:new).returns(mocked_connection)

capistrano = described_class.new('foo', 'bar', 'widget')
Expand All @@ -42,4 +48,4 @@
capistrano.ips('bananas', true).should == ['foo']
end
end
end
end
6 changes: 4 additions & 2 deletions spec/lib/mulder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

describe '.search' do
it 'uses the human formatter for the given params' do
mock_source = mock
Isomer::Sources::Yaml.expects(:new).with('config/aws.yml').returns(mock_source)
mock_config = mock
Mulder::Config.expects(:from).with(:yaml, file: 'config/aws.yml').returns(mock_config)
Isomer::Configuration.expects(:hydrate).with(Mulder::CONFIG, mock_source).returns(mock_config)

mock_connection = stub
Mulder::Connection.expects(:new).with(mock_config).returns(mock_connection)
Expand All @@ -24,4 +26,4 @@
end
end

end
end

0 comments on commit 1efb80d

Please sign in to comment.