Class: ActiveFacts::Input::CQL
- Inherits:
-
Object
- Object
- ActiveFacts::Input::CQL
- Defined in:
- lib/activefacts/input/cql.rb
Overview
Compile CQL to an ActiveFacts vocabulary. Invoke as
afgen --<generator> <file>.cql
Constant Summary collapse
- EXTENSIONS =
['fiml', 'fidl', 'fiql', 'cql']
Class Method Summary collapse
-
.read(file, filename = "stdin") ⇒ Object
Read the specified input stream.
-
.readfile(filename) ⇒ Object
Read the specified file.
-
.readstring(str, filename = "string") ⇒ Object
Read the specified input string.
Class Method Details
.read(file, filename = "stdin") ⇒ Object
Read the specified input stream
33 34 35 |
# File 'lib/activefacts/input/cql.rb', line 33 def self.read(file, filename = "stdin") readstring(file.read, filename) end |
.readfile(filename) ⇒ Object
Read the specified file
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/activefacts/input/cql.rb', line 17 def self.readfile(filename) if EXTENSIONS.detect { |extension| File.basename(filename, extension) == "-" } read(STDIN, "<standard input>") else File.open(filename) {|file| read(file, filename) } end rescue => e # Augment the exception message, but preserve the backtrace ne = StandardError.new("In #{filename} #{e..strip}") ne.set_backtrace(e.backtrace) raise ne end |
.readstring(str, filename = "string") ⇒ Object
Read the specified input string
38 39 40 41 |
# File 'lib/activefacts/input/cql.rb', line 38 def self.readstring(str, filename = "string") compiler = ActiveFacts::CQL::Compiler.new(filename) compiler.compile(str) end |