Class: ActiveCypher::Fixtures::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/active_cypher/fixtures/parser.rb

Overview

Parses a fixture profile file using instance_eval in a DSL context.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Parser

Returns a new instance of Parser.



9
10
11
12
# File 'lib/active_cypher/fixtures/parser.rb', line 9

def initialize(file)
  @file = file
  @dsl_context = ActiveCypher::Fixtures::DSLContext.new
end

Instance Attribute Details

#dsl_contextObject (readonly)

Returns the value of attribute dsl_context.



7
8
9
# File 'lib/active_cypher/fixtures/parser.rb', line 7

def dsl_context
  @dsl_context
end

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/active_cypher/fixtures/parser.rb', line 7

def file
  @file
end

Instance Method Details

#parseObject

Evaluates the profile file in the DSL context. Returns the DSLContext instance (which accumulates node/rel declarations).



16
17
18
19
20
# File 'lib/active_cypher/fixtures/parser.rb', line 16

def parse
  code = File.read(file)
  dsl_context.instance_eval(code, file)
  dsl_context
end