Class: Bricolage::S3Task::Put
- Inherits:
-
Action
- Object
- Action
- Bricolage::S3Task::Put
- Defined in:
- lib/bricolage/s3datasource.rb
Instance Method Summary collapse
- #check_arguments ⇒ Object
- #command_line(src, dest) ⇒ Object
- #each_src_dest ⇒ Object
-
#initialize(src, dest) ⇒ Put
constructor
A new instance of Put.
- #run ⇒ Object
- #single_source? ⇒ Boolean
- #source ⇒ Object
- #source_files ⇒ Object
Constructor Details
#initialize(src, dest) ⇒ Put
Returns a new instance of Put.
149 150 151 152 |
# File 'lib/bricolage/s3datasource.rb', line 149 def initialize(src, dest) @src = src @dest = dest end |
Instance Method Details
#check_arguments ⇒ Object
173 174 |
# File 'lib/bricolage/s3datasource.rb', line 173 def check_arguments end |
#command_line(src, dest) ⇒ Object
169 170 171 |
# File 'lib/bricolage/s3datasource.rb', line 169 def command_line(src, dest) "aws s3 cp #{src} #{ds.url(dest)}" end |
#each_src_dest ⇒ Object
162 163 164 165 166 167 |
# File 'lib/bricolage/s3datasource.rb', line 162 def each_src_dest source_files.each do |src| dest = (@dest.to_s.end_with?('/') ? "#{@dest}/#{File.basename(src)}" : @dest) yield src, dest end end |
#run ⇒ Object
184 185 186 187 188 189 190 191 |
# File 'lib/bricolage/s3datasource.rb', line 184 def run raise JobFailure, "no such file: #{@src}" if source_files.empty? each_src_dest do |src, dest| ds.logger.info command_line(src, dest) ds.object(dest).upload_file(src) end nil end |
#single_source? ⇒ Boolean
158 159 160 |
# File 'lib/bricolage/s3datasource.rb', line 158 def single_source? source_files.size == 1 and source_files.first == @src end |
#source ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/bricolage/s3datasource.rb', line 176 def source buf = StringIO.new each_src_dest do |src, dest| buf.puts command_line(src, dest) end buf.string end |
#source_files ⇒ Object
154 155 156 |
# File 'lib/bricolage/s3datasource.rb', line 154 def source_files @source_files ||= Dir.glob(@src) end |