autocomplete_address_safe 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 393fe668de18e243ae6e536a8b51f3c9e3f971d7
4
+ data.tar.gz: 14c1f68d5531244795e59125f981fbd737fe95a4
5
+ SHA512:
6
+ metadata.gz: f2f4370e5fd252be678370bcb3bd85c9dcd9e088e752c037d6dad3b572f21fbe865fb961223277ae07eee91a33f1ed8bc701d3936beca362a2c721d3b34fe812
7
+ data.tar.gz: 12a6cfd9007d4f18d0f4715976dee0cf80d03d790f44d401dbee4b015f1de475dacdc4e17deb7ae678cf53ef80c7d43e133107e9f3ea4ee73715a096587a99d5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in autocomplete_address_safe.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Felipe Ramirez Mac
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # AutocompleteAddressSafe
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/autocomplete_address_safe`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'autocomplete_address_safe'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install autocomplete_address_safe
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/autocomplete_address_safe/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+
2
+ var __AutocompleteAddress ={
3
+ options: {
4
+ lat: <%= Rails.application.config.autocomplete_address_safe.lat %>,
5
+ long: <%= Rails.application.config.autocomplete_address_safe.long %>,
6
+ locality: <%= Rails.application.config.autocomplete_address_safe.locality %>,
7
+ country: <%= Rails.application.config.autocomplete_address_safe.country %>,
8
+ administrative_area_level_1: <%= Rails.application.config.autocomplete_address_safe.administrative_area_level_1 %>,
9
+ route: <%= Rails.application.config.autocomplete_address_safe.route %>,
10
+ street_number: <%= Rails.application.config.autocomplete_address_safe.street_number %>,
11
+ postal_code: <%= Rails.application.config.autocomplete_address_safe.postal_code %>
12
+ //lat: {"<%= Rails.application.config.autocomplete_address_safe.lat %>"}
13
+ }
14
+
15
+ }
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,3 @@
1
+ $('document').ready(function(){
2
+ $('body').attr('onload', 'initialize()');
3
+ });
@@ -0,0 +1,21 @@
1
+ window.google = window.google || {};
2
+ google.maps = google.maps || {};
3
+ (function() {
4
+
5
+ function getScript(src) {
6
+ document.write('<' + 'script src="' + src + '"><' + '/script>');
7
+ }
8
+
9
+ var modules = google.maps.modules = {};
10
+ google.maps.__gjsload__ = function(name, text) {
11
+ modules[name] = text;
12
+ };
13
+
14
+ google.maps.Load = function(apiLoad) {
15
+ delete google.maps.Load;
16
+ apiLoad([0.009999999776482582,[[["https://mts0.googleapis.com/vt?lyrs=m@316000000\u0026src=api\u0026hl=es-ES\u0026","https://mts1.googleapis.com/vt?lyrs=m@316000000\u0026src=api\u0026hl=es-ES\u0026"],null,null,null,null,"m@316000000",["https://mts0.google.com/vt?lyrs=m@316000000\u0026src=api\u0026hl=es-ES\u0026","https://mts1.google.com/vt?lyrs=m@316000000\u0026src=api\u0026hl=es-ES\u0026"]],[["https://khms0.googleapis.com/kh?v=178\u0026hl=es-ES\u0026","https://khms1.googleapis.com/kh?v=178\u0026hl=es-ES\u0026"],null,null,null,1,"178",["https://khms0.google.com/kh?v=178\u0026hl=es-ES\u0026","https://khms1.google.com/kh?v=178\u0026hl=es-ES\u0026"]],null,[["https://mts0.googleapis.com/vt?lyrs=t@132,r@316000000\u0026src=api\u0026hl=es-ES\u0026","https://mts1.googleapis.com/vt?lyrs=t@132,r@316000000\u0026src=api\u0026hl=es-ES\u0026"],null,null,null,null,"t@132,r@316000000",["https://mts0.google.com/vt?lyrs=t@132,r@316000000\u0026src=api\u0026hl=es-ES\u0026","https://mts1.google.com/vt?lyrs=t@132,r@316000000\u0026src=api\u0026hl=es-ES\u0026"]],null,null,[["https://cbks0.googleapis.com/cbk?","https://cbks1.googleapis.com/cbk?"]],[["https://khms0.googleapis.com/kh?v=86\u0026hl=es-ES\u0026","https://khms1.googleapis.com/kh?v=86\u0026hl=es-ES\u0026"],null,null,null,null,"86",["https://khms0.google.com/kh?v=86\u0026hl=es-ES\u0026","https://khms1.google.com/kh?v=86\u0026hl=es-ES\u0026"]],[["https://mts0.googleapis.com/mapslt?hl=es-ES\u0026","https://mts1.googleapis.com/mapslt?hl=es-ES\u0026"]],[["https://mts0.googleapis.com/mapslt/ft?hl=es-ES\u0026","https://mts1.googleapis.com/mapslt/ft?hl=es-ES\u0026"]],[["https://mts0.googleapis.com/vt?hl=es-ES\u0026","https://mts1.googleapis.com/vt?hl=es-ES\u0026"]],[["https://mts0.googleapis.com/mapslt/loom?hl=es-ES\u0026","https://mts1.googleapis.com/mapslt/loom?hl=es-ES\u0026"]],[["https://mts0.googleapis.com/mapslt?hl=es-ES\u0026","https://mts1.googleapis.com/mapslt?hl=es-ES\u0026"]],[["https://mts0.googleapis.com/mapslt/ft?hl=es-ES\u0026","https://mts1.googleapis.com/mapslt/ft?hl=es-ES\u0026"]],[["https://mts0.googleapis.com/mapslt/loom?hl=es-ES\u0026","https://mts1.googleapis.com/mapslt/loom?hl=es-ES\u0026"]]],["es-ES","US",null,0,null,null,"https://maps.gstatic.com/mapfiles/","https://csi.gstatic.com","https://maps.googleapis.com","https://maps.googleapis.com",null,"https://maps.google.com","https://gg.google.com","https://maps.gstatic.com/maps-api-v3/api/images/","https://www.google.com/maps",0],["https://maps.gstatic.com/maps-api-v3/api/js/21/7/intl/es_ALL","3.21.7"],[3093155694],1,null,null,null,null,null,"",["places"],null,1,"https://khms.googleapis.com/mz?v=178\u0026",null,"https://earthbuilder.googleapis.com","https://earthbuilder.googleapis.com",null,"https://mts.googleapis.com/vt/icon",[["https://mts0.googleapis.com/vt","https://mts1.googleapis.com/vt"],["https://mts0.googleapis.com/vt","https://mts1.googleapis.com/vt"],null,null,null,null,null,null,null,null,null,null,["https://mts0.google.com/vt","https://mts1.google.com/vt"],"/maps/vt",316000000,132],2,500,[null,"https://g0.gstatic.com/landmark/tour","https://g0.gstatic.com/landmark/config",null,"https://www.google.com/maps/preview/log204","","https://static.panoramio.com.storage.googleapis.com/photos/",["https://geo0.ggpht.com/cbk","https://geo1.ggpht.com/cbk","https://geo2.ggpht.com/cbk","https://geo3.ggpht.com/cbk"]],["https://www.google.com/maps/api/js/master?pb=!1m2!1u21!2s7!2ses-ES!3sUS!4s21/7/intl/es_ALL","https://www.google.com/maps/api/js/widget?pb=!1m2!1u21!2s7!2ses-ES"],null,1,0,"/maps/api/js/ApplicationService.GetEntityDetails",0,null,null,[null,null,null,null,null,null,null,null,null,[0,0],[0,0,0]]], loadScriptTime);
17
+ };
18
+ var loadScriptTime = (new Date).getTime();
19
+ getScript("https://maps.gstatic.com/maps-api-v3/api/js/21/7/intl/es_ALL/main.js");
20
+ getScript("https://maps.gstatic.com/maps-api-v3/api/js/21/7/intl/es_ALL/places.js");
21
+ })();
@@ -0,0 +1,70 @@
1
+ // This example displays an address form, using the autocomplete feature
2
+ // of the Google Places API to help users fill in the information.
3
+
4
+ var placeSearch, autocomplete;
5
+ var componentForm = {
6
+ street_number: 'short_name',
7
+ route: 'long_name',
8
+ locality: 'long_name',
9
+ administrative_area_level_1: 'short_name',
10
+ country: 'long_name',
11
+ postal_code: 'short_name'
12
+ };
13
+
14
+ function initialize() {
15
+ // Create the autocomplete object, restricting the search
16
+ // to geographical location types.
17
+ autocomplete = new google.maps.places.Autocomplete(
18
+ /** @type {HTMLInputElement} */(document.getElementById('autocomplete')),
19
+ { types: ['geocode'] });
20
+ // When the user selects an address from the dropdown,
21
+ // populate the address fields in the form.
22
+ google.maps.event.addListener(autocomplete, 'place_changed', function() {
23
+ fillInAddress();
24
+ });
25
+ }
26
+
27
+ function fillInAddress() {
28
+ // Get the place details from the autocomplete object.
29
+ var place = autocomplete.getPlace();
30
+ /*for (var component in componentForm) {
31
+ document.getElementById(component).value = '';
32
+ document.getElementById(component).disabled = false;
33
+ }*/
34
+
35
+ console.log(__AutocompleteAddress.options);
36
+
37
+
38
+ //Get each component of the address from the place details
39
+ //and fill the corresponding field on the form.
40
+ for (var i = 0; i < place.address_components.length; i++) {
41
+ var addressType = place.address_components[i].types[0];
42
+ console.log(addressType +"=> " + __AutocompleteAddress.options[addressType])
43
+ if(__AutocompleteAddress.options[addressType]){
44
+ console.log("entro -> "+ addressType);
45
+ if (componentForm[addressType]) {
46
+ var val = place.address_components[i][componentForm[addressType]];
47
+ document.getElementById(addressType).value = val;
48
+ }
49
+ }
50
+ }
51
+ console.log(__AutocompleteAddress.options)
52
+ document.getElementById('lat').value = place.geometry.location.A;
53
+ document.getElementById('long').value = place.geometry.location.F;
54
+ }
55
+
56
+ // Bias the autocomplete object to the user's geographical location,
57
+ // as supplied by the browser's 'navigator.geolocation' object.
58
+ function geolocate() {
59
+ if (navigator.geolocation) {
60
+ navigator.geolocation.getCurrentPosition(function(position) {
61
+ var geolocation = new google.maps.LatLng(
62
+ position.coords.latitude, position.coords.longitude);
63
+ var circle = new google.maps.Circle({
64
+ center: geolocation,
65
+ radius: position.coords.accuracy
66
+ });
67
+ autocomplete.setBounds(circle.getBounds());
68
+ });
69
+ }
70
+ }
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'autocomplete_address_safe/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "autocomplete_address_safe"
8
+ spec.version = AutocompleteAddressSafe::VERSION
9
+ spec.authors = ["Saul Felipe Ramirez"]
10
+ spec.email = ["safe.ramirez@gmail.com"]
11
+
12
+ spec.summary = %q{Sirve para encontrar una ubicacion usando googlemaps}
13
+ spec.description = %q{Se usa para encontrar ubicaciones }
14
+ spec.homepage = "https://github.com/saferamirez/autocomplete_address_safe"
15
+ spec.license = "MIT"
16
+
17
+
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.9"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "autocomplete_address_safe"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ module AutocompleteAddressSafe
2
+
3
+ class Configuration
4
+ attr_accessor :lat
5
+ attr_accessor :long
6
+ attr_accessor :locality
7
+ attr_accessor :country
8
+ attr_accessor :administrative_area_level_1
9
+ attr_accessor :route
10
+ attr_accessor :street_number
11
+ attr_accessor :postal_code
12
+
13
+ def initialize
14
+ @lat = true
15
+ @long = true
16
+ @locality = true
17
+ @country = true
18
+ @administrative_area_level_1 = true
19
+ @route = true
20
+ @street_number = true
21
+ @postal_code = true
22
+ end
23
+
24
+ def set_options(&block)
25
+ block.yield(self)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ module AutocompleteAddressSafe
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module AutocompleteAddressSafe
2
+
3
+ def field_complete()
4
+ text_field 'autocomplete', nil, id:'autocomplete',placeholder:'Ingrese su ubicación', onfocus:'geolocate()', autocomplete: 'off'
5
+ end
6
+
7
+ end
@@ -0,0 +1,14 @@
1
+ class Railtie < Rails::Railtie
2
+
3
+ initializer "autocomplete_address_safe.configuration" do |app|
4
+ app.config.autocomplete_address_safe = AutocompleteAddressSafe::Configuration.new
5
+ #FileUtils.rm_rf("#{Rails.application.root}/tmp/cache/assets") if Rails.env.development?
6
+ end
7
+
8
+ initializer "autocomplete_address_safe.initialize_field_helper" do |app|
9
+ ActiveSupport.on_load(:action_view) do
10
+ include AutocompleteAddressSafe
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,3 @@
1
+ module AutocompleteAddressSafe
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "autocomplete_address_safe/version"
2
+ require "autocomplete_address_safe/engine"
3
+ require "autocomplete_address_safe/configuration"
4
+ require "autocomplete_address_safe/railtie"
5
+ require "autocomplete_address_safe/field_helper"
6
+
7
+
8
+ #module ActionView
9
+ # module Helpers
10
+ # module AssetTagHelper
11
+ # include AutocompleteAddressSafe
12
+ # end
13
+ # end
14
+ #end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autocomplete_address_safe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Saul Felipe Ramirez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: 'Se usa para encontrar ubicaciones '
42
+ email:
43
+ - safe.ramirez@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - app/assets/javascript/autocomplete_address_options.js.erb
56
+ - app/assets/javascript/autocomplete_address_safe.js
57
+ - app/assets/javascript/barracuda.js
58
+ - app/assets/javascript/googlecore.js
59
+ - app/assets/javascript/googlemaps.js
60
+ - autocomplete_address_safe.gemspec
61
+ - bin/console
62
+ - bin/setup
63
+ - lib/autocomplete_address_safe.rb
64
+ - lib/autocomplete_address_safe/configuration.rb
65
+ - lib/autocomplete_address_safe/engine.rb
66
+ - lib/autocomplete_address_safe/field_helper.rb
67
+ - lib/autocomplete_address_safe/railtie.rb
68
+ - lib/autocomplete_address_safe/version.rb
69
+ homepage: https://github.com/saferamirez/autocomplete_address_safe
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.4.6
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Sirve para encontrar una ubicacion usando googlemaps
93
+ test_files: []