Sha256: 5d133fec9b622f591dc5ea17fa5a62a689b14352c8751c426c5d9b0bb1ea4fca

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

require 'fig/logging'
require 'fig/packageerror'
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
  include Fig::Statement

  attr_reader :name, :statements

  def initialize(name, statements)
    @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, &block)
    @statements.each do |statement|
      yield package, statement
      statement.walk_statements_following_package_dependencies(
        repository, package, &block
      )
    end

    return
  end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fig-0.1.57 lib/fig/statement/configuration.rb
fig-0.1.55 lib/fig/statement/configuration.rb
fig-0.1.54 lib/fig/statement/configuration.rb
fig-0.1.53 lib/fig/statement/configuration.rb
fig-0.1.52 lib/fig/statement/configuration.rb