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
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
32 33 34 |
# File 'lib/activefacts/input/cql.rb', line 32 def self.read(file, filename = "stdin") readstring(file.read, filename) end |
.readfile(filename) ⇒ Object
Read the specified file
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/activefacts/input/cql.rb', line 16 def self.readfile(filename) if File.basename(filename, '.cql') == "-" 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
37 38 39 40 |
# File 'lib/activefacts/input/cql.rb', line 37 def self.readstring(str, filename = "string") compiler = ActiveFacts::CQL::Compiler.new(filename) compiler.compile(str) end |