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 76 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 14 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 33 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 25 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
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 68 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 29 def create_zip out PIM::Services::ZipService.create_zip(out) end
execute(&block)
click to toggle source
# File exporter.rb, line 21 def execute &block self.instance_exec(@context, &block) end
is_public_asset(url)
click to toggle source
# File exporter.rb, line 41 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 53 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 45 def url_file_basename url return File.basename(CGI.unescape(url)) end
url_file_extension(url)
click to toggle source
# File exporter.rb, line 49 def url_file_extension url return File.extension(CGI.unescape(url)) end
zip(gathering_key, out)
click to toggle source
# File exporter.rb, line 37 def zip gathering_key, out PIM::Services::ZipService.zip_gathering(gathering_key, out) end