Sha256: 31979b255a02fb4b79ec4e087c4cf67fd0cb06efd6b9da933363ae03081ea05a

Contents?: true

Size: 844 Bytes

Versions: 5

Compression:

Stored size: 844 Bytes

Contents

require 'fig/logging'
require 'fig/packageerror'
require 'fig/package/command'
require 'fig/package/statement'

module Fig; end
class Fig::Package; end

# A grouping of statements within a configuration.  May not be nested.
class Fig::Package::Configuration
  include Fig::Package::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::Package::Command)
    end
  end

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

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

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
fig18-0.1.51-i386-mswin32 lib/fig/package/configuration.rb
fig18-0.1.51-i386-mingw32 lib/fig/package/configuration.rb
fig18-0.1.51 lib/fig/package/configuration.rb
fig-0.1.51-java lib/fig/package/configuration.rb
fig-0.1.51 lib/fig/package/configuration.rb