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 +5 -5
- data/.travis.yml +2 -1
- data/README.md +1 -1
- data/autocomplete_zipcode.gemspec +3 -4
- data/lib/autocomplete_zipcode.rb +1 -1
- data/lib/autocomplete_zipcode/simple_form/ibge_input.rb +7 -0
- data/lib/autocomplete_zipcode/version.rb +1 -1
- data/vendor/assets/javascripts/autocomplete_zipcode.js +21 -16
- metadata +9 -10
- data/.rspec +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2ec5114e59c3310d2ec9d766a5515ff95e355e5ba25cc70e8a57bd58314433d2
|
4
|
+
data.tar.gz: c1b8c03503d5a926612ae1dcbe68a9d9361b1742cf3f7e76c80833d16a165108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 604b5f9deb4a558fa9ecf5853c523e7362ed24f2930ef9a5220dee3a3ecfaff153c83537dfaacd49eba0abc8a4e9168264aedb75c34e6aa21ca5e67260da846b
|
7
|
+
data.tar.gz: 517e796ae53f96c0ccb9f2cc698bb432dbf0ca847dbe5477b91dcb2064930c4e70f1888069f6d49a1b2cf3708a8f2b00d5c0470723b43a45e315f1de59d22092
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -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
|
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
|
21
|
-
spec.add_development_dependency "rake", "~>
|
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
|
data/lib/autocomplete_zipcode.rb
CHANGED
@@ -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
|
|
@@ -1,24 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
$(
|
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:
|
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:
|
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
|
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
|
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: '
|
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: '
|
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
|
-
|
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
|
87
|
+
summary: Fill in your brazillian addresses automagically
|
89
88
|
test_files: []
|
data/.rspec
DELETED