Class: Prick::Build::Node
- Inherits:
-
Object
- Object
- Prick::Build::Node
- Defined in:
- lib/prick/builder/node.rb
Direct Known Subclasses
BuildNode, ExecutableNode, FoxNode, InlineNode, ModuleNode, PSqlNode, SqlNode
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
only defined for :exe (String).
-
#kind ⇒ Object
readonly
:sql, :exe, :fox, :yml, :inline, :module.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#phase ⇒ Object
readonly
:init, :decl, :seed, :term or nil (for BuildNode).
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(parent, phase, kind, path, args = nil) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #lines ⇒ Object
- #name ⇒ Object
- #prefix_lines ⇒ Object
- #relpath ⇒ Object
-
#schema ⇒ Object
Note that schema defaults to ‘public’ which may not be what you want in some cases.
- #schema=(s) ⇒ Object
- #source ⇒ Object
- #source_lines ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(parent, phase, kind, path, args = nil) ⇒ Node
Returns a new instance of Node.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/prick/builder/node.rb', line 33 def initialize(parent, phase, kind, path, args = nil) constrain parent, BuildNode, NilClass constrain phase, :init, :decl, :seed, :term, nil constrain kind, :sql, :psql, :exe, :fox, :yml, :inline, :module constrain path, String, NilClass @parent, @phase, @kind, @path = parent, phase, kind, path @args = args&.empty? ? nil : args @has_schema = false @schema = nil @source = nil @source_lines = nil end |
Instance Attribute Details
#args ⇒ Object (readonly)
only defined for :exe (String)
9 10 11 |
# File 'lib/prick/builder/node.rb', line 9 def args @args end |
#kind ⇒ Object (readonly)
:sql, :exe, :fox, :yml, :inline, :module
7 8 9 |
# File 'lib/prick/builder/node.rb', line 7 def kind @kind end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/prick/builder/node.rb', line 4 def parent @parent end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/prick/builder/node.rb', line 8 def path @path end |
#phase ⇒ Object (readonly)
:init, :decl, :seed, :term or nil (for BuildNode)
6 7 8 |
# File 'lib/prick/builder/node.rb', line 6 def phase @phase end |
Instance Method Details
#dump ⇒ Object
48 |
# File 'lib/prick/builder/node.rb', line 48 def dump() puts "#{inspect} (#{@schema || 'nil'})" end |
#inspect ⇒ Object
47 |
# File 'lib/prick/builder/node.rb', line 47 def inspect() to_s end |
#lines ⇒ Object
31 |
# File 'lib/prick/builder/node.rb', line 31 def lines() prefix_lines + source_lines end |
#name ⇒ Object
11 |
# File 'lib/prick/builder/node.rb', line 11 def name() @name = File.basename(path) end |
#prefix_lines ⇒ Object
23 |
# File 'lib/prick/builder/node.rb', line 23 def prefix_lines() 0 end |
#relpath ⇒ Object
12 |
# File 'lib/prick/builder/node.rb', line 12 def relpath = path.sub(/^#{Dir.getwd}\//, "") |
#schema ⇒ Object
Note that schema defaults to ‘public’ which may not be what you want in some cases
16 |
# File 'lib/prick/builder/node.rb', line 16 def schema() @schema ||= parent&.schema || "public" end |
#schema=(s) ⇒ Object
17 |
# File 'lib/prick/builder/node.rb', line 17 def schema=(s) @schema = s end |
#source ⇒ Object
19 20 21 |
# File 'lib/prick/builder/node.rb', line 19 def source @source ||= read_source end |
#source_lines ⇒ Object
25 26 27 28 29 |
# File 'lib/prick/builder/node.rb', line 25 def source_lines() return @source_lines if @source_lines source @source_lines end |
#to_s ⇒ Object
46 |
# File 'lib/prick/builder/node.rb', line 46 def to_s() @to_s ||= [path, *args].join(" ") end |