Skip to content

Instantly share code, notes, and snippets.

@hectorcorrea
Created April 8, 2022 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hectorcorrea/bc40e0fd514d672098feae8c046ab9be to your computer and use it in GitHub Desktop.
Save hectorcorrea/bc40e0fd514d672098feae8c046ab9be to your computer and use it in GitHub Desktop.
Playing with the ezid-client gem
require "ezid-client"
require "byebug"
def show_ark(identifier)
puts "Target: #{identifier.target}"
puts "ID....: #{identifier.id}"
puts "Status: #{identifier.status}"
end
Ezid::Client.configure do |config|
config.default_shoulder = "ark:/99999/fk4"
config.user = "apitest"
config.password = "apitest"
end
if ARGV[0] == "mint"
identifier = Ezid::Identifier.mint
puts "Minted new ARK"
show_ark(identifier)
return
end
if ARGV[0] == "find" && ARGV[1]
id = ARGV[1]
identifier = Ezid::Identifier.find(id)
puts "ARK info"
show_ark(identifier)
return
end
if ARGV[0] == "target" && ARGV[1] && ARGV[2]
id = ARGV[1]
new_target = ARGV[2]
identifier = Ezid::Identifier.find(id)
identifier.target = new_target
identifier.save
puts "Updated target of ARK"
show_ark(identifier)
return
end
if ARGV[0] == "modify" && ARGV[1]
# This is not working yet, still need to figure it out.
#
id = ARGV[1]
# metadata = {who: "hector was here", what: "a link", when: "just now", other: "something else"}
metadata = {profile: "dc", target: "http://example2.com", creator: "hector"}
i = Ezid::Identifier.modify(id, metadata)
puts "Updated metadata of ARK"
return
end
puts 'syntax:'
puts ' eztest mint'
puts ' eztest find "ark:/xxx/yyy"'
puts ' eztest update "ark:/xxx/yyy" "http://newtarget"'
puts ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment