mapit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 David Padilla
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.
@@ -0,0 +1,18 @@
1
+ # mapit
2
+
3
+ Very, very simple gem that provides a helper to show a map of the specified address using Google Maps.
4
+
5
+ ## Usage
6
+
7
+ On any view, just use the helper *mapframe* setting the address as the first parameters and, optionally, any HTML attributes you'd like to add to the IFrame.
8
+
9
+ mapframe '1 Infinite Loop'
10
+ mapframe '1 Infinite Loop', :height => 100, :width => 300
11
+ mapframe '1 Infinite Loop', :class => 'some css class'
12
+
13
+
14
+ # About the Author
15
+
16
+ [Crowd Interactive](http://www.crowdint.com) is an American web design and development company that happens to work in Colima, Mexico.
17
+ We specialize in building and growing online retail stores. We don’t work with everyone – just companies we believe in. Call us today to see if there’s a fit.
18
+ Find more info [here](http://www.crowdint.com)!
@@ -0,0 +1,9 @@
1
+ require 'uri'
2
+ require 'mapit/view_helpers'
3
+ require 'mapit/class_methods'
4
+
5
+ class Mapit
6
+ extend ClassMethods
7
+ end
8
+
9
+ ActionView::Base.send :include, ViewHelpers
@@ -0,0 +1,7 @@
1
+ require 'action_view/helpers'
2
+
3
+ module ClassMethods
4
+ def url_for_address(query)
5
+ %{http://maps.google.com/maps?f=q&output=embed&q=#{URI.escape(query)}}
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ require 'action_view/helpers'
2
+
3
+ module ViewHelpers
4
+ def mapframe(address, options = {})
5
+ options = {
6
+ :marginheight => "0",
7
+ :marginwidth => "0",
8
+ :frameborder => "0",
9
+ :height => "300",
10
+ :width => "300",
11
+ :scrolling => "no",
12
+ :src => Mapit.url_for_address(address)
13
+ }.merge(options)
14
+
15
+ content_tag(:iframe, '', options, false)
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ gem 'activesupport'
5
+
6
+ require 'active_support'
7
+ require 'action_view'
8
+ require 'action_controller'
9
+ require 'action_view/test_case'
10
+
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ require 'mapit'
14
+
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ class HelpersTest < ActionView::TestCase
4
+ def setup
5
+ @view = ActionView::Base.new
6
+ end
7
+
8
+ def test_mapframe
9
+ assert_dom_equal(expected_result, @view.mapframe("228 Park Ave New York"))
10
+ end
11
+
12
+ def expected_result
13
+ %{<iframe width="300" height="300" frameborder="0"
14
+ scrolling="no" marginheight="0"
15
+ marginwidth="0"
16
+ src="http://maps.google.com/maps?f=q&amp;output=embed&amp;q=228%20Park%20Ave%20New%20York"></iframe>}
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ require 'helper'
2
+
3
+ class TestMapit < Test::Unit::TestCase
4
+ def test_url_for_address
5
+ assert_equal("http://maps.google.com/maps?f=q&amp;output=embed&amp;q=228%20Park%20Ave%20New%20York",
6
+ Mapit.url_for_address("228 Park Ave New York"))
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mapit
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - David Padilla
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-28 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: thoughtbot-shoulda
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 33
30
+ segments:
31
+ - 2
32
+ - 11
33
+ - 1
34
+ version: 2.11.1
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rails
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 2
48
+ - 3
49
+ - 8
50
+ version: 2.3.8
51
+ type: :development
52
+ version_requirements: *id002
53
+ description: Very, very simple gem that provides a helper to show a map of the specified address using Google Maps.
54
+ email: david@crowdint.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - LICENSE
61
+ - README.markdown
62
+ files:
63
+ - lib/mapit.rb
64
+ - lib/mapit/class_methods.rb
65
+ - lib/mapit/view_helpers.rb
66
+ - LICENSE
67
+ - README.markdown
68
+ - test/helper.rb
69
+ - test/test_helpers.rb
70
+ - test/test_mapit.rb
71
+ has_rdoc: true
72
+ homepage: http://github.com/crowdint/mapit
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options:
77
+ - --charset=UTF-8
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.7
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Simple gem to put maps on your apps
105
+ test_files:
106
+ - test/helper.rb
107
+ - test/test_helpers.rb
108
+ - test/test_mapit.rb