Module: Preservation::Builder
- Defined in:
- lib/preservation/builder.rb
Overview
Builder
Class Method Summary collapse
-
.build_directory_name(metadata_record, directory_name_scheme) ⇒ String
Build directory name.
-
.build_wget(username, password, file_url) ⇒ String
Build wget string.
Class Method Details
.build_directory_name(metadata_record, directory_name_scheme) ⇒ String
Build directory name
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/preservation/builder.rb', line 37 def self.build_directory_name(, directory_name_scheme) doi = [:doi] uuid = [:uuid] title = [:title].strip.gsub(' ', '-').gsub('/', '-') time = Time.new date = time.strftime("%Y-%m-%d") time = time.strftime("%H:%M:%S") join_str = '-----' case directory_name_scheme when :uuid_title [uuid, title].join(join_str) when :title_uuid [title, uuid].join(join_str) when :date_uuid_title [date, uuid, title].join(join_str) when :date_title_uuid [date, title, uuid].join(join_str) when :date_time_uuid [date, time, uuid].join(join_str) when :date_time_title [date, time, title].join(join_str) when :date_time_uuid_title [date, time, uuid, title].join(join_str) when :date_time_title_uuid [date, time, title, uuid].join(join_str) when :uuid uuid when :doi if doi.nil? || doi.empty? return '' end doi.gsub('/', '-') when :doi_short if doi.nil? || doi.empty? return '' end doi_short_to_remove = 'http://dx.doi.org/' short = doi.gsub(doi_short_to_remove, '') short.gsub!('/', '-') else uuid end end |
.build_wget(username, password, file_url) ⇒ String
Build wget string
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/preservation/builder.rb', line 13 def self.build_wget(username, password, file_url) # construct wget command with parameters wget_str = '' wget_str << 'wget' wget_str << ' ' wget_str << '--user' wget_str << ' ' wget_str << username wget_str << ' ' wget_str << '--password' wget_str << ' ' wget_str << '"' + password + '"' wget_str << ' ' wget_str << file_url wget_str << ' ' wget_str << '--no-check-certificate' wget_str end |