module Aspen

grammar:

-
  match:
    - (Person a) knows (Person b).
  template: {{{a}}}-[:KNOWS]->{{{b}}}.

Constants

SEPARATOR

TODO: There wants to be a pre-compiler stage/object.

VERSION

Public Class Methods

available_formats() click to toggle source
# File lib/aspen.rb, line 24
def self.available_formats
  @@available_formats
end
available_formats=(*args) click to toggle source
# File lib/aspen.rb, line 28
def self.available_formats=(*args)
  @@available_formats = Array(args).flatten
end
compile_code(code, environment = {}) click to toggle source
# File lib/aspen.rb, line 39
def self.compile_code(code, environment = {})
  tokens = Lexer.tokenize(code, environment)
  ast = Parser.parse(tokens, environment)
  Compiler.render(ast, environment)
end
compile_text(text, environment = {}) click to toggle source
# File lib/aspen.rb, line 45
def self.compile_text(text, environment = {})
  assert_text(text)

  if text.include?(SEPARATOR)
    env, _sep, code = text.partition(SEPARATOR)
    compile_code(code, YAML.load(env).merge(environment))
  else
    code = text
    compile_code(code, environment)
  end
end
convert() click to toggle source

@example

Aspen.convert.csv('path/to/csv').to_aspen
# File lib/aspen/conversion.rb, line 39
def self.convert
  Aspen::Conversion::Builder.new({})
end

Private Class Methods

assert_text(text) click to toggle source
# File lib/aspen.rb, line 59
def self.assert_text(text)
  if text.strip.empty?
    raise Aspen::Error, "Text must be provided to the `Aspen.compile_text` method."
  end
end