Module: Earth
Overview
The earth module is an interface for establishing a taps server (used to fetch data) and for loading data models from various domains.
Instance Method Summary collapse
- #classes ⇒ Object
- #database_options ⇒ Object
- #domains ⇒ Object
-
#init(*args) ⇒ Object
Earth.init will load any specified domains, any needed ActiveRecord plugins, and will apply each domain model’s schema to the database if the :apply_schemas option is given.
- #root ⇒ Object
- #taps_server ⇒ Object
-
#taps_server=(val) ⇒ Object
taps_server is a URL.
Instance Method Details
#classes ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/earth.rb', line 27 def classes [ AirConditionerUse, Aircraft, AircraftClass, AircraftManufacturer, Airline, Airport, AutomobileFuelType, AutomobileMake, AutomobileMakeFleetYear, AutomobileMakeYear, AutomobileModel, AutomobileModelYear, AutomobileSizeClass, AutomobileVariant, Breed, BreedGender, BusClass, CensusDivision, CensusRegion, ClimateDivision, ClothesMachineUse, Country, DietClass, DishwasherUse, EgridRegion, EgridSubregion, FlightConfiguration, FlightDistanceClass, FlightDomesticity, FlightFuelType, FlightPropulsion, FlightSeatClass, FlightSegment, FlightService, FoodGroup, Gender, PetroleumAdministrationForDefenseDistrict, RailClass, ResidenceAppliance, ResidenceClass, ResidenceFuelPrice, ResidenceFuelType, ResidentialEnergyConsumptionSurveyResponse, Species, State, Urbanity, ZipCode ] end |
#database_options ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/earth.rb', line 111 def if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite' {} else { :options => 'ENGINE=InnoDB default charset=utf8' } end end |
#domains ⇒ Object
83 84 85 |
# File 'lib/earth.rb', line 83 def domains %w{air automobile bus diet fuel locality pet rail residence} end |
#init(*args) ⇒ Object
Earth.init will load any specified domains, any needed ActiveRecord plugins, and will apply each domain model’s schema to the database if the :apply_schemas option is given. See Earth.domains for the list of allowable domains.
Earth.init should be performed after a connection is made to the database and before any domain models are referenced.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/earth.rb', line 94 def init(*args) load_plugins domains = [] = {} args.each do |arg| if arg.is_a?(Hash) = arg else domains << arg end end load_domains(domains, ) load_schemas if [:apply_schemas] end |
#root ⇒ Object
79 80 81 |
# File 'lib/earth.rb', line 79 def root File.join(File.dirname(__FILE__), '..') end |
#taps_server ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/earth.rb', line 14 def taps_server if defined?(@taps_server) @taps_server else @taps_server = nil end end |
#taps_server=(val) ⇒ Object
taps_server is a URL. See the data_miner gem docs
23 24 25 |
# File 'lib/earth.rb', line 23 def taps_server=(val) @taps_server = val end |