gmaps_proxy 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.
- data/.document +5 -0
- data/.gitignore +24 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/lib/gmaps_proxy.rb +75 -0
- data/test/helper.rb +10 -0
- data/test/test_gmaps_proxy.rb +7 -0
- metadata +85 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Elad Meidar
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= gmaps_proxy
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Elad Meidar. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "gmaps_proxy"
|
9
|
+
gem.summary = %Q{Enable GoogleMaps access simple access to countries that can't use the API (israel for example)}
|
10
|
+
gem.description = %Q{Due to some rights issues, some countries does not appear with full information on Google Maps API, this library offers a simple hack to make it easier to implement a simple map fragment in your application}
|
11
|
+
gem.email = "elad@eizesus.com"
|
12
|
+
gem.homepage = "http://github.com/eladmeidar/gmaps_proxy"
|
13
|
+
gem.authors = ["Elad Meidar", "Ziv Perry"]
|
14
|
+
gem.add_dependency 'nokogiri', ">=0"
|
15
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 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
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/test_*.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'rcov/rcovtask'
|
32
|
+
Rcov::RcovTask.new do |test|
|
33
|
+
test.libs << 'test'
|
34
|
+
test.pattern = 'test/**/test_*.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :test => :check_dependencies
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rake/rdoctask'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "gmaps_proxy #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/lib/gmaps_proxy.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
class EmptyAddress < StandardError; end
|
5
|
+
|
6
|
+
class GmapsProxy
|
7
|
+
|
8
|
+
GOOGLE_MAPS_URL = "http://maps.google.com/?hl=iw&q="
|
9
|
+
attr_accessor :address
|
10
|
+
|
11
|
+
def initialize(address = "Israel")
|
12
|
+
@address = URI.encode(address)
|
13
|
+
end
|
14
|
+
|
15
|
+
def address=(new_address)
|
16
|
+
self.address = URI.encode(address)
|
17
|
+
end
|
18
|
+
|
19
|
+
def pull
|
20
|
+
doc = Nokogiri::HTML(open(url_with_address))
|
21
|
+
image_tiles = doc.search("#inlineTiles img")
|
22
|
+
|
23
|
+
table = ""
|
24
|
+
|
25
|
+
table << "<tr>"
|
26
|
+
count = 0
|
27
|
+
image_tiles.each do |image_node|
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
table << "<td><img src='#{image_node['src']}'/></td>"
|
32
|
+
|
33
|
+
count += 1
|
34
|
+
if count == 2
|
35
|
+
table << "</tr>"
|
36
|
+
table << "<tr>"
|
37
|
+
count = 0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
table << "</tr>"
|
41
|
+
|
42
|
+
output =<<-EOS
|
43
|
+
<html>
|
44
|
+
<head>
|
45
|
+
<meta http-equiv=content-type content="text/html; charset=UTF-8" />
|
46
|
+
<title>GoogleMaps Proxy</title>
|
47
|
+
<style>
|
48
|
+
* { margin:0; padding:0;, line-height:0; }
|
49
|
+
div {
|
50
|
+
border:0;
|
51
|
+
background:red;
|
52
|
+
}
|
53
|
+
</style>
|
54
|
+
</head>
|
55
|
+
<body>
|
56
|
+
<table cellpadding="0" cellspacing="0">
|
57
|
+
#{table}
|
58
|
+
</table>
|
59
|
+
</body>
|
60
|
+
</html>
|
61
|
+
EOS
|
62
|
+
|
63
|
+
return output
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def url_with_address
|
68
|
+
ensure_valid_address!
|
69
|
+
[GOOGLE_MAPS_URL,self.address].join
|
70
|
+
end
|
71
|
+
|
72
|
+
def ensure_valid_address!
|
73
|
+
raise EmptyAddress if (self.address.nil? || self.address.empty?)
|
74
|
+
end
|
75
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gmaps_proxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elad Meidar
|
8
|
+
- Ziv Perry
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-01-31 00:00:00 -05:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: nokogiri
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: thoughtbot-shoulda
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
version:
|
36
|
+
description: Due to some rights issues, some countries does not appear with full information on Google Maps API, this library offers a simple hack to make it easier to implement a simple map fragment in your application
|
37
|
+
email: elad@eizesus.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- LICENSE
|
44
|
+
- README.rdoc
|
45
|
+
files:
|
46
|
+
- .document
|
47
|
+
- .gitignore
|
48
|
+
- LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- VERSION
|
52
|
+
- lib/gmaps_proxy.rb
|
53
|
+
- test/helper.rb
|
54
|
+
- test/test_gmaps_proxy.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/eladmeidar/gmaps_proxy
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.5
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Enable GoogleMaps access simple access to countries that can't use the API (israel for example)
|
83
|
+
test_files:
|
84
|
+
- test/helper.rb
|
85
|
+
- test/test_gmaps_proxy.rb
|