class PIM::Exporter

Attributes

content_type[R]
context[R]
items[R]
output[R]

Public Class Methods

export(content_type = nil, items = nil, output = nil, context = nil, &block) click to toggle source
# File exporter.rb, line 61
def self.export content_type = nil, items = nil, output = nil, context = nil, &block
  content_type ||= $content_type
  items ||= $items
  output ||= $output
  context ||= {
    :user => $user,
    :language => $language,
    :mapping => $mapping,
    :media_type => $media_type,
    :parameters => $parameters,
    :export_task_id => $export_task_id,
    :selection_id => $selection_id
  }
  exporter = Exporter.new(content_type, items, output, context)
  exporter.execute(&block)
  begin
    output.close unless output.closed?
  rescue
  end
end
new(content_type, items, output, context) click to toggle source
# File exporter.rb, line 17
def initialize content_type, items, output, context
  @content_type = content_type
  @items = items
  @output = output
  @context = context
end

Public Instance Methods

add_file(asset_or_url, zip_file, target_path = nil) click to toggle source
# File exporter.rb, line 36
def add_file asset_or_url, zip_file, target_path = nil
  PIM::Services::ZipService.add_to_zip asset_or_url, zip_file, target_path
end
create_gathering_key() click to toggle source
# File exporter.rb, line 28
def create_gathering_key
  PIM::Services::AssetService.create_gathering_key()
end
create_zip(out) click to toggle source
# File exporter.rb, line 32
def create_zip out
  PIM::Services::ZipService.create_zip(out)
end
execute(&block) click to toggle source
# File exporter.rb, line 24
def execute &block
  self.instance_exec(@context, &block)
end
is_public_asset(url) click to toggle source
# File exporter.rb, line 44
def is_public_asset url
  PIM::Services::AssetService.is_public_asset_url(url)
end
media_type_param(key) click to toggle source
# File exporter.rb, line 56
def media_type_param key
  media_type = context[:media_type]
  return media_type.parameters[key] if media_type
end
url_file_basename(url) click to toggle source
# File exporter.rb, line 48
def url_file_basename url
  return File.basename(CGI.unescape(url))
end
url_file_extension(url) click to toggle source
# File exporter.rb, line 52
def url_file_extension url
  return File.extension(CGI.unescape(url))
end
zip(gathering_key, out) click to toggle source
# File exporter.rb, line 40
def zip gathering_key, out
  PIM::Services::ZipService.zip_gathering(gathering_key, out)
end