Permalink
Browse files

added region to the presenter which allows it to be displayed in the …

…report
  • Loading branch information...
1 parent 2e3b1bf commit 556fb98e97cabf99513b9a8cd780b4017091d60a @wbailey committed May 27, 2012
Showing with 19 additions and 4 deletions.
  1. +1 −1 lib/claws/collection/ec2.rb
  2. +7 −2 lib/claws/presenter/ec2.rb
  3. BIN pkg/claws-1.1.0.gem
  4. +11 −1 spec/presenter/ec2_spec.rb
@@ -14,7 +14,7 @@ def get(filters = {})
end
region.instances.each do |instance|
- collection << Claws::EC2::Presenter.new(instance)
+ collection << Claws::EC2::Presenter.new(instance, :region => region.name)
end
end
@@ -6,12 +6,17 @@ module EC2
class Presenter
attr_writer :roles
- def initialize(instance, has_roles = [])
+ def initialize(instance, options = {})
@ec2 = instance.extend(Claws::Support)
- @roles = has_roles
+ @roles = options[:roles] || []
+ @region = options[:region]
freeze
end
+ def region
+ @region || 'N/A'
+ end
+
def roles
@roles.empty? ? 'N/A' : @roles.join(', ')
end
View
Binary file not shown.
View
@@ -28,7 +28,7 @@
cap = double('Claws::Capistrano')
cap.stub(:roles).with(host).and_return(%w{app web})
- @full_presenter = subject.new(full_instance, cap.roles(full_instance.public_dns))
+ @full_presenter = subject.new(full_instance, :region => 'us-east-1', :roles => cap.roles(full_instance.public_dns))
less_instance = double(AWS::EC2, :tags => nil)
@less_presenter = subject.new(less_instance)
@@ -42,6 +42,16 @@
end
end
+ describe '#region' do
+ it 'can be defined' do
+ @full_presenter.region.should == 'us-east-1'
+ end
+
+ it 'is not required' do
+ @less_presenter.region.should == 'N/A'
+ end
+ end
+
describe '#roles' do
it 'can be defined' do
@full_presenter.roles.should == 'app, web'

0 comments on commit 556fb98

Please sign in to comment.