class Endpointer::ResourceParser

Public Instance Methods

parse(resource_config) click to toggle source
# File lib/endpointer/resource_parser.rb, line 6
def parse(resource_config)
  parse_config(resource_config).map do |resource|
    Resource.new(resource["id"], resource["method"].to_sym, resource["url"], resource["headers"], resource["matchers"], resource["substitutions"])
  end
end

Private Instance Methods

parse_config(config) click to toggle source
# File lib/endpointer/resource_parser.rb, line 14
def parse_config(config)
  abort("Error: No config file present") if config.nil?
  begin
    JSON.parse(config)
  rescue JSON::ParserError
    abort("Error: The resource config is invalid")
  end
end