geo_rails 0.0.5

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 42bc5107783957bb0f02531f28725790ac3711df
4
+ data.tar.gz: 7996575f6ff21782e1806cd805d7abb8d719ae2e
5
+ SHA512:
6
+ metadata.gz: 04dc19905a0e280cefc774adb7e00f114ab224d902dbd6a3fd3a864606c0d907f6214a799e137a0166ce35be2c3241944e65d47f759a5a69f54cfa9e32b24f87
7
+ data.tar.gz: f4b5dfe727828c74ffa1b04c67dd3645680753723479477199356431f7876c00431334d741a0047474d0b667fb189117d1bbcf22494dcc42e4ee8b40ae6909bf
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 末永良太
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/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'GeoApi'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
@@ -0,0 +1,4 @@
1
+ module GeoApi
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,73 @@
1
+ <%= hidden_field_tag "authenticity_token", form_authenticity_token %>
2
+ <script>
3
+ if( navigator.geolocation )
4
+ {
5
+ navigator.geolocation.getCurrentPosition(
6
+
7
+ function( position )
8
+ {
9
+ var data = position.coords ;
10
+
11
+ var lat = data.latitude ;
12
+ var lng = data.longitude ;
13
+
14
+ //post geolocation
15
+ $.ajax({
16
+ type :"POST",
17
+ url: "<%= url %>" ,
18
+ data: {
19
+ lat: lat,
20
+ lng: lng,
21
+ "authenticity_token": $("#authenticity_token").val()
22
+ }
23
+ });
24
+
25
+ },
26
+
27
+ function( error )
28
+ {
29
+ var errorInfo = [
30
+ "unknown error" ,
31
+ "unauthorized" ,
32
+ "cannot get information" ,
33
+ "timeout"
34
+ ] ;
35
+
36
+ var errorNo = error.code ;
37
+ var errorMessage = errorInfo[ errorNo ] ;
38
+
39
+ //error handling
40
+ $.ajax({
41
+ type :"POST",
42
+ url: "<%= url %>" ,
43
+ data: {
44
+ error: errorMessage,
45
+ "authenticity_token": $("#authenticity_token").val()
46
+ }
47
+ });
48
+
49
+ } ,
50
+
51
+ {
52
+ "enableHighAccuracy": false,
53
+ "timeout": 8000,
54
+ "maximumAge": 2000,
55
+ }
56
+
57
+ ) ;
58
+ }
59
+
60
+ else
61
+ {
62
+ //error handling
63
+ $.ajax({
64
+ type :"POST",
65
+ url: "<%= url %>" ,
66
+ data: {
67
+ error: "unsupported browser",
68
+ "authenticity_token": $("#authenticity_token").val()
69
+ }
70
+ });
71
+ }
72
+
73
+ </script>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>GeoApi</title>
5
+ <%= stylesheet_link_tag "geo_api/application", media: "all" %>
6
+ <%= javascript_include_tag "geo_api/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,11 @@
1
+ require 'geo_api/get_geo'
2
+ module GeoApi
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace GeoApi
5
+ initializer 'geo_api.action_view_helpers' do
6
+ ActiveSupport.on_load :action_view do
7
+ include GeoApi::GetGeo
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module GeoApi
2
+ module GetGeo
3
+ def render_geo(url = {})
4
+ render_url = self.controller_name + "/"
5
+ render_url += url[:url][:action] unless url[:url][:action].nil?
6
+ render partial: "/geo/get_geo", locals: {url: render_url}
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module GeoApi
2
+ VERSION = "0.0.5"
3
+ end
data/lib/geo_api.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "geo_api/engine"
2
+
3
+ module GeoApi
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :geo_api do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geo_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - "末永良太"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: This gem gets geolocation data by using html5 geolocation api
42
+ email:
43
+ - suenagaryoutaabc@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - Rakefile
50
+ - app/helpers/geo_api/application_helper.rb
51
+ - app/views/geo/_get_geo.html.erb
52
+ - app/views/layouts/geo_api/application.html.erb
53
+ - lib/geo_api.rb
54
+ - lib/geo_api/engine.rb
55
+ - lib/geo_api/get_geo.rb
56
+ - lib/geo_api/version.rb
57
+ - lib/tasks/geo_api_tasks.rake
58
+ homepage: https://rubygems.org/profiles/asmsuechan
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: You can get geolocation easily
82
+ test_files: []