gmaps4rails 1.5.7 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. metadata +6 -386
  3. data/.gitignore +0 -17
  4. data/.travis.yml +0 -10
  5. data/Gemfile +0 -9
  6. data/Gemfile.lock +0 -182
  7. data/Guardfile +0 -24
  8. data/MIT-LICENSE +0 -20
  9. data/README.rdoc +0 -135
  10. data/Rakefile +0 -4
  11. data/app/assets/javascripts/gmaps4rails/gmaps4rails.base.js.coffee +0 -444
  12. data/app/assets/javascripts/gmaps4rails/gmaps4rails.bing.js.coffee +0 -174
  13. data/app/assets/javascripts/gmaps4rails/gmaps4rails.googlemaps.js.coffee +0 -339
  14. data/app/assets/javascripts/gmaps4rails/gmaps4rails.mapquest.js.coffee +0 -145
  15. data/app/assets/javascripts/gmaps4rails/gmaps4rails.openlayers.js.coffee +0 -261
  16. data/app/views/gmaps4rails/_gmaps4rails.html.erb +0 -20
  17. data/gmaps4rails.gemspec +0 -39
  18. data/lib/generators/gmaps4rails/install_generator.rb +0 -48
  19. data/lib/generators/templates/README +0 -2
  20. data/lib/gmaps4rails.rb +0 -26
  21. data/lib/gmaps4rails/acts_as_gmappable.rb +0 -54
  22. data/lib/gmaps4rails/api_wrappers/base_net_methods.rb +0 -40
  23. data/lib/gmaps4rails/api_wrappers/direction.rb +0 -87
  24. data/lib/gmaps4rails/api_wrappers/geocoder.rb +0 -54
  25. data/lib/gmaps4rails/api_wrappers/places.rb +0 -74
  26. data/lib/gmaps4rails/base.rb +0 -119
  27. data/lib/gmaps4rails/extensions/enumerable.rb +0 -14
  28. data/lib/gmaps4rails/extensions/hash.rb +0 -9
  29. data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +0 -33
  30. data/lib/gmaps4rails/js_builder.rb +0 -157
  31. data/lib/gmaps4rails/json_builder.rb +0 -140
  32. data/lib/gmaps4rails/model_handler.rb +0 -101
  33. data/lib/gmaps4rails/version.rb +0 -3
  34. data/lib/gmaps4rails/view_helper.rb +0 -175
  35. data/lib/tasks/gmaps4rails_tasks.rake +0 -4
  36. data/lib/tasks/jasmine.rake +0 -8
  37. data/public/javascripts/gmaps4rails/gmaps4rails.base.js +0 -464
  38. data/public/javascripts/gmaps4rails/gmaps4rails.bing.js +0 -226
  39. data/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js +0 -430
  40. data/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js +0 -178
  41. data/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js +0 -265
  42. data/public/stylesheets/gmaps4rails.css +0 -24
  43. data/spec/dummy/.gitignore +0 -2
  44. data/spec/dummy/.rspec +0 -1
  45. data/spec/dummy/README.rdoc +0 -261
  46. data/spec/dummy/Rakefile +0 -7
  47. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  48. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  49. data/spec/dummy/app/assets/stylesheets/gmaps4rails.css +0 -24
  50. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  51. data/spec/dummy/app/controllers/users_controller.rb +0 -101
  52. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  53. data/spec/dummy/app/mailers/.gitkeep +0 -0
  54. data/spec/dummy/app/models/.gitkeep +0 -0
  55. data/spec/dummy/app/models/place.rb +0 -16
  56. data/spec/dummy/app/models/user.rb +0 -12
  57. data/spec/dummy/app/views/layouts/application.html.erb +0 -16
  58. data/spec/dummy/app/views/users/_form.html.erb +0 -37
  59. data/spec/dummy/app/views/users/_map.html.erb +0 -5
  60. data/spec/dummy/app/views/users/edit.html.erb +0 -6
  61. data/spec/dummy/app/views/users/index.html.erb +0 -260
  62. data/spec/dummy/app/views/users/new.html.erb +0 -5
  63. data/spec/dummy/app/views/users/show.html.erb +0 -30
  64. data/spec/dummy/config.ru +0 -4
  65. data/spec/dummy/config/application.rb +0 -62
  66. data/spec/dummy/config/boot.rb +0 -10
  67. data/spec/dummy/config/database.yml +0 -25
  68. data/spec/dummy/config/environment.rb +0 -5
  69. data/spec/dummy/config/environments/development.rb +0 -37
  70. data/spec/dummy/config/environments/production.rb +0 -67
  71. data/spec/dummy/config/environments/test.rb +0 -37
  72. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  73. data/spec/dummy/config/initializers/gmaps4rails.rb +0 -1
  74. data/spec/dummy/config/initializers/inflections.rb +0 -15
  75. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  76. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  77. data/spec/dummy/config/initializers/session_store.rb +0 -8
  78. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  79. data/spec/dummy/config/locales/en.yml +0 -5
  80. data/spec/dummy/config/routes.rb +0 -60
  81. data/spec/dummy/db/migrate/20120408170155_create_users.rb +0 -16
  82. data/spec/dummy/db/schema.rb +0 -29
  83. data/spec/dummy/lib/assets/.gitkeep +0 -0
  84. data/spec/dummy/log/.gitkeep +0 -0
  85. data/spec/dummy/public/404.html +0 -26
  86. data/spec/dummy/public/422.html +0 -26
  87. data/spec/dummy/public/500.html +0 -25
  88. data/spec/dummy/public/favicon.ico +0 -0
  89. data/spec/dummy/public/javascripts/Player.js +0 -22
  90. data/spec/dummy/public/javascripts/Song.js +0 -7
  91. data/spec/dummy/public/logo.png +0 -0
  92. data/spec/dummy/script/rails +0 -6
  93. data/spec/factories/place_factory.rb +0 -16
  94. data/spec/factories/user_factory.rb +0 -23
  95. data/spec/fixtures/google_direction_valid.json +0 -65
  96. data/spec/fixtures/google_geocoding_toulon_france.json +0 -58
  97. data/spec/fixtures/google_places_valid.json +0 -45
  98. data/spec/fixtures/google_wrong_geocoding.json +0 -4
  99. data/spec/javascripts/basic_methods_spec.js +0 -103
  100. data/spec/javascripts/helpers/.gitkeep +0 -0
  101. data/spec/javascripts/helpers/SpecHelper.js +0 -87
  102. data/spec/javascripts/map_spec.js +0 -49
  103. data/spec/javascripts/markers_methods_spec.js +0 -368
  104. data/spec/javascripts/mocks_spec.js +0 -27
  105. data/spec/javascripts/support/jasmine.yml +0 -10
  106. data/spec/javascripts/support/jasmine_config.rb +0 -23
  107. data/spec/javascripts/support/jasmine_runner.rb +0 -20
  108. data/spec/launchers/all_but_requests.rb +0 -0
  109. data/spec/launchers/all_specs.rb +0 -0
  110. data/spec/launchers/requests.rb +0 -0
  111. data/spec/lib/base_spec.rb +0 -59
  112. data/spec/lib/direction_spec.rb +0 -53
  113. data/spec/lib/geocoder_spec.rb +0 -46
  114. data/spec/lib/js_builder_spec.rb +0 -139
  115. data/spec/lib/json_builder_spec.rb +0 -232
  116. data/spec/lib/places_spec.rb +0 -25
  117. data/spec/models/place_spec.rb +0 -35
  118. data/spec/models/user_spec.rb +0 -187
  119. data/spec/spec_helper.rb +0 -44
  120. data/spec/support/geocoding.rb +0 -41
  121. data/spec/support/matchers.rb +0 -73
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Places" do
4
-
5
- let(:places) { File.read "spec/fixtures/google_places_valid.json" }
6
-
7
- context "valid request" do
8
- before(:each) do
9
- stub_request(:get, "https://maps.googleapis.com/maps/api/place/search/json?key=key&language=en&location=0,0&radius=7500&sensor=false").
10
- to_return(:status => 200, :body => places, :headers => {})
11
- end
12
-
13
- it "does something" do
14
- results = Gmaps4rails.places(0, 0, "key")
15
- result = OpenStruct.new results.first
16
-
17
- result.lat.should eq -33.871983
18
- result.lng.should eq 151.199086
19
- result.name.should eq "Zaaffran Restaurant - BBQ and GRILL, Darling Harbour"
20
- result.reference.should =~ /^CpQBjAAAAHDHuimUQATR6gfoWNm.*/
21
- result.vicinity.should eq "Harbourside Centre 10 Darling Drive, Darling Harbour, Sydney"
22
- end
23
-
24
- end
25
- end
@@ -1,35 +0,0 @@
1
- if RUBY_VERSION == "1.9.3"
2
-
3
- require 'spec_helper'
4
-
5
- include Geocoding
6
-
7
- set_gmaps4rails_options!
8
-
9
- # Mongoid 3.x only
10
- require 'mongoid'
11
- require 'moped'
12
-
13
- Mongoid.configure do |config|
14
- config.connect_to('mongoid_geo_test')
15
- end
16
-
17
- describe Gmaps4rails::ActsAsGmappable do
18
-
19
- let(:place) { Factory(:place) }
20
- let(:invalid_place) { Factory.build(:invalid_place) }
21
-
22
- before(:each) do
23
- Geocoding.stub_geocoding
24
- end
25
-
26
- context "standard configuration, valid place" do
27
- it "should save longitude and latitude to the customized position array" do
28
- set_gmaps4rails_options!(:position => 'pos')
29
- place.pos.should_not be_nil
30
- place.should have_same_position_as TOULON
31
- end
32
- end
33
- end
34
-
35
- end
@@ -1,187 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Geocoding
4
-
5
- describe Gmaps4rails::ActsAsGmappable do
6
-
7
- let(:user) { Factory(:user) }
8
- let(:invalid_user) { FactoryGirl.build(:invalid_user) }
9
-
10
- before(:all) do
11
- set_gmaps4rails_options!
12
- end
13
-
14
- before(:each) do
15
- Geocoding.stub_geocoding
16
- end
17
-
18
- context "standard configuration, valid user" do
19
-
20
- it "should have a geocoded position" do
21
- user.should have_same_position_as TOULON
22
- end
23
-
24
- it "should set boolean to true once user is created" do
25
- user.gmaps.should be_true
26
- end
27
-
28
- context "process_geocoding" do
29
- context "Proc" do
30
- it "should prevent geocoding when returns false" do
31
- user.instance_eval do
32
- def gmaps4rails_options
33
- DEFAULT_CONFIG_HASH.merge({ :process_geocoding => lambda {|user| false } })
34
- end
35
- end
36
- Gmaps4rails.should_not_receive(:geocode)
37
- user.update_attributes(:address => "Strasbourg, france")
38
- end
39
-
40
- context "geocoding required" do
41
- it "should trigger the geocoding" do
42
- user.instance_eval do
43
- def gmaps4rails_options
44
- DEFAULT_CONFIG_HASH.merge({ :process_geocoding => lambda {|user| true } })
45
- end
46
- end
47
- Gmaps4rails.should_receive(:geocode)
48
- user.update_attributes(:address => "Strasbourg, france")
49
- end
50
-
51
- it "should update coordinates but not update checker" do
52
- #first default behavior
53
- user.update_attributes(:gmaps => false, :address => "Strasbourg, france")
54
- user.gmaps.should eq true
55
- #then tested behavior
56
- user.instance_eval do
57
- def gmaps4rails_options
58
- DEFAULT_CONFIG_HASH.merge({ :process_geocoding => lambda {|user| true } })
59
- end
60
- end
61
- user.update_attributes(:gmaps => false, :address => "Strasbourg, france")
62
- user.gmaps.should eq false
63
- end
64
- end
65
- end
66
- end
67
-
68
-
69
- it "should not geocode again after address changes if checker is true" do
70
- user.update_attributes({ :address => "Paris, France" })
71
- user.should have_same_position_as TOULON
72
- end
73
-
74
- it "should geocode after address changes if checker is false" do
75
- user.update_attributes({ :address => "Paris, France",
76
- :gmaps => false})
77
- user.should have_same_position_as PARIS
78
- end
79
- end
80
-
81
- context "standard configuration, invalid address" do
82
-
83
- it "should raise an error if validation option is turned on and address incorrect" do
84
- invalid_user.should_not be_valid, "Address invalid"
85
- end
86
-
87
- it "should not set boolean to true when address update fails" do
88
- invalid_user.gmaps.should_not be_true
89
- end
90
- end
91
-
92
-
93
- context "acts_as_gmappable options" do
94
-
95
- after(:all) do
96
- #reset all configuration to default
97
- set_gmaps4rails_options!
98
- end
99
-
100
- it "should call google api with http by default" do
101
- address = "toulon, france"
102
- Gmaps4rails.should_receive(:geocode).with(address, "en", false, "http").and_return [TOULON]
103
- User.create(:address => address)
104
- end
105
-
106
- it "should call google api with https if passed in settings" do
107
- set_gmaps4rails_options!({ :protocol => "https" })
108
- address = "toulon, france"
109
- Gmaps4rails.should_receive(:geocode).with(address, "en", false, "https").and_return [TOULON]
110
- User.create(:address => address)
111
- set_gmaps4rails_options!({ :protocol => "http" })
112
- end
113
-
114
- it "should use indifferently a db column for address if passed in config" do
115
- set_gmaps4rails_options!({:address => "sec_address"})
116
- user = Factory(:user, :sec_address => "Toulon, France")
117
- user.should have_same_position_as TOULON
118
- end
119
-
120
- it "should save the normalized address if requested" do
121
- set_gmaps4rails_options!({ :normalized_address => "norm_address" })
122
- user.norm_address.should == "Toulon, France"
123
- end
124
-
125
- it "should override user's address with normalized address if requested" do
126
- set_gmaps4rails_options!({ :normalized_address => "sec_address" })
127
- user = Factory(:user, :sec_address => "ToUlOn, FrAnCe")
128
- user.sec_address.should == "Toulon, France"
129
- end
130
-
131
- it "should display the proper error message when address is invalid" do
132
- set_gmaps4rails_options!({ :msg => "Custom Address invalid"})
133
- invalid_user.should_not be_valid
134
- invalid_user.errors[:address].should include("Custom Address invalid")
135
- end
136
-
137
- it "should not raise an error if validation option is turned off" do
138
- set_gmaps4rails_options!({ :validation => false })
139
- invalid_user.should be_valid
140
- end
141
-
142
- it "should save longitude and latitude to the customized columns" do
143
- set_gmaps4rails_options!({
144
- :lat_column => "lat_test",
145
- :lng_column => "long_test"
146
- })
147
- user.latitude.should be_nil
148
- user.should have_same_position_as TOULON
149
- end
150
-
151
- it "should not save the boolean if check_process is false" do
152
- set_gmaps4rails_options!({ :check_process => false })
153
- user.gmaps.should be_nil
154
- end
155
-
156
- it "should geocode after each save if 'check_process' is false" do
157
- set_gmaps4rails_options!({ :check_process => false })
158
- user = Factory(:user, :address => "Paris, France")
159
- user.should have_same_position_as PARIS
160
- end
161
-
162
- it "should save to the proper boolean checker set in checker" do
163
- set_gmaps4rails_options!({ :checker => "bool_test" })
164
- user.gmaps.should be_nil
165
- user.bool_test.should be_true
166
- end
167
-
168
- it "should call a callback in the model if asked to" do
169
- User.class_eval do
170
- def gmaps4rails_options
171
- DEFAULT_CONFIG_HASH.merge({ :callback => "save_callback" })
172
- end
173
-
174
- def save_callback(data)
175
- self.called_back = true
176
- end
177
-
178
- attr_accessor :called_back
179
- end
180
- user.called_back.should be_true
181
- end
182
-
183
- end
184
-
185
-
186
-
187
- end
@@ -1,44 +0,0 @@
1
- require 'rubygems'
2
- require 'spork'
3
-
4
- Spork.prefork do
5
- ENV["RAILS_ENV"] ||= 'test'
6
- require File.expand_path("../dummy/config/environment", __FILE__)
7
- require 'rspec/rails'
8
- require 'pry'
9
- #require 'capybara/rspec'
10
- require 'factory_girl_rails'
11
- require 'database_cleaner'
12
- require "jasmine"
13
- require 'webmock/rspec'
14
-
15
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
16
- FactoryGirl.definition_file_paths = [ File.join(Rails.root, '../factories') ]
17
-
18
- RSpec.configure do |config|
19
- config.treat_symbols_as_metadata_keys_with_true_values = true
20
- config.filter_run :focus => true
21
- config.run_all_when_everything_filtered = true
22
-
23
- config.use_transactional_fixtures = true
24
- config.infer_base_class_for_anonymous_controllers = false
25
-
26
- config.before(:suite) do
27
- DatabaseCleaner.strategy = :truncation
28
- end
29
-
30
- config.before(:each) do
31
- DatabaseCleaner.start
32
- DatabaseCleaner.clean
33
- end
34
-
35
- config.after(:each) do
36
- DatabaseCleaner.clean
37
- end
38
- end
39
- end
40
-
41
- Spork.each_run do
42
- FactoryGirl.reload
43
- File.open("#{Rails.root}/log/test.log", 'w') {|file| file.truncate(0) } #cleans the log file to make it readable and control it's size
44
- end
@@ -1,41 +0,0 @@
1
- module Geocoding
2
-
3
- DEFAULT_CONFIG_HASH = {
4
- :lat_column => "latitude",
5
- :lng_column => "longitude",
6
- :check_process => true,
7
- :checker => "gmaps",
8
- :msg => "Address invalid",
9
- :validation => true,
10
- :address => "address",
11
- :language => "en",
12
- :protocol => "http",
13
- :process_geocoding => true,
14
- :position => nil
15
- }
16
-
17
- PARIS = { :latitude => 48.856614, :longitude => 2.3522219 }
18
- TOULON = { :latitude => 43.124228, :longitude => 5.928 }
19
-
20
- #set model configuration
21
- def set_gmaps4rails_options!(change_conf = {})
22
- User.class_eval do
23
- define_method "gmaps4rails_options" do
24
- DEFAULT_CONFIG_HASH.merge(change_conf)
25
- end
26
- end
27
- end
28
-
29
- def self.stub_geocoding
30
- Gmaps4rails.stub(:geocode) do |*args|
31
- case args[0]
32
- when "Paris, France"
33
- [{:lat=>48.856614, :lng=>2.3522219, :matched_address=>"Paris, France", :bounds=>{"northeast"=>{"lat"=>48.902145, "lng"=>2.4699209}, "southwest"=>{"lat"=>48.815573, "lng"=>2.224199}}, :full_data=>{"address_components"=>[{"long_name"=>"Paris", "short_name"=>"Paris", "types"=>["locality", "political"]}, {"long_name"=>"Paris", "short_name"=>"75", "types"=>["administrative_area_level_2", "political"]}, {"long_name"=>"Ile-de-France", "short_name"=>"IdF", "types"=>["administrative_area_level_1", "political"]}, {"long_name"=>"France", "short_name"=>"FR", "types"=>["country", "political"]}], "formatted_address"=>"Paris, France", "geometry"=>{"bounds"=>{"northeast"=>{"lat"=>48.902145, "lng"=>2.4699209}, "southwest"=>{"lat"=>48.815573, "lng"=>2.224199}}, "location"=>{"lat"=>48.856614, "lng"=>2.3522219}, "location_type"=>"APPROXIMATE", "viewport"=>{"northeast"=>{"lat"=>48.9153104, "lng"=>2.4802813}, "southwest"=>{"lat"=>48.7978487, "lng"=>2.2241625}}}, "types"=>["locality", "political"]}}]
34
- when "home"
35
- raise Gmaps4rails::GeocodeStatus
36
- else
37
- [{:lat=>43.124228, :lng=>5.928, :matched_address=>"Toulon, France", :bounds=>{"northeast"=>{"lat"=>43.171673, "lng"=>5.987382999999999}, "southwest"=>{"lat"=>43.101049, "lng"=>5.879479}}, :full_data=>{"address_components"=>[{"long_name"=>"Toulon", "short_name"=>"Toulon", "types"=>["locality", "political"]}, {"long_name"=>"Var", "short_name"=>"83", "types"=>["administrative_area_level_2", "political"]}, {"long_name"=>"Provence-Alpes-Cote d'Azur", "short_name"=>"PACA", "types"=>["administrative_area_level_1", "political"]}, {"long_name"=>"France", "short_name"=>"FR", "types"=>["country", "political"]}], "formatted_address"=>"Toulon, France", "geometry"=>{"bounds"=>{"northeast"=>{"lat"=>43.171673, "lng"=>5.987382999999999}, "southwest"=>{"lat"=>43.101049, "lng"=>5.879479}}, "location"=>{"lat"=>43.124228, "lng"=>5.928}, "location_type"=>"APPROXIMATE", "viewport"=>{"northeast"=>{"lat"=>43.156795, "lng"=>5.9920297}, "southwest"=>{"lat"=>43.0916437, "lng"=>5.8639703}}}, "types"=>["locality", "political"]}}]
38
- end
39
- end
40
- end
41
- end
@@ -1,73 +0,0 @@
1
- require 'rspec/expectations'
2
- require 'ostruct'
3
-
4
- def has_same_content_as?(actual, expected)
5
- case actual
6
- when Array
7
- case expected
8
- when Array
9
- result = true
10
- case actual.first
11
- when Array
12
- actual.each do |actual_subarray|
13
- bool = false
14
- expected.each do |expected_subarray|
15
- bool = bool || has_same_content_as?(actual_subarray, expected_subarray)
16
- end
17
- result = result && bool
18
- end
19
- result
20
- else
21
- (actual - expected).empty?
22
- end
23
- else
24
- false
25
- end
26
- else
27
- false
28
- end
29
- end
30
-
31
- class PositionMatcher
32
- attr_reader :object, :position_hash
33
- delegate :position, :lat_column, :lng_column, :to => :@options
34
-
35
- def initialize object, position_hash
36
- @object, @position_hash = object, position_hash
37
- @options = ::OpenStruct.new object.gmaps4rails_options
38
- end
39
-
40
- def same_pos?
41
- position_hash[:latitude] == lat && position_hash[:longitude] == lng
42
- end
43
-
44
- protected
45
-
46
- def lat
47
- position ? object.send("#{position}")[0] : object.send("#{lat_column}")
48
- end
49
-
50
- def lng
51
- position ? object.send("#{position}")[1] : object.send("#{lng_column}")
52
- end
53
-
54
- end
55
-
56
- def position_matcher object, position_hash
57
- PositionMatcher.new object, position_hash
58
- end
59
-
60
- RSpec::Matchers.define :have_same_position_as do |position_hash|
61
- match do |object|
62
- position_matcher(object, position_hash).same_pos?
63
- end
64
- end
65
-
66
- RSpec::Matchers.define :be_same_json_as do |expected|
67
- match do |actual|
68
- has_same_content_as?(JSON.parse(actual), JSON.parse(expected))
69
- end
70
- failure_message_for_should do |actual|
71
- "Both object don't have the same content. Beware though, be sure to compare only arrays."
72
- end
73
- end