Sha256: bbe79f3e95e1930d06ee3c042671d9ed7da79d08749fb0bfa8ffc00ce0e5b9fe

Contents?: true

Size: 1.3 KB

Versions: 26

Compression:

Stored size: 1.3 KB

Contents

require 'fig/statement'
require 'fig/statement/command'
require 'fig/statement/synthetic_raw_text'

module Fig; end

# A grouping of statements within a package.  May not be nested.
#
# Any processing of statements is guaranteed to hit any Overrides first.
class Fig::Statement::Configuration < Fig::Statement
  attr_reader :name, :statements

  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

  def statement_type()
    return 'config'
  end

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

  # Block will receive a Statement.
  def walk_statements(&block)
    @statements.each do |statement|
      yield statement
      statement.walk_statements(&block)
    end
  end

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

  def minimum_grammar_for_emitting_input()
    return [0]
  end

  def minimum_grammar_for_publishing()
    return [0]
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
fig-1.23.0 lib/fig/statement/configuration.rb
fig-1.22.1.beta.1 lib/fig/statement/configuration.rb
fig-1.22.0 lib/fig/statement/configuration.rb
fig-1.21.1.beta.2 lib/fig/statement/configuration.rb
fig-1.21.1.beta.1 lib/fig/statement/configuration.rb
fig-1.21.0 lib/fig/statement/configuration.rb
fig-1.20.1.beta.1 lib/fig/statement/configuration.rb
fig-1.20.0 lib/fig/statement/configuration.rb
fig-1.19.0 lib/fig/statement/configuration.rb
fig-1.18.0 lib/fig/statement/configuration.rb
fig-1.17.0 lib/fig/statement/configuration.rb
fig-1.16.1.beta.1 lib/fig/statement/configuration.rb
fig-1.16.0 lib/fig/statement/configuration.rb
fig-1.15.1.beta.2 lib/fig/statement/configuration.rb
fig-1.15.1.beta.1 lib/fig/statement/configuration.rb
fig-1.15.0 lib/fig/statement/configuration.rb
fig-1.14.0 lib/fig/statement/configuration.rb
fig-1.13.0 lib/fig/statement/configuration.rb
fig-1.12.0 lib/fig/statement/configuration.rb
fig-1.11.0 lib/fig/statement/configuration.rb