Sha256: 6011dbfaf5a2ff77fc1e39ac37e977663a65434e7b8a2143dc7838c2db71bae6

Contents?: true

Size: 770 Bytes

Versions: 7

Compression:

Stored size: 770 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
      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

7 entries across 7 versions & 1 rubygems

Version Path
construi-0.29.0 lib/construi/config.rb
construi-0.27.0 lib/construi/config.rb
construi-0.25.0 lib/construi/config.rb
construi-0.23.0 lib/construi/config.rb
construi-0.21.0 lib/construi/config.rb
construi-0.19.0 lib/construi/config.rb
construi-0.8.0 lib/construi/config.rb