Sha256: 1a1ab75f783c50b47ea171da5eb72481437d7fba17dcbfc03d198656a4f7eac1

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

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

module Fig; end

# A grouping of statements within a configuration.  May not be nested.
class Fig::Statement::Configuration < Fig::Statement
  attr_reader :name, :statements

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

    @name = name
    @statements = statements
  end

  def with_name(name)
    Configuration.new(name, statements)
  end

  def command
    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

  # Block will receive a Package and a Statement.
  def walk_statements_following_package_dependencies(repository, package, configuration, &block)
    @statements.each do |statement|
      yield package, self, statement
      statement.walk_statements_following_package_dependencies(
        repository, package, self, &block
      )
    end

    return
  end

  def unparse(indent)
    unparse_statements(indent, "config #{@name}", @statements, 'end')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fig-0.1.62 lib/fig/statement/configuration.rb
fig-0.1.61 lib/fig/statement/configuration.rb
fig-0.1.59 lib/fig/statement/configuration.rb