Class: Interscript::DSL::Document

Inherits:
Object
  • Object
show all
Includes:
SymbolMM
Defined in:
lib/interscript/dsl/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SymbolMM

#method_missing

Constructor Details

#initialize(name = nil, &block) ⇒ Document

Returns a new instance of Document.



6
7
8
9
10
# File 'lib/interscript/dsl/document.rb', line 6

def initialize(name = nil, &block)
  @node = Interscript::Node::Document.new
  @node.name = name if name
  self.instance_exec &block if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Interscript::DSL::SymbolMM

Instance Attribute Details

#nodeObject

Returns the value of attribute node.



4
5
6
# File 'lib/interscript/dsl/document.rb', line 4

def node
  @node
end

Instance Method Details

#aliases(&block) ⇒ Object



22
23
24
25
26
# File 'lib/interscript/dsl/document.rb', line 22

def aliases(&block)
  aliases = Interscript::DSL::Aliases.new(&block)
  @node.aliases = aliases.node
  @node.aliases.transform_values { |v| v.doc_name = @node.name; v }
end

#dependency(full_name, **kargs) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/interscript/dsl/document.rb', line 28

def dependency(full_name, **kargs)
  puts "dependency(#{name.inspect}, #{kargs.inspect}" if $DEBUG
  dep = Interscript::Node::Dependency.new
  dep.name = kargs[:as]
  dep.full_name = full_name
  dep.import = kargs[:import] || false

  dep.document = Interscript::DSL.parse(full_name)
  @node.dependencies << dep
  @node.dep_aliases[dep.name] = dep if dep.name
end

#metadata(&block) ⇒ Object



12
13
14
15
# File 'lib/interscript/dsl/document.rb', line 12

def (&block)
   = Interscript::DSL::Metadata.new(&block)
  @node. = .node
end

#stage(name = :main, dont_reverse: false, &block) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/interscript/dsl/document.rb', line 40

def stage(name = :main, dont_reverse: false, &block)
  puts "stage(#{name}) from #{self.inspect}" if $DEBUG
  stage = Interscript::DSL::Stage.new(name, &block)
  stage.node.doc_name = @node.name
  stage.node.dont_reverse = dont_reverse
  @node.stages[name] = stage.node
end

#tests(&block) ⇒ Object



17
18
19
20
# File 'lib/interscript/dsl/document.rb', line 17

def tests(&block)
  tests = Interscript::DSL::Tests.new(&block)
  @node.tests = tests.node
end