class Lurker::Json::Reader

Attributes

path[R]

Public Class Methods

new(path) click to toggle source
# File lib/lurker/json/reader.rb, line 6
def initialize(path)
  @path = path
  @attempts_left = 1
end

Public Instance Methods

payload()
Alias for: read
read() click to toggle source
# File lib/lurker/json/reader.rb, line 11
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
Also aliased as: payload