geokit-rails3-1beta 0.2.0.beta1 → 0.3.1.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. data/CONFIG.markdown +67 -0
  2. data/Gemfile +3 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.markdown +653 -0
  5. data/Rakefile +17 -0
  6. data/geokit-rails3-1beta.gemspec +31 -0
  7. data/lib/geokit-rails3-1beta.rb +10 -0
  8. data/lib/{geokit-rails3 → geokit-rails3-1beta}/acts_as_mappable.old.rb +0 -0
  9. data/lib/{geokit-rails3 → geokit-rails3-1beta}/acts_as_mappable.rb +0 -0
  10. data/lib/{geokit-rails3 → geokit-rails3-1beta}/adapters/abstract.rb +0 -0
  11. data/lib/{geokit-rails3 → geokit-rails3-1beta}/adapters/mysql.rb +0 -0
  12. data/lib/{geokit-rails3 → geokit-rails3-1beta}/adapters/mysql2.rb +0 -0
  13. data/lib/{geokit-rails3 → geokit-rails3-1beta}/adapters/postgresql.rb +0 -0
  14. data/lib/{geokit-rails3 → geokit-rails3-1beta}/adapters/sqlserver.rb +0 -0
  15. data/lib/{geokit-rails3 → geokit-rails3-1beta}/core_extensions.rb +0 -0
  16. data/lib/{geokit-rails3 → geokit-rails3-1beta}/defaults.rb +0 -0
  17. data/lib/{geokit-rails3 → geokit-rails3-1beta}/geocoder_control.rb +0 -0
  18. data/lib/{geokit-rails3 → geokit-rails3-1beta}/ip_geocode_lookup.rb +0 -0
  19. data/lib/{geokit-rails3 → geokit-rails3-1beta}/railtie.rb +3 -3
  20. data/lib/geokit-rails3-1beta/version.rb +3 -0
  21. metadata +26 -69
  22. data/lib/geokit-rails3.rb +0 -10
  23. data/lib/geokit-rails3/version.rb +0 -3
  24. data/test/acts_as_mappable_test.rb +0 -420
  25. data/test/boot.rb +0 -32
  26. data/test/database.yml +0 -20
  27. data/test/fixtures/companies.yml +0 -7
  28. data/test/fixtures/custom_locations.yml +0 -54
  29. data/test/fixtures/locations.yml +0 -54
  30. data/test/fixtures/mock_addresses.yml +0 -17
  31. data/test/fixtures/mock_families.yml +0 -2
  32. data/test/fixtures/mock_houses.yml +0 -9
  33. data/test/fixtures/mock_organizations.yml +0 -5
  34. data/test/fixtures/mock_people.yml +0 -5
  35. data/test/fixtures/stores.yml +0 -0
  36. data/test/ip_geocode_lookup_test.disabled.rb +0 -82
  37. data/test/models/company.rb +0 -3
  38. data/test/models/custom_location.rb +0 -12
  39. data/test/models/location.rb +0 -4
  40. data/test/models/mock_address.rb +0 -4
  41. data/test/models/mock_family.rb +0 -3
  42. data/test/models/mock_house.rb +0 -3
  43. data/test/models/mock_organization.rb +0 -4
  44. data/test/models/mock_person.rb +0 -4
  45. data/test/models/store.rb +0 -3
  46. data/test/schema.rb +0 -60
  47. data/test/tasks.rake +0 -38
  48. data/test/test_helper.rb +0 -23
