Sha256: 3bb5cc2f0c5e02c8aad25f552e65345b24e147a6225fe4cb396cc1b16dfae9b5
Contents?: true
Size: 612 Bytes
Versions: 11
Compression:
Stored size: 612 Bytes
Contents
module Lurker module Json class Reader attr_reader :path def initialize(path) @path = path @attempts_left = 1 end def read return YAML.load_file(@path) unless @path.match(/\.erb$/) context = Lurker::ErbSchemaContext.new erb = ERB.new(IO.read @path).result(context.get_binding) YAML.load(erb) rescue Errno::ENOENT raise if @attempts_left.zero? @path = @path.sub(/\#\/?$/, '').sub(/\.json/, '.json.yml') @attempts_left -= 1 retry end alias_method :payload, :read end end end
Version data entries
11 entries across 11 versions & 1 rubygems