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 105
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 15
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 34
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_digital_asset(content, path, gathering_key: nil) click to toggle source

Creates a digital asset with the specified content.

Parameters:

content: IO, StringIO or String
path: Path, i.e. filename to store the asset with
gathering_key: Gathering-Key to create the asset into (optional, will create a new one if nil)

Returns:

DigitalAsset
# File exporter.rb, line 93
def create_digital_asset content, path, gathering_key: nil
  PIM::Services::AssetService.create_digital_asset content, path, gathering_key: gathering_key
end
create_gathering_key() click to toggle source
# File exporter.rb, line 26
def create_gathering_key
  PIM::Services::AssetService.create_gathering_key()
end
create_trafo_digital_asset(items, content_type, gathering_key: nil, filename_prefix: nil, filename_suffix: nil) click to toggle source

Creates a digital asset by ‘transforming’ the specified items.

Parameters:

items: List of items to export (mandatory)
content_type: Content-type to transform to (mandatory)
gathering_key: Gathering-Key to create the asset into (optional, will create a new one if nil)
filename_prefix: Prefix to use for the filename, formated like "[PREFIX]-FILENAME" (optional)
filename_suffix: Suffix to use for the filename, formated like "FILENAME.[SUFFIX]" (optional)s

Returns:

DigitalAsset
# File exporter.rb, line 75
def create_trafo_digital_asset items, content_type, gathering_key: nil, filename_prefix: nil, filename_suffix: nil
  PIM::Services::ExportService.create_trafo_digital_asset(items,
                                                          content_type,
                                                          gathering_key: gathering_key,
                                                          filename_prefix: filename_prefix,
                                                          filename_suffix: filename_suffix)
end
create_zip(out) click to toggle source
# File exporter.rb, line 30
def create_zip out
  PIM::Services::ZipService.create_zip(out)
end
execute(&block) click to toggle source
# File exporter.rb, line 22
def execute &block
  self.instance_exec(@context, &block)
end
get_item_validation_results(*args) click to toggle source
# File exporter.rb, line 97
def get_item_validation_results *args
  PIM::Services::ItemService.get_item_validation_results *args
end
is_public_asset(url) click to toggle source
# File exporter.rb, line 42
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 54
def media_type_param key
  media_type = context[:media_type]
  return media_type.parameters[key] if media_type
end
replace_extension(path, new_extension) click to toggle source
# File exporter.rb, line 59
def replace_extension path, new_extension
  return Pathname(path).sub_ext(new_extension).to_path
end
translate_validation_messages(*args) click to toggle source
# File exporter.rb, line 101
def translate_validation_messages *args
  PIM::Services::TranslationService.translate_validation_messages *args
end
url_file_basename(url) click to toggle source
# File exporter.rb, line 46
def url_file_basename url
  return File.basename(CGI.unescape(url))
end
url_file_extension(url) click to toggle source
# File exporter.rb, line 50
def url_file_extension url
  return File.extension(CGI.unescape(url))
end
zip(gathering_key, out) click to toggle source
# File exporter.rb, line 38
def zip gathering_key, out
  PIM::Services::ZipService.zip_gathering(gathering_key, out)
end