From 1efb80d86705797168cb81a97f6e90f975fccd0c Mon Sep 17 00:00:00 2001 From: Paul Guelpa Date: Mon, 22 Jun 2015 14:57:30 -0400 Subject: [PATCH] Update Isomer --- lib/mulder.rb | 4 ++-- lib/mulder/capistrano.rb | 4 ++-- lib/mulder/config.rb | 8 ++++---- mulder.gemspec | 2 +- spec/lib/mulder/capistrano_spec.rb | 20 +++++++++++++------- spec/lib/mulder_spec.rb | 6 ++++-- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/mulder.rb b/lib/mulder.rb index be6d72d..f8cfb15 100644 --- a/lib/mulder.rb +++ b/lib/mulder.rb @@ -9,7 +9,7 @@ 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 @@ -17,4 +17,4 @@ def self.search(app, env, role, format, config_file) formatter.output end -end \ No newline at end of file +end diff --git a/lib/mulder/capistrano.rb b/lib/mulder/capistrano.rb index e187dd9..14be134 100644 --- a/lib/mulder/capistrano.rb +++ b/lib/mulder/capistrano.rb @@ -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 @@ -20,4 +20,4 @@ def ips(role, use_private = false) client(role).instances.collect(&type_of_ips).compact end end -end \ No newline at end of file +end diff --git a/lib/mulder/config.rb b/lib/mulder/config.rb index 37b782e..b079abc 100644 --- a/lib/mulder/config.rb +++ b/lib/mulder/config.rb @@ -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 \ No newline at end of file +end diff --git a/mulder.gemspec b/mulder.gemspec index 78c27d6..c3568cd 100644 --- a/mulder.gemspec +++ b/mulder.gemspec @@ -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' diff --git a/spec/lib/mulder/capistrano_spec.rb b/spec/lib/mulder/capistrano_spec.rb index 30ca7ea..5dec3d4 100644 --- a/spec/lib/mulder/capistrano_spec.rb +++ b/spec/lib/mulder/capistrano_spec.rb @@ -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') @@ -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') @@ -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') @@ -42,4 +48,4 @@ capistrano.ips('bananas', true).should == ['foo'] end end -end \ No newline at end of file +end diff --git a/spec/lib/mulder_spec.rb b/spec/lib/mulder_spec.rb index 42c75f2..35a4352 100644 --- a/spec/lib/mulder_spec.rb +++ b/spec/lib/mulder_spec.rb @@ -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) @@ -24,4 +26,4 @@ end end -end \ No newline at end of file +end