Sha256: d4a42b975bc6631adfdbb5031504617aa5555c193c6d46156fb93a9e4cdf0521

Contents?: true

Size: 953 Bytes

Versions: 17

Compression:

Stored size: 953 Bytes

Contents

require "render_me_pretty"

class Kubes::Compiler::Strategy
  class Erb < Base
    extend Kubes::Compiler::Dsl::Core::Fields
    include Kubes::Compiler::Dsl::Core::Helpers
    include Kubes::Compiler::Shared::Helpers
    include Kubes::Compiler::Layering

    def run
      @data = {}

      render_files(pre_layers)
      render(@path) # main resource definition
      render_files(post_layers)

      Result.new(@save_file, @data)
    end

    def render_files(paths)
      paths.each do |path|
        render(path)
      end
    end

    # render and merge
    def render(path)
      result = render_result(path)
      @data.deeper_merge!(result)
    end

    def render_result(path)
      if File.exist?(path)
        yaml = RenderMePretty.result(path, context: self)
        result = YAML.load(yaml)
        result.is_a?(Hash) ? result : {} # in case of blank yaml doc a Boolean false is returned
      else
        {}
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
kubes-0.4.3 lib/kubes/compiler/strategy/erb.rb
kubes-0.4.2 lib/kubes/compiler/strategy/erb.rb
kubes-0.4.1 lib/kubes/compiler/strategy/erb.rb
kubes-0.4.0 lib/kubes/compiler/strategy/erb.rb
kubes-0.3.5 lib/kubes/compiler/strategy/erb.rb
kubes-0.3.4 lib/kubes/compiler/strategy/erb.rb
kubes-0.3.3 lib/kubes/compiler/strategy/erb.rb
kubes-0.3.2 lib/kubes/compiler/strategy/erb.rb
kubes-0.3.1 lib/kubes/compiler/strategy/erb.rb
kubes-0.3.0 lib/kubes/compiler/strategy/erb.rb
kubes-0.2.6 lib/kubes/compiler/strategy/erb.rb
kubes-0.2.5 lib/kubes/compiler/strategy/erb.rb
kubes-0.2.4 lib/kubes/compiler/strategy/erb.rb
kubes-0.2.3 lib/kubes/compiler/strategy/erb.rb
kubes-0.2.2 lib/kubes/compiler/strategy/erb.rb
kubes-0.2.1 lib/kubes/compiler/strategy/erb.rb
kubes-0.2.0 lib/kubes/compiler/strategy/erb.rb