geofsh 0.1.1 → 0.1.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.md CHANGED
@@ -32,9 +32,7 @@ An example of using Geofsh with simple_form:
32
32
 
33
33
  Google maps can easily be incorporated into your rails app using geofsh gem. First, you must include google's javascript api:
34
34
 
35
- = javascript_include_tag "https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY_HERE&sensor=false"
36
-
37
- For instructions on how to recieve a google map's API key, visit [Google's api tutorial](https://developers.google.com/maps/documentation/javascript/tutorial#api_key).
35
+ = javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false"
38
36
 
39
37
  To enable google maps in your rails app, simply add a div to your view with the element id 'google-map':
40
38
 
@@ -12,6 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = %q{Provides latitude and longitude from HTML5 geolocation API and automatically places them in corresponding form fields}
13
13
  gem.homepage = "https://github.com/joofsh/geofsh"
14
14
 
15
+ gem.add_dependency "coffee-rails", "~> 3.2.1"
15
16
  gem.add_dependency "railties", "~> 3.1"
16
17
 
17
18
  gem.files = `git ls-files`.split($/)
@@ -1,3 +1,3 @@
1
1
  module Geofsh
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,4 +1,4 @@
1
- <%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?key=AIzaSyDBmbRrJZrO5IExRamjDLBgyWzTLs1Ohx8&sensor=false" %>
1
+ <%= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" %>
2
2
  <%= javascript_include_tag 'geofsh' %>
3
3
 
4
4
  <p> This is your latitude and longitude input fields. Are they working? </p>
@@ -8,11 +8,13 @@ describe 'Home Requests' do
8
8
 
9
9
 
10
10
  it 'loads geofsh lat/lng data into fields', js: true do
11
+ sleep 1.5
11
12
  find_field('latitude').value.should_not be_blank
12
13
  find_field('longitude').value.should_not be_blank
13
14
  end
14
15
 
15
16
  it 'loads a google map', js: true do
17
+ sleep 1.5
16
18
  page.should have_selector "div#google-map"
17
19
  page.should have_selector "div", text: "Satellite"
18
20
  page.should have_selector "img", src: "https://maps.gstatic.com/mapfiles/google_white.png"
@@ -0,0 +1,40 @@
1
+ googleMap = (geolat, geolng) ->
2
+ geoCoords = new google.maps.LatLng(geolat, geolng)
3
+ mapOptions =
4
+ zoom: 16
5
+ center: geoCoords
6
+ mapTypeId: google.maps.MapTypeId.ROADMAP
7
+
8
+ map = new google.maps.Map(document.getElementById("google-map"), mapOptions)
9
+ addMarker geoCoords, map, "You are here!"
10
+
11
+ addMarker = (position, map, title) ->
12
+ marker = new google.maps.Marker(
13
+ position: position
14
+ map: map
15
+ title: title
16
+ )
17
+
18
+ geolocSuccess = (position) ->
19
+ geolat = position.coords.latitude
20
+ geolng = position.coords.longitude
21
+ $("input#latitude").val geolat if $("input#latitude")
22
+ $("input#longitude").val geolng if $("input#longitude")
23
+ googleMap geolat, geolng if $("#google-map")
24
+
25
+ geolocError = ->
26
+ hideGeoLoc()
27
+ "Geolocation Unsuccessful"
28
+
29
+ hideGeoLoc = ->
30
+ $(".geoloc-hide").parent().hide()
31
+
32
+ getPosition = ->
33
+ if navigator.geolocation
34
+ navigator.geolocation.getCurrentPosition geolocSuccess, geolocError
35
+ else
36
+ hideGeoLoc()
37
+ "Geolocation not supported"
38
+
39
+ $ ->
40
+ getPosition()
@@ -1,43 +1,50 @@
1
- (function(){
2
- var geolocError, addMarker, getPosition, hideAddressAndZip, hideGeoLoc, geolocSuccess, googleMap, mapOptions, map, marker, geolat, geolng, geoCoords;
1
+ // Generated by CoffeeScript 1.3.3
2
+ (function() {
3
+ var addMarker, geolocError, geolocSuccess, getPosition, googleMap, hideGeoLoc;
3
4
 
4
5
  googleMap = function(geolat, geolng) {
5
- if(document.getElementById("google-map")){
6
- geoCoords = new google.maps.LatLng(geolat, geolng);
7
- mapOptions = {
8
- zoom: 16,
9
- center: geoCoords,
10
- mapTypeId: google.maps.MapTypeId.ROADMAP
11
- };
12
-
13
- map = new google.maps.Map(document.getElementById("google-map"), mapOptions);
14
- addMarker(geoCoords, "You are here!");
15
- }
6
+ var geoCoords, map, mapOptions;
7
+ geoCoords = new google.maps.LatLng(geolat, geolng);
8
+ mapOptions = {
9
+ zoom: 16,
10
+ center: geoCoords,
11
+ mapTypeId: google.maps.MapTypeId.ROADMAP
12
+ };
13
+ map = new google.maps.Map(document.getElementById("google-map"), mapOptions);
14
+ return addMarker(geoCoords, map, "You are here!");
16
15
  };
17
16
 
18
- addMarker = function(position, title) {
19
- marker = new google.maps.Marker({
17
+ addMarker = function(position, map, title) {
18
+ var marker;
19
+ return marker = new google.maps.Marker({
20
20
  position: position,
21
21
  map: map,
22
22
  title: title
23
- });
24
- }
23
+ });
24
+ };
25
+
25
26
  geolocSuccess = function(position) {
27
+ var geolat, geolng;
26
28
  geolat = position.coords.latitude;
27
29
  geolng = position.coords.longitude;
28
- $('input#latitude').val(geolat);
29
- $('input#longitude').val(geolng);
30
- return googleMap(geolat, geolng);
30
+ if ($("input#latitude")) {
31
+ $("input#latitude").val(geolat);
32
+ }
33
+ if ($("input#longitude")) {
34
+ $("input#longitude").val(geolng);
35
+ }
36
+ if ($("#google-map")) {
37
+ return googleMap(geolat, geolng);
38
+ }
31
39
  };
32
40
 
33
41
  geolocError = function() {
34
- hideGeoLoc();
35
- return "Geolocation Unsuccessful";
42
+ hideGeoLoc();
43
+ return "Geolocation Unsuccessful";
36
44
  };
37
45
 
38
-
39
46
  hideGeoLoc = function() {
40
- return $('.geoloc-hide').parent().hide();
47
+ return $(".geoloc-hide").parent().hide();
41
48
  };
42
49
 
43
50
  getPosition = function() {
@@ -49,9 +56,8 @@
49
56
  }
50
57
  };
51
58
 
52
-
53
59
  $(function() {
54
60
  return getPosition();
55
- })
56
- }).call(this);
61
+ });
57
62
 
