Class: Pione::Package::Document
- Inherits:
-
Object
- Object
- Pione::Package::Document
- Defined in:
- lib/pione/package/document.rb
Overview
Package::Document provides functions that read PIONE document.
Class Method Summary collapse
-
.load(env, src, package_name, editor, tag, filename) ⇒ Object
Load a PIONE rule document into the environment.
-
.parse(src, package_name, editor, tag, filename) ⇒ Object
Parse a PIONE rule document as a string and return the package context.
Class Method Details
.load(env, src, package_name, editor, tag, filename) ⇒ Object
Load a PIONE rule document into the environment.
7 8 9 10 |
# File 'lib/pione/package/document.rb', line 7 def load(env, src, package_name, editor, tag, filename) _src = src.kind_of?(Location::DataLocation) ? src.read : src parse(_src, package_name, editor, tag, filename).eval(env) end |
.parse(src, package_name, editor, tag, filename) ⇒ Object
Parse a PIONE rule document as a string and return the package context.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pione/package/document.rb', line 14 def parse(src, package_name, editor, tag, filename) # make transformer options opt = {package_name: package_name, editor: editor, tag: tag, filename: filename} # parse the document stree = Lang::DocumentParser.new.parse(src) # model transformation return Lang::DocumentTransformer.new.apply(stree, opt) end |