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.



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

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.



11
12
13
# File 'lib/fig/statement/configuration.rb', line 11

def name
  @name
end

#statementsObject (readonly)

Returns the value of attribute statements.



11
12
13
# File 'lib/fig/statement/configuration.rb', line 11

def statements
  @statements
end

Instance Method Details

#command_statementObject



34
35
36
37
38
# File 'lib/fig/statement/configuration.rb', line 34

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

#deparse_as_version(deparser) ⇒ Object



48
49
50
# File 'lib/fig/statement/configuration.rb', line 48

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

#minimum_grammar_for_emitting_inputObject



52
53
54
# File 'lib/fig/statement/configuration.rb', line 52

def minimum_grammar_for_emitting_input()
  return [0]
end

#minimum_grammar_for_publishingObject



56
57
58
# File 'lib/fig/statement/configuration.rb', line 56

def minimum_grammar_for_publishing()
  return [0]
end

#statement_typeObject



30
31
32
# File 'lib/fig/statement/configuration.rb', line 30

def statement_type()
  return 'config'
end

#walk_statements(&block) ⇒ Object

Block will receive a Statement.



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

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