63
+ }).call(this);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geofsh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-07 00:00:00.000000000 Z
12
+ date: 2012-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: coffee-rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.1
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: railties
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -58,7 +74,6 @@ files:
58
74
  - testapp/app/models/.gitkeep
59
75
  - testapp/app/views/home/index.html.erb
60
76
  - testapp/app/views/layouts/application.html.erb
61
- - testapp/app/views/layouts/application.html.haml
62
77
  - testapp/config.ru
63
78
  - testapp/config/application.rb
64
79
  - testapp/config/boot.rb
@@ -86,11 +101,12 @@ files:
86
101
  - testapp/public/robots.txt
87
102
  - testapp/script/rails
88
103
  - testapp/spec/controllers/home_controller_spec.rb
89
- - testapp/spec/requests/home_spec.rb
104
+ - testapp/spec/integration/home_spec.rb
90
105
  - testapp/spec/spec_helper.rb
91
106
  - testapp/vendor/assets/javascripts/.gitkeep
92
107
  - testapp/vendor/assets/stylesheets/.gitkeep
93
108
  - testapp/vendor/plugins/.gitkeep
109
+ - vendor/assets/javascripts/geofsh.coffee
94
110
  - vendor/assets/javascripts/geofsh.js
95
111
  homepage: https://github.com/joofsh/geofsh
96
112
  licenses: []
@@ -104,18 +120,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
120
  - - ! '>='
105
121
  - !ruby/object:Gem::Version
106
122
  version: '0'
107
- segments:
108
- - 0
109
- hash: 225897693785589626
110
123
  required_rubygems_version: !ruby/object:Gem::Requirement
111
124
  none: false
112
125
  requirements:
113
126
  - - ! '>='
114
127
  - !ruby/object:Gem::Version
115
128
  version: '0'
116
- segments:
117
- - 0
118
- hash: 225897693785589626
119
129
  requirements: []
120
130
  rubyforge_project:
121
131
  rubygems_version: 1.8.24
@@ -124,3 +134,4 @@ specification_version: 3
124
134
  summary: Provides latitude and longitude from HTML5 geolocation API and automatically
125
135
  places them in corresponding form fields
126
136
  test_files: []
137
+ has_rdoc:
@@ -1,10 +0,0 @@
1
- !!!
2
- %html
3
- %head
4
- %title Testapp
5
- = stylesheet_link_tag "application", :media => "all"
6
- = javascript_include_tag "application"
7
- = csrf_meta_tags
8
- %body
9
- = yield
10
-