From 8814b405bf2f8bed6a5b0f8cf6b973bc3ef24cc9 Mon Sep 17 00:00:00 2001 From: Jiri Stransky Date: Wed, 30 Jan 2013 17:31:51 +0100 Subject: [PATCH 1/3] Move REST client code to AeolusClient namespace --- lib/aeolus_cli/common_cli.rb | 18 +++++++++--------- lib/aeolus_cli/formatting/human_format.rb | 4 ++-- lib/aeolus_cli/formatting/machine_format.rb | 4 ++-- lib/aeolus_cli/model/provider_type.rb | 11 ----------- lib/aeolus_cli/provider.rb | 6 +++--- lib/aeolus_cli/provider_account.rb | 8 ++++---- .../model => aeolus_client}/base.rb | 4 ++-- .../model => aeolus_client}/provider.rb | 6 +++--- .../provider_account.rb | 8 ++++---- lib/aeolus_client/provider_type.rb | 11 +++++++++++ spec/config_spec.rb | 12 ++++++------ 11 files changed, 46 insertions(+), 46 deletions(-) delete mode 100644 lib/aeolus_cli/model/provider_type.rb rename lib/{aeolus_cli/model => aeolus_client}/base.rb (93%) rename lib/{aeolus_cli/model => aeolus_client}/provider.rb (87%) rename lib/{aeolus_cli/model => aeolus_client}/provider_account.rb (86%) create mode 100644 lib/aeolus_client/provider_type.rb diff --git a/lib/aeolus_cli/common_cli.rb b/lib/aeolus_cli/common_cli.rb index a1a7528..46a0d3e 100644 --- a/lib/aeolus_cli/common_cli.rb +++ b/lib/aeolus_cli/common_cli.rb @@ -1,8 +1,8 @@ require 'active_resource' require 'thor' require 'aeolus_cli/formatting' -require 'aeolus_cli/model/base' -require 'aeolus_cli/model/provider_type' +require 'aeolus_client/base' +require 'aeolus_client/provider_type' class AeolusCli::CommonCli < Thor class_option :conductor_url, :type => :string @@ -96,9 +96,9 @@ def load_aeolus_config(options) ("Error in configuration file: #{key} is missing" ) unless @config[:conductor].has_key?(key) end - AeolusCli::Model::Base.site = @config[:conductor][:url] - AeolusCli::Model::Base.user = @config[:conductor][:username] - AeolusCli::Model::Base.password = @config[:conductor][:password] + AeolusClient::Base.site = @config[:conductor][:url] + AeolusClient::Base.user = @config[:conductor][:username] + AeolusClient::Base.password = @config[:conductor][:password] else raise AeolusCli::ConfigError.new("Error in configuration file") end @@ -127,13 +127,13 @@ def load_aeolus_config(options) end # allow overrides from command line if options[:conductor_url] - AeolusCli::Model::Base.site = options[:conductor_url] + AeolusClient::Base.site = options[:conductor_url] end if options[:username] - AeolusCli::Model::Base.user = options[:username] + AeolusClient::Base.user = options[:username] end if options[:password] - AeolusCli::Model::Base.password = options[:password] + AeolusClient::Base.password = options[:password] end end @@ -179,7 +179,7 @@ def provider_type(type_s) def provider_type_hash deltacloud_driver_to_provider_type = Hash.new - provider_types = AeolusCli::Model::ProviderType.all + provider_types = AeolusClient::ProviderType.all if provider_types.size == 0 raise "Retrieved zero provider types from Conductor" end diff --git a/lib/aeolus_cli/formatting/human_format.rb b/lib/aeolus_cli/formatting/human_format.rb index 00606f4..ff80c3c 100644 --- a/lib/aeolus_cli/formatting/human_format.rb +++ b/lib/aeolus_cli/formatting/human_format.rb @@ -9,8 +9,8 @@ class HumanFormat < Format def initialize(shell) super(shell) - register("AeolusCli::Model::Provider", ProviderPresenter) - register("AeolusCli::Model::ProviderAccount", ProviderAccountPresenter) + register("AeolusClient::Provider", ProviderPresenter) + register("AeolusClient::ProviderAccount", ProviderAccountPresenter) end def detail(object, fields_override = nil) diff --git a/lib/aeolus_cli/formatting/machine_format.rb b/lib/aeolus_cli/formatting/machine_format.rb index 41ba16f..987248d 100644 --- a/lib/aeolus_cli/formatting/machine_format.rb +++ b/lib/aeolus_cli/formatting/machine_format.rb @@ -9,8 +9,8 @@ def initialize(shell, separator = "\t") super(shell) @separator = separator - register("AeolusCli::Model::Provider", ProviderPresenter) - register("AeolusCli::Model::ProviderAccount", ProviderAccountPresenter) + register("AeolusClient::Provider", ProviderPresenter) + register("AeolusClient::ProviderAccount", ProviderAccountPresenter) end def detail(object, fields_override = nil) diff --git a/lib/aeolus_cli/model/provider_type.rb b/lib/aeolus_cli/model/provider_type.rb deleted file mode 100644 index ba5f3ef..0000000 --- a/lib/aeolus_cli/model/provider_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ProviderTypeXMLFormat - include ActiveResource::Formats::XmlFormat - - def decode(xml) - ActiveResource::Formats::XmlFormat.decode(xml)['provider_type'] - end -end - -class AeolusCli::Model::ProviderType < AeolusCli::Model::Base - self.format = ProviderTypeXMLFormat.new -end diff --git a/lib/aeolus_cli/provider.rb b/lib/aeolus_cli/provider.rb index 9b13ad5..56dd116 100644 --- a/lib/aeolus_cli/provider.rb +++ b/lib/aeolus_cli/provider.rb @@ -1,12 +1,12 @@ require 'aeolus_cli/common_cli' -require 'aeolus_cli/model/provider' +require 'aeolus_client/provider' class AeolusCli::Provider < AeolusCli::CommonCli desc "list", "List all providers" method_options_for_resource_list def list - providers = AeolusCli::Model::Provider.all + providers = AeolusClient::Provider.all output_format.list(providers, resource_fields(options[:fields]), resource_sort_by(options[:sort_by])) @@ -19,7 +19,7 @@ def list method_option :deltacloud_provider, :type => :string def add(provider_name) # TODO: validation on provider_type (make sure exists) - p = AeolusCli::Model::Provider.new(:name => provider_name, + p = AeolusClient::Provider.new(:name => provider_name, :url => options[:deltacloud_url], :provider_type => provider_type(options[:provider_type]), :deltacloud_provider => options[:deltacloud_provider]) diff --git a/lib/aeolus_cli/provider_account.rb b/lib/aeolus_cli/provider_account.rb index ca040e3..e36b547 100644 --- a/lib/aeolus_cli/provider_account.rb +++ b/lib/aeolus_cli/provider_account.rb @@ -1,5 +1,5 @@ require 'aeolus_cli/common_cli' -require 'aeolus_cli/model/provider_account' +require 'aeolus_client/provider_account' class AeolusCli::ProviderAccount < AeolusCli::CommonCli @@ -7,7 +7,7 @@ class AeolusCli::ProviderAccount < AeolusCli::CommonCli method_options_for_resource_list # TODO maybe an optional variable for provider_type def list - accounts = AeolusCli::Model::ProviderAccount.all_full_detail + accounts = AeolusClient::ProviderAccount.all_full_detail output_format.list(accounts, resource_fields(options[:fields]), resource_sort_by(options[:sort_by])) @@ -22,13 +22,13 @@ def list :default => "unlimited", :desc => "maximum running instances" def add(label) credentials = credentials_from_file(options[:credentials_file]) - provider = AeolusCli::Model::Provider.all.find {|p| p.name == options[:provider_name]} + provider = AeolusClient::Provider.all.find {|p| p.name == options[:provider_name]} unless provider self.shell.say "ERROR: The provider '#{options[:provider_name]}' does not exist" exit(1) end - pa = AeolusCli::Model::ProviderAccount.new( + pa = AeolusClient::ProviderAccount.new( :label => label, :provider => {:id => provider.id}, :credentials => credentials, diff --git a/lib/aeolus_cli/model/base.rb b/lib/aeolus_client/base.rb similarity index 93% rename from lib/aeolus_cli/model/base.rb rename to lib/aeolus_client/base.rb index f063a40..681e934 100644 --- a/lib/aeolus_cli/model/base.rb +++ b/lib/aeolus_client/base.rb @@ -28,10 +28,10 @@ def from_xml(xml, save_cache = false) # declaring the namespace but for style reasons not including the Base # class definition within the block (saving as much excessive # indentation as possible) -module AeolusCli::Model +module AeolusClient end -class AeolusCli::Model::Base < ActiveResource::Base +class AeolusClient::Base < ActiveResource::Base self.timeout = 600 self.format = :xml end diff --git a/lib/aeolus_cli/model/provider.rb b/lib/aeolus_client/provider.rb similarity index 87% rename from lib/aeolus_cli/model/provider.rb rename to lib/aeolus_client/provider.rb index 2e4f7a8..f34ae44 100644 --- a/lib/aeolus_cli/model/provider.rb +++ b/lib/aeolus_client/provider.rb @@ -1,4 +1,4 @@ -class ProviderXMLFormat +class AeolusClient::ProviderXMLFormat include ActiveResource::Formats::XmlFormat def decode(xml) @@ -29,6 +29,6 @@ def decode(xml) end end -class AeolusCli::Model::Provider < AeolusCli::Model::Base - self.format = ProviderXMLFormat.new +class AeolusClient::Provider < AeolusClient::Base + self.format = AeolusClient::ProviderXMLFormat.new end diff --git a/lib/aeolus_cli/model/provider_account.rb b/lib/aeolus_client/provider_account.rb similarity index 86% rename from lib/aeolus_cli/model/provider_account.rb rename to lib/aeolus_client/provider_account.rb index 1c831db..dca82d1 100644 --- a/lib/aeolus_cli/model/provider_account.rb +++ b/lib/aeolus_client/provider_account.rb @@ -1,4 +1,4 @@ -class ProviderAccountXMLFormat +class AeolusClient::ProviderAccountXMLFormat include ActiveResource::Formats::XmlFormat def decode(xml) @@ -32,15 +32,15 @@ def decode(xml) end end -class AeolusCli::Model::ProviderAccount < AeolusCli::Model::Base - self.format = ProviderAccountXMLFormat.new +class AeolusClient::ProviderAccount < AeolusClient::Base + self.format = AeolusClient::ProviderAccountXMLFormat.new # FIXME: This should not be necessary when we update API to show full # representations in resource collections. def self.all_full_detail self.all.map! do |account| # getting a separate resource gives more details than collection - AeolusCli::Model::ProviderAccount.find(account.id) + AeolusClient::ProviderAccount.find(account.id) end end end diff --git a/lib/aeolus_client/provider_type.rb b/lib/aeolus_client/provider_type.rb new file mode 100644 index 0000000..59c8b82 --- /dev/null +++ b/lib/aeolus_client/provider_type.rb @@ -0,0 +1,11 @@ +class AeolusClient::ProviderTypeXMLFormat + include ActiveResource::Formats::XmlFormat + + def decode(xml) + ActiveResource::Formats::XmlFormat.decode(xml)['provider_type'] + end +end + +class AeolusClient::ProviderType < AeolusClient::Base + self.format = AeolusClient::ProviderTypeXMLFormat.new +end diff --git a/spec/config_spec.rb b/spec/config_spec.rb index 9f93712..92357f8 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -12,9 +12,9 @@ AeolusCli::Provider.start end it 'the configuration file should be loaded' do - AeolusCli::Model::Base.site.to_s.should == 'http://example.com:3013/api' - AeolusCli::Model::Base.user.to_s.should == 'master' - AeolusCli::Model::Base.password.to_s.should == 'ofuniverse' + AeolusClient::Base.site.to_s.should == 'http://example.com:3013/api' + AeolusClient::Base.user.to_s.should == 'master' + AeolusClient::Base.password.to_s.should == 'ofuniverse' ActiveResource::Base.logger.level.should == Logger::DEBUG end end @@ -24,7 +24,7 @@ AeolusCli::Provider.start(["--username", "override-user"]) end it 'the configuration file should be loaded' do - AeolusCli::Model::Base.user.to_s.should == 'override-user' + AeolusClient::Base.user.to_s.should == 'override-user' end end @@ -33,7 +33,7 @@ AeolusCli::Provider.start(["--password", "override-password"]) end it 'the configuration file should be loaded' do - AeolusCli::Model::Base.password.to_s.should == 'override-password' + AeolusClient::Base.password.to_s.should == 'override-password' end end @@ -43,7 +43,7 @@ "https://localhost/conductor/api"]) end it 'the configuration file should be loaded' do - AeolusCli::Model::Base.site.to_s.should == + AeolusClient::Base.site.to_s.should == 'https://localhost/conductor/api' end end From c501f73fa6fa3bab8bb35a9cc5dea32cb626ab56 Mon Sep 17 00:00:00 2001 From: Jiri Stransky Date: Fri, 1 Feb 2013 12:04:52 +0100 Subject: [PATCH 2/3] Move code and ensure proper requires General things concerning AeolusClient namespace are moved to aeolus_client.rb. Logging configuration that is done by requiring aeolus_client/base.rb is marked as FIXME for removal when configuration refactoring is done. Require aeolus_client/base.rb for resource classes that inherit from it. --- lib/aeolus_client.rb | 24 +++++++++++++++++++++ lib/aeolus_client/base.rb | 30 ++------------------------- lib/aeolus_client/provider.rb | 2 ++ lib/aeolus_client/provider_account.rb | 2 ++ lib/aeolus_client/provider_type.rb | 2 ++ 5 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 lib/aeolus_client.rb diff --git a/lib/aeolus_client.rb b/lib/aeolus_client.rb new file mode 100644 index 0000000..b85f150 --- /dev/null +++ b/lib/aeolus_client.rb @@ -0,0 +1,24 @@ +require 'active_resource' + +module AeolusClient +end + +module ActiveResource + class Errors < ActiveModel::Errors + # Grabs errors from an XML response. + def from_xml(xml, save_cache = false) + array = Array.wrap(Hash.from_xml(xml)['errors']['error']) + # The below is added because the default behaviour (the above + # line) only works fine if the error string is not buried in + # another layer of xml. + # + # from_array (in this Errors class) is brittle and will blow up + # if it doesn't get an array of strings. + if array.size >= 1 && array[0].is_a?(Hash) && + array[0].has_key?('message') + array.map! {|error| error['message']} + end + from_array array, save_cache + end + end +end diff --git a/lib/aeolus_client/base.rb b/lib/aeolus_client/base.rb index 681e934..f985cdf 100644 --- a/lib/aeolus_client/base.rb +++ b/lib/aeolus_client/base.rb @@ -1,36 +1,10 @@ -require 'active_resource' -require 'aeolus_cli' +require 'aeolus_client' require 'logger' +# FIXME: get rid of these when refactoring config loading: ActiveResource::Base.logger = Logger.new(STDOUT) ActiveResource::Base.logger.level = Logger::INFO -module ActiveResource - class Errors - # Grabs errors from an XML response. - def from_xml(xml, save_cache = false) - array = Array.wrap(Hash.from_xml(xml)['errors']['error']) - # The below is added because the default behaviour (the above - # line) only works fine if the error string is not buried in - # another layer of xml. - # - # from_array (in this Errors class) is brittle and will blow up - # if it doesn't get an array of strings. - if array.size >= 1 && array[0].is_a?(Hash) && - array[0].has_key?('message') - array.map! {|error| error['message']} - end - from_array array, save_cache - end - end -end - -# declaring the namespace but for style reasons not including the Base -# class definition within the block (saving as much excessive -# indentation as possible) -module AeolusClient -end - class AeolusClient::Base < ActiveResource::Base self.timeout = 600 self.format = :xml diff --git a/lib/aeolus_client/provider.rb b/lib/aeolus_client/provider.rb index f34ae44..0b1f5b8 100644 --- a/lib/aeolus_client/provider.rb +++ b/lib/aeolus_client/provider.rb @@ -1,3 +1,5 @@ +require 'aeolus_client/base' + class AeolusClient::ProviderXMLFormat include ActiveResource::Formats::XmlFormat diff --git a/lib/aeolus_client/provider_account.rb b/lib/aeolus_client/provider_account.rb index dca82d1..d5846f3 100644 --- a/lib/aeolus_client/provider_account.rb +++ b/lib/aeolus_client/provider_account.rb @@ -1,3 +1,5 @@ +require 'aeolus_client/base' + class AeolusClient::ProviderAccountXMLFormat include ActiveResource::Formats::XmlFormat diff --git a/lib/aeolus_client/provider_type.rb b/lib/aeolus_client/provider_type.rb index 59c8b82..c90f378 100644 --- a/lib/aeolus_client/provider_type.rb +++ b/lib/aeolus_client/provider_type.rb @@ -1,3 +1,5 @@ +require 'aeolus_client/base' + class AeolusClient::ProviderTypeXMLFormat include ActiveResource::Formats::XmlFormat From af1f29d76dcdd09d7b4d3b523dbaef2b5e6c13ed Mon Sep 17 00:00:00 2001 From: Jiri Stransky Date: Fri, 1 Feb 2013 14:15:42 +0100 Subject: [PATCH 3/3] Put CLI and Client under a common Aeolus module These module names were changed: AeolusCli -> Aeolus::Cli AeolusClient -> Aeolus::Client This scopes our code under common Aeolus module. To adhere to gem naming conventions in Ruby, the gem name was changed accordingly: aeolus_cli -> aeolus-cli Closes #20. --- Gemfile | 2 +- Gemfile.lock | 4 +-- aeolus_cli.gemspec => aeolus-cli.gemspec | 6 ++-- bin/aeolus | 4 +-- lib/aeolus/cli.rb | 15 +++++++++ lib/{aeolus_cli => aeolus/cli}/common_cli.rb | 32 +++++++++---------- lib/{aeolus_cli => aeolus/cli}/formatting.rb | 6 ++-- .../cli}/formatting/errors.rb | 2 +- .../cli}/formatting/format.rb | 6 ++-- .../cli}/formatting/human_format.rb | 14 ++++---- .../cli}/formatting/human_presenter_filter.rb | 2 +- .../cli}/formatting/machine_format.rb | 12 +++---- .../cli}/formatting/presenter.rb | 4 +-- .../cli}/formatting/presenter_sorter.rb | 2 +- .../formatting/provider_account_presenter.rb | 4 +-- .../cli}/formatting/provider_presenter.rb | 4 +-- lib/aeolus/cli/main.rb | 14 ++++++++ lib/{aeolus_cli => aeolus/cli}/provider.rb | 10 +++--- .../cli}/provider_account.rb | 12 +++---- lib/aeolus/cli/version.rb | 5 +++ lib/{aeolus_client.rb => aeolus/client.rb} | 5 ++- lib/{aeolus_client => aeolus/client}/base.rb | 4 +-- .../client}/provider.rb | 8 ++--- .../client}/provider_account.rb | 10 +++--- lib/aeolus/client/provider_type.rb | 13 ++++++++ lib/aeolus_cli.rb | 12 ------- lib/aeolus_cli/main.rb | 14 -------- lib/aeolus_cli/version.rb | 3 -- lib/aeolus_client/provider_type.rb | 13 -------- .../cli}/common_cli_spec.rb | 6 ++-- .../cli}/formatting/format_spec.rb | 10 +++--- .../cli}/formatting/human_format_spec.rb | 6 ++-- .../formatting/human_presenter_filter_spec.rb | 6 ++-- .../cli}/formatting/machine_format_spec.rb | 6 ++-- .../cli}/formatting/presenter_sorter_spec.rb | 6 ++-- .../cli}/formatting/presenter_spec.rb | 10 +++--- .../provider_account_presenter_spec.rb | 6 ++-- .../cli}/formatting_spec.rb | 8 ++--- spec/config_spec.rb | 22 ++++++------- 39 files changed, 168 insertions(+), 160 deletions(-) rename aeolus_cli.gemspec => aeolus-cli.gemspec (89%) create mode 100644 lib/aeolus/cli.rb rename lib/{aeolus_cli => aeolus/cli}/common_cli.rb (86%) rename lib/{aeolus_cli => aeolus/cli}/formatting.rb (80%) rename lib/{aeolus_cli => aeolus/cli}/formatting/errors.rb (94%) rename lib/{aeolus_cli => aeolus/cli}/formatting/format.rb (94%) rename lib/{aeolus_cli => aeolus/cli}/formatting/human_format.rb (74%) rename lib/{aeolus_cli => aeolus/cli}/formatting/human_presenter_filter.rb (95%) rename lib/{aeolus_cli => aeolus/cli}/formatting/machine_format.rb (68%) rename lib/{aeolus_cli => aeolus/cli}/formatting/presenter.rb (97%) rename lib/{aeolus_cli => aeolus/cli}/formatting/presenter_sorter.rb (97%) rename lib/{aeolus_cli => aeolus/cli}/formatting/provider_account_presenter.rb (89%) rename lib/{aeolus_cli => aeolus/cli}/formatting/provider_presenter.rb (78%) create mode 100644 lib/aeolus/cli/main.rb rename lib/{aeolus_cli => aeolus/cli}/provider.rb (84%) rename lib/{aeolus_cli => aeolus/cli}/provider_account.rb (84%) create mode 100644 lib/aeolus/cli/version.rb rename lib/{aeolus_client.rb => aeolus/client.rb} (94%) rename lib/{aeolus_client => aeolus/client}/base.rb (75%) rename lib/{aeolus_client => aeolus/client}/provider.rb (84%) rename lib/{aeolus_client => aeolus/client}/provider_account.rb (84%) create mode 100644 lib/aeolus/client/provider_type.rb delete mode 100644 lib/aeolus_cli.rb delete mode 100644 lib/aeolus_cli/main.rb delete mode 100644 lib/aeolus_cli/version.rb delete mode 100644 lib/aeolus_client/provider_type.rb rename spec/{aeolus_cli => aeolus/cli}/common_cli_spec.rb (90%) rename spec/{aeolus_cli => aeolus/cli}/formatting/format_spec.rb (88%) rename spec/{aeolus_cli => aeolus/cli}/formatting/human_format_spec.rb (89%) rename spec/{aeolus_cli => aeolus/cli}/formatting/human_presenter_filter_spec.rb (84%) rename spec/{aeolus_cli => aeolus/cli}/formatting/machine_format_spec.rb (84%) rename spec/{aeolus_cli => aeolus/cli}/formatting/presenter_sorter_spec.rb (82%) rename spec/{aeolus_cli => aeolus/cli}/formatting/presenter_spec.rb (92%) rename spec/{aeolus_cli => aeolus/cli}/formatting/provider_account_presenter_spec.rb (81%) rename spec/{aeolus_cli => aeolus/cli}/formatting_spec.rb (75%) diff --git a/Gemfile b/Gemfile index 150f524..a37aef3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in aeolus_cli.gemspec +# Specify your gem's dependencies in aeolus-cli.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 4076812..df9b7aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - aeolus_cli (0.0.2) + aeolus-cli (0.0.2) activeresource (~> 3.2.9) activesupport (~> 3.2.9) nokogiri (~> 1.5.5) @@ -54,7 +54,7 @@ PLATFORMS ruby DEPENDENCIES - aeolus_cli! + aeolus-cli! aruba cucumber rspec diff --git a/aeolus_cli.gemspec b/aeolus-cli.gemspec similarity index 89% rename from aeolus_cli.gemspec rename to aeolus-cli.gemspec index 9d61035..b79ee3a 100644 --- a/aeolus_cli.gemspec +++ b/aeolus-cli.gemspec @@ -1,11 +1,11 @@ # -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'aeolus_cli/version' +require 'aeolus/cli/version' Gem::Specification.new do |gem| - gem.name = "aeolus_cli" - gem.version = AeolusCli::VERSION + gem.name = "aeolus-cli" + gem.version = Aeolus::Cli::VERSION gem.authors = "Crag Wolfe" gem.email = "cwolfe@redhat.com" gem.description = %q{Command-line interface to aeolus} diff --git a/bin/aeolus b/bin/aeolus index 6cf9980..9596bcb 100755 --- a/bin/aeolus +++ b/bin/aeolus @@ -1,9 +1,9 @@ #!/usr/bin/env ruby -require 'aeolus_cli/main' +require 'aeolus/cli/main' begin - AeolusCli::Main.start + Aeolus::Cli::Main.start rescue Exception => ex if $aeolus_cli_supress_trace_message exit 1 diff --git a/lib/aeolus/cli.rb b/lib/aeolus/cli.rb new file mode 100644 index 0000000..c044baa --- /dev/null +++ b/lib/aeolus/cli.rb @@ -0,0 +1,15 @@ +module Aeolus +end + +module Aeolus::Cli +end + +class Aeolus::Cli::Error < StandardError + attr_reader :message + + def initialize(message) + @message = message + end +end + +class Aeolus::Cli::ConfigError < Aeolus::Cli::Error; end diff --git a/lib/aeolus_cli/common_cli.rb b/lib/aeolus/cli/common_cli.rb similarity index 86% rename from lib/aeolus_cli/common_cli.rb rename to lib/aeolus/cli/common_cli.rb index 46a0d3e..c492b05 100644 --- a/lib/aeolus_cli/common_cli.rb +++ b/lib/aeolus/cli/common_cli.rb @@ -1,10 +1,10 @@ require 'active_resource' require 'thor' -require 'aeolus_cli/formatting' -require 'aeolus_client/base' -require 'aeolus_client/provider_type' +require 'aeolus/cli/formatting' +require 'aeolus/client/base' +require 'aeolus/client/provider_type' -class AeolusCli::CommonCli < Thor +class Aeolus::Cli::CommonCli < Thor class_option :conductor_url, :type => :string class_option :username, :type => :string class_option :password, :type => :string @@ -74,7 +74,7 @@ def load_aeolus_config(options) if ENV.has_key?("AEOLUS_CLI_CONF") config_fname = ENV["AEOLUS_CLI_CONF"] if !is_file?(config_fname) - raise AeolusCli::ConfigError.new( + raise Aeolus::Cli::ConfigError.new( "environment variable AEOLUS_CLI_CONF with value "+ "'#{ ENV['AEOLUS_CLI_CONF']}' does not point to an existing file") end @@ -92,15 +92,15 @@ def load_aeolus_config(options) @config = YAML::load(File.open(File.expand_path(config_fname))) if @config.has_key?(:conductor) [:url, :password, :username].each do |key| - raise AeolusCli::ConfigError.new \ + raise Aeolus::Cli::ConfigError.new \ ("Error in configuration file: #{key} is missing" ) unless @config[:conductor].has_key?(key) end - AeolusClient::Base.site = @config[:conductor][:url] - AeolusClient::Base.user = @config[:conductor][:username] - AeolusClient::Base.password = @config[:conductor][:password] + Aeolus::Client::Base.site = @config[:conductor][:url] + Aeolus::Client::Base.user = @config[:conductor][:username] + Aeolus::Client::Base.password = @config[:conductor][:password] else - raise AeolusCli::ConfigError.new("Error in configuration file") + raise Aeolus::Cli::ConfigError.new("Error in configuration file") end if @config.has_key?(:logging) if @config[:logging].has_key?(:logfile) @@ -116,7 +116,7 @@ def load_aeolus_config(options) if @config[:logging].has_key?(:level) log_level = @config[:logging][:level] if ! ['DEBUG','WARN','INFO','ERROR','FATAL'].include?(log_level) - raise AeolusCli::ConfigError.new \ + raise Aeolus::Cli::ConfigError.new \ ("log level specified in configuration #{log_level}, is not valid."+ ". shoud be one of DEBUG, WARN, INFO, ERROR or FATAL") else @@ -127,19 +127,19 @@ def load_aeolus_config(options) end # allow overrides from command line if options[:conductor_url] - AeolusClient::Base.site = options[:conductor_url] + Aeolus::Client::Base.site = options[:conductor_url] end if options[:username] - AeolusClient::Base.user = options[:username] + Aeolus::Client::Base.user = options[:username] end if options[:password] - AeolusClient::Base.password = options[:password] + Aeolus::Client::Base.password = options[:password] end end # Set output format (human vs. machine) def set_output_format(options) - @output_format = AeolusCli::Formatting.create_format(shell, options) + @output_format = Aeolus::Cli::Formatting.create_format(shell, options) end # Transforms e.g. 'name,status' into [:name, :status] @@ -179,7 +179,7 @@ def provider_type(type_s) def provider_type_hash deltacloud_driver_to_provider_type = Hash.new - provider_types = AeolusClient::ProviderType.all + provider_types = Aeolus::Client::ProviderType.all if provider_types.size == 0 raise "Retrieved zero provider types from Conductor" end diff --git a/lib/aeolus_cli/formatting.rb b/lib/aeolus/cli/formatting.rb similarity index 80% rename from lib/aeolus_cli/formatting.rb rename to lib/aeolus/cli/formatting.rb index f73710a..f03d788 100644 --- a/lib/aeolus_cli/formatting.rb +++ b/lib/aeolus/cli/formatting.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/errors' +require 'aeolus/cli/formatting/errors' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting class << self def create_format(shell, options) format_name = options[:format] || default_format @@ -17,7 +17,7 @@ def default_format def load_format_class(format_name) class_name = format_name.gsub(/^(.)/) { |first_letter| first_letter.upcase } + "Format" begin - require "aeolus_cli/formatting/#{format_name}_format" + require "aeolus/cli/formatting/#{format_name}_format" const_get(class_name) rescue LoadError, NameError raise UnknownFormatError.new(format_name) diff --git a/lib/aeolus_cli/formatting/errors.rb b/lib/aeolus/cli/formatting/errors.rb similarity index 94% rename from lib/aeolus_cli/formatting/errors.rb rename to lib/aeolus/cli/formatting/errors.rb index 51a7d7d..39ffb62 100644 --- a/lib/aeolus_cli/formatting/errors.rb +++ b/lib/aeolus/cli/formatting/errors.rb @@ -1,4 +1,4 @@ -module AeolusCli::Formatting +module Aeolus::Cli::Formatting class PresenterMissingError < StandardError def initialize(format, object) super("Presenter not defined for #{object.class.name} in #{format.to_s}") diff --git a/lib/aeolus_cli/formatting/format.rb b/lib/aeolus/cli/formatting/format.rb similarity index 94% rename from lib/aeolus_cli/formatting/format.rb rename to lib/aeolus/cli/formatting/format.rb index 1e587a5..607329c 100644 --- a/lib/aeolus_cli/formatting/format.rb +++ b/lib/aeolus/cli/formatting/format.rb @@ -1,7 +1,7 @@ -require 'aeolus_cli/formatting/errors' -require 'aeolus_cli/formatting/presenter_sorter' +require 'aeolus/cli/formatting/errors' +require 'aeolus/cli/formatting/presenter_sorter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # This class (or more precisely, classes that inherit from this one) can # format various objects for printing. Formatting is done via presenters. # Presenter classes can be registered with the Format to indicate which diff --git a/lib/aeolus_cli/formatting/human_format.rb b/lib/aeolus/cli/formatting/human_format.rb similarity index 74% rename from lib/aeolus_cli/formatting/human_format.rb rename to lib/aeolus/cli/formatting/human_format.rb index ff80c3c..4ef2a2c 100644 --- a/lib/aeolus_cli/formatting/human_format.rb +++ b/lib/aeolus/cli/formatting/human_format.rb @@ -1,16 +1,16 @@ -require 'aeolus_cli/formatting/format' -require 'aeolus_cli/formatting/human_presenter_filter' -require 'aeolus_cli/formatting/provider_presenter' -require 'aeolus_cli/formatting/provider_account_presenter' +require 'aeolus/cli/formatting/format' +require 'aeolus/cli/formatting/human_presenter_filter' +require 'aeolus/cli/formatting/provider_presenter' +require 'aeolus/cli/formatting/provider_account_presenter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Format that prints objects in a human-friendly way. class HumanFormat < Format def initialize(shell) super(shell) - register("AeolusClient::Provider", ProviderPresenter) - register("AeolusClient::ProviderAccount", ProviderAccountPresenter) + register("Aeolus::Client::Provider", ProviderPresenter) + register("Aeolus::Client::ProviderAccount", ProviderAccountPresenter) end def detail(object, fields_override = nil) diff --git a/lib/aeolus_cli/formatting/human_presenter_filter.rb b/lib/aeolus/cli/formatting/human_presenter_filter.rb similarity index 95% rename from lib/aeolus_cli/formatting/human_presenter_filter.rb rename to lib/aeolus/cli/formatting/human_presenter_filter.rb index e1604ef..6cfd624 100644 --- a/lib/aeolus_cli/formatting/human_presenter_filter.rb +++ b/lib/aeolus/cli/formatting/human_presenter_filter.rb @@ -1,6 +1,6 @@ require 'delegate' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Wrapper for presenters that alters/adds behavior for # more human-friendly output. class HumanPresenterFilter < SimpleDelegator diff --git a/lib/aeolus_cli/formatting/machine_format.rb b/lib/aeolus/cli/formatting/machine_format.rb similarity index 68% rename from lib/aeolus_cli/formatting/machine_format.rb rename to lib/aeolus/cli/formatting/machine_format.rb index 987248d..1d6ace9 100644 --- a/lib/aeolus_cli/formatting/machine_format.rb +++ b/lib/aeolus/cli/formatting/machine_format.rb @@ -1,16 +1,16 @@ -require 'aeolus_cli/formatting/format' -require 'aeolus_cli/formatting/provider_presenter' -require 'aeolus_cli/formatting/provider_account_presenter' +require 'aeolus/cli/formatting/format' +require 'aeolus/cli/formatting/provider_presenter' +require 'aeolus/cli/formatting/provider_account_presenter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Format that prints objects in a machine-friendly way. class MachineFormat < Format def initialize(shell, separator = "\t") super(shell) @separator = separator - register("AeolusClient::Provider", ProviderPresenter) - register("AeolusClient::ProviderAccount", ProviderAccountPresenter) + register("Aeolus::Client::Provider", ProviderPresenter) + register("Aeolus::Client::ProviderAccount", ProviderAccountPresenter) end def detail(object, fields_override = nil) diff --git a/lib/aeolus_cli/formatting/presenter.rb b/lib/aeolus/cli/formatting/presenter.rb similarity index 97% rename from lib/aeolus_cli/formatting/presenter.rb rename to lib/aeolus/cli/formatting/presenter.rb index 8a32bdd..979c995 100644 --- a/lib/aeolus_cli/formatting/presenter.rb +++ b/lib/aeolus/cli/formatting/presenter.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/errors' +require 'aeolus/cli/formatting/errors' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Presenter class formats a single object for output. The generic Presenter # produces sort of machine-friendly output. class Presenter diff --git a/lib/aeolus_cli/formatting/presenter_sorter.rb b/lib/aeolus/cli/formatting/presenter_sorter.rb similarity index 97% rename from lib/aeolus_cli/formatting/presenter_sorter.rb rename to lib/aeolus/cli/formatting/presenter_sorter.rb index 1369371..0489151 100644 --- a/lib/aeolus_cli/formatting/presenter_sorter.rb +++ b/lib/aeolus/cli/formatting/presenter_sorter.rb @@ -1,4 +1,4 @@ -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Sorts array of Presenter objects by their field values. class PresenterSorter # Parameter sort_by is expected like e.g. [[:status, :desc], [:name, :asc]], diff --git a/lib/aeolus_cli/formatting/provider_account_presenter.rb b/lib/aeolus/cli/formatting/provider_account_presenter.rb similarity index 89% rename from lib/aeolus_cli/formatting/provider_account_presenter.rb rename to lib/aeolus/cli/formatting/provider_account_presenter.rb index 7dcdf1a..d28751d 100644 --- a/lib/aeolus_cli/formatting/provider_account_presenter.rb +++ b/lib/aeolus/cli/formatting/provider_account_presenter.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/presenter' +require 'aeolus/cli/formatting/presenter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting class ProviderAccountPresenter < Presenter default_list_item_fields(:name, :provider, :username, :quota) default_detail_fields(:name, :provider, :username, :quota) diff --git a/lib/aeolus_cli/formatting/provider_presenter.rb b/lib/aeolus/cli/formatting/provider_presenter.rb similarity index 78% rename from lib/aeolus_cli/formatting/provider_presenter.rb rename to lib/aeolus/cli/formatting/provider_presenter.rb index 89ab218..9798c4f 100644 --- a/lib/aeolus_cli/formatting/provider_presenter.rb +++ b/lib/aeolus/cli/formatting/provider_presenter.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/presenter' +require 'aeolus/cli/formatting/presenter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting class ProviderPresenter < Presenter default_list_item_fields(:name, :provider_type, :deltacloud_provider, :deltacloud_url) default_detail_fields(:id, :name, :provider_type, :deltacloud_provider, :deltacloud_url) diff --git a/lib/aeolus/cli/main.rb b/lib/aeolus/cli/main.rb new file mode 100644 index 0000000..02799c1 --- /dev/null +++ b/lib/aeolus/cli/main.rb @@ -0,0 +1,14 @@ +require 'aeolus/cli' +require 'thor' +require 'aeolus/cli/provider' +require 'aeolus/cli/provider_account' + +class Aeolus::Cli::Main < Thor + + desc 'provider', 'show provider subcommands' + subcommand 'provider', Aeolus::Cli::Provider + + desc 'provider_account', 'show provider account subcommands' + subcommand 'provider_account', Aeolus::Cli::ProviderAccount + +end diff --git a/lib/aeolus_cli/provider.rb b/lib/aeolus/cli/provider.rb similarity index 84% rename from lib/aeolus_cli/provider.rb rename to lib/aeolus/cli/provider.rb index 56dd116..82a2f9b 100644 --- a/lib/aeolus_cli/provider.rb +++ b/lib/aeolus/cli/provider.rb @@ -1,12 +1,12 @@ -require 'aeolus_cli/common_cli' -require 'aeolus_client/provider' +require 'aeolus/cli/common_cli' +require 'aeolus/client/provider' -class AeolusCli::Provider < AeolusCli::CommonCli +class Aeolus::Cli::Provider < Aeolus::Cli::CommonCli desc "list", "List all providers" method_options_for_resource_list def list - providers = AeolusClient::Provider.all + providers = Aeolus::Client::Provider.all output_format.list(providers, resource_fields(options[:fields]), resource_sort_by(options[:sort_by])) @@ -19,7 +19,7 @@ def list method_option :deltacloud_provider, :type => :string def add(provider_name) # TODO: validation on provider_type (make sure exists) - p = AeolusClient::Provider.new(:name => provider_name, + p = Aeolus::Client::Provider.new(:name => provider_name, :url => options[:deltacloud_url], :provider_type => provider_type(options[:provider_type]), :deltacloud_provider => options[:deltacloud_provider]) diff --git a/lib/aeolus_cli/provider_account.rb b/lib/aeolus/cli/provider_account.rb similarity index 84% rename from lib/aeolus_cli/provider_account.rb rename to lib/aeolus/cli/provider_account.rb index e36b547..af0737b 100644 --- a/lib/aeolus_cli/provider_account.rb +++ b/lib/aeolus/cli/provider_account.rb @@ -1,13 +1,13 @@ -require 'aeolus_cli/common_cli' -require 'aeolus_client/provider_account' +require 'aeolus/cli/common_cli' +require 'aeolus/client/provider_account' -class AeolusCli::ProviderAccount < AeolusCli::CommonCli +class Aeolus::Cli::ProviderAccount < Aeolus::Cli::CommonCli desc "list", "list provider accounts" method_options_for_resource_list # TODO maybe an optional variable for provider_type def list - accounts = AeolusClient::ProviderAccount.all_full_detail + accounts = Aeolus::Client::ProviderAccount.all_full_detail output_format.list(accounts, resource_fields(options[:fields]), resource_sort_by(options[:sort_by])) @@ -22,13 +22,13 @@ def list :default => "unlimited", :desc => "maximum running instances" def add(label) credentials = credentials_from_file(options[:credentials_file]) - provider = AeolusClient::Provider.all.find {|p| p.name == options[:provider_name]} + provider = Aeolus::Client::Provider.all.find {|p| p.name == options[:provider_name]} unless provider self.shell.say "ERROR: The provider '#{options[:provider_name]}' does not exist" exit(1) end - pa = AeolusClient::ProviderAccount.new( + pa = Aeolus::Client::ProviderAccount.new( :label => label, :provider => {:id => provider.id}, :credentials => credentials, diff --git a/lib/aeolus/cli/version.rb b/lib/aeolus/cli/version.rb new file mode 100644 index 0000000..b93a5a7 --- /dev/null +++ b/lib/aeolus/cli/version.rb @@ -0,0 +1,5 @@ +module Aeolus + module Cli + VERSION = "0.0.2" + end +end diff --git a/lib/aeolus_client.rb b/lib/aeolus/client.rb similarity index 94% rename from lib/aeolus_client.rb rename to lib/aeolus/client.rb index b85f150..f649d99 100644 --- a/lib/aeolus_client.rb +++ b/lib/aeolus/client.rb @@ -1,6 +1,9 @@ require 'active_resource' -module AeolusClient +module Aeolus +end + +module Aeolus::Client end module ActiveResource diff --git a/lib/aeolus_client/base.rb b/lib/aeolus/client/base.rb similarity index 75% rename from lib/aeolus_client/base.rb rename to lib/aeolus/client/base.rb index f985cdf..09c0c22 100644 --- a/lib/aeolus_client/base.rb +++ b/lib/aeolus/client/base.rb @@ -1,11 +1,11 @@ -require 'aeolus_client' +require 'aeolus/client' require 'logger' # FIXME: get rid of these when refactoring config loading: ActiveResource::Base.logger = Logger.new(STDOUT) ActiveResource::Base.logger.level = Logger::INFO -class AeolusClient::Base < ActiveResource::Base +class Aeolus::Client::Base < ActiveResource::Base self.timeout = 600 self.format = :xml end diff --git a/lib/aeolus_client/provider.rb b/lib/aeolus/client/provider.rb similarity index 84% rename from lib/aeolus_client/provider.rb rename to lib/aeolus/client/provider.rb index 0b1f5b8..c70fbc3 100644 --- a/lib/aeolus_client/provider.rb +++ b/lib/aeolus/client/provider.rb @@ -1,6 +1,6 @@ -require 'aeolus_client/base' +require 'aeolus/client/base' -class AeolusClient::ProviderXMLFormat +class Aeolus::Client::ProviderXMLFormat include ActiveResource::Formats::XmlFormat def decode(xml) @@ -31,6 +31,6 @@ def decode(xml) end end -class AeolusClient::Provider < AeolusClient::Base - self.format = AeolusClient::ProviderXMLFormat.new +class Aeolus::Client::Provider < Aeolus::Client::Base + self.format = Aeolus::Client::ProviderXMLFormat.new end diff --git a/lib/aeolus_client/provider_account.rb b/lib/aeolus/client/provider_account.rb similarity index 84% rename from lib/aeolus_client/provider_account.rb rename to lib/aeolus/client/provider_account.rb index d5846f3..5f545eb 100644 --- a/lib/aeolus_client/provider_account.rb +++ b/lib/aeolus/client/provider_account.rb @@ -1,6 +1,6 @@ -require 'aeolus_client/base' +require 'aeolus/client/base' -class AeolusClient::ProviderAccountXMLFormat +class Aeolus::Client::ProviderAccountXMLFormat include ActiveResource::Formats::XmlFormat def decode(xml) @@ -34,15 +34,15 @@ def decode(xml) end end -class AeolusClient::ProviderAccount < AeolusClient::Base - self.format = AeolusClient::ProviderAccountXMLFormat.new +class Aeolus::Client::ProviderAccount < Aeolus::Client::Base + self.format = Aeolus::Client::ProviderAccountXMLFormat.new # FIXME: This should not be necessary when we update API to show full # representations in resource collections. def self.all_full_detail self.all.map! do |account| # getting a separate resource gives more details than collection - AeolusClient::ProviderAccount.find(account.id) + Aeolus::Client::ProviderAccount.find(account.id) end end end diff --git a/lib/aeolus/client/provider_type.rb b/lib/aeolus/client/provider_type.rb new file mode 100644 index 0000000..4943384 --- /dev/null +++ b/lib/aeolus/client/provider_type.rb @@ -0,0 +1,13 @@ +require 'aeolus/client/base' + +class Aeolus::Client::ProviderTypeXMLFormat + include ActiveResource::Formats::XmlFormat + + def decode(xml) + ActiveResource::Formats::XmlFormat.decode(xml)['provider_type'] + end +end + +class Aeolus::Client::ProviderType < Aeolus::Client::Base + self.format = Aeolus::Client::ProviderTypeXMLFormat.new +end diff --git a/lib/aeolus_cli.rb b/lib/aeolus_cli.rb deleted file mode 100644 index f2c9c03..0000000 --- a/lib/aeolus_cli.rb +++ /dev/null @@ -1,12 +0,0 @@ -module AeolusCli -end - -class AeolusCli::Error < StandardError - attr_reader :message - - def initialize(message) - @message = message - end -end - -class AeolusCli::ConfigError < AeolusCli::Error; end diff --git a/lib/aeolus_cli/main.rb b/lib/aeolus_cli/main.rb deleted file mode 100644 index eb9221a..0000000 --- a/lib/aeolus_cli/main.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'aeolus_cli' -require 'thor' -require 'aeolus_cli/provider' -require 'aeolus_cli/provider_account' - -class AeolusCli::Main < Thor - - desc 'provider', 'show provider subcommands' - subcommand 'provider', AeolusCli::Provider - - desc 'provider_account', 'show provider account subcommands' - subcommand 'provider_account', AeolusCli::ProviderAccount - -end diff --git a/lib/aeolus_cli/version.rb b/lib/aeolus_cli/version.rb deleted file mode 100644 index 770ea7c..0000000 --- a/lib/aeolus_cli/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module AeolusCli - VERSION = "0.0.2" -end diff --git a/lib/aeolus_client/provider_type.rb b/lib/aeolus_client/provider_type.rb deleted file mode 100644 index c90f378..0000000 --- a/lib/aeolus_client/provider_type.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'aeolus_client/base' - -class AeolusClient::ProviderTypeXMLFormat - include ActiveResource::Formats::XmlFormat - - def decode(xml) - ActiveResource::Formats::XmlFormat.decode(xml)['provider_type'] - end -end - -class AeolusClient::ProviderType < AeolusClient::Base - self.format = AeolusClient::ProviderTypeXMLFormat.new -end diff --git a/spec/aeolus_cli/common_cli_spec.rb b/spec/aeolus/cli/common_cli_spec.rb similarity index 90% rename from spec/aeolus_cli/common_cli_spec.rb rename to spec/aeolus/cli/common_cli_spec.rb index 091f9ed..c6e2bec 100644 --- a/spec/aeolus_cli/common_cli_spec.rb +++ b/spec/aeolus/cli/common_cli_spec.rb @@ -1,7 +1,7 @@ -require 'aeolus_cli/common_cli' +require 'aeolus/cli/common_cli' -describe AeolusCli::CommonCli do - let(:common_cli) { AeolusCli::CommonCli.new() } +describe Aeolus::Cli::CommonCli do + let(:common_cli) { Aeolus::Cli::CommonCli.new() } context "#resource_fields" do context "non-empty fields" do diff --git a/spec/aeolus_cli/formatting/format_spec.rb b/spec/aeolus/cli/formatting/format_spec.rb similarity index 88% rename from spec/aeolus_cli/formatting/format_spec.rb rename to spec/aeolus/cli/formatting/format_spec.rb index 2c4bf5a..126d85b 100644 --- a/spec/aeolus_cli/formatting/format_spec.rb +++ b/spec/aeolus/cli/formatting/format_spec.rb @@ -1,9 +1,9 @@ -require 'aeolus_cli/formatting/format' +require 'aeolus/cli/formatting/format' -describe AeolusCli::Formatting::Format do +describe Aeolus::Cli::Formatting::Format do let(:shell) { double('shell') } - let(:format) { AeolusCli::Formatting::Format.new(shell) } + let(:format) { Aeolus::Cli::Formatting::Format.new(shell) } context "with a presenter" do let(:presenter) { double('presenter') } @@ -18,7 +18,7 @@ it do expect { subject } - .to raise_error AeolusCli::Formatting::PresenterMissingError + .to raise_error Aeolus::Cli::Formatting::PresenterMissingError end end @@ -37,7 +37,7 @@ let(:sorted_presenters) { double('sorted_presenters') } let(:sorter) { double('sorter', :sorted_presenters => sorted_presenters) } before do - AeolusCli::Formatting::PresenterSorter + Aeolus::Cli::Formatting::PresenterSorter .should_receive(:new) .with([presenter, presenter], [:name, :asc]) .and_return(sorter) diff --git a/spec/aeolus_cli/formatting/human_format_spec.rb b/spec/aeolus/cli/formatting/human_format_spec.rb similarity index 89% rename from spec/aeolus_cli/formatting/human_format_spec.rb rename to spec/aeolus/cli/formatting/human_format_spec.rb index cb8ed9d..0657ce1 100644 --- a/spec/aeolus_cli/formatting/human_format_spec.rb +++ b/spec/aeolus/cli/formatting/human_format_spec.rb @@ -1,9 +1,9 @@ -require 'aeolus_cli/formatting/human_format' +require 'aeolus/cli/formatting/human_format' -describe AeolusCli::Formatting::HumanFormat do +describe Aeolus::Cli::Formatting::HumanFormat do let(:shell) { double('shell') } - let(:format) { AeolusCli::Formatting::HumanFormat.new(shell) } + let(:format) { Aeolus::Cli::Formatting::HumanFormat.new(shell) } context "printing a detail" do before do diff --git a/spec/aeolus_cli/formatting/human_presenter_filter_spec.rb b/spec/aeolus/cli/formatting/human_presenter_filter_spec.rb similarity index 84% rename from spec/aeolus_cli/formatting/human_presenter_filter_spec.rb rename to spec/aeolus/cli/formatting/human_presenter_filter_spec.rb index 123c603..bce8451 100644 --- a/spec/aeolus_cli/formatting/human_presenter_filter_spec.rb +++ b/spec/aeolus/cli/formatting/human_presenter_filter_spec.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/human_presenter_filter' +require 'aeolus/cli/formatting/human_presenter_filter' -describe AeolusCli::Formatting::HumanPresenterFilter do +describe Aeolus::Cli::Formatting::HumanPresenterFilter do let(:presenter) do bare_presenter = double('bare presenter') bare_presenter.stub('detail') @@ -13,7 +13,7 @@ .and_return(['Joe the Virtual Machine', 'true']) bare_presenter.stub('list_item_fields') .and_return(['name', 'is_cool']) - AeolusCli::Formatting::HumanPresenterFilter.new(bare_presenter) + Aeolus::Cli::Formatting::HumanPresenterFilter.new(bare_presenter) end context "detail" do diff --git a/spec/aeolus_cli/formatting/machine_format_spec.rb b/spec/aeolus/cli/formatting/machine_format_spec.rb similarity index 84% rename from spec/aeolus_cli/formatting/machine_format_spec.rb rename to spec/aeolus/cli/formatting/machine_format_spec.rb index f538d56..7c1d80a 100644 --- a/spec/aeolus_cli/formatting/machine_format_spec.rb +++ b/spec/aeolus/cli/formatting/machine_format_spec.rb @@ -1,9 +1,9 @@ -require 'aeolus_cli/formatting/machine_format' +require 'aeolus/cli/formatting/machine_format' -describe AeolusCli::Formatting::MachineFormat do +describe Aeolus::Cli::Formatting::MachineFormat do let(:shell) { double('shell') } - let(:format) { AeolusCli::Formatting::MachineFormat.new(shell, ';') } + let(:format) { Aeolus::Cli::Formatting::MachineFormat.new(shell, ';') } context "printing a detail" do before do diff --git a/spec/aeolus_cli/formatting/presenter_sorter_spec.rb b/spec/aeolus/cli/formatting/presenter_sorter_spec.rb similarity index 82% rename from spec/aeolus_cli/formatting/presenter_sorter_spec.rb rename to spec/aeolus/cli/formatting/presenter_sorter_spec.rb index 1924df2..b5c187c 100644 --- a/spec/aeolus_cli/formatting/presenter_sorter_spec.rb +++ b/spec/aeolus/cli/formatting/presenter_sorter_spec.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/presenter_sorter' +require 'aeolus/cli/formatting/presenter_sorter' -describe AeolusCli::Formatting::PresenterSorter do +describe Aeolus::Cli::Formatting::PresenterSorter do def stub_fields(presenter, status, owner) presenter.stub(:field) do |param| @@ -23,7 +23,7 @@ def stub_fields(presenter, status, owner) let(:presenters) { [p4, p1, p3, p2] } let(:sorted_presenters) { [p1, p2, p3, p4] } let(:sort_by) { [[:status, :desc], [:owner, :asc]] } - let(:sorter) { AeolusCli::Formatting::PresenterSorter.new(presenters, sort_by) } + let(:sorter) { Aeolus::Cli::Formatting::PresenterSorter.new(presenters, sort_by) } context "#sorted_data" do subject { sorter.sorted_presenters } diff --git a/spec/aeolus_cli/formatting/presenter_spec.rb b/spec/aeolus/cli/formatting/presenter_spec.rb similarity index 92% rename from spec/aeolus_cli/formatting/presenter_spec.rb rename to spec/aeolus/cli/formatting/presenter_spec.rb index bdc12ac..c4113e0 100644 --- a/spec/aeolus_cli/formatting/presenter_spec.rb +++ b/spec/aeolus/cli/formatting/presenter_spec.rb @@ -1,8 +1,8 @@ -require 'aeolus_cli/formatting/presenter' +require 'aeolus/cli/formatting/presenter' -describe AeolusCli::Formatting::Presenter do +describe Aeolus::Cli::Formatting::Presenter do let(:presenter_class) do - Class.new(AeolusCli::Formatting::Presenter) do + Class.new(Aeolus::Cli::Formatting::Presenter) do default_detail_fields(:name, :status, :is_cool) default_list_item_fields(:name, :is_cool) end @@ -49,7 +49,7 @@ subject { presenter.field(:old_field) } it do expect { subject } - .to raise_error AeolusCli::Formatting::UnknownFieldError + .to raise_error Aeolus::Cli::Formatting::UnknownFieldError end end end @@ -76,7 +76,7 @@ subject { presenter.field(:some_unknown_field) } it do expect { subject } - .to raise_error AeolusCli::Formatting::UnknownFieldError + .to raise_error Aeolus::Cli::Formatting::UnknownFieldError end end diff --git a/spec/aeolus_cli/formatting/provider_account_presenter_spec.rb b/spec/aeolus/cli/formatting/provider_account_presenter_spec.rb similarity index 81% rename from spec/aeolus_cli/formatting/provider_account_presenter_spec.rb rename to spec/aeolus/cli/formatting/provider_account_presenter_spec.rb index c69e5db..64650fd 100644 --- a/spec/aeolus_cli/formatting/provider_account_presenter_spec.rb +++ b/spec/aeolus/cli/formatting/provider_account_presenter_spec.rb @@ -1,7 +1,7 @@ -require 'aeolus_cli/formatting/presenter' +require 'aeolus/cli/formatting/presenter' -describe AeolusCli::Formatting::ProviderAccountPresenter do - let(:presenter) { AeolusCli::Formatting::ProviderAccountPresenter.new(presented_object) } +describe Aeolus::Cli::Formatting::ProviderAccountPresenter do + let(:presenter) { Aeolus::Cli::Formatting::ProviderAccountPresenter.new(presented_object) } context "with full resource details" do let(:presented_object) do diff --git a/spec/aeolus_cli/formatting_spec.rb b/spec/aeolus/cli/formatting_spec.rb similarity index 75% rename from spec/aeolus_cli/formatting_spec.rb rename to spec/aeolus/cli/formatting_spec.rb index 3ca97cc..305863f 100644 --- a/spec/aeolus_cli/formatting_spec.rb +++ b/spec/aeolus/cli/formatting_spec.rb @@ -1,7 +1,7 @@ -require 'aeolus_cli/formatting' +require 'aeolus/cli/formatting' -describe AeolusCli::Formatting do - let(:formatting) { AeolusCli::Formatting } +describe Aeolus::Cli::Formatting do + let(:formatting) { Aeolus::Cli::Formatting } let(:shell) { double('shell') } context ".create_format" do @@ -14,7 +14,7 @@ end before do - formatting.should_receive(:require).with("aeolus_cli/formatting/human_format").and_return(true) + formatting.should_receive(:require).with("aeolus/cli/formatting/human_format").and_return(true) formatting.should_receive(:const_get).with("HumanFormat").and_return(human_format_class) end diff --git a/spec/config_spec.rb b/spec/config_spec.rb index 92357f8..8ec9791 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -1,4 +1,4 @@ -require 'aeolus_cli/main' +require 'aeolus/cli/main' describe "loading configuration-file by environment variable" do @@ -9,41 +9,41 @@ describe 'with no command line overrides' do before do - AeolusCli::Provider.start + Aeolus::Cli::Provider.start end it 'the configuration file should be loaded' do - AeolusClient::Base.site.to_s.should == 'http://example.com:3013/api' - AeolusClient::Base.user.to_s.should == 'master' - AeolusClient::Base.password.to_s.should == 'ofuniverse' + Aeolus::Client::Base.site.to_s.should == 'http://example.com:3013/api' + Aeolus::Client::Base.user.to_s.should == 'master' + Aeolus::Client::Base.password.to_s.should == 'ofuniverse' ActiveResource::Base.logger.level.should == Logger::DEBUG end end describe 'with --username override' do before do - AeolusCli::Provider.start(["--username", "override-user"]) + Aeolus::Cli::Provider.start(["--username", "override-user"]) end it 'the configuration file should be loaded' do - AeolusClient::Base.user.to_s.should == 'override-user' + Aeolus::Client::Base.user.to_s.should == 'override-user' end end describe 'with --password override' do before do - AeolusCli::Provider.start(["--password", "override-password"]) + Aeolus::Cli::Provider.start(["--password", "override-password"]) end it 'the configuration file should be loaded' do - AeolusClient::Base.password.to_s.should == 'override-password' + Aeolus::Client::Base.password.to_s.should == 'override-password' end end describe 'with --conductor-url override' do before do - AeolusCli::Provider.start(["--conductor-url", + Aeolus::Cli::Provider.start(["--conductor-url", "https://localhost/conductor/api"]) end it 'the configuration file should be loaded' do - AeolusClient::Base.site.to_s.should == + Aeolus::Client::Base.site.to_s.should == 'https://localhost/conductor/api' end end