Sha256: d4ec2a0f6a4f27b07e737aa2ef8d5f76b19543c9b87dc0942b996de08649f7ec
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
#! env ruby # # ActiveFacts: Read a Vocabulary (from a NORMA, CQL or other file) and run a generator # # Copyright (c) 2009 Clifford Heath. Read the LICENSE file. # $:.unshift File.dirname(File.expand_path(__FILE__))+"/../lib" require 'rubygems' require 'ruby-debug' require 'activefacts' require 'activefacts/vocabulary' debugger if debug :exception true # Ok, got the stack set up, continue to the fault arg = ARGV.shift # Load the required generator, or the default "text" generator: generator = "text" if arg =~ /^--([^=]*)(?:=(.*))?/ generator = $1 generator_options = ($2||"").split(/,/) arg = ARGV.shift end output_handler = "activefacts/generate/#{generator.downcase}" require output_handler output_class = generator.upcase.gsub(%r{[/\\]+},'::') output_klass = eval("ActiveFacts::Generate::#{output_class}") raise "Expected #{output_handler} to define #{output_class}" unless output_klass # Load the file type input method extension = arg.sub(/\A.*\./,'').downcase input_handler = "activefacts/input/#{extension}" require input_handler input_class = extension.upcase input_klass = ActiveFacts::Input.const_get(input_class.to_sym) raise "Expected #{input_handler} to define #{input_class}" unless input_klass # Read the input file: begin vocabulary = input_klass.readfile(arg) rescue => e puts "#{e.message}" puts "#{e}:\n\t#{e.backtrace*"\n\t"}" if debug end # Generate the output: output_klass.new(vocabulary, *generator_options).generate if vocabulary
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activefacts-0.7.1 | bin/afgen |
activefacts-0.7.2 | bin/afgen |