earth 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/.rvmrc +8 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE +20 -0
  6. data/README.markdown +38 -0
  7. data/Rakefile +71 -0
  8. data/VERSION +1 -0
  9. data/earth.gemspec +265 -0
  10. data/lib/earth.rb +169 -0
  11. data/lib/earth/air.rb +13 -0
  12. data/lib/earth/air/aircraft.rb +32 -0
  13. data/lib/earth/air/aircraft/data_miner.rb +171 -0
  14. data/lib/earth/air/aircraft_class.rb +10 -0
  15. data/lib/earth/air/aircraft_class/data_miner.rb +42 -0
  16. data/lib/earth/air/aircraft_manufacturer.rb +9 -0
  17. data/lib/earth/air/aircraft_manufacturer/data_miner.rb +20 -0
  18. data/lib/earth/air/airline.rb +16 -0
  19. data/lib/earth/air/airline/data_miner.rb +57 -0
  20. data/lib/earth/air/airport.rb +44 -0
  21. data/lib/earth/air/airport/data_miner.rb +80 -0
  22. data/lib/earth/air/data_miner.rb +15 -0
  23. data/lib/earth/air/flight_configuration.rb +18 -0
  24. data/lib/earth/air/flight_configuration/data_miner.rb +4 -0
  25. data/lib/earth/air/flight_distance_class.rb +7 -0
  26. data/lib/earth/air/flight_distance_class/data_miner.rb +16 -0
  27. data/lib/earth/air/flight_domesticity.rb +6 -0
  28. data/lib/earth/air/flight_domesticity/data_miner.rb +57 -0
  29. data/lib/earth/air/flight_fuel_type.rb +17 -0
  30. data/lib/earth/air/flight_fuel_type/data_miner.rb +4 -0
  31. data/lib/earth/air/flight_propulsion.rb +18 -0
  32. data/lib/earth/air/flight_propulsion/data_miner.rb +4 -0
  33. data/lib/earth/air/flight_seat_class.rb +12 -0
  34. data/lib/earth/air/flight_seat_class/data_miner.rb +36 -0
  35. data/lib/earth/air/flight_segment.rb +38 -0
  36. data/lib/earth/air/flight_segment/data_miner.rb +334 -0
  37. data/lib/earth/air/flight_service.rb +18 -0
  38. data/lib/earth/air/flight_service/data_miner.rb +4 -0
  39. data/lib/earth/all.rb +10 -0
  40. data/lib/earth/automobile.rb +8 -0
  41. data/lib/earth/automobile/automobile_fuel_type.rb +18 -0
  42. data/lib/earth/automobile/automobile_fuel_type/data_miner.rb +45 -0
  43. data/lib/earth/automobile/automobile_make.rb +14 -0
  44. data/lib/earth/automobile/automobile_make/data_miner.rb +68 -0
  45. data/lib/earth/automobile/automobile_make_fleet_year.rb +15 -0
  46. data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +29 -0
  47. data/lib/earth/automobile/automobile_make_year.rb +14 -0
  48. data/lib/earth/automobile/automobile_make_year/data_miner.rb +45 -0
  49. data/lib/earth/automobile/automobile_model.rb +14 -0
  50. data/lib/earth/automobile/automobile_model/data_miner.rb +38 -0
  51. data/lib/earth/automobile/automobile_model_year.rb +15 -0
  52. data/lib/earth/automobile/automobile_model_year/data_miner.rb +51 -0
  53. data/lib/earth/automobile/automobile_size_class.rb +14 -0
  54. data/lib/earth/automobile/automobile_size_class/data_miner.rb +43 -0
  55. data/lib/earth/automobile/automobile_variant.rb +17 -0
  56. data/lib/earth/automobile/automobile_variant/data_miner.rb +464 -0
  57. data/lib/earth/automobile/data_miner.rb +8 -0
  58. data/lib/earth/bus.rb +1 -0
  59. data/lib/earth/bus/bus_class.rb +19 -0
  60. data/lib/earth/bus/bus_class/data_miner.rb +41 -0
  61. data/lib/earth/bus/data_miner.rb +1 -0
  62. data/lib/earth/conversions_ext.rb +45 -0
  63. data/lib/earth/data_miner.rb +10 -0
  64. data/lib/earth/diet.rb +2 -0
  65. data/lib/earth/diet/data_miner.rb +2 -0
  66. data/lib/earth/diet/diet_class.rb +15 -0
  67. data/lib/earth/diet/diet_class/data_miner.rb +36 -0
  68. data/lib/earth/diet/food_group.rb +17 -0
  69. data/lib/earth/diet/food_group/data_miner.rb +26 -0
  70. data/lib/earth/fuel.rb +2 -0
  71. data/lib/earth/fuel/data_miner.rb +2 -0
  72. data/lib/earth/fuel/fuel_price.rb +13 -0
  73. data/lib/earth/fuel/fuel_price/data_miner.rb +20 -0
  74. data/lib/earth/fuel/fuel_type.rb +18 -0
  75. data/lib/earth/fuel/fuel_type/data_miner.rb +37 -0
  76. data/lib/earth/industry.rb +10 -0
  77. data/lib/earth/industry/data_miner.rb +2 -0
  78. data/lib/earth/industry/industries_product_lines.rb +6 -0
  79. data/lib/earth/industry/industries_sectors.rb +6 -0
  80. data/lib/earth/industry/industry.rb +12 -0
  81. data/lib/earth/industry/industry/data_miner.rb +21 -0
  82. data/lib/earth/industry/merchant.rb +5 -0
  83. data/lib/earth/industry/merchant_categories_industries.rb +8 -0
  84. data/lib/earth/industry/merchant_category.rb +6 -0
  85. data/lib/earth/industry/product_line.rb +10 -0
  86. data/lib/earth/industry/product_line/data_miner.rb +18 -0
  87. data/lib/earth/industry/product_lines_sectors.rb +6 -0
  88. data/lib/earth/industry/sector.rb +3 -0
  89. data/lib/earth/inflectors.rb +9 -0
  90. data/lib/earth/locality.rb +10 -0
  91. data/lib/earth/locality/census_division.rb +17 -0
  92. data/lib/earth/locality/census_division/data_miner.rb +21 -0
  93. data/lib/earth/locality/census_region.rb +13 -0
  94. data/lib/earth/locality/census_region/data_miner.rb +17 -0
  95. data/lib/earth/locality/climate_division.rb +17 -0
  96. data/lib/earth/locality/climate_division/data_miner.rb +20 -0
  97. data/lib/earth/locality/country.rb +13 -0
  98. data/lib/earth/locality/country/data_miner.rb +19 -0
  99. data/lib/earth/locality/data_miner.rb +10 -0
  100. data/lib/earth/locality/egrid_region.rb +15 -0
  101. data/lib/earth/locality/egrid_region/data_miner.rb +19 -0
  102. data/lib/earth/locality/egrid_subregion.rb +16 -0
  103. data/lib/earth/locality/egrid_subregion/data_miner.rb +26 -0
  104. data/lib/earth/locality/petroleum_administration_for_defense_district.rb +13 -0
  105. data/lib/earth/locality/petroleum_administration_for_defense_district/data_miner.rb +21 -0
  106. data/lib/earth/locality/state.rb +22 -0
  107. data/lib/earth/locality/state/data_miner.rb +37 -0
  108. data/lib/earth/locality/urbanity.rb +20 -0
  109. data/lib/earth/locality/urbanity/data_miner.rb +4 -0
  110. data/lib/earth/locality/zip_code.rb +29 -0
  111. data/lib/earth/locality/zip_code/data_miner.rb +36 -0
  112. data/lib/earth/pet.rb +4 -0
  113. data/lib/earth/pet/breed.rb +15 -0
  114. data/lib/earth/pet/breed/data_miner.rb +25 -0
  115. data/lib/earth/pet/breed_gender.rb +14 -0
  116. data/lib/earth/pet/breed_gender/data_miner.rb +21 -0
  117. data/lib/earth/pet/data_miner.rb +4 -0
  118. data/lib/earth/pet/gender.rb +10 -0
  119. data/lib/earth/pet/gender/data_miner.rb +13 -0
  120. data/lib/earth/pet/species.rb +40 -0
  121. data/lib/earth/pet/species/data_miner.rb +42 -0
  122. data/lib/earth/rail.rb +1 -0
  123. data/lib/earth/rail/data_miner.rb +1 -0
  124. data/lib/earth/rail/rail_class.rb +16 -0
  125. data/lib/earth/rail/rail_class/data_miner.rb +36 -0
  126. data/lib/earth/residence.rb +8 -0
  127. data/lib/earth/residence/air_conditioner_use.rb +30 -0
  128. data/lib/earth/residence/air_conditioner_use/data_miner.rb +4 -0
  129. data/lib/earth/residence/clothes_machine_use.rb +33 -0
  130. data/lib/earth/residence/clothes_machine_use/data_miner.rb +4 -0
  131. data/lib/earth/residence/data_miner.rb +8 -0
  132. data/lib/earth/residence/dishwasher_use.rb +33 -0
  133. data/lib/earth/residence/dishwasher_use/data_miner.rb +4 -0
  134. data/lib/earth/residence/residence_appliance.rb +7 -0
  135. data/lib/earth/residence/residence_appliance/data_miner.rb +19 -0
  136. data/lib/earth/residence/residence_class.rb +26 -0
  137. data/lib/earth/residence/residence_class/data_miner.rb +4 -0
  138. data/lib/earth/residence/residence_fuel_price.rb +18 -0
  139. data/lib/earth/residence/residence_fuel_price/data_miner.rb +200 -0
  140. data/lib/earth/residence/residence_fuel_type.rb +33 -0
  141. data/lib/earth/residence/residence_fuel_type/data_miner.rb +18 -0
  142. data/lib/earth/residence/residential_energy_consumption_survey_response.rb +67 -0
  143. data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +264 -0
  144. data/lib/earth/schema.rb +8 -0
  145. data/spec/lib/earth_spec.rb +25 -0
  146. data/spec/spec_helper.rb +11 -0
  147. data/vendor/geokit-rails/CHANGELOG.rdoc +46 -0
  148. data/vendor/geokit-rails/MIT-LICENSE +20 -0
  149. data/vendor/geokit-rails/README.markdown +561 -0
  150. data/vendor/geokit-rails/Rakefile +18 -0
  151. data/vendor/geokit-rails/about.yml +9 -0
  152. data/vendor/geokit-rails/assets/api_keys_template +61 -0
  153. data/vendor/geokit-rails/init.rb +1 -0
  154. data/vendor/geokit-rails/install.rb +14 -0
  155. data/vendor/geokit-rails/lib/geokit-rails.rb +24 -0
  156. data/vendor/geokit-rails/lib/geokit-rails/acts_as_mappable.rb +456 -0
  157. data/vendor/geokit-rails/lib/geokit-rails/adapters/abstract.rb +31 -0
  158. data/vendor/geokit-rails/lib/geokit-rails/adapters/mysql.rb +22 -0
  159. data/vendor/geokit-rails/lib/geokit-rails/adapters/postgresql.rb +22 -0
  160. data/vendor/geokit-rails/lib/geokit-rails/adapters/sqlserver.rb +43 -0
  161. data/vendor/geokit-rails/lib/geokit-rails/defaults.rb +22 -0
  162. data/vendor/geokit-rails/lib/geokit-rails/geocoder_control.rb +16 -0
  163. data/vendor/geokit-rails/lib/geokit-rails/ip_geocode_lookup.rb +46 -0
  164. data/vendor/geokit-rails/test/acts_as_mappable_test.rb +474 -0
  165. data/vendor/geokit-rails/test/boot.rb +25 -0
  166. data/vendor/geokit-rails/test/database.yml +20 -0
  167. data/vendor/geokit-rails/test/fixtures/companies.yml +7 -0
  168. data/vendor/geokit-rails/test/fixtures/custom_locations.yml +54 -0
  169. data/vendor/geokit-rails/test/fixtures/locations.yml +54 -0
  170. data/vendor/geokit-rails/test/fixtures/mock_addresses.yml +17 -0
  171. data/vendor/geokit-rails/test/fixtures/mock_families.yml +2 -0
  172. data/vendor/geokit-rails/test/fixtures/mock_houses.yml +9 -0
  173. data/vendor/geokit-rails/test/fixtures/mock_organizations.yml +5 -0
  174. data/vendor/geokit-rails/test/fixtures/mock_people.yml +5 -0
  175. data/vendor/geokit-rails/test/fixtures/stores.yml +0 -0
  176. data/vendor/geokit-rails/test/ip_geocode_lookup_test.rb +77 -0
  177. data/vendor/geokit-rails/test/models/company.rb +3 -0
  178. data/vendor/geokit-rails/test/models/custom_location.rb +12 -0
  179. data/vendor/geokit-rails/test/models/location.rb +4 -0
  180. data/vendor/geokit-rails/test/models/mock_address.rb +4 -0
  181. data/vendor/geokit-rails/test/models/mock_family.rb +3 -0
  182. data/vendor/geokit-rails/test/models/mock_house.rb +3 -0
  183. data/vendor/geokit-rails/test/models/mock_organization.rb +4 -0
  184. data/vendor/geokit-rails/test/models/mock_person.rb +4 -0
  185. data/vendor/geokit-rails/test/models/store.rb +3 -0
  186. data/vendor/geokit-rails/test/schema.rb +60 -0
  187. data/vendor/geokit-rails/test/tasks.rake +31 -0
  188. data/vendor/geokit-rails/test/test_helper.rb +23 -0
  189. metadata +444 -0
