Sha256: 4fd706c8bc74bc65794bf4527d186cc35bb4ba8ba8abbf95bc7a9c3560164ee4

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

module Construi

  class Config
    private_class_method :new

    attr_reader :yaml

    def initialize(yaml)
      @yaml = yaml
    end

    def self.load(content)
      new YAML.load(content)
    end

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

    def image
      @yaml['image']
    end

    def env
      return [] if @yaml['environment'].nil?

      @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

1 entries across 1 versions & 1 rubygems

Version Path
construi-0.30.0 lib/construi/config.rb