Sha256: c9ac46eb22f1e11cc6c3b72e062221f97a625e255af27574a52f0cd90cdd75aa

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

#! /usr/bin/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.
#
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
$:.unshift File.dirname(File.expand_path(__FILE__))+"/../lib"

require 'activefacts/metamodel'
require 'activefacts/compositions/binary'
require 'activefacts/compositions/relational'
require 'activefacts/compositions/validator'

options = {}
while arg = ARGV.shift and arg =~ /^-/
  option, value = arg.split(/=/, 2)
  options[option.sub(/^-*/,'')] = value =~ /,/ ? value.split(',') : (value || true)
end

validate = options.delete('validate')

# Load the file type input method
if arg
  arg, input_options = *arg.split(/=/, 2)
  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
end

# Read the input file:
begin
  if input_klass
    vocabulary = input_klass.readfile(arg, *input_options)
  else
    vocabulary = true
  end

  exit 0 unless vocabulary

  vocabulary.finalise unless vocabulary == true

  compositor = ActiveFacts::Compositions::Relational.new(vocabulary.constellation, "test", options)
  compositor.generate
  trace.enable 'composition_validator'
  compositor.validate do |component, problem|
    trace :composition_validator, "!!PROBLEM!! #{component.inspect}: #{problem}"
  end if validate

rescue => e
  $stderr.puts "#{e.message}"
  # puts "\t#{e.backtrace*"\n\t"}"
  $stderr.puts "\t#{e.backtrace*"\n\t"}" if trace :exception
  exit 1
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activefacts-compositions-1.9.4 bin/schema_compositor