@@ -1,32 +0,0 @@
1
- require 'pathname'
2
-
3
- require 'test/unit'
4
- require 'active_support/test_case'
5
-
6
- require 'active_record'
7
- require 'active_record/test_case'
8
- require 'active_record/fixtures'
9
-
10
- require 'action_controller'
11
- # require 'action_dispatch'
12
- # require 'action_dispatch/testing/test_process'
13
-
14
- pwd = Pathname.new(File.dirname(__FILE__)).expand_path
15
-
16
- PLUGIN_ROOT = pwd + '..'
17
- ADAPTER = ENV['DB'] || 'mysql'
18
-
19
- $LOAD_PATH << (PLUGIN_ROOT + 'lib')
20
- $LOAD_PATH << (PLUGIN_ROOT + 'test/models')
21
-
22
- config_file = PLUGIN_ROOT + 'test/database.yml'
23
- db_config = YAML::load(IO.read(config_file))
24
- logger_file = PLUGIN_ROOT + "test/#{ADAPTER}-debug.log"
25
- schema_file = PLUGIN_ROOT + 'test/schema.rb'
26
-
27
- ActiveRecord::Base.configurations = db_config
28
- ActiveRecord::Base.logger = Logger.new(logger_file)
29
- ActiveRecord::Base.establish_connection(db_config[ADAPTER])
30
-
31
- ActiveRecord::Migration.verbose = false
32
- load schema_file
@@ -1,20 +0,0 @@
1
- baes: &base
2
- host: localhost
3
- username: tests
4
- password:
5
-
6
- mysql:
7
- adapter: mysql
8
- database: geokit_rails_tests
9
- <<: *base
10
-
11
- postgresql:
12
- adapter: postgresql
13
- database: geokit_rails_tests
14
- <<: *base
15
-
16
- sqlserver:
17
- adapter: sqlserver
18
- mode: ODBC
19
- dsn: geokit_rails_tests
20
- username: tests
@@ -1,7 +0,0 @@
1
- starbucks:
2
- id: 1
3
- name: Starbucks
4
-
5
- barnes_and_noble:
6
- id: 2
7
- name: Barnes & Noble
@@ -1,54 +0,0 @@
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
@@ -1,54 +0,0 @@
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
@@ -1,17 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- my_family:
2
- mock_house: my_house
@@ -1,9 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- starbucks:
2
- name: Starbucks
3
-
4
- barnes_and_noble:
5
- name: Barnes & Noble
@@ -1,5 +0,0 @@
1
- father:
2
- mock_family: my_family
3
-
4
- mother:
5
- mock_family: my_family
File without changes
@@ -1,82 +0,0 @@
1
- require 'test_helper'
2
-
3
- module TestApp
4
- class Application < Rails::Application
5
- end
6
- end
7
-
8
- TestApp::Application.routes.draw do
9
- match ':controller(/:action(/:id(.:format)))'
10
- end
11
-
12
- class LocationAwareController < ActionController::Base #:nodoc: all
13
- geocode_ip_address
14
-
15
- def index
16
- render :nothing => true
17
- end
18
-
19
- def rescue_action(e) raise e end;
20
- end
21
-
22
- class ActionController::TestRequest #:nodoc: all
23
- attr_accessor :remote_ip
24
- end
25
-
26
- class IpGeocodeLookupTest < ActionController::TestCase
27
- tests LocationAwareController
28
-
29
- def setup
30
- @success = GeoKit::GeoLoc.new
31
- @success.provider = "hostip"
32
- @success.lat = 41.7696
33
- @success.lng = -88.4588
34
- @success.city = "Sugar Grove"
35
- @success.state = "IL"
36
- @success.country_code = "US"
37
- @success.success = true
38
-
39
- @failure = GeoKit::GeoLoc.new
40
- @failure.provider = "hostip"
41
- @failure.city = "(Private Address)"
42
- @failure.success = false
43
- end
44
-
45
- def test_no_location_in_cookie_or_session
46
- Geokit::Geocoders::MultiGeocoder.expects(:geocode).with("good ip").returns(@success)
47
- @request.remote_ip = "good ip"
48
- get :index
49
- verify
50
- end
51
-
52
- def test_location_in_cookie
53
- @request.remote_ip = "good ip"
54
- @request.cookies['geo_location'] = @success.to_yaml
55
- get :index
56
- verify
57
- end
58
-
59
- def test_location_in_session
60
- @request.remote_ip = "good ip"
61
- @request.session[:geo_location] = @success
62
- @request.cookies['geo_location'] = CGI::Cookie.new('geo_location', @success.to_yaml)
63
- get :index
64
- verify
65
- end
66
-
67
- def test_ip_not_located
68
- Geokit::Geocoders::MultiGeocoder.expects(:geocode).with("bad ip").returns(@failure)
69
- @request.remote_ip = "bad ip"
70
- get :index
71
- assert_nil @request.session[:geo_location]
72
- end
73
-
74
- private
75
-
76
- def verify
77
- assert_response :success
78
- assert_equal @success, @request.session[:geo_location]
79
- assert_not_nil cookies['geo_location']
80
- assert_equal @success, YAML.load(cookies['geo_location'])
81
- end
82
- end
@@ -1,3 +0,0 @@
1
- class Company < ActiveRecord::Base
2
- has_many :locations
3
- end
@@ -1,12 +0,0 @@
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
@@ -1,4 +0,0 @@
1
- class Location < ActiveRecord::Base
2
- belongs_to :company
3
- acts_as_mappable
4
- end
@@ -1,4 +0,0 @@
1
- class MockAddress < ActiveRecord::Base
2
- belongs_to :addressable, :polymorphic => true
3
- acts_as_mappable
4
- end
@@ -1,3 +0,0 @@
1
- class MockFamily < ActiveRecord::Base
2
- belongs_to :mock_house
3
- end
@@ -1,3 +0,0 @@
1
- class MockHouse < ActiveRecord::Base
2
- acts_as_mappable
3
- end
@@ -1,4 +0,0 @@
1
- class MockOrganization < ActiveRecord::Base
2
- has_one :mock_address, :as => :addressable
3
- acts_as_mappable :through => :mock_address
4
- end
@@ -1,4 +0,0 @@
1
- class MockPerson < ActiveRecord::Base
2
- belongs_to :mock_family
3
- acts_as_mappable :through => { :mock_family => :mock_house }
4
- end
@@ -1,3 +0,0 @@
1
- class Store < ActiveRecord::Base
2
- acts_as_mappable :auto_geocode => true
3
- end
@@ -1,60 +0,0 @@
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
@@ -1,38 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- class EnvTestTask < Rake::TestTask
4
- attr_accessor :env
5
-
6
- def ruby(*args)
7
- env.each { |key, value| ENV[key] = value } if env
8
- super
9
- env.keys.each { |key| ENV.delete(key) } if env
10
- end
11
-
12
- end
13
-
14
- desc 'Test the GeoKit plugin.'
15
- Rake::TestTask.new(:test) do |test|
16
- test.libs << 'lib' << 'test'
17
- test.pattern = 'test/**/test_*.rb'
18
- test.verbose = true
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)
32
-
33
- require 'rcov/rcovtask'
34
- Rcov::RcovTask.new do |test|
35
- test.libs << 'test'
36
- test.pattern = 'test/**/test_*.rb'
37
- test.verbose = true
38
- end