Class: ROF::Filters::FileToUrl

Inherits:
ROF::Filter show all
Defined in:
lib/rof/filters/file_to_url.rb

Overview

Convert any content datastream files into a bendo URL, and alter the rof to use the URL and not upload the file to fedora directly. The bendo URL will only exist for items having a bendo-item id set. The URL generated supposes the file keeps the same relative path the item originally had in the rof file.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FileToUrl

Returns a new instance of FileToUrl.



11
12
# File 'lib/rof/filters/file_to_url.rb', line 11

def initialize(options = {})
end

Instance Method Details

#process(obj_list) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rof/filters/file_to_url.rb', line 14

def process(obj_list)
  obj_list.map! do |obj|
    bendo_item = obj['bendo-item']
    content_file = obj['content-file']
    if bendo_item && content_file
      new_meta = obj.fetch('content-meta', {})
      new_meta['URL'] = "bendo:/item/#{bendo_item}/#{content_file}"
      obj['content-meta'] = new_meta
      obj.delete('content-file')
    end
    obj
  end
end