class Ddr::IngestTools::ManifestArkMinter::ManifestUpdater
Constants
- DEFAULT_CONFIG_FILE
Attributes
config[R]
logger[R]
manifest[R]
output[R]
Public Class Methods
new(config: DEFAULT_CONFIG_FILE, manifest:, output:, logger: nil)
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 12 def initialize(config: DEFAULT_CONFIG_FILE, manifest:, output:, logger: nil) @config = config @manifest = manifest @output = output @logger = logger || Logger.new(STDOUT) end
Public Instance Methods
call()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 19 def call configure if needs_updating? update else logger.info("Manifest file already has ARKs ... nothing to mint") end end
Private Instance Methods
configure()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 30 def configure conf = YAML::load(IO.read(config)) Ddr::IngestTools::ManifestArkMinter.configure do |config| config.ezid_default_shoulder = conf.fetch('ezid_default_shoulder') config.ezid_password = conf.fetch('ezid_password') config.ezid_user = conf.fetch('ezid_user') end end
manifest_as_csv_table()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 56 def manifest_as_csv_table @manifest_as_csv_table ||= parser.as_csv_table end
minter()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 71 def minter @minter ||= Minter.new end
needs_updating?()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 67 def needs_updating? parser.arks_missing? end
parser()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 75 def parser @parser ||= ManifestParser.new(manifest) end
update()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 39 def update update_manifest_table write_updated_manifest end
update_manifest_table()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 44 def update_manifest_table logger.info("Minting ARKs for manifest file") mint_counter = 0 manifest_as_csv_table.each do |row| unless row['ark'] row['ark'] = minter.mint mint_counter += 1 end end logger.info("Minted #{mint_counter} ARK(s)") end
write_updated_manifest()
click to toggle source
# File lib/ddr/ingesttools/manifest_ark_minter/manifest_updater.rb, line 60 def write_updated_manifest File.open(output, 'w') do |f| f.write(manifest_as_csv_table.to_csv) end logger.info("Updated manifest file is at #{output}") end