Method: Earth.init

Defined in:
lib/earth.rb

.init(*args) ⇒ Object

Earth.init is the gateway to using Earth. It can load all models at once, connect to the database using Rails conventions, and set up the models to pull data from original sources instead of Brighter Planet’s pre-processed data service.

  • :mine_original_sources, if true, will load files necessary to data mine from scratch rather than downloading from data.brighterplanet.com. Note that you must run Earth.init before requiring models in order for this option to work properly.

  • :connect will connect to the database for you

Parameters:

  • load_directive (Symbol)

    use :all to load all models at once (optional)

  • options (Hash)

    load options



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/earth.rb', line 37

def Earth.init(*args)
  options = args.extract_options!

  if options[:connect]
    connect 
    Warnings.check_mysql_ansi_mode
  end

  Earth.mine_original_sources = options[:load_data_miner] || options[:mine_original_sources]
  
  if args.include? :all
    require 'earth/all'
  elsif args.length > 0
    Kernel.warn "Deprecation Warning: `Earth.init :domain` will be removed. Use `require 'earth/domain'` instead"
    args.each do |argh|
      require "earth/#{argh}"
    end
  end
end