ym4r_gm 0.2.0

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.
@@ -0,0 +1,34 @@
1
+ module Ym4r
2
+ module GmPlugin
3
+ #A point in pixel coordinates
4
+ class GPoint < Struct.new(:x,:y)
5
+ include MappingObject
6
+ def create
7
+ "new GPoint(#{x},#{y})"
8
+ end
9
+ end
10
+ #A rectangular that contains all the pixel points passed as arguments
11
+ class GBounds
12
+ include MappingObject
13
+ attr_accessor :points
14
+ #Accepts both an array of GPoint and an array of 2-element arrays
15
+ def initialize(points)
16
+ if !points.empty? and points[0].is_a?(Array)
17
+ @points = points.collect { |pt| GPoint.new(pt[0],pt[1]) }
18
+ else
19
+ @points = points
20
+ end
21
+ end
22
+ def create
23
+ "new GBounds([#{@points.map { |pt| pt.to_javascript}.join(",")}])"
24
+ end
25
+ end
26
+ #A size object, in pixel space
27
+ class GSize < Struct.new(:width,:height)
28
+ include MappingObject
29
+ def create
30
+ "new GSize(#{width},#{height})"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :gm do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,12 @@
1
+ require 'gm_plugin/key'
2
+ require 'gm_plugin/mapping'
3
+ require 'gm_plugin/map'
4
+ require 'gm_plugin/control'
5
+ require 'gm_plugin/point'
6
+ require 'gm_plugin/overlay'
7
+ require 'gm_plugin/layer'
8
+ require 'gm_plugin/helper'
9
+ require 'gm_plugin/geocoding'
10
+ require 'gm_plugin/encoder'
11
+
12
+ include Ym4r::GmPlugin
@@ -0,0 +1,22 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the gm plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for the gm plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'ym4r_gm-doc'
18
+ rdoc.title = 'GM'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
@@ -0,0 +1,91 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+
3
+
4
+ if ENV["RAILS_ROOT"]
5
+ require File.expand_path(ENV["RAILS_ROOT"] + "/config/environment")
6
+ else
7
+ warn "In order to run the unit tests, the environment variable RAILS_ROOT must be set to a valid Rails app's root directory."
8
+ exit
9
+ end
10
+
11
+ require 'ym4r_gm'
12
+ require 'test/unit'
13
+
14
+ include Ym4r::GmPlugin
15
+
16
+ class TestGoogleMaps< Test::Unit::TestCase
17
+ def test_javascriptify_method
18
+ assert_equal("addOverlayToHello",MappingObject::javascriptify_method("add_overlay_to_hello"))
19
+ end
20
+
21
+ def test_javascriptify_variable_mapping_object
22
+ map = GMap.new("div")
23
+ assert_equal(map.to_javascript,MappingObject::javascriptify_variable(map))
24
+ end
25
+
26
+ def test_javascriptify_variable_numeric
27
+ assert_equal("123.4",MappingObject::javascriptify_variable(123.4))
28
+ end
29
+
30
+ def test_javascriptify_variable_array
31
+ map = GMap.new("div")
32
+ assert_equal("[123.4,#{map.to_javascript},[123.4,#{map.to_javascript}]]",MappingObject::javascriptify_variable([123.4,map,[123.4,map]]))
33
+ end
34
+
35
+ def test_javascriptify_variable_hash
36
+ map = GMap.new("div")
37
+ test_str = MappingObject::javascriptify_variable("hello" => map, "chopotopoto" => [123.55,map])
38
+ assert("{hello : #{map.to_javascript},chopotopoto : [123.55,#{map.to_javascript}]}" == test_str || "{chopotopoto : [123.55,#{map.to_javascript}],hello : #{map.to_javascript}}" == test_str)
39
+ end
40
+
41
+ def test_method_call_on_mapping_object
42
+ map = GMap.new("div","map")
43
+ assert_equal("map.addHello(123.4);",map.add_hello(123.4).to_s)
44
+ end
45
+
46
+ def test_nested_calls_on_mapping_object
47
+ gmap = GMap.new("div","map")
48
+ assert_equal("map.addHello(map.hoYoYo(123.4),map);",gmap.add_hello(gmap.ho_yo_yo(123.4),gmap).to_s)
49
+ end
50
+
51
+ def test_declare_variable_latlng
52
+ point = GLatLng.new([123.4,123.6])
53
+ assert_equal("var point = new GLatLng(123.4,123.6);",point.declare("point"))
54
+ assert_equal("point",point.variable)
55
+ assert_equal("point",point.variable.to_str)
56
+ end
57
+
58
+ def test_array_indexing
59
+ obj = Variable.new("obj")
60
+ assert_equal("obj[0]",obj[0].variable)
61
+ assert_equal("obj[0]",obj[0].variable.to_str)
62
+ end
63
+
64
+ def test_google_maps_geocoding
65
+ placemarks = Geocoding.get("Rue Clovis Paris")
66
+ assert_equal(Geocoding::GEO_SUCCESS,placemarks.status)
67
+ assert_equal(1,placemarks.length)
68
+ placemark = placemarks[0]
69
+ assert_equal("FR",placemark.country_code)
70
+ assert_equal("Paris",placemark.locality)
71
+ assert_equal("75005",placemark.postal_code)
72
+
73
+ #test iwht multiple placemarks
74
+ placemarks = Geocoding.get('hoogstraat, nl')
75
+ assert_equal(Geocoding::GEO_SUCCESS,placemarks.status)
76
+ assert(placemarks.length > 1)
77
+ assert(placemarks[0].latitude != placemarks[1].latitude )
78
+ end
79
+
80
+ def test_gmap_polyline_encoder
81
+ points = [
82
+ [37.76, -122.20],
83
+ [37.77, -122.22],
84
+ [37.78, -122.19]
85
+ ]
86
+
87
+ encoded_points = GMapPolylineEncoder.new.encode(points)
88
+ assert_equal("__neF~dzhVo}@~{Bo}@ozD", encoded_points[:points])
89
+ end
90
+ end
91
+
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ym4r_gm}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Grzegorz Błaszczyk"]
12
+ s.date = %q{2010-12-08}
13
+ s.description = %q{Fork of YM4R_GM for Rails 3 and Ruby 1.9.2}
14
+ s.email = %q{grzegorz.blaszczyk@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "gmaps_api_key.yml.sample",
26
+ "init.rb",
27
+ "install.rb",
28
+ "javascript/clusterer.js",
29
+ "javascript/geoRssOverlay.js",
30
+ "javascript/markerGroup.js",
31
+ "javascript/wms-gs.js",
32
+ "javascript/ym4r-gm.js",
33
+ "lib/gm_plugin/control.rb",
34
+ "lib/gm_plugin/encoder.rb",
35
+ "lib/gm_plugin/geocoding.rb",
36
+ "lib/gm_plugin/helper.rb",
37
+ "lib/gm_plugin/key.rb",
38
+ "lib/gm_plugin/layer.rb",
39
+ "lib/gm_plugin/map.rb",
40
+ "lib/gm_plugin/mapping.rb",
41
+ "lib/gm_plugin/overlay.rb",
42
+ "lib/gm_plugin/point.rb",
43
+ "lib/tasks/gm_tasks.rake",
44
+ "lib/ym4r_gm.rb",
45
+ "rakefile.rb",
46
+ "test/gm_test.rb",
47
+ "ym4r_gm.gemspec"
48
+ ]
49
+ s.homepage = %q{http://github.com/grzegorzblaszczyk/ym4r_gm}
50
+ s.licenses = ["MIT"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = %q{1.3.7}
53
+ s.summary = %q{Fork of YM4R_GM for Rails 3 and Ruby 1.9.2}
54
+ s.test_files = [
55
+ "test/gm_test.rb"
56
+ ]
57
+
58
+ if s.respond_to? :specification_version then
59
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_runtime_dependency(%q<ym4r>, [">= 0"])
64
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
65
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
67
+ s.add_development_dependency(%q<rcov>, [">= 0"])
68
+ else
69
+ s.add_dependency(%q<ym4r>, [">= 0"])
70
+ s.add_dependency(%q<shoulda>, [">= 0"])
71
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
72
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
73
+ s.add_dependency(%q<rcov>, [">= 0"])
74
+ end
75
+ else
76
+ s.add_dependency(%q<ym4r>, [">= 0"])
77
+ s.add_dependency(%q<shoulda>, [">= 0"])
78
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
79
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
80
+ s.add_dependency(%q<rcov>, [">= 0"])
81
+ end
82
+ end
83
+
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ym4r_gm
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
+ platform: ruby
11
+ authors:
12
+ - "Grzegorz B\xC5\x82aszczyk"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-08 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: ym4r
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ prerelease: false
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: shoulda
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: &id003 !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 1
55
+ - 0
56
+ - 0
57
+ version: 1.0.0
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: jeweler
63
+ requirement: &id004 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 1
70
+ - 5
71
+ - 1
72
+ version: 1.5.1
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: rcov
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: *id005
89
+ description: Fork of YM4R_GM for Rails 3 and Ruby 1.9.2
90
+ email: grzegorz.blaszczyk@gmail.com
91
+ executables: []
92
+
93
+ extensions: []
94
+
95
+ extra_rdoc_files:
96
+ - README.md
97
+ files:
98
+ - .document
99
+ - Gemfile
100
+ - Gemfile.lock
101
+ - README.md
102
+ - Rakefile
103
+ - VERSION
104
+ - gmaps_api_key.yml.sample
105
+ - init.rb
106
+ - install.rb
107
+ - javascript/clusterer.js
108
+ - javascript/geoRssOverlay.js
109
+ - javascript/markerGroup.js
110
+ - javascript/wms-gs.js
111
+ - javascript/ym4r-gm.js
112
+ - lib/gm_plugin/control.rb
113
+ - lib/gm_plugin/encoder.rb
114
+ - lib/gm_plugin/geocoding.rb
115
+ - lib/gm_plugin/helper.rb
116
+ - lib/gm_plugin/key.rb
117
+ - lib/gm_plugin/layer.rb
118
+ - lib/gm_plugin/map.rb
119
+ - lib/gm_plugin/mapping.rb
120
+ - lib/gm_plugin/overlay.rb
121
+ - lib/gm_plugin/point.rb
122
+ - lib/tasks/gm_tasks.rake
123
+ - lib/ym4r_gm.rb
124
+ - rakefile.rb
125
+ - test/gm_test.rb
126
+ - ym4r_gm.gemspec
127
+ has_rdoc: true
128
+ homepage: http://github.com/grzegorzblaszczyk/ym4r_gm
129
+ licenses:
130
+ - MIT
131
+ post_install_message:
132
+ rdoc_options: []
133
+
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ hash: -1430238682925958947
142
+ segments:
143
+ - 0
144
+ version: "0"
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ segments:
151
+ - 0
152
+ version: "0"
153
+ requirements: []
154
+
155
+ rubyforge_project:
156
+ rubygems_version: 1.3.7
157
+ signing_key:
158
+ specification_version: 3
159
+ summary: Fork of YM4R_GM for Rails 3 and Ruby 1.9.2
160
+ test_files:
161
+ - test/gm_test.rb