Module: Aspen

Defined in:
lib/aspen/schemas/grammar_schema.rb,
lib/aspen.rb,
lib/aspen/ast.rb,
lib/aspen/edge.rb,
lib/aspen/list.rb,
lib/aspen/node.rb,
lib/aspen/lexer.rb,
lib/aspen/errors.rb,
lib/aspen/parser.rb,
lib/aspen/actions.rb,
lib/aspen/helpers.rb,
lib/aspen/version.rb,
lib/aspen/adapters.rb,
lib/aspen/compiler.rb,
lib/aspen/discourse.rb,
lib/aspen/renderers.rb,
lib/aspen/statement.rb,
lib/aspen/conversion.rb,
lib/aspen/actions/push.rb,
lib/aspen/cli/commands.rb,
lib/aspen/actions/watch.rb,
lib/aspen/ast/nodes/edge.rb,
lib/aspen/ast/nodes/node.rb,
lib/aspen/ast/nodes/type.rb,
lib/aspen/custom_grammar.rb,
lib/aspen/system_default.rb,
lib/aspen/abstract_parser.rb,
lib/aspen/actions/compile.rb,
lib/aspen/ast/nodes/label.rb,
lib/aspen/cli/commands/new.rb,
lib/aspen/custom_statement.rb,
lib/aspen/ast/nodes/comment.rb,
lib/aspen/ast/nodes/content.rb,
lib/aspen/cli/commands/push.rb,
lib/aspen/abstract_statement.rb,
lib/aspen/cli/commands/build.rb,
lib/aspen/cli/commands/watch.rb,
lib/aspen/custom_grammar/ast.rb,
lib/aspen/ast/nodes/attribute.rb,
lib/aspen/ast/nodes/narrative.rb,
lib/aspen/ast/nodes/statement.rb,
lib/aspen/cli/commands/compile.rb,
lib/aspen/cli/commands/version.rb,
lib/aspen/custom_grammar/lexer.rb,
lib/aspen/cli/commands/generate.rb,
lib/aspen/custom_grammar/parser.rb,
lib/aspen/custom_grammar/grammar.rb,
lib/aspen/custom_grammar/matcher.rb,
lib/aspen/custom_grammar/compiler.rb,
lib/aspen/renderers/gexf_renderer.rb,
lib/aspen/renderers/json_renderer.rb,
lib/aspen/cli/commands/build_steps.rb,
lib/aspen/schemas/discourse_schema.rb,
lib/aspen/renderers/cypher_renderer.rb,
lib/aspen/ast/nodes/custom_statement.rb,
lib/aspen/custom_grammar/ast/nodes/bare.rb,
lib/aspen/renderers/cypher_base_renderer.rb,
lib/aspen/renderers/cypher_batch_renderer.rb,
lib/aspen/custom_grammar/ast/nodes/content.rb,
lib/aspen/custom_grammar/ast/nodes/expression.rb,
lib/aspen/contracts/default_attribute_contract.rb,
lib/aspen/custom_grammar/ast/nodes/capture_segment.rb

Overview

grammar:

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

Defined Under Namespace

Modules: AST, Actions, Adapters, CLI, Contracts, Conversion, CustomGrammar, Helpers, Renderers, Schemas, SystemDefault Classes: AbstractParser, AbstractStatement, ArgumentError, AttributeCollisionError, CompileError, Compiler, CustomStatement, Discourse, Edge, Error, Errors, LexError, Lexer, List, MatchError, Node, ParseError, Parser, Statement

Constant Summary collapse

SEPARATOR =

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

"----".freeze
VERSION =
"0.1.2"
@@available_formats =
[]

Class Method Summary collapse

Class Method Details

.available_formatsObject



24
25
26
# File 'lib/aspen.rb', line 24

def self.available_formats
  @@available_formats
end

.available_formats=(*args) ⇒ Object



28
29
30
# File 'lib/aspen.rb', line 28

def self.available_formats=(*args)
  @@available_formats = Array(args).flatten
end

.compile_code(code, environment = {}) ⇒ Object



39
40
41
42
43
# 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 = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# 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

.convertObject

Examples:

Aspen.convert.csv('path/to/csv').to_aspen


39
40
41
# File 'lib/aspen/conversion.rb', line 39

def self.convert
  Aspen::Conversion::Builder.new({})
end