@@ -0,0 +1,25 @@
1
+ require 'active_support'
2
+ require 'active_support/test_case'
3
+
4
+ require 'test/unit'
5
+ require 'test/unit/testcase'
6
+ require 'active_support/testing/setup_and_teardown'
7
+
8
+ require 'active_record'
9
+ require 'active_record/fixtures'
10
+
11
+ require 'action_controller'
12
+ require 'action_controller/test_process'
13
+
14
+ PLUGIN_ROOT = File.join(File.dirname(__FILE__), '..')
15
+ ADAPTER = ENV['DB'] || 'mysql'
16
+
17
+ $LOAD_PATH << File.join(PLUGIN_ROOT, 'lib') << File.join(PLUGIN_ROOT, 'test', 'models')
18
+
19
+ FIXTURES_PATH = File.join(PLUGIN_ROOT, 'test', 'fixtures')
20
+ ActiveRecord::Base.configurations = config = YAML::load(IO.read(File.join(PLUGIN_ROOT, 'test', 'database.yml')))
21
+ ActiveRecord::Base.logger = Logger.new(File.join(PLUGIN_ROOT, 'test', "#{ADAPTER}-debug.log"))
22
+ ActiveRecord::Base.establish_connection(config[ADAPTER])
23
+
24
+ ActiveRecord::Migration.verbose = false
25
+ load File.join(PLUGIN_ROOT, 'test', 'schema.rb')
@@ -0,0 +1,20 @@
1
+ baes: &base
2
+ host: localhost
3
+ username: root
4
+ password:
5
+
6
+ mysql:
7
+ adapter: mysql
8
+ database: geokit_plugin_test
9
+ <<: *base
10
+
11
+ postgresql:
12
+ adapter: postgresql
13
+ database: geokit_plugin_test
14
+ <<: *base
15
+
16
+ sqlserver:
17
+ adapter: sqlserver
18
+ mode: ODBC
19
+ dsn: geokit_tests
20
+ username: ruby
@@ -0,0 +1,7 @@
1
+ starbucks:
2
+ id: 1
3
+ name: Starbucks
4
+
5
+ barnes_and_noble:
6
+ id: 2
7
+ name: Barnes & Noble
@@ -0,0 +1,54 @@
1
+ a:
2
+ id: 1
3
+ company_id: 1
4
+ street: 7979 N MacArthur Blvd
5
+ city: Irving
6
+ state: TX
7
+ postal_code: 75063
8
+ latitude: 32.918593
9
+ longitude: -96.958444
10
+ b:
11
+ id: 2
12
+ company_id: 1
13
+ street: 7750 N Macarthur Blvd # 160
14
+ city: Irving
15
+ state: TX
16
+ postal_code: 75063
17
+ latitude: 32.914144
18
+ longitude: -96.958444
19
+ c:
20
+ id: 3
21
+ company_id: 1
22
+ street: 5904 N Macarthur Blvd # 160
23
+ city: Irving
24
+ state: TX
25
+ postal_code: 75039
26
+ latitude: 32.895155
27
+ longitude: -96.958444
28
+ d:
29
+ id: 4
30
+ company_id: 1
31
+ street: 817 S Macarthur Blvd # 145
32
+ city: Coppell
33
+ state: TX
34
+ postal_code: 75019
35
+ latitude: 32.951613
36
+ longitude: -96.958444
37
+ e:
38
+ id: 5
39
+ company_id: 1
40
+ street: 106 N Denton Tap Rd # 350
41
+ city: Coppell
42
+ state: TX
43
+ postal_code: 75019
44
+ latitude: 32.969527
45
+ longitude: -96.990159
46
+ f:
47
+ id: 6
48
+ company_id: 2
49
+ street: 5904 N Macarthur Blvd # 160
50
+ city: Irving
51
+ state: TX
52
+ postal_code: 75039
53
+ latitude: 32.895155
54
+ longitude: -96.958444
@@ -0,0 +1,54 @@
1
+ a:
2
+ id: 1
3
+ company_id: 1
4
+ street: 7979 N MacArthur Blvd
5
+ city: Irving
6
+ state: TX
7
+ postal_code: 75063
8
+ lat: 32.918593
9
+ lng: -96.958444
10
+ b:
11
+ id: 2
12
+ company_id: 1
13
+ street: 7750 N Macarthur Blvd # 160
14
+ city: Irving
15
+ state: TX
16
+ postal_code: 75063
17
+ lat: 32.914144
18
+ lng: -96.958444
19
+ c:
20
+ id: 3
21
+ company_id: 1
22
+ street: 5904 N Macarthur Blvd # 160
23
+ city: Irving
24
+ state: TX
25
+ postal_code: 75039
26
+ lat: 32.895155
27
+ lng: -96.958444
28
+ d:
29
+ id: 4
30
+ company_id: 1
31
+ street: 817 S Macarthur Blvd # 145
32
+ city: Coppell
33
+ state: TX
34
+ postal_code: 75019
35
+ lat: 32.951613
36
+ lng: -96.958444
37
+ e:
38
+ id: 5
39
+ company_id: 1
40
+ street: 106 N Denton Tap Rd # 350
41
+ city: Coppell
42
+ state: TX
43
+ postal_code: 75019
44
+ lat: 32.969527
45
+ lng: -96.990159
46
+ f:
47
+ id: 6
48
+ company_id: 2
49
+ street: 5904 N Macarthur Blvd # 160
50
+ city: Irving
51
+ state: TX
52
+ postal_code: 75039
53
+ lat: 32.895155
54
+ lng: -96.958444
@@ -0,0 +1,17 @@
1
+ address_starbucks:
2
+ addressable: starbucks (MockOrganization)
3
+ street: 106 N Denton Tap Rd # 350
4
+ city: Coppell
5
+ state: TX
6
+ postal_code: 75019
7
+ lat: 32.969527
8
+ lng: -96.990159
9
+
10
+ address_barnes_and_noble:
11
+ addressable: barnes_and_noble (MockOrganization)
12
+ street: 5904 N Macarthur Blvd # 160
13
+ city: Irving
14
+ state: TX
15
+ postal_code: 75039
16
+ lat: 32.895155
17
+ lng: -96.958444
@@ -0,0 +1,2 @@
1
+ my_family:
2
+ mock_house: my_house
@@ -0,0 +1,9 @@
1
+ another_house:
2
+ address: 106 N Denton Tap Rd # 350
3
+ lat: 32.969527
4
+ lng: -96.990159
5
+
6
+ my_house:
7
+ address: 5904 N Macarthur Blvd # 160
8
+ lat: 32.895155
9
+ lng: -96.958444
@@ -0,0 +1,5 @@
1
+ starbucks:
2
+ name: Starbucks
3
+
4
+ barnes_and_noble:
5
+ name: Barnes & Noble
@@ -0,0 +1,5 @@
1
+ father:
2
+ mock_family: my_family
3
+
4
+ mother:
5
+ mock_family: my_family
File without changes
@@ -0,0 +1,77 @@
1
+ require 'test_helper'
2
+
3
+ ActionController::Routing::Routes.draw do |map|
4
+ map.connect ':controller/:action/:id'
5
+ end
6
+
7
+ class LocationAwareController < ActionController::Base #:nodoc: all
8
+ geocode_ip_address
9
+
10
+ def index
11
+ render :nothing => true
12
+ end
13
+
14
+ def rescue_action(e) raise e end;
15
+ end
16
+
17
+ class ActionController::TestRequest #:nodoc: all
18
+ attr_accessor :remote_ip
19
+ end
20
+
21
+ class IpGeocodeLookupTest < ActionController::TestCase
22
+ tests LocationAwareController
23
+
24
+ def setup
25
+ @success = GeoKit::GeoLoc.new
26
+ @success.provider = "hostip"
27
+ @success.lat = 41.7696
28
+ @success.lng = -88.4588
29
+ @success.city = "Sugar Grove"
30
+ @success.state = "IL"
31
+ @success.country_code = "US"
32
+ @success.success = true
33
+
34
+ @failure = GeoKit::GeoLoc.new
35
+ @failure.provider = "hostip"
36
+ @failure.city = "(Private Address)"
37
+ @failure.success = false
38
+ end
39
+
40
+ def test_no_location_in_cookie_or_session
41
+ Geokit::Geocoders::MultiGeocoder.expects(:geocode).with("good ip").returns(@success)
42
+ @request.remote_ip = "good ip"
43
+ get :index
44
+ verify
45
+ end
46
+
47
+ def test_location_in_cookie
48
+ @request.remote_ip = "good ip"
49
+ @request.cookies['geo_location'] = @success.to_yaml
50
+ get :index
51
+ verify
52
+ end
53
+
54
+ def test_location_in_session
55
+ @request.remote_ip = "good ip"
56
+ @request.session[:geo_location] = @success
57
+ @request.cookies['geo_location'] = CGI::Cookie.new('geo_location', @success.to_yaml)
58
+ get :index
59
+ verify
60
+ end
61
+
62
+ def test_ip_not_located
63
+ Geokit::Geocoders::MultiGeocoder.expects(:geocode).with("bad ip").returns(@failure)
64
+ @request.remote_ip = "bad ip"
65
+ get :index
66
+ assert_nil @request.session[:geo_location]
67
+ end
68
+
69
+ private
70
+
71
+ def verify
72
+ assert_response :success
73
+ assert_equal @success, @request.session[:geo_location]
74
+ assert_not_nil cookies['geo_location']
75
+ assert_equal @success, YAML.load(cookies['geo_location'])
76
+ end
77
+ end
@@ -0,0 +1,3 @@
1
+ class Company < ActiveRecord::Base
2
+ has_many :locations
3
+ end
@@ -0,0 +1,12 @@
1
+ class CustomLocation < ActiveRecord::Base
2
+ belongs_to :company
3
+ acts_as_mappable :distance_column_name => 'dist',
4
+ :default_units => :kms,
5
+ :default_formula => :flat,
6
+ :lat_column_name => 'latitude',
7
+ :lng_column_name => 'longitude'
8
+
9
+ def to_s
10
+ "lat: #{latitude} lng: #{longitude} dist: #{dist}"
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ class Location < ActiveRecord::Base
2
+ belongs_to :company
3
+ acts_as_mappable
4
+ end
@@ -0,0 +1,4 @@
1
+ class MockAddress < ActiveRecord::Base
2
+ belongs_to :addressable, :polymorphic => true
3
+ acts_as_mappable
4
+ end
@@ -0,0 +1,3 @@
1
+ class MockFamily < ActiveRecord::Base
2
+ belongs_to :mock_house
3
+ end
@@ -0,0 +1,3 @@
1
+ class MockHouse < ActiveRecord::Base
2
+ acts_as_mappable
3
+ end
@@ -0,0 +1,4 @@
1
+ class MockOrganization < ActiveRecord::Base
2
+ has_one :mock_address, :as => :addressable
3
+ acts_as_mappable :through => :mock_address
4
+ end
@@ -0,0 +1,4 @@
1
+ class MockPerson < ActiveRecord::Base
2
+ belongs_to :mock_family
3
+ acts_as_mappable :through => { :mock_family => :mock_house }
4
+ end
@@ -0,0 +1,3 @@
1
+ class Store < ActiveRecord::Base
2
+ acts_as_mappable :auto_geocode => true
3
+ end
@@ -0,0 +1,60 @@
1
+ ActiveRecord::Schema.define(:version => 0) do
2
+ create_table :companies, :force => true do |t|
3
+ t.column :name, :string
4
+ end
5
+
6
+ create_table :locations, :force => true do |t|
7
+ t.column :company_id, :integer, :default => 0, :null => false
8
+ t.column :street, :string, :limit => 60
9
+ t.column :city, :string, :limit => 60
10
+ t.column :state, :string, :limit => 2
11
+ t.column :postal_code, :string, :limit => 16
12
+ t.column :lat, :decimal, :precision => 15, :scale => 10
13
+ t.column :lng, :decimal, :precision => 15, :scale => 10
14
+ end
15
+
16
+ create_table :custom_locations, :force => true do |t|
17
+ t.column :company_id, :integer, :default => 0, :null => false
18
+ t.column :street, :string, :limit => 60
19
+ t.column :city, :string, :limit => 60
20
+ t.column :state, :string, :limit => 2
21
+ t.column :postal_code, :string, :limit => 16
22
+ t.column :latitude, :decimal, :precision => 15, :scale => 10
23
+ t.column :longitude, :decimal, :precision => 15, :scale => 10
24
+ end
25
+
26
+ create_table :stores, :force=> true do |t|
27
+ t.column :address, :string
28
+ t.column :lat, :decimal, :precision => 15, :scale => 10
29
+ t.column :lng, :decimal, :precision => 15, :scale => 10
30
+ end
31
+
32
+ create_table :mock_organizations, :force => true do |t|
33
+ t.column :name, :string
34
+ end
35
+
36
+ create_table :mock_addresses, :force => true do |t|
37
+ t.column :addressable_id, :integer, :null => false
38
+ t.column :addressable_type, :string, :null => false
39
+ t.column :street, :string, :limit => 60
40
+ t.column :city, :string, :limit => 60
41
+ t.column :state, :string, :limit => 2
42
+ t.column :postal_code, :string, :limit => 16
43
+ t.column :lat, :decimal, :precision => 15, :scale => 10
44
+ t.column :lng, :decimal, :precision => 15, :scale => 10
45
+ end
46
+
47
+ create_table :mock_houses, :force=> true do |t|
48
+ t.column :address, :string
49
+ t.column :lat, :decimal, :precision => 15, :scale => 10
50
+ t.column :lng, :decimal, :precision => 15, :scale => 10
51
+ end
52
+
53
+ create_table :mock_families, :force => true do |t|
54
+ t.belongs_to :mock_house
55
+ end
56
+
57
+ create_table :mock_people, :force => true do |t|
58
+ t.belongs_to :mock_family
59
+ end
60
+ end
@@ -0,0 +1,31 @@
1
+ require 'rake/testtask'
2
+
3
+ desc 'Test the GeoKit plugin.'
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.pattern = 'test/**/*_test.rb'
6
+ t.verbose = true
7
+ t.libs << 'test'
8
+ end
9
+
10
+ class EnvTestTask < Rake::TestTask
11
+ attr_accessor :env
12
+
13
+ def ruby(*args)
14
+ env.each { |key, value| ENV[key] = value } if env
15
+ super
16
+ env.keys.each { |key| ENV.delete(key) } if env
17
+ end
18
+
19
+ end
20
+
21
+ %w(mysql postgresql sqlserver).each do |configuration|
22
+ EnvTestTask.new("test_#{configuration}") do |t|
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = true
25
+ t.env = { 'DB' => configuration }
26
+ t.libs << 'test'
27
+ end
28
+ end
29
+
30
+ desc 'Test available databases.'
31
+ task :test_databases => %w(test_mysql test_postgresql test_sqlserver)