Sha256: 3f3308dc837be060b12858f21059f6e16634d089e212955001acca171a43991a

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

require "rubygems"
require "json"

require File.join(File.dirname(__FILE__), "patches", "hash")

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)
        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
    end

    def read
      @config.symbolize_keys
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recognizer-0.1.6 lib/recognizer/config.rb