Sha256: caef3e495df9fd4b7a97c439ec5217f3e883f2d27327ea0245908a3d4c86a3de

Contents?: true

Size: 820 Bytes

Versions: 7

Compression:

Stored size: 820 Bytes

Contents

class Kubes::Compiler::Strategy
  class Result
    include Kubes::Compiler::Util::YamlDump

    attr_reader :filename
    def initialize(filename, data)
      @filename, @data = filename, data
    end

    def io?
      @data.respond_to?(:read)
    end

    # decorate(:pre) or decorate(:post)
    def decorate!(phase)
      klass = "Kubes::Compiler::Decorator::#{phase.to_s.camelize}".constantize
      results = [@data].flatten
      results.map! do |r|
        klass.new(r).result
      end
    end

    def content
      data = filter_skip(@data)
      return if data.empty?
      result = data.size == 1 ? data.first : data
      yaml_dump(result)
    end

    def skip?
      content.nil?
    end

    def filter_skip(data)
      data.reject do |item|
        item.dig('kubes', 'skip')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kubes-0.8.6 lib/kubes/compiler/strategy/result.rb
kubes-0.8.5 lib/kubes/compiler/strategy/result.rb
kubes-0.8.4 lib/kubes/compiler/strategy/result.rb
kubes-0.8.3 lib/kubes/compiler/strategy/result.rb
kubes-0.8.2 lib/kubes/compiler/strategy/result.rb
kubes-0.8.1 lib/kubes/compiler/strategy/result.rb
kubes-0.8.0 lib/kubes/compiler/strategy/result.rb