autocomplete_zipcode 0.1.2.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 58379c76f97826e278472b58d8d8904d1d3b3cf8
4
- data.tar.gz: a1bc433c466b0e5caaf3381c1813b09b3ae1d845
2
+ SHA256:
3
+ metadata.gz: 2ec5114e59c3310d2ec9d766a5515ff95e355e5ba25cc70e8a57bd58314433d2
4
+ data.tar.gz: c1b8c03503d5a926612ae1dcbe68a9d9361b1742cf3f7e76c80833d16a165108
5
5
  SHA512:
6
- metadata.gz: b3053dbf7498549a23a62616ce92511985aacf255221dbb09ff3a3a90f3de266235b6caeaf5574df567471bb6410bad3aef357f23036ab0899d97084df2c1c44
7
- data.tar.gz: 6cf37a029a4c301b1d15a0e55bdd3746828d6f5b6c1e167e0e531bc64cdfd92f17e38b75afa093f4c8828b9eedb17100469384b3362226fe74c8c16290386413
6
+ metadata.gz: 604b5f9deb4a558fa9ecf5853c523e7362ed24f2930ef9a5220dee3a3ecfaff153c83537dfaacd49eba0abc8a4e9168264aedb75c34e6aa21ca5e67260da846b
7
+ data.tar.gz: 517e796ae53f96c0ccb9f2cc698bb432dbf0ca847dbe5477b91dcb2064930c4e70f1888069f6d49a1b2cf3708a8f2b00d5c0470723b43a45e315f1de59d22092
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
3
+ - 2.6.3
4
+ before_install: gem install bundler:2.1.4
data/README.md CHANGED
@@ -26,8 +26,8 @@ In app/assets/javascripts/application.js, you should add as follows:
26
26
 
27
27
  ```js
28
28
  //= require ...
29
+ //= require turbolinks
29
30
  //= require autocomplete_zipcode
30
- //= require ...
31
31
  ```
32
32
 
33
33
  Basic Example:
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Marcelo Barreto"]
10
10
  spec.email = ["marcelobarretojunior@gmail.com"]
11
11
 
12
- spec.summary = %q{Fill in your brazilian addresses automagically}
12
+ spec.summary = %q{Fill in your brazillian addresses automagically}
13
13
  spec.homepage = "https://github.com/marcelobarreto/autocomplete_zipcode"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.8"
21
- spec.add_development_dependency "rake", "~> 10.0"
22
- #spec.add_runtime_dependency 'rails-assets-jquery'
20
+ spec.add_development_dependency "bundler", "~> 2.1"
21
+ spec.add_development_dependency "rake", "~> 13.0"
23
22
  end
@@ -1,6 +1,6 @@
1
1
  require "autocomplete_zipcode/version"
2
2
 
3
- [:zipcode, :street, :neighborhood, :city, :state].each do |input|
3
+ [:zipcode, :street, :neighborhood, :city, :state, :ibge].each do |input|
4
4
  autoload :"#{input.capitalize}Input", "autocomplete_zipcode/simple_form/#{input}_input"
5
5
  end
6
6
 
@@ -0,0 +1,7 @@
1
+ class IbgeInput < SimpleForm::Inputs::StringInput
2
+ def input(wrapper_options)
3
+ input_html_options[:data] ||= {}
4
+ input_html_options[:data].merge!({ provider: 'ibge' })
5
+ super
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module AutocompleteZicode
2
- VERSION = "0.1.2.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,24 +1,29 @@
1
- var ready = function() {
2
- zipcode_input = $('[data-provider="zipcode"]')
3
- zipcode_input.keyup(function(e){
4
- var zipcode = zipcode_input.val().replace(/[^0-9]/g, '');
5
- if(zipcode.length == 8) {
6
- $.get('https://viacep.com.br/ws/'+ zipcode +'/json/').then(function(response) {
7
- if (response.erro) {
8
- var event = new Event('zipcode.error');
1
+ const inputs = {
2
+ street: 'logradouro',
3
+ neighborhood: 'bairro',
4
+ city: 'localidade',
5
+ state: 'uf',
6
+ ibge: 'ibge',
7
+ };
9
8
 
10
- document.dispatchEvent(event);
11
- }
9
+ const ready = () => {
10
+ const zipCodeInput = $('[data-provider="zipcode"]');
11
+ zipCodeInput.keyup(() => {
12
+ const zipcode = zipCodeInput.val().replace(/[^0-9]/g, '');
12
13
 
13
- var inputs = {
14
- street: 'logradouro',
15
- neighborhood: 'bairro',
16
- city: 'localidade',
17
- state: 'uf'
14
+ if(zipcode.length === 8) {
15
+ $.get(`https://viacep.com.br/ws/${zipcode}/json`).then(response => {
16
+ let event;
17
+ if (response.erro) {
18
+ event = new Event('zipcode.error');
19
+ } else {
20
+ event = new Event('zipcode.success');
18
21
  }
19
22
 
23
+ document.dispatchEvent(event);
24
+
20
25
  for(var key in inputs) {
21
- $('[data-provider="' + key + '"]').val(response[inputs[key]])
26
+ $(`[data-provider="'${key}'"]`).val(response[inputs[key]]);
22
27
  }
23
28
  });
24
29
  };
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autocomplete_zipcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Barreto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-14 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  description:
42
42
  email:
43
43
  - marcelobarretojunior@gmail.com
@@ -46,7 +46,6 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
- - ".rspec"
50
49
  - ".travis.yml"
51
50
  - Gemfile
52
51
  - README.md
@@ -56,6 +55,7 @@ files:
56
55
  - bin/setup
57
56
  - lib/autocomplete_zipcode.rb
58
57
  - lib/autocomplete_zipcode/simple_form/city_input.rb
58
+ - lib/autocomplete_zipcode/simple_form/ibge_input.rb
59
59
  - lib/autocomplete_zipcode/simple_form/neighborhood_input.rb
60
60
  - lib/autocomplete_zipcode/simple_form/state_input.rb
61
61
  - lib/autocomplete_zipcode/simple_form/street_input.rb
@@ -81,9 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.6.11
84
+ rubygems_version: 3.0.8
86
85
  signing_key:
87
86
  specification_version: 4
88
- summary: Fill in your brazilian addresses automagically
87
+ summary: Fill in your brazillian addresses automagically
89
88
  test_files: []
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color