lib/rdf-vocab.rb in rdf-vocab-0.5.0 vs lib/rdf-vocab.rb in rdf-vocab-0.6.0
- old
+ new
@@ -1,6 +1,7 @@
require "yaml"
+require "uri"
require "rdf/cli/vocab-loader"
module RDF
module Vocab
@@ -10,9 +11,18 @@
def self.generate(vocab, output=nil)
loader = RDF::VocabularyLoader.new
loader.module_name = "RDF::Vocab" unless config[vocab]["module_name"]
config[vocab].each do |param, value|
+ if param == "source"
+ if URI.parse(value).scheme.nil? && !File.exists?(value)
+ if File.exists?(path = File.join(File.expand_path("../../sources", __FILE__), value))
+ value = path
+ else
+ raise IOError, "Source file not found."
+ end
+ end
+ end
loader.send("#{param}=", value)
end
loader.output = output if output # default: $stdout
loader.run
end