Module: PushmiPullyu::AIP

Defined in:
lib/pushmi_pullyu/aip.rb

Defined Under Namespace

Classes: Creator, Downloader, FedoraFetcher, FileListCreator, NoidInvalid, OwnerEmailEditor, User

Class Method Summary collapse

Class Method Details

.create(noid) {|aip_filename, aip_directory| ... } ⇒ Object

Yields:

  • (aip_filename, aip_directory)

Raises:


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pushmi_pullyu/aip.rb', line 7

def create(noid)
  raise NoidInvalid if noid.blank? || noid.include?('/')

  aip_directory = "#{PushmiPullyu.options[:workdir]}/#{noid}"
  aip_filename = "#{aip_directory}.tar"

  PushmiPullyu::AIP::Downloader.new(noid, aip_directory).run
  PushmiPullyu::AIP::Creator.new(noid, aip_directory, aip_filename).run

  yield aip_filename, aip_directory

  FileUtils.rm_rf(aip_filename) if File.exist?(aip_filename)
  FileUtils.rm_rf(aip_directory) if File.exist?(aip_directory)
end