geo_magic 0.2.4.1 → 0.2.4.2
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.
- data/README.textile +22 -9
- data/VERSION +1 -1
- data/geo_magic.gemspec +5 -2
- data/lib/geo_magic/geocode/config.rb +0 -2
- data/lib/rails/config.rb +8 -18
- data/spec/fixtures/config/map_api_keys.yml +4 -0
- data/spec/geo_magic/geocoder_rails_spec.rb +37 -0
- data/spec/geo_magic/geocoder_spec.rb +2 -13
- metadata +7 -4
data/README.textile
CHANGED
@@ -91,9 +91,9 @@ Single Geocode Geocoder:
|
|
91
91
|
|
92
92
|
<pre>
|
93
93
|
# Use Graticule Multi geocoder, which tries multiple geocode services in succession!
|
94
|
-
|
95
|
-
|
96
|
-
location =
|
94
|
+
geocoder = GeoMagic.geo_coder(:type => :geocode)
|
95
|
+
geocoder.configure File.expand_path('../fixtures/map_api_keys.yaml', File.dirname(__FILE__)), :development
|
96
|
+
location = geocoder.instance.geocode "Mullerstrasse 9, Munich"
|
97
97
|
location.city
|
98
98
|
</pre>
|
99
99
|
|
@@ -101,9 +101,9 @@ Single Graticule Geocoder:
|
|
101
101
|
|
102
102
|
<pre>
|
103
103
|
# Use Graticule Multi geocoder, which tries multiple geocode services in succession!
|
104
|
-
|
105
|
-
|
106
|
-
location =
|
104
|
+
geocoder = GeoMagic.geo_coder(:type => graticule)
|
105
|
+
geocoder.configure File.expand_path('../fixtures/map_api_keys.yaml', File.dirname(__FILE__)), :development
|
106
|
+
location = geocoder.instance.geocode "Mullerstrasse 9, Munich"
|
107
107
|
location.city
|
108
108
|
</pre>
|
109
109
|
|
@@ -111,7 +111,7 @@ Multi Graticule Geocoder:
|
|
111
111
|
|
112
112
|
<pre>
|
113
113
|
# Use Graticule Multi geocoder, which tries multiple geocode services in succession!
|
114
|
-
|
114
|
+
geocoder = GeoMagic.geo_coder(:type => graticule_multi)
|
115
115
|
..
|
116
116
|
</pre>
|
117
117
|
|
@@ -119,13 +119,26 @@ Multi Graticule Customization:
|
|
119
119
|
|
120
120
|
<pre>
|
121
121
|
# Use Graticule Multi geocoder, which tries multiple geocode services in succession!
|
122
|
-
|
123
|
-
location =
|
122
|
+
geocoder = GeoMagic.geo_coder(:type => graticule_multi)
|
123
|
+
location = geocoder.instance(:timeout => 3) do |result|
|
124
124
|
[:address, :street].include?(result.precision)]
|
125
125
|
end
|
126
126
|
..
|
127
127
|
</pre>
|
128
128
|
|
129
|
+
Geocoder in Rails:
|
130
|
+
|
131
|
+
<pre>
|
132
|
+
geocoder = GeoMagic.geo_coder(:env => :rails)
|
133
|
+
geocoder.configure
|
134
|
+
|
135
|
+
location = geocoder.instance.geocode "Mullerstrasse 9, Munich"
|
136
|
+
location.city.should == 'Munich'
|
137
|
+
</pre>
|
138
|
+
|
139
|
+
By default, the configuration expects a file in config/map_api_keys.yml containing the keys for each environment (see spec/fictures folder).
|
140
|
+
This can be customized if needed: @geocoder.configure '../my_keys.yaml'@
|
141
|
+
|
129
142
|
h3. Create random points in Radius
|
130
143
|
|
131
144
|
* @create_points_in_square@
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.4.
|
1
|
+
0.2.4.2
|
data/geo_magic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{geo_magic}
|
8
|
-
s.version = "0.2.4.
|
8
|
+
s.version = "0.2.4.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2011-01
|
12
|
+
s.date = %q{2011-02-01}
|
13
13
|
s.description = %q{Get IP and location data using freegeoip.net - can also calculate of distance between map points using haversine supporting multiple distance units}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -43,9 +43,11 @@ Gem::Specification.new do |s|
|
|
43
43
|
"lib/geo_magic/remote.rb",
|
44
44
|
"lib/geo_magic/util.rb",
|
45
45
|
"lib/rails/config.rb",
|
46
|
+
"spec/fixtures/config/map_api_keys.yml",
|
46
47
|
"spec/fixtures/map_api_keys.yaml",
|
47
48
|
"spec/fixtures/streets.de.yml",
|
48
49
|
"spec/geo_magic/calculate_spec.rb",
|
50
|
+
"spec/geo_magic/geocoder_rails_spec.rb",
|
49
51
|
"spec/geo_magic/geocoder_spec.rb",
|
50
52
|
"spec/geo_magic/include_calc_spec.rb",
|
51
53
|
"spec/geo_magic/include_remote_spec.rb",
|
@@ -63,6 +65,7 @@ Gem::Specification.new do |s|
|
|
63
65
|
s.summary = %q{Get your IP and location data and calculate distances on the globe}
|
64
66
|
s.test_files = [
|
65
67
|
"spec/geo_magic/calculate_spec.rb",
|
68
|
+
"spec/geo_magic/geocoder_rails_spec.rb",
|
66
69
|
"spec/geo_magic/geocoder_spec.rb",
|
67
70
|
"spec/geo_magic/include_calc_spec.rb",
|
68
71
|
"spec/geo_magic/include_remote_spec.rb",
|
data/lib/rails/config.rb
CHANGED
@@ -1,28 +1,18 @@
|
|
1
|
+
require 'geo_magic/geocode/config'
|
2
|
+
|
1
3
|
module GeoMagic
|
2
4
|
module RailsServiceAdapter
|
3
|
-
|
4
|
-
|
5
|
-
def geocode location_str
|
6
|
-
raise 'method #geocode must be implemented by adapter subclass'
|
7
|
-
end
|
8
|
-
|
9
|
-
def reverse_geocode latitude, longitude
|
10
|
-
raise 'method #reverse_geocode should be implemented by adapter subclass'
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
5
|
+
include GeoMagic::ServiceAdapter
|
14
6
|
|
15
7
|
def env
|
16
|
-
ENV['HEROKU_SITE']
|
8
|
+
heroku = ENV['HEROKU_SITE'] if ENV
|
9
|
+
rails_env = ::Rails.env.downcase if ::Rails.env
|
10
|
+
heroku || rails_env || 'development'
|
17
11
|
end
|
18
12
|
|
19
|
-
def
|
20
|
-
@config ||= ::YAML.load_file("#{::Rails.root}/config
|
13
|
+
def configure file_name = 'map_api_keys.yml'
|
14
|
+
@config ||= ::YAML.load_file("#{::Rails.root}/config/#{file_name}")[env]
|
21
15
|
end
|
22
|
-
|
23
|
-
def google_key
|
24
|
-
config['google_key']
|
25
|
-
end
|
26
16
|
end
|
27
17
|
end
|
28
18
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Geocoder with Rails 3
|
2
|
+
|
3
|
+
# Expects map api keys (fx for google maps) to be defined in ROOT/config/map_api_keys.yml
|
4
|
+
# See spec/fixtures/map_api_keys.yml for example
|
5
|
+
#
|
6
|
+
# Use @geocoder.configure(path, env) to customize this
|
7
|
+
|
8
|
+
require 'spec_helper'
|
9
|
+
require 'geo_magic'
|
10
|
+
require 'helper/streets'
|
11
|
+
|
12
|
+
module Rails
|
13
|
+
def self.root
|
14
|
+
SPEC_DIR + '/fixtures'
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.env
|
18
|
+
'test'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "GeoMagic Geocoder" do
|
23
|
+
it "should geocode for rails" do
|
24
|
+
@geocoder = GeoMagic.geo_coder(:env => :rails)
|
25
|
+
@geocoder.configure
|
26
|
+
location = @geocoder.instance.geocode "Mullerstrasse 9, Munich"
|
27
|
+
location.city.should == 'Munich'
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
it "should geocode for rails with custom config file" do
|
32
|
+
@geocoder = GeoMagic.geo_coder(:env => :rails)
|
33
|
+
@geocoder.configure '../map_api_keys.yaml'
|
34
|
+
location = @geocoder.instance.geocode "Mullerstrasse 9, Munich"
|
35
|
+
location.city.should == 'Munich'
|
36
|
+
end
|
37
|
+
end
|
@@ -47,6 +47,8 @@ describe "GeoMagic Geocoder" do
|
|
47
47
|
@geocoder = GeoMagic.geo_coder
|
48
48
|
@geocoder.configure File.expand_path('../fixtures/map_api_keys.yaml', File.dirname(__FILE__)), :development
|
49
49
|
|
50
|
+
puts "config: #{@geocoder.config}"
|
51
|
+
|
50
52
|
@streets = Streets.load :munich
|
51
53
|
end
|
52
54
|
|
@@ -70,18 +72,5 @@ describe "GeoMagic Geocoder" do
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
end
|
73
|
-
|
74
|
-
# Geocoder with Rails 3
|
75
|
-
|
76
|
-
# Expects map api keys (fx for google maps) to be defined in ROOT/config/map_api_keys.yml
|
77
|
-
# See spec/fixtures/map_api_keys.yml for example
|
78
|
-
|
79
|
-
# Use @geocoder.configure(path, env) to customize this
|
80
|
-
|
81
|
-
# it "should geocode for rails" do
|
82
|
-
# @geocoder = GeoMap.geo_coder(:env => :rails)
|
83
|
-
# location = @geocoder.instance.geocode "Mullerstrasse 9, Munich"
|
84
|
-
# location.city.should == 'Munich'
|
85
|
-
# end
|
86
75
|
end
|
87
76
|
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 2
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.2.4.
|
9
|
+
- 2
|
10
|
+
version: 0.2.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kristian Mandrup
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01
|
18
|
+
date: 2011-02-01 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -172,9 +172,11 @@ files:
|
|
172
172
|
- lib/geo_magic/remote.rb
|
173
173
|
- lib/geo_magic/util.rb
|
174
174
|
- lib/rails/config.rb
|
175
|
+
- spec/fixtures/config/map_api_keys.yml
|
175
176
|
- spec/fixtures/map_api_keys.yaml
|
176
177
|
- spec/fixtures/streets.de.yml
|
177
178
|
- spec/geo_magic/calculate_spec.rb
|
179
|
+
- spec/geo_magic/geocoder_rails_spec.rb
|
178
180
|
- spec/geo_magic/geocoder_spec.rb
|
179
181
|
- spec/geo_magic/include_calc_spec.rb
|
180
182
|
- spec/geo_magic/include_remote_spec.rb
|
@@ -198,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
200
|
requirements:
|
199
201
|
- - ">="
|
200
202
|
- !ruby/object:Gem::Version
|
201
|
-
hash:
|
203
|
+
hash: -3203749080952033166
|
202
204
|
segments:
|
203
205
|
- 0
|
204
206
|
version: "0"
|
@@ -219,6 +221,7 @@ specification_version: 3
|
|
219
221
|
summary: Get your IP and location data and calculate distances on the globe
|
220
222
|
test_files:
|
221
223
|
- spec/geo_magic/calculate_spec.rb
|
224
|
+
- spec/geo_magic/geocoder_rails_spec.rb
|
222
225
|
- spec/geo_magic/geocoder_spec.rb
|
223
226
|
- spec/geo_magic/include_calc_spec.rb
|
224
227
|
- spec/geo_magic/include_remote_spec.rb
|