Sha256: e1155a71f66c81881e21875d2b31509a6f6c278c0590b96ce4af22a9d59086b1
Contents?: true
Size: 854 Bytes
Versions: 6
Compression:
Stored size: 854 Bytes
Contents
require "json" module Recognizer class Config def initialize(options={}) unless options[:config_file] raise "Missing config file path" end if File.readable?(options[:config_file]) config_file_contents = File.open(options[:config_file], "r").read begin @config = JSON.parse(config_file_contents, :symbolize_names => true) rescue JSON::ParserError => error raise "Config file must be valid JSON: #{error}" end else raise "Config file does not exist or is not readable: #{options[:config_file]}" end validate end def validate unless @config[:librato][:email] && @config[:librato][:api_key] raise "You must provide a Librato Metrics account email and API key" end end def read @config end end end
Version data entries
6 entries across 6 versions & 1 rubygems