Class: Sumomo::Stack::EC2Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/sumomo/ec2.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, &block) ⇒ EC2Tasks

Returns a new instance of EC2Tasks.



124
125
126
127
128
129
# File 'lib/sumomo/ec2.rb', line 124

def initialize(bucket_name, &block)
  @script = ''
  @bucket_name = bucket_name
  @tags = []
  instance_eval(&block) if block
end

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script.



143
144
145
# File 'lib/sumomo/ec2.rb', line 143

def script
  @script
end

#tagsObject (readonly)

Returns the value of attribute tags.



145
146
147
# File 'lib/sumomo/ec2.rb', line 145

def tags
  @tags
end

Instance Method Details

#download_file(name, local_path) ⇒ Object



137
138
139
140
141
# File 'lib/sumomo/ec2.rb', line 137

def download_file(name, local_path)
  @script += <<~SNIPPET
    sudo aws s3 cp s3://#{@bucket_name}/uploads/#{name} #{local_path}
  SNIPPET
end

#mkdir(name) ⇒ Object



131
132
133
134
135
# File 'lib/sumomo/ec2.rb', line 131

def mkdir(name)
  @script += <<~SNIPPET
    sudo mkdir -p #{name}
  SNIPPET
end

#tag(name, value) ⇒ Object



147
148
149
# File 'lib/sumomo/ec2.rb', line 147

def tag(name, value)
  @tags << [name, value]
end