Sha256: ab8bebac54a64d9491ecc0eead08739a63ddf83e13d4e7a399833b7719d1c7ff

Contents?: true

Size: 743 Bytes

Versions: 8

Compression:

Stored size: 743 Bytes

Contents

require 'yaml'

module Percheron
  class Config

    extend Forwardable

    def_delegators :contents, :docker

    def initialize(file)
      @file = Pathname.new(file).expand_path
      valid?
      docker_setup!
      self
    end

    def stacks
      contents.stacks.inject({}) do |all, stack_config|
        all[stack_config.name] = stack_config unless all[stack_config.name]
        all
      end
    end

    def file_base_path
      file.dirname
    end

    def valid?
      Validators::Config.new(file).valid?
    end

    private

      attr_reader :file

      def contents
        Hashie::Mash.new(YAML.load_file(file))
      end

      def docker_setup!
        Percheron::DockerConnection.new(self).setup!
      end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
percheron-0.3.2 lib/percheron/config.rb
percheron-0.3.1 lib/percheron/config.rb
percheron-0.3.0 lib/percheron/config.rb
percheron-0.2.4 lib/percheron/config.rb
percheron-0.2.3 lib/percheron/config.rb
percheron-0.2.2 lib/percheron/config.rb
percheron-0.2.1 lib/percheron/config.rb
percheron-0.2.0 lib/percheron/config.rb