Sha256: 6c0f97e5c7504dcfd460aa67120779bffc529af92eeaedf21ff3d353ab1edf33

Contents?: true

Size: 724 Bytes

Versions: 2

Compression:

Stored size: 724 Bytes

Contents

module Construi

  class Config
    private_class_method :new

    attr_reader :yaml

    def initialize(yaml)
      @yaml = yaml
    end

    def self.load(path)
      new(YAML.load_file(path))
    end

    def image
      @yaml['image']
    end

    def env
      @yaml['environment'].reduce([]) do |acc, e|
        key = e.partition('=').first
        value = e.partition('=').last

        value = ENV[key] if value.empty?

        acc << "#{key}=#{value}" unless value.nil? or value.empty?
        acc
      end
    end

    def target(target)
      Target.new(@yaml['targets'][target])
    end
  end

  class Target
    def initialize(yaml)
      @yaml = yaml
    end

    def commands
      @yaml
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
construi-0.7.0 lib/construi/config.rb
construi-0.6.0 lib/construi/config.rb