Class: PgObjects::Parser
- Inherits:
-
Object
- Object
- PgObjects::Parser
- Defined in:
- lib/pg_objects/parser.rb
Overview
Reads directives from SQL-comments
--!depends_on name_a
--!depends_on name_a, name_b, name_c
#!depends_on name_a
The directive must start the line (no leading whitespace). Dependencies may be listed on one line separated by commas and/or whitespace, or across several directive lines.
name_of_dependency: short or full name of object as well as object_name
Constant Summary collapse
- DEPENDS_ON_DIRECTIVE =
/\A(?:--|#)!depends_on\s+(.+)/
Instance Method Summary collapse
- #fetch_directives ⇒ Object
- #fetch_object_name ⇒ Object
- #fetch_qualified_object_name ⇒ Object
- #load(source) ⇒ Object
Instance Method Details
#fetch_directives ⇒ Object
30 31 32 33 34 |
# File 'lib/pg_objects/parser.rb', line 30 def fetch_directives { depends_on: fetch_dependencies } end |
#fetch_object_name ⇒ Object
36 37 38 39 40 |
# File 'lib/pg_objects/parser.rb', line 36 def fetch_object_name parsed_object.name rescue PgQuery::ParseError, PgObjects::UnknownObjectTypeError nil end |
#fetch_qualified_object_name ⇒ Object
42 43 44 45 46 |
# File 'lib/pg_objects/parser.rb', line 42 def fetch_qualified_object_name parsed_object.qualified_name rescue PgQuery::ParseError, PgObjects::UnknownObjectTypeError nil end |
#load(source) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/pg_objects/parser.rb', line 23 def load(source) @source = source @parsed = nil @parsed_object = nil self end |