Created
February 10, 2014 01:22
-
-
Save jpstroop/8908719 to your computer and use it in GitHub Desktop.
Use RDF.rb to generate an `RDF::Vocabulary` or `RDF::StrictVocabulary`. Based on https://github.com/ruby-rdf/rdf/blob/develop/Rakefile#L39-L95
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'linkeddata' | |
require 'rdf/cli/vocab-loader' | |
vocab_sources = { | |
lifecycle: { | |
prefix: "http://purl.org/vocab/lifecycle/schema#", | |
source: "http://vocab.org/lifecycle/schema-20080603.rdf", | |
strict: true | |
} | |
} | |
vocab_sources.each do |id, v| | |
begin | |
out = StringIO.new | |
loader = RDF::VocabularyLoader.new(id.to_s.upcase) | |
loader.prefix = v[:prefix] | |
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("./#{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