ymaps 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +23 -0
- data/Gemfile +3 -0
- data/Rakefile +4 -26
- data/lib/geokit/geocoders/yandex_geocoder.rb +16 -6
- data/lib/ymaps/action_view/html_helper.rb +6 -6
- data/lib/ymaps/action_view/ymapsml_helper.rb +59 -50
- data/lib/ymaps/version.rb +3 -0
- data/ymaps.gemspec +18 -56
- metadata +24 -22
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,24 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = 'ymaps'
|
8
|
-
gem.summary = %Q{Helpers for using YMaps}
|
9
|
-
gem.description = %Q{Different helpers for generating YMapsML, using YMaps widgets and geocoding via Yandex.Maps}
|
10
|
-
gem.email = 'rotuka@rotuka.com'
|
11
|
-
gem.homepage = 'http://github.com/rotuka/ymaps'
|
12
|
-
gem.authors = ['Alexander Semyonov']
|
13
|
-
gem.add_development_dependency 'shoulda', '>= 0'
|
14
|
-
gem.add_development_dependency 'yard', '>= 0'
|
15
|
-
gem.add_dependency 'geokit', '1.5.0'
|
16
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
-
end
|
18
|
-
Jeweler::GemcutterTasks.new
|
19
|
-
rescue LoadError
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
-
end
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
22
3
|
|
23
4
|
require 'rake/testtask'
|
24
5
|
Rake::TestTask.new(:test) do |test|
|
@@ -46,12 +27,9 @@ task :default => :test
|
|
46
27
|
|
47
28
|
begin
|
48
29
|
require 'yard'
|
49
|
-
YARD::Rake::YardocTask.new
|
30
|
+
YARD::Rake::YardocTask.new(:doc)
|
50
31
|
rescue LoadError
|
51
|
-
task :
|
32
|
+
task :doc do
|
52
33
|
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
53
34
|
end
|
54
35
|
end
|
55
|
-
|
56
|
-
task :rdoc => :yard
|
57
|
-
task :doc => :yard
|
@@ -10,15 +10,25 @@ module Geokit
|
|
10
10
|
"#{lng} #{lat}"
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def gml_lnglat
|
14
14
|
"#{lng},#{lat}"
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def gml_lnglat=(lnglat)
|
18
18
|
self.lng, self.lat = lnglat[0], lnglat[1]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
class Bounds
|
23
|
+
def lower
|
24
|
+
sw
|
25
|
+
end
|
26
|
+
|
27
|
+
def upper
|
28
|
+
ne
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
22
32
|
class GeoLoc
|
23
33
|
attr_accessor :kind
|
24
34
|
attr_writer :street_number, :street_name
|
@@ -88,7 +98,7 @@ module Geokit
|
|
88
98
|
|
89
99
|
def self.do_reverse_geocode(latlng)
|
90
100
|
latlng = LatLng.normalize(latlng)
|
91
|
-
call_geocoder_service(latlng.
|
101
|
+
call_geocoder_service(latlng.gml_lnglat) || GeoLoc.new
|
92
102
|
end
|
93
103
|
|
94
104
|
def self.do_geocode(address, options = {})
|
@@ -125,7 +135,7 @@ module Geokit
|
|
125
135
|
res.provider = 'yandex'
|
126
136
|
|
127
137
|
# basics
|
128
|
-
res.
|
138
|
+
res.gml_lnglat = doc.elements['.//Point/pos'].text.to_s.split(' ')
|
129
139
|
|
130
140
|
# extended -- false if not available
|
131
141
|
res.full_address = doc.elements['.//GeocoderMetaData/text'].try(:text)
|
@@ -144,8 +154,8 @@ module Geokit
|
|
144
154
|
|
145
155
|
if suggested_bounds = doc.elements['.//boundedBy']
|
146
156
|
res.suggested_bounds = Bounds.normalize(
|
147
|
-
suggested_bounds.elements['.//lowerCorner'].text.to_s.split(' '),
|
148
|
-
suggested_bounds.elements['.//upperCorner'].text.to_s.split(' ')
|
157
|
+
suggested_bounds.elements['.//lowerCorner'].text.to_s.split(' ').reverse,
|
158
|
+
suggested_bounds.elements['.//upperCorner'].text.to_s.split(' ').reverse
|
149
159
|
)
|
150
160
|
end
|
151
161
|
|
@@ -3,15 +3,15 @@ module YMaps
|
|
3
3
|
module HtmlHelper
|
4
4
|
class StaticMapPoint < Struct.new('MapPoint', :style, :color, :size, :number, :lat, :lng)
|
5
5
|
def to_s
|
6
|
-
"#{
|
6
|
+
"#{gml_lnglat},#{style}#{color}#{size}#{number}"
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
@
|
9
|
+
def gml_lnglat
|
10
|
+
@gml_lnglat ||= "#{lng},#{lat}"
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
@
|
13
|
+
def gml_lnglat=(latlng)
|
14
|
+
@gml_lnglat = latlng
|
15
15
|
end
|
16
16
|
|
17
17
|
def attributes=(attrs)
|
@@ -65,7 +65,7 @@ module YMaps
|
|
65
65
|
)
|
66
66
|
|
67
67
|
collection = Array(resources).inject([]) do |result, resource|
|
68
|
-
common_point.
|
68
|
+
common_point.gml_lnglat = resource.latlng.gml_lnglat
|
69
69
|
common_point.number += 1
|
70
70
|
result << common_point.to_s
|
71
71
|
result
|
@@ -64,7 +64,63 @@ module YMaps
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
class
|
67
|
+
class YMapsBuilder < Builder
|
68
|
+
def initialize(xml, view, ymaps_options = {})
|
69
|
+
@xml, @view, @ymaps_options = xml, view, ymaps_options
|
70
|
+
end
|
71
|
+
|
72
|
+
def collection(options = {})
|
73
|
+
GeoObjectCollection do
|
74
|
+
if options.key?(:style)
|
75
|
+
@xml.style("\##{options.delete(:style)}")
|
76
|
+
end
|
77
|
+
featureMembers { yield }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def object(object, options = {})
|
82
|
+
GeoObject do
|
83
|
+
if options.key?(:style)
|
84
|
+
@xml.style("\##{options.delete(:style)}")
|
85
|
+
end
|
86
|
+
point(object.latlng) if object.respond_to?(:latlng)
|
87
|
+
bounds(object.bounds) if object.respond_to?(:bounds)
|
88
|
+
name(options.delete(:name) { object.to_s })
|
89
|
+
yield self
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def point(latlng)
|
94
|
+
Point {
|
95
|
+
pos(latlng.gml_pos)
|
96
|
+
} if latlng
|
97
|
+
end
|
98
|
+
|
99
|
+
def bounds(bounds)
|
100
|
+
boundedBy {
|
101
|
+
Envelope {
|
102
|
+
lowerCorner(bounds.lower.gml_pos)
|
103
|
+
upperCorner(bounds.upper.gml_pos)
|
104
|
+
}
|
105
|
+
} if bounds
|
106
|
+
end
|
107
|
+
|
108
|
+
def meta_data
|
109
|
+
metaDataProperty {
|
110
|
+
AnyMetaData {
|
111
|
+
yield(@xml)
|
112
|
+
}
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
def representation
|
117
|
+
Representation {
|
118
|
+
yield(YMapsReprBuilder.new(@xml, @view))
|
119
|
+
}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class YMapsReprBuilder < YMapsBuilder
|
68
124
|
ACCEPTABLE_STYLES = {
|
69
125
|
:balloon_content => [:template],
|
70
126
|
:hint_content => [:template],
|
@@ -76,9 +132,8 @@ module YMaps
|
|
76
132
|
|
77
133
|
def view(options = {})
|
78
134
|
View {
|
79
|
-
if options[:type]
|
80
|
-
|
81
|
-
end
|
135
|
+
mapType(options[:type].to_s.upcase) if options[:type]
|
136
|
+
bounds(options[:bounds]) if options[:bounds]
|
82
137
|
yield if block_given?
|
83
138
|
}
|
84
139
|
end
|
@@ -151,51 +206,5 @@ module YMaps
|
|
151
206
|
prefixed_method(:offset, :x => x, :y => y)
|
152
207
|
end
|
153
208
|
end
|
154
|
-
|
155
|
-
class YMapsBuilder < Builder
|
156
|
-
def initialize(xml, view, ymaps_options = {})
|
157
|
-
@xml, @view, @ymaps_options = xml, view, ymaps_options
|
158
|
-
end
|
159
|
-
|
160
|
-
def collection(options = {})
|
161
|
-
GeoObjectCollection do
|
162
|
-
if options.key?(:style)
|
163
|
-
@xml.style("\##{options.delete(:style)}")
|
164
|
-
end
|
165
|
-
featureMembers { yield }
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def object(object, options = {})
|
170
|
-
GeoObject do
|
171
|
-
if options.key?(:style)
|
172
|
-
@xml.style("\##{options.delete(:style)}")
|
173
|
-
end
|
174
|
-
point(object.latlng)
|
175
|
-
name(options.delete(:name) { object.to_s })
|
176
|
-
yield self
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def point(latlng)
|
181
|
-
Point {
|
182
|
-
pos(latlng.gml_pos)
|
183
|
-
}
|
184
|
-
end
|
185
|
-
|
186
|
-
def meta_data
|
187
|
-
metaDataProperty {
|
188
|
-
AnyMetaData {
|
189
|
-
yield(@xml)
|
190
|
-
}
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
|
-
def representation
|
195
|
-
Representation {
|
196
|
-
yield(YMapsReprBuilder.new(@xml))
|
197
|
-
}
|
198
|
-
end
|
199
|
-
end
|
200
209
|
end
|
201
210
|
end
|
data/ymaps.gemspec
CHANGED
@@ -1,64 +1,26 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'ymaps/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
s.name = 'ymaps'
|
7
|
+
s.version = YMaps::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Alexander Semyonov']
|
10
|
+
s.email = ['al@semyonov.us']
|
11
|
+
s.homepage = 'http://github.com/rotuka/ymaps'
|
12
|
+
s.summary = %q{Helpers for using YMaps}
|
13
13
|
s.description = %q{Different helpers for generating YMapsML, using YMaps widgets and geocoding via Yandex.Maps}
|
14
|
-
|
15
|
-
s.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
s.files
|
20
|
-
".document",
|
21
|
-
"LICENSE",
|
22
|
-
"README.rdoc",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"init.rb",
|
26
|
-
"lib/geokit/geocoders/yandex_geocoder.rb",
|
27
|
-
"lib/geokit/inflector.rb",
|
28
|
-
"lib/ymaps.rb",
|
29
|
-
"lib/ymaps/action_view.rb",
|
30
|
-
"lib/ymaps/action_view/html_helper.rb",
|
31
|
-
"lib/ymaps/action_view/ymapsml_helper.rb",
|
32
|
-
"test/helper.rb",
|
33
|
-
"test/test_ymaps.rb",
|
34
|
-
"ymaps.gemspec"
|
35
|
-
]
|
36
|
-
s.homepage = %q{http://github.com/rotuka/ymaps}
|
14
|
+
|
15
|
+
s.rubyforge_project = 'ymaps'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
37
20
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = %q{1.3.7}
|
39
|
-
s.summary = %q{Helpers for using YMaps}
|
40
|
-
s.test_files = [
|
41
|
-
"test/helper.rb",
|
42
|
-
"test/test_ymaps.rb"
|
43
|
-
]
|
44
21
|
|
45
|
-
|
46
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
-
s.specification_version = 3
|
22
|
+
s.add_dependency('geokit', '= 1.5.0')
|
48
23
|
|
49
|
-
|
50
|
-
|
51
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
52
|
-
s.add_runtime_dependency(%q<geokit>, ["= 1.5.0"])
|
53
|
-
else
|
54
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
55
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
56
|
-
s.add_dependency(%q<geokit>, ["= 1.5.0"])
|
57
|
-
end
|
58
|
-
else
|
59
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
60
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
61
|
-
s.add_dependency(%q<geokit>, ["= 1.5.0"])
|
62
|
-
end
|
24
|
+
s.add_development_dependency('shoulda', '>= 0')
|
25
|
+
s.add_development_dependency('yard', '>= 0')
|
63
26
|
end
|
64
|
-
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexander Semyonov
|
@@ -14,24 +14,26 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-05-09 00:00:00 +06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: geokit
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - "="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
|
+
- 1
|
30
|
+
- 5
|
29
31
|
- 0
|
30
|
-
version:
|
31
|
-
type: :
|
32
|
+
version: 1.5.0
|
33
|
+
type: :runtime
|
32
34
|
version_requirements: *id001
|
33
35
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
36
|
+
name: shoulda
|
35
37
|
prerelease: false
|
36
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
39
|
none: false
|
@@ -44,31 +46,31 @@ dependencies:
|
|
44
46
|
type: :development
|
45
47
|
version_requirements: *id002
|
46
48
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
49
|
+
name: yard
|
48
50
|
prerelease: false
|
49
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
50
52
|
none: false
|
51
53
|
requirements:
|
52
|
-
- - "
|
54
|
+
- - ">="
|
53
55
|
- !ruby/object:Gem::Version
|
54
56
|
segments:
|
55
|
-
- 1
|
56
|
-
- 5
|
57
57
|
- 0
|
58
|
-
version:
|
59
|
-
type: :
|
58
|
+
version: "0"
|
59
|
+
type: :development
|
60
60
|
version_requirements: *id003
|
61
61
|
description: Different helpers for generating YMapsML, using YMaps widgets and geocoding via Yandex.Maps
|
62
|
-
email:
|
62
|
+
email:
|
63
|
+
- al@semyonov.us
|
63
64
|
executables: []
|
64
65
|
|
65
66
|
extensions: []
|
66
67
|
|
67
|
-
extra_rdoc_files:
|
68
|
-
|
69
|
-
- README.rdoc
|
68
|
+
extra_rdoc_files: []
|
69
|
+
|
70
70
|
files:
|
71
71
|
- .document
|
72
|
+
- .gitignore
|
73
|
+
- Gemfile
|
72
74
|
- LICENSE
|
73
75
|
- README.rdoc
|
74
76
|
- Rakefile
|
@@ -80,6 +82,7 @@ files:
|
|
80
82
|
- lib/ymaps/action_view.rb
|
81
83
|
- lib/ymaps/action_view/html_helper.rb
|
82
84
|
- lib/ymaps/action_view/ymapsml_helper.rb
|
85
|
+
- lib/ymaps/version.rb
|
83
86
|
- test/helper.rb
|
84
87
|
- test/test_ymaps.rb
|
85
88
|
- ymaps.gemspec
|
@@ -110,11 +113,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
113
|
version: "0"
|
111
114
|
requirements: []
|
112
115
|
|
113
|
-
rubyforge_project:
|
116
|
+
rubyforge_project: ymaps
|
114
117
|
rubygems_version: 1.3.7
|
115
118
|
signing_key:
|
116
119
|
specification_version: 3
|
117
120
|
summary: Helpers for using YMaps
|
118
|
-
test_files:
|
119
|
-
|
120
|
-
- test/test_ymaps.rb
|
121
|
+
test_files: []
|
122
|
+
|