Skip to content

Commit

Permalink
added region to the presenter which allows it to be displayed in the …
Browse files Browse the repository at this point in the history
…report
  • Loading branch information
wbailey committed May 27, 2012
1 parent 2e3b1bf commit 556fb98
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/claws/collection/ec2.rb
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions lib/claws/presenter/ec2.rb
Expand Up @@ -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
Expand Down
Binary file modified pkg/claws-1.1.0.gem
Binary file not shown.
12 changes: 11 additions & 1 deletion spec/presenter/ec2_spec.rb
Expand Up @@ -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)
Expand All @@ -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'
Expand Down

0 comments on commit 556fb98

Please sign in to comment.