class ContainedMr::Mock::Template
@see {ContainedMr::Template}
Attributes
_definition[R]
@return {Hash<String, Object>} YAML-parsed mapreduced.yml
_zip_contents[R]
@return {Hash<String, Symbol|String>} maps file names in the template .zip
to their contents, and maps directory entries to the :directory symbol
Public Class Methods
new(name_prefix, id, zip_io)
click to toggle source
@see {ContainedMr::Template#initialize}
# File lib/contained_mr/mock/template.rb, line 18 def initialize(name_prefix, id, zip_io) @name_prefix = name_prefix @id = id @image_id = 'mock-template-image-id' @item_count = nil @_definition = nil @destroyed = false @_zip_contents = {} process_zip zip_io end
Public Instance Methods
destroy!()
click to toggle source
@see {ContainedMr::Template#destroy!}
# File lib/contained_mr/mock/template.rb, line 32 def destroy! @destroyed = true self end
destroyed?()
click to toggle source
@return {Boolean} true if {#destroy!} was called
# File lib/contained_mr/mock/template.rb, line 13 def destroyed? @destroyed end
job_class()
click to toggle source
@see {ContainedMr::Template#new_job}
# File lib/contained_mr/mock/template.rb, line 38 def job_class ContainedMr::Mock::Job end
Private Instance Methods
process_zip(zip_io)
click to toggle source
Reads the template .zip and parses the definition.
# File lib/contained_mr/mock/template.rb, line 43 def process_zip(zip_io) # TODO(pwnall): zip_io.read -> zip_io after rubyzip releases 1.1.8 Zip::File.open_buffer zip_io.read do |zip| zip.each do |zip_entry| file_name = zip_entry.name if zip_entry.directory? @_zip_contents[file_name] = :directory elsif zip_entry.file? if file_name == 'mapreduced.yml' read_definition zip_entry.get_input_stream next end @_zip_contents[file_name] = zip_entry.get_input_stream.read end end end @_zip_contents.freeze end