Sha256: 38f49f20b03861acbd8152e9ff8d9a2100d4df40f08bb08d38206c4c61ce3190

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

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::CustomHelpers
    include Kubes::Compiler::Shared::CustomVariables
    include Kubes::Compiler::Shared::Helpers
    include Kubes::Compiler::Shared::PluginHelpers

    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_plugin_helpers
      load_custom_variables
      load_custom_helpers
    end

    def render_result(path)
      if File.exist?(path)
        yaml = RenderMePretty.result(path, context: self)
        result = yaml_load(path, yaml)
        result.is_a?(Hash) ? result : {} # in case of blank yaml doc a Boolean false is returned
      else
        {}
      end
    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

9 entries across 9 versions & 1 rubygems

Version Path
kubes-0.6.8 lib/kubes/compiler/strategy/erb.rb
kubes-0.6.7 lib/kubes/compiler/strategy/erb.rb
kubes-0.6.6 lib/kubes/compiler/strategy/erb.rb
kubes-0.6.5 lib/kubes/compiler/strategy/erb.rb
kubes-0.6.4 lib/kubes/compiler/strategy/erb.rb
kubes-0.6.3 lib/kubes/compiler/strategy/erb.rb
kubes-0.6.2 lib/kubes/compiler/strategy/erb.rb
kubes-0.6.1 lib/kubes/compiler/strategy/erb.rb
kubes-0.6.0 lib/kubes/compiler/strategy/erb.rb