Class: Fig::Statement::Configuration

Inherits:
Fig::Statement show all
Defined in:
lib/fig/statement/configuration.rb

Overview

A grouping of statements within a package. May not be nested.

Any processing of statements is guaranteed to hit any Overrides first.

Constant Summary

Constants inherited from Fig::Statement

ENVIRONMENT_VARIABLE_NAME_REGEX

Instance Attribute Summary collapse

Attributes inherited from Fig::Statement

#column, #line, #source_description

Instance Method Summary collapse

Methods inherited from Fig::Statement

#is_asset?, #is_environment_variable?, position_description, #position_string, #urls

Constructor Details

#initialize(line_column, source_description, name, statements) ⇒ Configuration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fig/statement/configuration.rb', line 15

def initialize(line_column, source_description, name, statements)
  super(line_column, source_description)

  @name = name

  overrides, others = statements.partition do
    |statement| statement.is_a?(Fig::Statement::Override)
  end

  text = []
  if ! overrides.empty?
    text << Fig::Statement::SyntheticRawText.new(nil, nil, "\n")
  end

  @statements = [overrides, text, others].flatten
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/fig/statement/configuration.rb', line 13

def name
  @name
end

#statementsObject (readonly)

Returns the value of attribute statements.



13
14
15
# File 'lib/fig/statement/configuration.rb', line 13

def statements
  @statements
end

Instance Method Details

#command_statementObject



36
37
38
39
40
# File 'lib/fig/statement/configuration.rb', line 36

def command_statement
  return statements.find do
    |statement| statement.is_a?(Fig::Statement::Command)
  end
end

#deparse_as_version(deparser) ⇒ Object



50
51
52
# File 'lib/fig/statement/configuration.rb', line 50

def deparse_as_version(deparser)
  return deparser.configuration(self)
end

#minimum_grammar_for_emitting_inputObject



54
55
56
# File 'lib/fig/statement/configuration.rb', line 54

def minimum_grammar_for_emitting_input()
  return [0]
end

#minimum_grammar_for_publishingObject



58
59
60
# File 'lib/fig/statement/configuration.rb', line 58

def minimum_grammar_for_publishing()
  return [0]
end

#statement_typeObject



32
33
34
# File 'lib/fig/statement/configuration.rb', line 32

def statement_type()
  return 'config'
end

#walk_statements(&block) ⇒ Object

Block will receive a Statement.



43
44
45
46
47
48
# File 'lib/fig/statement/configuration.rb', line 43

def walk_statements(&block)
  @statements.each do |statement|
    yield statement
    statement.walk_statements(&block)
  end
end