Sha256: b822b4da7df0049712e6ca954defbee2ec3081d382ce5446c809507f92d7bcfb

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

require 'yaml'
require 'mechanize'
require 'parallel'

require 'gis_scraper/version'
require 'gis_scraper/feature_scraper'
require 'gis_scraper/layer'

# stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem
module GisScraper

  @config = {threads: 8} # threads used for scraping
  @valid_keys = @config.keys

  def self.configure(opts = {})
    opts.each { |k,v| @config[k.to_sym] = v if @valid_keys.include? k.to_sym }
  end

  def self.configure_with(path_to_yaml_file)
    begin
      config = YAML::load(IO.read(path_to_yaml_file))
    rescue Errno::ENOENT
      puts "YAML configuration file couldn't be found. Using defaults"
      return
    rescue Psych::SyntaxError
      puts 'YAML configuration file contains invalid syntax. Using defaults'
      return
    end

    configure(config)
  end

  def self.config
    @config
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gis_scraper-0.1.2.pre lib/gis_scraper.rb