Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jpstroop
Last active August 29, 2015 14:02
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 jpstroop/3be400311725d7104a15 to your computer and use it in GitHub Desktop.
Save jpstroop/3be400311725d7104a15 to your computer and use it in GitHub Desktop.
require 'linkeddata'
require 'rdf/cli/vocab-loader'
vocab_sources = {
lifecycle: {
uri: "http://purl.org/vocab/lifecycle/schema#",
source: "http://vocab.org/lifecycle/schema-20080603.rdf",
strict: true
},
exif: {
uri: "http://www.w3.org/2003/12/exif/ns#",
source: "http://www.w3.org/2003/12/exif/ns",
strict: true
},
marc_relators: {
uri: "http://id.loc.gov/vocabulary/relators/",
source: "http://id.loc.gov/vocabulary/relators.nt",
strict: true
}
}
vocab_sources.each do |id, v|
begin
out = StringIO.new
loader = RDF::VocabularyLoader.new(id.to_s.upcase)
loader.uri = v[:uri]
loader.source = v[:source] if v[:source]
loader.extra = v[:extra] if v[:extra]
loader.strict = v.fetch(:strict, true)
loader.output = out
loader.run
out.rewind
File.open("#{File.dirname(__FILE__)}/#{id}.rb", "w") {|f| f.write out.read}
rescue
puts "Failed to load #{id}: #{$!.message}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment