Sha256: 7950ce3a54a779299c4b43c5d72296c8db1ca64fd4c2a1a8cc61161967ef1beb
Contents?: true
Size: 671 Bytes
Versions: 43
Compression:
Stored size: 671 Bytes
Contents
require "json" require "erb" require "fileutils" class ChefDnaParser class << self attr_accessor :dna, :parsed, :file_path, :test_dna def test_dna=(json) @test_dna = json end def load_dna @parsed ||= {} @dna ||= "" if @test_dna @dna = ERB.new(@test_dna).result(binding) else @file_path = ENV["DNA"] || ENV["dna"] || default_dna_path @dna = ERB.new(File.read(file_path)).result(binding) end @parsed = JSON.parse(@dna) end def default_dna_path File.join(rails_root, "chef", "node.json") end def rails_root FileUtils.pwd end end end
Version data entries
43 entries across 43 versions & 1 rubygems