Class: Prick::Build::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/prick/builder/parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Parser

Returns a new instance of Parser.



11
12
13
14
# File 'lib/prick/builder/parser.rb', line 11

def initialize(conn)
  @conn = conn
  @unit = nil
end

Instance Attribute Details

#connObject (readonly)

Returns the value of attribute conn.



8
9
10
# File 'lib/prick/builder/parser.rb', line 8

def conn
  @conn
end

#unitObject (readonly)

The singular RootBuildNode object



9
10
11
# File 'lib/prick/builder/parser.rb', line 9

def unit
  @unit
end

Class Method Details

.parse(conn, path, single: true) ⇒ Object



4
5
6
# File 'lib/prick/builder/parser.rb', line 4

def self.parse(conn, path, single: true)
  Parser.new(conn).parse(path, single: single).unit
end

Instance Method Details

#parse(path, single: false) ⇒ Object

Return a RootBuildNode object. #path can be a file or a directory



17
18
19
20
21
22
23
24
25
# File 'lib/prick/builder/parser.rb', line 17

def parse(path, single: false)
  File.exist?(path) or raise Error, "Can't find #{path}"
  if single
    parse_path(path)
  else
    parse_directory(nil, path)
  end
  self
end