Sha256: 81b96a0d0043f8027465951745cba2e90e3c09d061e06b92a821da63adebbe2f

Contents?: true

Size: 979 Bytes

Versions: 10

Compression:

Stored size: 979 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::Layering
    include Kubes::Compiler::Shared::RuntimeHelpers

    def initialize(options={})
      super
      # For ERB scope is in this same Strategy::Erb class
      # For DSL scope is within the each for the Resource classes. IE: kubes/compile/dsl/core/base.rb
      load_runtime_helpers
    end

    def render_result(path)
      return unless File.exist?(path)

      yaml = RenderMePretty.result(path, context: self)
      result = yaml_load(path, yaml)
      # in case of blank yaml doc a Boolean false is returned. else Hash or Array is returned
      %w[Array Hash].include?(result.class.to_s) ? result : {}
    end

    def yaml_load(path, yaml)
      YAML.load(yaml)
    rescue Psych::SyntaxError
      YamlError.new(path, yaml).show
      exit 1
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kubes-0.7.10 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.9 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.8 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.7 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.6 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.5 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.4 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.3 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.2 lib/kubes/compiler/strategy/erb.rb
kubes-0.7.1 lib/kubes/compiler/strategy/erb.rb