Class: Hyrax::Ingest::SIP
- Inherits:
-
Object
- Object
- Hyrax::Ingest::SIP
- Defined in:
- lib/hyrax/ingest/sip.rb
Overview
A model for reading Submission Information Packages (SIPs) from a file_pathsystem.
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
description of a readonly attribute.
Instance Method Summary collapse
-
#file_paths ⇒ Array
A list of File objects that are part of the SIP.
-
#find_file_path(basename_or_regex) ⇒ File
The file from the SIP that matches the param.
-
#initialize(path:) ⇒ SIP
constructor
A new instance of SIP.
-
#read_file(basename_or_regex) ⇒ String
Reads the content of a file from the SIP, and automatically rewinds it so it can be read again.
Constructor Details
Instance Attribute Details
#path ⇒ String (readonly)
description of a readonly attribute
9 10 11 |
# File 'lib/hyrax/ingest/sip.rb', line 9 def path @path end |
Instance Method Details
#file_paths ⇒ Array
Returns A list of File objects that are part of the SIP.
19 20 21 22 23 24 |
# File 'lib/hyrax/ingest/sip.rb', line 19 def file_paths @file_paths ||= single_file_path @file_paths ||= file_paths_from_dir @file_paths ||= file_paths_from_tarball @file_paths ||= [] end |
#find_file_path(basename_or_regex) ⇒ File
Returns The file from the SIP that matches the param.
28 29 30 31 32 |
# File 'lib/hyrax/ingest/sip.rb', line 28 def find_file_path(basename_or_regex) file_path = file_path_from_regex(basename_or_regex) || file_path_from_basename(basename_or_regex) raise Hyrax::Ingest::Errors::FileNotFoundInSIP.new(path, basename_or_regex) unless file_path file_path end |
#read_file(basename_or_regex) ⇒ String
Reads the content of a file from the SIP, and automatically rewinds it so it can be read again.
38 39 40 |
# File 'lib/hyrax/ingest/sip.rb', line 38 def read_file(basename_or_regex) File.read(find_file_path(basename_or_regex)) end |