gmaps4rails 2.0.0.pre → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -4
- data/Gemfile +5 -1
- data/Gemfile.lock +31 -113
- data/README.rdoc +53 -70
- data/Rakefile +21 -1
- data/gmaps4rails.gemspec +4 -19
- data/js_compilation/gmaps_google.js +961 -0
- data/lib/generators/gmaps4rails/copy_coffee_generator.rb +14 -0
- data/lib/generators/gmaps4rails/copy_js_generator.rb +15 -0
- data/lib/gmaps4rails.rb +12 -22
- data/lib/gmaps4rails/markers_builder.rb +74 -0
- data/lib/gmaps4rails/rails/engine.rb +6 -0
- data/lib/gmaps4rails/rails/railtie.rb +6 -0
- data/lib/gmaps4rails/version.rb +2 -2
- data/script/compile_coffee_files.rb +19 -0
- data/script/gmaps4rails.rake +7 -0
- data/spec/javascripts/google/builders/marker_spec.js +96 -0
- data/spec/javascripts/helpers/SpecHelper.js +101 -0
- data/spec/javascripts/helpers/matchers.js +12 -0
- data/spec/javascripts/helpers/underscore.js +6 -0
- data/spec/javascripts/objects/handler_spec.js +320 -0
- data/spec/javascripts/support/jasmine.yml +86 -0
- data/spec/javascripts/support/jasmine_helper.rb +11 -0
- data/spec/lib/base_spec.rb +10 -52
- data/spec/lib/markers_builder_spec.rb +49 -0
- data/spec/spec_helper.rb +1 -25
- data/vendor/assets/javascripts/gmaps/base.coffee +16 -0
- data/vendor/assets/javascripts/gmaps/base/base.coffee +17 -0
- data/vendor/assets/javascripts/gmaps/google.coffee +3 -0
- data/vendor/assets/javascripts/gmaps/google/builders/bound.coffee +6 -0
- data/vendor/assets/javascripts/gmaps/google/builders/circle.coffee +21 -0
- data/vendor/assets/javascripts/gmaps/google/builders/clusterer.coffee +6 -0
- data/vendor/assets/javascripts/gmaps/google/builders/kml.coffee +17 -0
- data/vendor/assets/javascripts/gmaps/google/builders/map.coffee +27 -0
- data/vendor/assets/javascripts/gmaps/google/builders/marker.coffee +100 -0
- data/vendor/assets/javascripts/gmaps/google/builders/polygon.coffee +24 -0
- data/vendor/assets/javascripts/gmaps/google/builders/polyline.coffee +24 -0
- data/vendor/assets/javascripts/gmaps/google/objects/bound.coffee +13 -0
- data/vendor/assets/javascripts/gmaps/google/objects/circle.coffee +9 -0
- data/vendor/assets/javascripts/gmaps/google/objects/clusterer.coffee +13 -0
- data/vendor/assets/javascripts/gmaps/google/objects/common.coffee +23 -0
- data/vendor/assets/javascripts/gmaps/google/objects/kml.coffee +15 -0
- data/vendor/assets/javascripts/gmaps/google/objects/map.coffee +19 -0
- data/vendor/assets/javascripts/gmaps/google/objects/marker.coffee +11 -0
- data/vendor/assets/javascripts/gmaps/google/objects/polygon.coffee +8 -0
- data/vendor/assets/javascripts/gmaps/google/objects/polyline.coffee +8 -0
- data/vendor/assets/javascripts/gmaps/google/primitives.coffee +43 -0
- data/vendor/assets/javascripts/gmaps/objects/base_builder.coffee +20 -0
- data/vendor/assets/javascripts/gmaps/objects/builder.coffee +12 -0
- data/vendor/assets/javascripts/gmaps/objects/handler.coffee +153 -0
- data/vendor/assets/javascripts/gmaps/objects/null_clusterer.coffee +4 -0
- metadata +66 -299
- data/Guardfile.old +0 -24
- data/app/views/gmaps4rails/_gmaps4rails.html.erb +0 -20
- data/lib/generators/gmaps4rails/install_generator.rb +0 -43
- data/lib/generators/templates/README +0 -2
- data/lib/gmaps4rails/acts_as_gmappable.rb +0 -54
- data/lib/gmaps4rails/api_wrappers/base_net_methods.rb +0 -40
- data/lib/gmaps4rails/api_wrappers/direction.rb +0 -87
- data/lib/gmaps4rails/api_wrappers/geocoder.rb +0 -54
- data/lib/gmaps4rails/api_wrappers/places.rb +0 -74
- data/lib/gmaps4rails/base.rb +0 -126
- data/lib/gmaps4rails/extensions/enumerable.rb +0 -14
- data/lib/gmaps4rails/extensions/hash.rb +0 -9
- data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +0 -33
- data/lib/gmaps4rails/js_builder.rb +0 -154
- data/lib/gmaps4rails/json_builder.rb +0 -140
- data/lib/gmaps4rails/model_handler.rb +0 -101
- data/lib/gmaps4rails/view_helper.rb +0 -172
- data/lib/tasks/jasmine.rake +0 -8
- data/public/javascripts/gmaps4rails/all.js +0 -2144
- data/public/javascripts/gmaps4rails/base.js +0 -792
- data/public/javascripts/gmaps4rails/google.js +0 -556
- data/public/javascripts/gmaps4rails/openlayers.js +0 -377
- data/public/stylesheets/gmaps4rails.css +0 -24
- data/spec/dummy/.gitignore +0 -3
- data/spec/dummy/.rspec +0 -1
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -18
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/assets/stylesheets/gmaps4rails.css +0 -24
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/users_controller.rb +0 -105
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/place.rb +0 -16
- data/spec/dummy/app/models/user.rb +0 -12
- data/spec/dummy/app/views/layouts/application.html.erb +0 -17
- data/spec/dummy/app/views/users/_form.html.erb +0 -37
- data/spec/dummy/app/views/users/edit.html.erb +0 -6
- data/spec/dummy/app/views/users/index.html.erb +0 -268
- data/spec/dummy/app/views/users/new.html.erb +0 -5
- data/spec/dummy/app/views/users/show.html.erb +0 -30
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -62
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/gmaps4rails.rb +0 -1
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -60
- data/spec/dummy/db/migrate/20120408170155_create_users.rb +0 -16
- data/spec/dummy/db/schema.rb +0 -29
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/Player.js +0 -22
- data/spec/dummy/public/javascripts/Song.js +0 -7
- data/spec/dummy/public/logo.png +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/factories/place_factory.rb +0 -16
- data/spec/factories/user_factory.rb +0 -23
- data/spec/fixtures/google_direction_valid.json +0 -65
- data/spec/fixtures/google_geocoding_toulon_france.json +0 -58
- data/spec/fixtures/google_places_valid.json +0 -45
- data/spec/fixtures/google_wrong_geocoding.json +0 -4
- data/spec/launchers/all_but_requests.rb +0 -0
- data/spec/launchers/all_specs.rb +0 -0
- data/spec/launchers/requests.rb +0 -0
- data/spec/lib/direction_spec.rb +0 -53
- data/spec/lib/geocoder_spec.rb +0 -46
- data/spec/lib/js_builder_spec.rb +0 -134
- data/spec/lib/json_builder_spec.rb +0 -232
- data/spec/lib/places_spec.rb +0 -25
- data/spec/models/place_spec.rb +0 -39
- data/spec/models/user_spec.rb +0 -187
- data/spec/support/geocoding.rb +0 -40
- data/spec/support/matchers.rb +0 -73
- data/todo +0 -0
- data/vendor/assets/javascripts/gmaps4rails/all.js +0 -1
- data/vendor/assets/javascripts/gmaps4rails/base.coffee +0 -1
- data/vendor/assets/javascripts/gmaps4rails/base/common.coffee +0 -43
- data/vendor/assets/javascripts/gmaps4rails/base/configuration.coffee +0 -7
- data/vendor/assets/javascripts/gmaps4rails/base/gmaps.coffee +0 -13
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/basic_interface.coffee +0 -15
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/controller_interface.coffee +0 -15
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/map_interface.coffee +0 -27
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/marker_interface.coffee +0 -15
- data/vendor/assets/javascripts/gmaps4rails/base/main.coffee +0 -124
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/circle_controller.coffee +0 -29
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/kml_controller.coffee +0 -5
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/marker_controller.coffee +0 -76
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polygon_controller.coffee +0 -29
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polyline_controller.coffee +0 -29
- data/vendor/assets/javascripts/gmaps4rails/base/objects/circle.coffee +0 -12
- data/vendor/assets/javascripts/gmaps4rails/base/objects/kml.coffee +0 -8
- data/vendor/assets/javascripts/gmaps4rails/base/objects/map.coffee +0 -62
- data/vendor/assets/javascripts/gmaps4rails/base/objects/marker.coffee +0 -24
- data/vendor/assets/javascripts/gmaps4rails/base/objects/polygon.coffee +0 -11
- data/vendor/assets/javascripts/gmaps4rails/base/objects/polyline.coffee +0 -11
- data/vendor/assets/javascripts/gmaps4rails/bing.coffee +0 -1
- data/vendor/assets/javascripts/gmaps4rails/bing/main.coffee +0 -29
- data/vendor/assets/javascripts/gmaps4rails/bing/objects/map.coffee +0 -63
- data/vendor/assets/javascripts/gmaps4rails/bing/objects/marker.coffee +0 -78
- data/vendor/assets/javascripts/gmaps4rails/bing/shared.coffee +0 -20
- data/vendor/assets/javascripts/gmaps4rails/google.coffee +0 -1
- data/vendor/assets/javascripts/gmaps4rails/google/main.coffee +0 -47
- data/vendor/assets/javascripts/gmaps4rails/google/objects/circle.coffee +0 -38
- data/vendor/assets/javascripts/gmaps4rails/google/objects/kml.coffee +0 -16
- data/vendor/assets/javascripts/gmaps4rails/google/objects/map.coffee +0 -71
- data/vendor/assets/javascripts/gmaps4rails/google/objects/marker.coffee +0 -114
- data/vendor/assets/javascripts/gmaps4rails/google/objects/polygon.coffee +0 -38
- data/vendor/assets/javascripts/gmaps4rails/google/objects/polyline.coffee +0 -49
- data/vendor/assets/javascripts/gmaps4rails/google/shared.coffee +0 -27
- data/vendor/assets/javascripts/gmaps4rails/openlayers.coffee +0 -1
- data/vendor/assets/javascripts/gmaps4rails/openlayers/main.coffee +0 -138
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/map.coffee +0 -49
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/marker.coffee +0 -68
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/polyline.coffee +0 -39
- data/vendor/assets/javascripts/gmaps4rails/openlayers/shared.coffee +0 -19
@@ -0,0 +1,14 @@
|
|
1
|
+
module Gmaps4rails
|
2
|
+
module Generators
|
3
|
+
class CopyCoffeeGenerator < ::Rails::Generators::Base
|
4
|
+
|
5
|
+
desc "This generator copies coffee files to app/assets/javascripts"
|
6
|
+
source_root File.expand_path('../../../../vendor/assets/javascripts', __FILE__)
|
7
|
+
|
8
|
+
def copy_coffee
|
9
|
+
say_status("copying", "coffee files", :green)
|
10
|
+
directory 'gmaps', 'app/assets/javascripts/gmaps'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Gmaps4rails
|
2
|
+
module Generators
|
3
|
+
class CopyJsGenerator < ::Rails::Generators::Base
|
4
|
+
|
5
|
+
desc "This generator copies js files to public/javascripts"
|
6
|
+
source_root File.expand_path('../../../../js_compilation', __FILE__)
|
7
|
+
|
8
|
+
def copy_js
|
9
|
+
say_status("copying", "js file", :green)
|
10
|
+
copy_file "gmaps_google.js", "public/javascripts/gmaps_google.js"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/gmaps4rails.rb
CHANGED
@@ -1,26 +1,16 @@
|
|
1
|
+
if defined?(::Rails)
|
2
|
+
require 'gmaps4rails/rails/engine' if ::Rails.version >= '3.1'
|
3
|
+
require 'gmaps4rails/rails/railtie'
|
4
|
+
end
|
5
|
+
require 'gmaps4rails/version'
|
6
|
+
|
1
7
|
module Gmaps4rails
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
class Engine < Rails::Engine
|
6
|
-
|
7
|
-
initializer "gmaps4rails view helpers" do |app|
|
8
|
-
ActionView::Base.send :include, Gmaps4railsHelper
|
9
|
-
end
|
10
|
-
|
8
|
+
autoload :MarkersBuilder, 'gmaps4rails/markers_builder'
|
9
|
+
|
10
|
+
module Rails
|
11
11
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
initializer "include acts_as_gmappable within ORM" do
|
16
|
-
ActiveSupport.on_load(:active_record) do
|
17
|
-
ActiveRecord::Base.send(:include, Gmaps4rails::ActsAsGmappable)
|
18
|
-
end
|
19
|
-
|
20
|
-
ActiveSupport.on_load(:mongoid) do
|
21
|
-
Mongoid::Document.send(:include, Gmaps4rails::ActsAsGmappable)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
12
|
+
|
13
|
+
def Gmaps4rails.build_markers(collection, &block)
|
14
|
+
::Gmaps4rails::MarkersBuilder.new(collection).call(&block)
|
25
15
|
end
|
26
16
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Gmaps4rails
|
2
|
+
# the to_gmaps4rails method accepts a block to customize:
|
3
|
+
# - infowindow
|
4
|
+
# - picture
|
5
|
+
# - shadow
|
6
|
+
# - title
|
7
|
+
# - sidebar
|
8
|
+
# - json
|
9
|
+
#
|
10
|
+
# This works this way:
|
11
|
+
# @users = User.all
|
12
|
+
# @json = Gmaps4rails.build_markers @users do |user, marker|
|
13
|
+
# marker.lat user.latitude
|
14
|
+
# marker.lng user.longitude
|
15
|
+
# marker.infowindow render_to_string(:partial => "/users/my_template", :locals => { :object => user}).gsub(/\n/, '').gsub(/"/, '\"')
|
16
|
+
# marker.picture({
|
17
|
+
# :url => "http://www.blankdots.com/img/github-32x32.png",
|
18
|
+
# :width => "32",
|
19
|
+
# :height => "32"
|
20
|
+
# })
|
21
|
+
# marker.title "i'm the title"
|
22
|
+
# marker.json({ :id => user.id })
|
23
|
+
# end
|
24
|
+
class MarkersBuilder
|
25
|
+
|
26
|
+
def initialize(collection)
|
27
|
+
@collection = Array(collection)
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(&block)
|
31
|
+
@collection.map do |object|
|
32
|
+
MarkerBuilder.new(object).call(&block)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class MarkerBuilder
|
37
|
+
|
38
|
+
attr_reader :object, :hash
|
39
|
+
def initialize(object)
|
40
|
+
@object = object
|
41
|
+
@hash = {}
|
42
|
+
end
|
43
|
+
|
44
|
+
def call(&block)
|
45
|
+
block.call(object, self)
|
46
|
+
hash
|
47
|
+
end
|
48
|
+
|
49
|
+
def lat(float)
|
50
|
+
@hash[:lat] = float
|
51
|
+
end
|
52
|
+
|
53
|
+
def lng(float)
|
54
|
+
@hash[:lng] = float
|
55
|
+
end
|
56
|
+
|
57
|
+
def infowindow(string)
|
58
|
+
@hash[:infowindow] = string
|
59
|
+
end
|
60
|
+
|
61
|
+
def title(string)
|
62
|
+
@hash[:marker_title] = string
|
63
|
+
end
|
64
|
+
|
65
|
+
def json(json)
|
66
|
+
@hash.merge! json
|
67
|
+
end
|
68
|
+
|
69
|
+
def picture(hash)
|
70
|
+
@hash[:picture] = hash
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/gmaps4rails/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Gmaps4rails
|
2
|
-
VERSION = "2.0.0
|
3
|
-
end
|
2
|
+
VERSION = "2.0.0"
|
3
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'sprockets'
|
3
|
+
|
4
|
+
app_path = File.expand_path('../..', __FILE__)
|
5
|
+
|
6
|
+
source_path = (app_path + "/vendor/assets/javascripts/gmaps/")
|
7
|
+
destination_path = (app_path + "/js_compilation/")
|
8
|
+
|
9
|
+
%w(google).each do |name|
|
10
|
+
#main source file:
|
11
|
+
main_source_file_name = "#{name}.coffee"
|
12
|
+
#desired output file
|
13
|
+
compiled_file_path = (destination_path + "gmaps_#{name}.js")
|
14
|
+
|
15
|
+
env = Sprockets::Environment.new
|
16
|
+
env.append_path source_path
|
17
|
+
|
18
|
+
open(compiled_file_path, "w").write( env[main_source_file_name] )
|
19
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
describe("Gmaps.Google.Builders.Marker", function() {
|
2
|
+
|
3
|
+
var subject_klass, instance, primitives;
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
primitives = spec_helpers.override_primitives();
|
7
|
+
subject_klass = spec_helpers.google.Builders.Marker(primitives);
|
8
|
+
});
|
9
|
+
|
10
|
+
describe("constructor", function() {
|
11
|
+
var serviceObject, infowindow;
|
12
|
+
beforeEach(function() {
|
13
|
+
spyOn(subject_klass.prototype, 'create_marker');
|
14
|
+
spyOn(subject_klass.prototype, 'create_infowindow');
|
15
|
+
});
|
16
|
+
|
17
|
+
it("sets vars", function() {
|
18
|
+
instance = new subject_klass();
|
19
|
+
expect(subject_klass.prototype.create_marker).toHaveBeenCalled();
|
20
|
+
expect(subject_klass.prototype.create_infowindow).toHaveBeenCalled();
|
21
|
+
});
|
22
|
+
|
23
|
+
describe("marker_options", function() {
|
24
|
+
describe("coordinates", function() {
|
25
|
+
var args = { lat: 40, lng: 42};
|
26
|
+
|
27
|
+
it("only coordinates, without randomization", function() {
|
28
|
+
instance = new subject_klass(args, {}, {});
|
29
|
+
|
30
|
+
instance.marker_options();
|
31
|
+
|
32
|
+
expect(primitives.latLng).toHaveBeenCalledWith(args.lat, args.lng);
|
33
|
+
});
|
34
|
+
|
35
|
+
it("only coordinates, with randomization", function() {
|
36
|
+
instance = new subject_klass(args, {}, { maxRandomDistance: 12 });
|
37
|
+
|
38
|
+
instance.marker_options();
|
39
|
+
|
40
|
+
expect(primitives.latLng).not.toHaveBeenCalledWith(args.lat, args.lng);
|
41
|
+
|
42
|
+
called_lat = primitives.latLng.mostRecentCall.args[0];
|
43
|
+
called_lng = primitives.latLng.mostRecentCall.args[1];
|
44
|
+
|
45
|
+
expect(called_lat).toBeWithinOf(args.lat, 0.0001);
|
46
|
+
expect(called_lng).toBeWithinOf(args.lng, 0.0001);
|
47
|
+
});
|
48
|
+
});
|
49
|
+
|
50
|
+
describe("title", function() {
|
51
|
+
it("without title", function() {
|
52
|
+
instance = new subject_klass({}, {}, {});
|
53
|
+
|
54
|
+
var result = instance.marker_options();
|
55
|
+
|
56
|
+
expect(result.title).toBeUndefined();
|
57
|
+
});
|
58
|
+
|
59
|
+
it("with title", function() {
|
60
|
+
instance = new subject_klass({marker_title: 'title'}, {}, { maxRandomDistance: 12 });
|
61
|
+
|
62
|
+
var result = instance.marker_options();
|
63
|
+
|
64
|
+
expect(result.title).toEqual('title');
|
65
|
+
});
|
66
|
+
});
|
67
|
+
|
68
|
+
describe("merge with provider options", function() {
|
69
|
+
it("no provider options", function() {
|
70
|
+
instance = new subject_klass({}, {}, {});
|
71
|
+
|
72
|
+
var result = instance.marker_options();
|
73
|
+
|
74
|
+
expect(result.zIndex).toBeUndefined();
|
75
|
+
});
|
76
|
+
|
77
|
+
it("provider options", function() {
|
78
|
+
instance = new subject_klass({}, { zIndex: 'zIndex'}, { maxRandomDistance: 12 });
|
79
|
+
|
80
|
+
var result = instance.marker_options();
|
81
|
+
|
82
|
+
expect(result.zIndex).toEqual('zIndex');
|
83
|
+
});
|
84
|
+
|
85
|
+
it("provider options with overlapping keys", function() {
|
86
|
+
instance = new subject_klass({marker_title: 'arg_title'}, { title: 'provider_title'}, { maxRandomDistance: 12 });
|
87
|
+
|
88
|
+
var result = instance.marker_options();
|
89
|
+
|
90
|
+
expect(result.title).toEqual('arg_title');
|
91
|
+
});
|
92
|
+
});
|
93
|
+
});
|
94
|
+
});
|
95
|
+
|
96
|
+
});
|
@@ -0,0 +1,101 @@
|
|
1
|
+
spec_helpers = {
|
2
|
+
|
3
|
+
createHandlersSpies: function(){
|
4
|
+
Gmaps.Specs = {
|
5
|
+
spies: {
|
6
|
+
Builders: {}
|
7
|
+
},
|
8
|
+
Objects: {},
|
9
|
+
Builders: {}
|
10
|
+
};
|
11
|
+
|
12
|
+
classes = ['Bound', 'Circle', 'Map', 'Marker', 'Polyline', 'Polygon', 'Kml', 'Clusterer' ];
|
13
|
+
|
14
|
+
_.each(classes, function(klass_name){
|
15
|
+
Gmaps.Specs.Objects[klass_name] = function(){};
|
16
|
+
|
17
|
+
Gmaps.Specs.spies.Builders[klass_name] = jasmine.createSpy(klass_name + ' build');
|
18
|
+
|
19
|
+
Gmaps.Specs.Builders[klass_name] = function(){
|
20
|
+
return {
|
21
|
+
build: function() {
|
22
|
+
return Gmaps.Specs.spies.Builders[klass_name];
|
23
|
+
}
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
spyOn(Gmaps.Specs.Builders, klass_name).andCallThrough();
|
28
|
+
})
|
29
|
+
},
|
30
|
+
override_primitives: function(){
|
31
|
+
factory = {
|
32
|
+
point: jasmine.createSpy('point'),
|
33
|
+
size: jasmine.createSpy('size'),
|
34
|
+
circle: jasmine.createSpy('circle'),
|
35
|
+
latLng: jasmine.createSpy('latLng'),
|
36
|
+
latLngBounds: jasmine.createSpy('latLngBounds'),
|
37
|
+
map: jasmine.createSpy('map'),
|
38
|
+
mapTypez: jasmine.createSpy('mapTypes'),
|
39
|
+
markerImage: jasmine.createSpy('markerImage'),
|
40
|
+
marker: jasmine.createSpy('marker'),
|
41
|
+
infowindow: jasmine.createSpy('infowindow'),
|
42
|
+
listener: jasmine.createSpy('addListener'),
|
43
|
+
clusterer: jasmine.createSpy('clusterer'),
|
44
|
+
listenerOnce: jasmine.createSpy('addListenerOnce'),
|
45
|
+
polyline: jasmine.createSpy('polyline'),
|
46
|
+
polygon: jasmine.createSpy('polygon'),
|
47
|
+
kml: jasmine.createSpy('kml'),
|
48
|
+
|
49
|
+
addListener: function(object, event_name, fn){
|
50
|
+
factory.listener(object, event_name, fn);
|
51
|
+
},
|
52
|
+
addListenerOnce: function(object, event_name, fn){
|
53
|
+
factory.listenerOnce(object, event_name, fn);
|
54
|
+
},
|
55
|
+
mapTypes: function(type){
|
56
|
+
factory.mapTypez[type];
|
57
|
+
},
|
58
|
+
latLngFromPosition: function(position){
|
59
|
+
if (_.isArray(position)){
|
60
|
+
return new factory.latLng(position[0], position[1])
|
61
|
+
} else {
|
62
|
+
if (_.isNumber(position.lat) && _.isNumber(position.lng)) {
|
63
|
+
return new factory.latLng(position.lat, position.lng)
|
64
|
+
} else {
|
65
|
+
return position;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
};
|
70
|
+
return factory;
|
71
|
+
},
|
72
|
+
|
73
|
+
google: {
|
74
|
+
|
75
|
+
Builders: {
|
76
|
+
Marker: function(primitives){
|
77
|
+
var MarkerBuilder, _ref,
|
78
|
+
__hasProp = {}.hasOwnProperty,
|
79
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
80
|
+
|
81
|
+
return (function(_super) {
|
82
|
+
__extends(MarkerBuilder, _super);
|
83
|
+
|
84
|
+
function MarkerBuilder() {
|
85
|
+
_ref = MarkerBuilder.__super__.constructor.apply(this, arguments);
|
86
|
+
return _ref;
|
87
|
+
}
|
88
|
+
|
89
|
+
MarkerBuilder.OBJECT = Gmaps.Google.Objects.Marker;
|
90
|
+
|
91
|
+
MarkerBuilder.PRIMITIVES = primitives;
|
92
|
+
|
93
|
+
return MarkerBuilder;
|
94
|
+
|
95
|
+
})(Gmaps.Google.Builders.Marker);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
};
|
100
|
+
|
101
|
+
window.spec_helpers = spec_helpers;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
beforeEach(function() {
|
2
|
+
var matchers = {
|
3
|
+
toBeFunction: function() {
|
4
|
+
return this.actual instanceof Function;
|
5
|
+
},
|
6
|
+
toBeWithinOf: function(expected, delta) {
|
7
|
+
return ((expected - delta) <= this.actual && (expected + delta) >= this.actual);
|
8
|
+
}
|
9
|
+
};
|
10
|
+
|
11
|
+
this.addMatchers(matchers);
|
12
|
+
});
|
@@ -0,0 +1,6 @@
|
|
1
|
+
// Underscore.js 1.5.2
|
2
|
+
// http://underscorejs.org
|
3
|
+
// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
4
|
+
// Underscore may be freely distributed under the MIT license.
|
5
|
+
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?(this._wrapped=n,void 0):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.5.2";var A=j.each=j.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var E="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(E);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(E);return r},j.find=j.detect=function(n,t,r){var e;return O(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var O=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:O(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,function(n){return n[t]})},j.where=function(n,t,r){return j.isEmpty(t)?r?void 0:[]:j[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},j.findWhere=function(n,t){return j.where(n,t,!0)},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);if(!t&&j.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>e.computed&&(e={value:n,computed:a})}),e.value},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);if(!t&&j.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a<e.computed&&(e={value:n,computed:a})}),e.value},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return arguments.length<2||r?n[j.random(n.length-1)]:j.shuffle(n).slice(0,Math.max(0,t))};var k=function(n){return j.isFunction(n)?n:function(t){return t[n]}};j.sortBy=function(n,t,r){var e=k(t);return j.pluck(j.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={},i=null==r?j.identity:k(r);return A(t,function(r,a){var o=i.call(e,r,a,t);n(u,o,r)}),u}};j.groupBy=F(function(n,t,r){(j.has(n,t)?n[t]:n[t]=[]).push(r)}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=null==r?j.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])<u?i=o+1:a=o}return i},j.toArray=function(n){return n?j.isArray(n)?o.call(n):n.length===+n.length?j.map(n,j.identity):j.values(n):[]},j.size=function(n){return null==n?0:n.length===+n.length?n.length:j.keys(n).length},j.first=j.head=j.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.indexOf(t,n)>=0})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:new Date,a=null,i=n.apply(e,u)};return function(){var l=new Date;o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u)):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o;return function(){i=this,u=arguments,a=new Date;var c=function(){var l=new Date-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u)))},l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u)),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=w||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var I={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};I.unescape=j.invert(I.escape);var T={escape:new RegExp("["+j.keys(I.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(I.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return I[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);
|
6
|
+
//# sourceMappingURL=underscore-min.map
|
@@ -0,0 +1,320 @@
|
|
1
|
+
describe("Gmaps.Objects.Handler", function() {
|
2
|
+
|
3
|
+
var subjectClass = Gmaps.Objects.Handler;
|
4
|
+
var subject = null;
|
5
|
+
var builders_path = function() { return Gmaps.Specs.Builders; };
|
6
|
+
var builders = function(name){ return builders_path()[name]; };
|
7
|
+
var stubbed_path = function(name){ return Gmaps.Specs.spies.Builders; };
|
8
|
+
var stubbed = function(name){ return stubbed_path()[name]; };
|
9
|
+
var primitives = spec_helpers.override_primitives()
|
10
|
+
var build_subject = function() {
|
11
|
+
subject = new subjectClass('Specs', { primitives: primitives });
|
12
|
+
};
|
13
|
+
|
14
|
+
beforeEach(function() {
|
15
|
+
spec_helpers.createHandlersSpies();
|
16
|
+
});
|
17
|
+
|
18
|
+
it("function exists", function() {
|
19
|
+
expect(typeof subjectClass).toBe('function');
|
20
|
+
});
|
21
|
+
|
22
|
+
describe("constructor", function() {
|
23
|
+
beforeEach(function() {
|
24
|
+
build_subject();
|
25
|
+
});
|
26
|
+
|
27
|
+
describe("primitives setter", function() {
|
28
|
+
it("uses expected primitives", function() {
|
29
|
+
new subject.primitives.point();
|
30
|
+
expect(primitives.point).toHaveBeenCalled();
|
31
|
+
});
|
32
|
+
});
|
33
|
+
|
34
|
+
describe("options setter", function() {
|
35
|
+
it("default", function() {
|
36
|
+
expect(_.isEqual(subject.builders, subject._default_builders())).toBeTruthy();
|
37
|
+
expect(_.isEqual(subject.models, subject._default_models())).toBeTruthy();
|
38
|
+
expect(_.isEqual(subject.marker_options, subject._default_marker_options())).toBeTruthy();
|
39
|
+
});
|
40
|
+
|
41
|
+
it("redefines builders", function() {
|
42
|
+
var MarkerBuilder = function(){};
|
43
|
+
subject = new subjectClass('Specs', { primitives: primitives, builders: { Marker: MarkerBuilder } });
|
44
|
+
expect(subject.builders.Marker).toBe(MarkerBuilder);
|
45
|
+
});
|
46
|
+
|
47
|
+
it("redefines models", function() {
|
48
|
+
var MarkerModel = function(){};
|
49
|
+
subject = new subjectClass('Specs', { primitives: primitives, models: { Marker: MarkerModel } });
|
50
|
+
expect(subject.models.Marker).toBe(MarkerModel);
|
51
|
+
});
|
52
|
+
|
53
|
+
it("redefines marker_options", function() {
|
54
|
+
var marker_options = { foo: 1 };
|
55
|
+
subject = new subjectClass('Specs', { primitives: primitives, markers: marker_options });
|
56
|
+
expect(subject.marker_options.foo).toBe(marker_options.foo);
|
57
|
+
});
|
58
|
+
|
59
|
+
it("Clusterer: default model if clusterer required", function() {
|
60
|
+
subject = new subjectClass('Specs', {
|
61
|
+
primitives: primitives,
|
62
|
+
markers: { clusterer: {} }
|
63
|
+
});
|
64
|
+
expect(subject.models.Clusterer).not.toBe(Gmaps.Objects.NullClusterer);
|
65
|
+
});
|
66
|
+
|
67
|
+
it("Clusterer: null clusterer if no clusterer required", function() {
|
68
|
+
subject = new subjectClass('Specs', {
|
69
|
+
primitives: primitives,
|
70
|
+
markers: { clusterer: null }
|
71
|
+
});
|
72
|
+
expect(subject.models.Clusterer).toBe(Gmaps.Objects.NullClusterer);
|
73
|
+
});
|
74
|
+
|
75
|
+
it("creates bounds", function() {
|
76
|
+
expect(subject.bounds).toBe(stubbed('Bound'));
|
77
|
+
});
|
78
|
+
});
|
79
|
+
});
|
80
|
+
|
81
|
+
describe("buildMap", function() {
|
82
|
+
beforeEach(function() {
|
83
|
+
build_subject();
|
84
|
+
});
|
85
|
+
|
86
|
+
it("delegates to builder", function() {
|
87
|
+
var options = jasmine.createSpy('options');
|
88
|
+
var onMapLoad = function(){};
|
89
|
+
subject.buildMap(options, onMapLoad);
|
90
|
+
expect(Gmaps.Specs.Builders.Map).toHaveBeenCalledWith(options, jasmine.any(Function), undefined)
|
91
|
+
expect(subject.map).toBe(stubbed('Map'));
|
92
|
+
});
|
93
|
+
});
|
94
|
+
|
95
|
+
describe("with map", function() {
|
96
|
+
var map;
|
97
|
+
|
98
|
+
var assign_stubbed_map = function() {
|
99
|
+
map = jasmine.createSpy('map');
|
100
|
+
spyOn(subject, 'getMap').andReturn(map);
|
101
|
+
};
|
102
|
+
|
103
|
+
describe("add collection", function() {
|
104
|
+
|
105
|
+
var object_data, objects_data, provider_options, built_object;
|
106
|
+
|
107
|
+
beforeEach(function() {
|
108
|
+
built_object = jasmine.createSpy('built_object');
|
109
|
+
object_data = jasmine.createSpy('object_data');
|
110
|
+
objects_data = [object_data];
|
111
|
+
provider_options = jasmine.createSpy('provider_options');
|
112
|
+
build_subject();
|
113
|
+
assign_stubbed_map();
|
114
|
+
});
|
115
|
+
|
116
|
+
describe("addMarkers", function() {
|
117
|
+
it("loops and delegates to addMarker", function() {
|
118
|
+
spyOn(subject, 'addMarker').andReturn(built_object);
|
119
|
+
|
120
|
+
var result = subject.addMarkers(objects_data, provider_options);
|
121
|
+
|
122
|
+
expect(subject.addMarker).toHaveBeenCalledWith(object_data, provider_options);
|
123
|
+
expect(result).toEqual([built_object]);
|
124
|
+
});
|
125
|
+
});
|
126
|
+
|
127
|
+
describe("addCircles", function() {
|
128
|
+
it("loops and delegates to addCircle", function() {
|
129
|
+
spyOn(subject, 'addCircle').andReturn(built_object);
|
130
|
+
|
131
|
+
var result = subject.addCircles(objects_data, provider_options);
|
132
|
+
|
133
|
+
expect(subject.addCircle).toHaveBeenCalledWith(object_data, provider_options);
|
134
|
+
expect(result).toEqual([built_object]);
|
135
|
+
});
|
136
|
+
});
|
137
|
+
|
138
|
+
describe("addPolylines", function() {
|
139
|
+
it("loops and delegates to addPolyline", function() {
|
140
|
+
spyOn(subject, 'addPolyline').andReturn(built_object);
|
141
|
+
|
142
|
+
var result = subject.addPolylines(objects_data, provider_options);
|
143
|
+
|
144
|
+
expect(subject.addPolyline).toHaveBeenCalledWith(object_data, provider_options);
|
145
|
+
expect(result).toEqual([built_object]);
|
146
|
+
});
|
147
|
+
});
|
148
|
+
|
149
|
+
describe("addPolygons", function() {
|
150
|
+
it("loops and delegates to addPolygon", function() {
|
151
|
+
spyOn(subject, 'addPolygon').andReturn(built_object);
|
152
|
+
|
153
|
+
var result = subject.addPolygons(objects_data, provider_options);
|
154
|
+
|
155
|
+
expect(subject.addPolygon).toHaveBeenCalledWith(object_data, provider_options);
|
156
|
+
expect(result).toEqual([built_object]);
|
157
|
+
});
|
158
|
+
});
|
159
|
+
|
160
|
+
describe("addKmls", function() {
|
161
|
+
it("loops and delegates to addKml", function() {
|
162
|
+
spyOn(subject, 'addKml').andReturn(built_object);
|
163
|
+
|
164
|
+
var result = subject.addKmls(objects_data, provider_options);
|
165
|
+
|
166
|
+
expect(subject.addKml).toHaveBeenCalledWith(object_data, provider_options);
|
167
|
+
expect(result).toEqual([built_object]);
|
168
|
+
});
|
169
|
+
});
|
170
|
+
});
|
171
|
+
|
172
|
+
describe("add single item", function() {
|
173
|
+
var object, object_data, provider_options, builder_spy;
|
174
|
+
|
175
|
+
var create_context = function(name){
|
176
|
+
stubbed_path()[name] = object;
|
177
|
+
builder_spy = builders(name);
|
178
|
+
|
179
|
+
build_subject();
|
180
|
+
assign_stubbed_map();
|
181
|
+
};
|
182
|
+
|
183
|
+
beforeEach(function() {
|
184
|
+
object = jasmine.createSpyObj('object', ['setMap']);
|
185
|
+
object_data = jasmine.createSpy('object_data');
|
186
|
+
provider_options = jasmine.createSpy('provider_options');
|
187
|
+
});
|
188
|
+
|
189
|
+
describe("addMarker", function() {
|
190
|
+
var clusterer;
|
191
|
+
|
192
|
+
beforeEach(function() {
|
193
|
+
clusterer = jasmine.createSpyObj('clusterer', ['addMarker']);
|
194
|
+
create_context('Marker');
|
195
|
+
subject.clusterer = clusterer;
|
196
|
+
});
|
197
|
+
|
198
|
+
it("delegates marker creation to builder", function() {
|
199
|
+
var result = subject.addMarker(object_data, provider_options);
|
200
|
+
expect(builder_spy).toHaveBeenCalledWith(object_data, provider_options, subject.marker_options);
|
201
|
+
});
|
202
|
+
|
203
|
+
it("associate map to Marker", function() {
|
204
|
+
subject.addMarker(object_data, provider_options);
|
205
|
+
|
206
|
+
expect(object.setMap).toHaveBeenCalledWith(map);
|
207
|
+
});
|
208
|
+
|
209
|
+
it("clusterer receives marker", function() {
|
210
|
+
subject.addMarker(object_data, provider_options);
|
211
|
+
|
212
|
+
expect(clusterer.addMarker).toHaveBeenCalledWith(object);
|
213
|
+
});
|
214
|
+
|
215
|
+
it("returns marker", function() {
|
216
|
+
var result = subject.addMarker(object_data, provider_options);
|
217
|
+
|
218
|
+
expect(result).toBe(object);
|
219
|
+
});
|
220
|
+
});
|
221
|
+
|
222
|
+
describe("addCircle", function() {
|
223
|
+
beforeEach(function() {
|
224
|
+
create_context('Circle');
|
225
|
+
});
|
226
|
+
|
227
|
+
it("delegates circle creation to builder", function() {
|
228
|
+
subject.addCircle(object_data, provider_options);
|
229
|
+
|
230
|
+
expect(builder_spy).toHaveBeenCalledWith(object_data, provider_options, undefined);
|
231
|
+
});
|
232
|
+
|
233
|
+
it("associate map to circle", function() {
|
234
|
+
subject.addCircle(object_data, provider_options);
|
235
|
+
|
236
|
+
expect(object.setMap).toHaveBeenCalledWith(map);
|
237
|
+
});
|
238
|
+
|
239
|
+
it("returns circle", function() {
|
240
|
+
var result = subject.addCircle(object_data, provider_options);
|
241
|
+
|
242
|
+
expect(result).toBe(object);
|
243
|
+
});
|
244
|
+
});
|
245
|
+
|
246
|
+
describe("addPolyline", function() {
|
247
|
+
beforeEach(function() {
|
248
|
+
create_context('Polyline');
|
249
|
+
});
|
250
|
+
|
251
|
+
it("delegates polyline creation to builder", function() {
|
252
|
+
subject.addPolyline(object_data, provider_options);
|
253
|
+
|
254
|
+
expect(builder_spy).toHaveBeenCalledWith(object_data, provider_options, undefined);
|
255
|
+
});
|
256
|
+
|
257
|
+
it("associate map to polyline", function() {
|
258
|
+
subject.addPolyline(object_data, provider_options);
|
259
|
+
|
260
|
+
expect(object.setMap).toHaveBeenCalledWith(map);
|
261
|
+
});
|
262
|
+
|
263
|
+
it("returns polyline", function() {
|
264
|
+
var result = subject.addPolyline(object_data, provider_options);
|
265
|
+
|
266
|
+
expect(result).toBe(object);
|
267
|
+
});
|
268
|
+
});
|
269
|
+
|
270
|
+
describe("addPolygon", function() {
|
271
|
+
beforeEach(function() {
|
272
|
+
create_context('Polygon');
|
273
|
+
});
|
274
|
+
|
275
|
+
it("delegates polygon creation to builder", function() {
|
276
|
+
subject.addPolygon(object_data, provider_options);
|
277
|
+
|
278
|
+
expect(builder_spy).toHaveBeenCalledWith(object_data, provider_options, undefined);
|
279
|
+
});
|
280
|
+
|
281
|
+
it("associate map to polygon", function() {
|
282
|
+
subject.addPolygon(object_data, provider_options);
|
283
|
+
|
284
|
+
expect(object.setMap).toHaveBeenCalledWith(map);
|
285
|
+
});
|
286
|
+
|
287
|
+
it("returns polygon", function() {
|
288
|
+
var result = subject.addPolygon(object_data, provider_options);
|
289
|
+
|
290
|
+
expect(result).toBe(object);
|
291
|
+
});
|
292
|
+
});
|
293
|
+
|
294
|
+
describe("addKml", function() {
|
295
|
+
beforeEach(function() {
|
296
|
+
create_context('Kml');
|
297
|
+
});
|
298
|
+
|
299
|
+
it("delegates kml creation to builder", function() {
|
300
|
+
subject.addKml(object_data, provider_options);
|
301
|
+
|
302
|
+
expect(builder_spy).toHaveBeenCalledWith(object_data, provider_options, undefined);
|
303
|
+
});
|
304
|
+
|
305
|
+
it("associate map to kml", function() {
|
306
|
+
subject.addKml(object_data, provider_options);
|
307
|
+
|
308
|
+
expect(object.setMap).toHaveBeenCalledWith(map);
|
309
|
+
});
|
310
|
+
|
311
|
+
it("returns kml", function() {
|
312
|
+
var result = subject.addKml(object_data, provider_options);
|
313
|
+
|
314
|
+
expect(result).toBe(object);
|
315
|
+
});
|
316
|
+
});
|
317
|
+
});
|
318
|
+
});
|
319
|
+
|
320
|
+
});
|