Class: Fig::Parser

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

Overview

Parses .fig files (wrapping the Treetop-generated parser object) and deals with a few restrictions on them.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_config, check_include_versions) ⇒ Parser

Returns a new instance of Parser.



32
33
34
35
# File 'lib/fig/parser.rb', line 32

def initialize(application_config, check_include_versions)
  @application_config     = application_config
  @check_include_versions = check_include_versions
end

Class Method Details

.keyword?(string) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/fig/parser.rb', line 28

def self.keyword?(string)
  return KEYWORDS.include? string
end

.strict_keyword?(string) ⇒ Boolean

Keywords that we really want to lock down.

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/fig/parser.rb', line 20

def self.strict_keyword?(string)
  # "config" is considered too useful for users, so we allow that where we
  # restrict other keywords.
  return false if string == 'config'

  return keyword? string
end

Instance Method Details

#parse_package(descriptor, directory, source_description, unparsed_text) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fig/parser.rb', line 37

def parse_package(descriptor, directory, source_description, unparsed_text)
  version = get_grammar_version(
    descriptor, directory, source_description, unparsed_text
  )

  if version == 0
    return parse_v0(descriptor, directory, source_description, unparsed_text)
  end

  return parse_v1(descriptor, directory, source_description, unparsed_text)
end