cep 0.0.6 → 0.0.7
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 +4 -4
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +95 -0
- data/Guardfile +11 -0
- data/MIT-LICENSE +20 -0
- data/README.md +70 -0
- data/Rakefile +4 -0
- data/cep.gemspec +27 -0
- data/lib/cep/version.rb +3 -0
- data/lib/correios/address_search_response.rb +83 -0
- data/spec/fixtures/responses/rua_bento_goncalves_novo_hamburgo.html +506 -0
- data/spec/integration/cep_address_search_spec.rb +19 -0
- data/spec/lib/cep_spec.rb +67 -0
- data/spec/lib/correios/address_search_response_spec.rb +85 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/rua_bento_goncalves_novo_hamburgo_search.rb +90 -0
- metadata +34 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 305ae9b6dc019f1da3ac869c942c9e66d070a702
|
|
4
|
+
data.tar.gz: 00101d49abd30fe686e05791384c9733e280b229
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd46d5f99eb749573faf0ab8e797d311153a7228ab408104dc960ec6c016bb4c9ff8be0a3eb5cba8b556a8c20001392b644c79f0581b6a29d29afc78dec89cd6
|
|
7
|
+
data.tar.gz: 3bc2cd593f63054f4f2aa757c1bb21e1b2d082abffc10cfdcc25dc49f6b5fb333f528e853b239647dde51fd8ffbf847a67ca15a0d6481415f158ceacbcf5ab1d
|
data/.gitignore
ADDED
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
cep (0.0.7)
|
|
5
|
+
activesupport
|
|
6
|
+
addressable
|
|
7
|
+
i18n
|
|
8
|
+
nokogiri
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
activesupport (4.1.7)
|
|
14
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
15
|
+
json (~> 1.7, >= 1.7.7)
|
|
16
|
+
minitest (~> 5.1)
|
|
17
|
+
thread_safe (~> 0.1)
|
|
18
|
+
tzinfo (~> 1.1)
|
|
19
|
+
addressable (2.3.6)
|
|
20
|
+
coderay (1.0.9)
|
|
21
|
+
coveralls (0.7.0)
|
|
22
|
+
multi_json (~> 1.3)
|
|
23
|
+
rest-client
|
|
24
|
+
simplecov (>= 0.7)
|
|
25
|
+
term-ansicolor
|
|
26
|
+
thor
|
|
27
|
+
diff-lcs (1.2.4)
|
|
28
|
+
ffi (1.9.0)
|
|
29
|
+
formatador (0.2.4)
|
|
30
|
+
guard (1.8.2)
|
|
31
|
+
formatador (>= 0.2.4)
|
|
32
|
+
listen (>= 1.0.0)
|
|
33
|
+
lumberjack (>= 1.0.2)
|
|
34
|
+
pry (>= 0.9.10)
|
|
35
|
+
thor (>= 0.14.6)
|
|
36
|
+
guard-rspec (3.0.2)
|
|
37
|
+
guard (>= 1.8)
|
|
38
|
+
rspec (~> 2.13)
|
|
39
|
+
i18n (0.6.11)
|
|
40
|
+
json (1.8.1)
|
|
41
|
+
listen (1.3.0)
|
|
42
|
+
rb-fsevent (>= 0.9.3)
|
|
43
|
+
rb-inotify (>= 0.9)
|
|
44
|
+
rb-kqueue (>= 0.2)
|
|
45
|
+
lumberjack (1.0.4)
|
|
46
|
+
method_source (0.8.2)
|
|
47
|
+
mime-types (1.25.1)
|
|
48
|
+
mini_portile (0.6.1)
|
|
49
|
+
minitest (5.4.2)
|
|
50
|
+
multi_json (1.8.0)
|
|
51
|
+
nokogiri (1.6.4.1)
|
|
52
|
+
mini_portile (~> 0.6.0)
|
|
53
|
+
pry (0.9.12.2)
|
|
54
|
+
coderay (~> 1.0.5)
|
|
55
|
+
method_source (~> 0.8)
|
|
56
|
+
slop (~> 3.4)
|
|
57
|
+
rake (10.3.2)
|
|
58
|
+
rb-fsevent (0.9.3)
|
|
59
|
+
rb-inotify (0.9.1)
|
|
60
|
+
ffi (>= 0.5.0)
|
|
61
|
+
rb-kqueue (0.2.0)
|
|
62
|
+
ffi (>= 0.5.0)
|
|
63
|
+
rest-client (1.6.7)
|
|
64
|
+
mime-types (>= 1.16)
|
|
65
|
+
rspec (2.14.1)
|
|
66
|
+
rspec-core (~> 2.14.0)
|
|
67
|
+
rspec-expectations (~> 2.14.0)
|
|
68
|
+
rspec-mocks (~> 2.14.0)
|
|
69
|
+
rspec-core (2.14.5)
|
|
70
|
+
rspec-expectations (2.14.2)
|
|
71
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
72
|
+
rspec-mocks (2.14.3)
|
|
73
|
+
simplecov (0.7.1)
|
|
74
|
+
multi_json (~> 1.0)
|
|
75
|
+
simplecov-html (~> 0.7.1)
|
|
76
|
+
simplecov-html (0.7.1)
|
|
77
|
+
slop (3.4.6)
|
|
78
|
+
term-ansicolor (1.2.2)
|
|
79
|
+
tins (~> 0.8)
|
|
80
|
+
thor (0.18.1)
|
|
81
|
+
thread_safe (0.3.4)
|
|
82
|
+
tins (0.13.1)
|
|
83
|
+
tzinfo (1.2.2)
|
|
84
|
+
thread_safe (~> 0.1)
|
|
85
|
+
|
|
86
|
+
PLATFORMS
|
|
87
|
+
ruby
|
|
88
|
+
|
|
89
|
+
DEPENDENCIES
|
|
90
|
+
cep!
|
|
91
|
+
coveralls
|
|
92
|
+
guard-rspec
|
|
93
|
+
rake
|
|
94
|
+
rspec
|
|
95
|
+
simplecov
|
data/Guardfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
guard 'rspec',
|
|
2
|
+
:notification => false,
|
|
3
|
+
:all_on_start => false,
|
|
4
|
+
:focus => true,
|
|
5
|
+
:all_after_pass => false do
|
|
6
|
+
|
|
7
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
8
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
9
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
10
|
+
end
|
|
11
|
+
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2013 Marcelo Guilherme Jacobus Jr
|
|
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/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# CEP
|
|
2
|
+
|
|
3
|
+
Consultas ao CEP.
|
|
4
|
+
|
|
5
|
+
[](http://travis-ci.org/mjacobus/cep?branch=development)
|
|
6
|
+
[](https://coveralls.io/r/mjacobus/cep)
|
|
7
|
+
[](https://codeclimate.com/github/mjacobus/cep)
|
|
8
|
+
[](http://badge.fury.io/rb/cep)
|
|
9
|
+
[](https://gemnasium.com/mjacobus/cep)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Add this line to your application's Gemfile:
|
|
14
|
+
|
|
15
|
+
gem 'cep'
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
$ gem install cep
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
### Para consultar endereço, pelo cep:
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
Cep.new.cep("02045970")
|
|
30
|
+
|
|
31
|
+
# {
|
|
32
|
+
# logradouro: "Rua Guajurus, 69",
|
|
33
|
+
# bairro: "Jardim São Paulo(Zona Norte)",
|
|
34
|
+
# localidade: "São Paulo",
|
|
35
|
+
# estado: "SP",
|
|
36
|
+
# cep: "02045970"
|
|
37
|
+
# }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Para consultar cep, pelo endereço:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
Cep.new.address("Avenida Conde da Boa Vista Recife")
|
|
44
|
+
|
|
45
|
+
#[{:tipo_logradouro=>"Avenida",
|
|
46
|
+
# :logradouro=>"Avenida Conde da Boa Vista - até 1016 - lado par",
|
|
47
|
+
# :bairro=>"Boa Vista",
|
|
48
|
+
# :localidade=>"Recife",
|
|
49
|
+
# :uf=>"PE",
|
|
50
|
+
# :cep=>"50060004"},
|
|
51
|
+
# {:tipo_logradouro=>"Avenida",
|
|
52
|
+
# :logradouro=>"Avenida Conde da Boa Vista - até 1017 - lado ímpar",
|
|
53
|
+
# :bairro=>"Boa Vista",
|
|
54
|
+
# :localidade=>"Recife",
|
|
55
|
+
# :uf=>"PE",
|
|
56
|
+
# :cep=>"50060002"}]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Contributors
|
|
60
|
+
- [Marcelo Jacobus](https://github.com/mjacobus)
|
|
61
|
+
- [Fernando Pereira](https://github.com/fernandopereira)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## Contributing
|
|
65
|
+
|
|
66
|
+
1. Fork it
|
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
70
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/cep.gemspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'cep/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'cep'
|
|
7
|
+
s.version = Cep::VERSION
|
|
8
|
+
s.date = Date.today.strftime('%Y-%m-%d')
|
|
9
|
+
s.summary = "API for getting address of a given CEP or ADDRESS"
|
|
10
|
+
s.description = "API for getting address of a given CEP or ADDRESS"
|
|
11
|
+
s.authors = ["Marcelo Jacobus","Fernando Pereira"]
|
|
12
|
+
s.email = ['marcelo.jacobus@gmail.com', '']
|
|
13
|
+
s.files = `git ls-files`.split("\n")
|
|
14
|
+
s.homepage = 'https://github.com/mjacobus/cep.git'
|
|
15
|
+
s.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
s.required_ruby_version = '>= 1.9.3'
|
|
18
|
+
s.add_dependency "nokogiri"
|
|
19
|
+
s.add_dependency "addressable"
|
|
20
|
+
s.add_dependency "activesupport"
|
|
21
|
+
s.add_dependency "i18n"
|
|
22
|
+
s.add_development_dependency "rake"
|
|
23
|
+
s.add_development_dependency "rspec"
|
|
24
|
+
s.add_development_dependency "simplecov"
|
|
25
|
+
s.add_development_dependency "guard-rspec"
|
|
26
|
+
s.add_development_dependency "coveralls"
|
|
27
|
+
end
|
data/lib/cep/version.rb
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'nokogiri'
|
|
2
|
+
# TODO: Cherry pick inflections
|
|
3
|
+
require 'active_support/all'
|
|
4
|
+
|
|
5
|
+
module Correios
|
|
6
|
+
class AddressSearchResponse
|
|
7
|
+
attr_reader :body
|
|
8
|
+
|
|
9
|
+
def initialize(html_body)
|
|
10
|
+
@body = html_body
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def addresses
|
|
14
|
+
@addresses ||= items.map{|item| address(item)}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
def address(node)
|
|
19
|
+
titles = node.css('.resposta').map(&:content).map do |content|
|
|
20
|
+
content_to_key(content)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
contents = node.css('.respostadestaque').map(&:content).map do |content|
|
|
24
|
+
clean_content(content)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
hash = {}
|
|
28
|
+
contents.each_with_index do |content, index|
|
|
29
|
+
hash.merge!(content_to_hash(content, titles[index]))
|
|
30
|
+
end
|
|
31
|
+
set_up_address(hash)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def set_up_address(address)
|
|
35
|
+
if address[:logradouro]
|
|
36
|
+
tipo_logradouro = address[:logradouro].split(' ').first
|
|
37
|
+
address.merge!(tipo_logradouro: tipo_logradouro)
|
|
38
|
+
end
|
|
39
|
+
address
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def items
|
|
43
|
+
@items ||= Nokogiri::HTML(body).css('.caixacampobranco, .caixacampoazul')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clean_content(content)
|
|
47
|
+
content.gsub(/\n+/,' ').
|
|
48
|
+
gsub(/^\n+/, '').
|
|
49
|
+
strip.gsub(/\s+/, ' ')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def content_to_key(content)
|
|
53
|
+
parts = clean_content(content).split('/').map do |content|
|
|
54
|
+
content.parameterize.to_sym
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
if parts.length == 1
|
|
58
|
+
parts = parts.first
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
parts
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def content_to_hash(content, keys)
|
|
65
|
+
if keys.is_a?(Symbol)
|
|
66
|
+
{keys => clean_content(content)}
|
|
67
|
+
else
|
|
68
|
+
contents = clean_content(content).split('/')
|
|
69
|
+
contents_copy = contents.dup
|
|
70
|
+
values = {}
|
|
71
|
+
keys.each_with_index do |key, index|
|
|
72
|
+
content = contents_copy[index]
|
|
73
|
+
values[key] = clean_content(contents.delete(content))
|
|
74
|
+
end
|
|
75
|
+
unless contents.empty?
|
|
76
|
+
values[keys.last] += '/' + contents.join('/')
|
|
77
|
+
end
|
|
78
|
+
values
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
|
|
7
|
+
|
|
8
|
+
<html lang="en">
|
|
9
|
+
<head>
|
|
10
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
11
|
+
<!-- Meta usado no site da globo: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -->
|
|
12
|
+
|
|
13
|
+
<script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
|
|
14
|
+
|
|
15
|
+
<script language="JavaScript" src="scripts/template.js" type="text/javascript"></script>
|
|
16
|
+
<script language="JavaScript" src="scripts/aplicacao.js" type="text/javascript"></script>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<link rel="stylesheet" type="text/css" href="css/template.css">
|
|
20
|
+
<link rel="stylesheet" type="text/css" href="css/aplicacao.css">
|
|
21
|
+
<title>Correios Mobile</title>
|
|
22
|
+
<link rel="icon" href="images/template/icon.png" type="image/png"/>
|
|
23
|
+
</head>
|
|
24
|
+
<body>
|
|
25
|
+
<div id="divTelaAguarde">
|
|
26
|
+
<center>
|
|
27
|
+
<span class="style1"><br><br><br><br><br><br><br><br><br><img src="images/template/62x62.gif" /><br></span>
|
|
28
|
+
<span class="item"> Aguarde...</span>
|
|
29
|
+
</center>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class="container">
|
|
33
|
+
<div class="fundo">
|
|
34
|
+
<div>
|
|
35
|
+
<a href="index.do" class="logo"></a>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
<script>
|
|
42
|
+
function anterior()
|
|
43
|
+
{
|
|
44
|
+
_mostraTelaAguarde();
|
|
45
|
+
$('#metodo').val('anterior');
|
|
46
|
+
$('#frmCep').submit();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function proximo()
|
|
50
|
+
{
|
|
51
|
+
_mostraTelaAguarde();
|
|
52
|
+
$('#metodo').val('proximo');
|
|
53
|
+
$('#frmCep').submit();
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
<div class="conteudo">
|
|
57
|
+
<div class="secao">Busca CEP - Endereço</div><br/>
|
|
58
|
+
|
|
59
|
+
<form name="buscaCepForm" method="post" action="/movel/buscaCepConfirma.do" id="frmCep">
|
|
60
|
+
|
|
61
|
+
Logradouro <b>1 - 7</b> de <b>7</b>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
<div class="caixacampobranco">
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
<span class="resposta">Logradouro: </span>
|
|
72
|
+
<span class="respostadestaque">
|
|
73
|
+
Rua Bento Gonçalves - até 999/1000
|
|
74
|
+
|
|
75
|
+
</span><br/>
|
|
76
|
+
<span class="resposta">Bairro: </span><span class="respostadestaque">Centro</span><br/>
|
|
77
|
+
<span class="resposta">Localidade / UF: </span>
|
|
78
|
+
<span class="respostadestaque">
|
|
79
|
+
Novo Hamburgo
|
|
80
|
+
|
|
81
|
+
/RS
|
|
82
|
+
|
|
83
|
+
</span><br/>
|
|
84
|
+
<span class="resposta">CEP: </span><span class="respostadestaque">93410001</span><br/>
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
<div style="text-align: right;" class="mopcoes orientacao"><span>Opções <img style="position: relative right:0px;" src="images/template/mais.png"/></span></div>
|
|
95
|
+
|
|
96
|
+
</div>
|
|
97
|
+
<div class="divopcoes">
|
|
98
|
+
|
|
99
|
+
<!-- Para usuários originários do Busca CEP -->
|
|
100
|
+
<div> Simule um envio utilizando <br/> o CEP <strong>93410001</strong> como:</div>
|
|
101
|
+
<ul>
|
|
102
|
+
<li>
|
|
103
|
+
<a onclick="retornarParaPrecos('93410001','1');">CEP Origem <img src="images/template/cep_r.png"/></a>
|
|
104
|
+
</li>
|
|
105
|
+
<li>
|
|
106
|
+
<a onclick="retornarParaPrecos('93410001','2');"><img src="images/template/cep_d.png"/>CEP Destino</a>
|
|
107
|
+
</li>
|
|
108
|
+
</ul>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
<div class="caixacampoazul">
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
<span class="resposta">Logradouro: </span>
|
|
121
|
+
<span class="respostadestaque">
|
|
122
|
+
Rua Bento Gonçalves - de 1001/1002 a 1699/1700
|
|
123
|
+
|
|
124
|
+
</span><br/>
|
|
125
|
+
<span class="resposta">Bairro: </span><span class="respostadestaque">Centro</span><br/>
|
|
126
|
+
<span class="resposta">Localidade / UF: </span>
|
|
127
|
+
<span class="respostadestaque">
|
|
128
|
+
Novo Hamburgo
|
|
129
|
+
|
|
130
|
+
/RS
|
|
131
|
+
|
|
132
|
+
</span><br/>
|
|
133
|
+
<span class="resposta">CEP: </span><span class="respostadestaque">93410002</span><br/>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
<div style="text-align: right;" class="mopcoes orientacao"><span>Opções <img style="position: relative right:0px;" src="images/template/mais.png"/></span></div>
|
|
144
|
+
|
|
145
|
+
</div>
|
|
146
|
+
<div class="divopcoes">
|
|
147
|
+
|
|
148
|
+
<!-- Para usuários originários do Busca CEP -->
|
|
149
|
+
<div> Simule um envio utilizando <br/> o CEP <strong>93410002</strong> como:</div>
|
|
150
|
+
<ul>
|
|
151
|
+
<li>
|
|
152
|
+
<a onclick="retornarParaPrecos('93410002','1');">CEP Origem <img src="images/template/cep_r.png"/></a>
|
|
153
|
+
</li>
|
|
154
|
+
<li>
|
|
155
|
+
<a onclick="retornarParaPrecos('93410002','2');"><img src="images/template/cep_d.png"/>CEP Destino</a>
|
|
156
|
+
</li>
|
|
157
|
+
</ul>
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
<div class="caixacampobranco">
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
<span class="resposta">Logradouro: </span>
|
|
170
|
+
<span class="respostadestaque">
|
|
171
|
+
Rua Bento Gonçalves - de 1701/1702 a 2099/2100
|
|
172
|
+
|
|
173
|
+
</span><br/>
|
|
174
|
+
<span class="resposta">Bairro: </span><span class="respostadestaque">Centro</span><br/>
|
|
175
|
+
<span class="resposta">Localidade / UF: </span>
|
|
176
|
+
<span class="respostadestaque">
|
|
177
|
+
Novo Hamburgo
|
|
178
|
+
|
|
179
|
+
/RS
|
|
180
|
+
|
|
181
|
+
</span><br/>
|
|
182
|
+
<span class="resposta">CEP: </span><span class="respostadestaque">93410003</span><br/>
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
<div style="text-align: right;" class="mopcoes orientacao"><span>Opções <img style="position: relative right:0px;" src="images/template/mais.png"/></span></div>
|
|
193
|
+
|
|
194
|
+
</div>
|
|
195
|
+
<div class="divopcoes">
|
|
196
|
+
|
|
197
|
+
<!-- Para usuários originários do Busca CEP -->
|
|
198
|
+
<div> Simule um envio utilizando <br/> o CEP <strong>93410003</strong> como:</div>
|
|
199
|
+
<ul>
|
|
200
|
+
<li>
|
|
201
|
+
<a onclick="retornarParaPrecos('93410003','1');">CEP Origem <img src="images/template/cep_r.png"/></a>
|
|
202
|
+
</li>
|
|
203
|
+
<li>
|
|
204
|
+
<a onclick="retornarParaPrecos('93410003','2');"><img src="images/template/cep_d.png"/>CEP Destino</a>
|
|
205
|
+
</li>
|
|
206
|
+
</ul>
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
<div class="caixacampoazul">
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
<span class="resposta">Logradouro: </span>
|
|
219
|
+
<span class="respostadestaque">
|
|
220
|
+
Rua Bento Gonçalves - de 2101/2102 a 2499/2500
|
|
221
|
+
|
|
222
|
+
</span><br/>
|
|
223
|
+
<span class="resposta">Bairro: </span><span class="respostadestaque">Centro</span><br/>
|
|
224
|
+
<span class="resposta">Localidade / UF: </span>
|
|
225
|
+
<span class="respostadestaque">
|
|
226
|
+
Novo Hamburgo
|
|
227
|
+
|
|
228
|
+
/RS
|
|
229
|
+
|
|
230
|
+
</span><br/>
|
|
231
|
+
<span class="resposta">CEP: </span><span class="respostadestaque">93510000</span><br/>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
<div style="text-align: right;" class="mopcoes orientacao"><span>Opções <img style="position: relative right:0px;" src="images/template/mais.png"/></span></div>
|
|
242
|
+
|
|
243
|
+
</div>
|
|
244
|
+
<div class="divopcoes">
|
|
245
|
+
|
|
246
|
+
<!-- Para usuários originários do Busca CEP -->
|
|
247
|
+
<div> Simule um envio utilizando <br/> o CEP <strong>93510000</strong> como:</div>
|
|
248
|
+
<ul>
|
|
249
|
+
<li>
|
|
250
|
+
<a onclick="retornarParaPrecos('93510000','1');">CEP Origem <img src="images/template/cep_r.png"/></a>
|
|
251
|
+
</li>
|
|
252
|
+
<li>
|
|
253
|
+
<a onclick="retornarParaPrecos('93510000','2');"><img src="images/template/cep_d.png"/>CEP Destino</a>
|
|
254
|
+
</li>
|
|
255
|
+
</ul>
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
</div>
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
<div class="caixacampobranco">
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
<span class="resposta">Logradouro: </span>
|
|
268
|
+
<span class="respostadestaque">
|
|
269
|
+
Rua Bento Gonçalves - de 2501/2502 a 2949/2950
|
|
270
|
+
|
|
271
|
+
</span><br/>
|
|
272
|
+
<span class="resposta">Bairro: </span><span class="respostadestaque">Centro</span><br/>
|
|
273
|
+
<span class="resposta">Localidade / UF: </span>
|
|
274
|
+
<span class="respostadestaque">
|
|
275
|
+
Novo Hamburgo
|
|
276
|
+
|
|
277
|
+
/RS
|
|
278
|
+
|
|
279
|
+
</span><br/>
|
|
280
|
+
<span class="resposta">CEP: </span><span class="respostadestaque">93510001</span><br/>
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
<div style="text-align: right;" class="mopcoes orientacao"><span>Opções <img style="position: relative right:0px;" src="images/template/mais.png"/></span></div>
|
|
291
|
+
|
|
292
|
+
</div>
|
|
293
|
+
<div class="divopcoes">
|
|
294
|
+
|
|
295
|
+
<!-- Para usuários originários do Busca CEP -->
|
|
296
|
+
<div> Simule um envio utilizando <br/> o CEP <strong>93510001</strong> como:</div>
|
|
297
|
+
<ul>
|
|
298
|
+
<li>
|
|
299
|
+
<a onclick="retornarParaPrecos('93510001','1');">CEP Origem <img src="images/template/cep_r.png"/></a>
|
|
300
|
+
</li>
|
|
301
|
+
<li>
|
|
302
|
+
<a onclick="retornarParaPrecos('93510001','2');"><img src="images/template/cep_d.png"/>CEP Destino</a>
|
|
303
|
+
</li>
|
|
304
|
+
</ul>
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
</div>
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
<div class="caixacampoazul">
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
<span class="resposta">Logradouro: </span>
|
|
317
|
+
<span class="respostadestaque">
|
|
318
|
+
Rua Bento Gonçalves - de 2951/2952 ao fim
|
|
319
|
+
|
|
320
|
+
</span><br/>
|
|
321
|
+
<span class="resposta">Bairro: </span><span class="respostadestaque">Centro</span><br/>
|
|
322
|
+
<span class="resposta">Localidade / UF: </span>
|
|
323
|
+
<span class="respostadestaque">
|
|
324
|
+
Novo Hamburgo
|
|
325
|
+
|
|
326
|
+
/RS
|
|
327
|
+
|
|
328
|
+
</span><br/>
|
|
329
|
+
<span class="resposta">CEP: </span><span class="respostadestaque">93520000</span><br/>
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
<div style="text-align: right;" class="mopcoes orientacao"><span>Opções <img style="position: relative right:0px;" src="images/template/mais.png"/></span></div>
|
|
340
|
+
|
|
341
|
+
</div>
|
|
342
|
+
<div class="divopcoes">
|
|
343
|
+
|
|
344
|
+
<!-- Para usuários originários do Busca CEP -->
|
|
345
|
+
<div> Simule um envio utilizando <br/> o CEP <strong>93520000</strong> como:</div>
|
|
346
|
+
<ul>
|
|
347
|
+
<li>
|
|
348
|
+
<a onclick="retornarParaPrecos('93520000','1');">CEP Origem <img src="images/template/cep_r.png"/></a>
|
|
349
|
+
</li>
|
|
350
|
+
<li>
|
|
351
|
+
<a onclick="retornarParaPrecos('93520000','2');"><img src="images/template/cep_d.png"/>CEP Destino</a>
|
|
352
|
+
</li>
|
|
353
|
+
</ul>
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
</div>
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
<div class="caixacampobranco">
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
<span class="resposta">Endereço: </span>
|
|
374
|
+
<span class="respostadestaque">
|
|
375
|
+
Rua Bento Gonçalves, 2399
|
|
376
|
+
|
|
377
|
+
</span><br/>
|
|
378
|
+
<span class="resposta">Bairro: </span><span class="respostadestaque">Centro</span><br/>
|
|
379
|
+
<span class="resposta">Localidade/UF: </span>
|
|
380
|
+
<span class="respostadestaque">
|
|
381
|
+
Novo Hamburgo
|
|
382
|
+
|
|
383
|
+
/RS
|
|
384
|
+
|
|
385
|
+
</span><br/>
|
|
386
|
+
<span class="resposta">CEP: </span><span class="respostadestaque">93510970</span><br/>
|
|
387
|
+
<span class="resposta">Unidade: </span><span class="respostadestaque">ACF Calçadão</span><br/>
|
|
388
|
+
|
|
389
|
+
<div style="text-align: right;" class="mopcoes orientacao"><span>Opções <img style="position: relative right:0px;" src="images/template/mais.png"/></span></div>
|
|
390
|
+
|
|
391
|
+
</div>
|
|
392
|
+
<div class="divopcoes">
|
|
393
|
+
|
|
394
|
+
<!-- Para usuários originários do Busca CEP -->
|
|
395
|
+
<div> Simule um envio utilizando <br/> o CEP <strong>93510970</strong> como:</div>
|
|
396
|
+
<ul>
|
|
397
|
+
<li>
|
|
398
|
+
<a onclick="retornarParaPrecos('93510970','1');">CEP Origem <img src="images/template/cep_r.png"/></a>
|
|
399
|
+
</li>
|
|
400
|
+
<li>
|
|
401
|
+
<a onclick="retornarParaPrecos('93510970','2');"><img src="images/template/cep_d.png"/>CEP Destino</a>
|
|
402
|
+
</li>
|
|
403
|
+
</ul>
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
<div class="botoes">
|
|
412
|
+
<div class="iconeesq">
|
|
413
|
+
|
|
414
|
+
<a href="buscaCep.do"><img src="images/template/seta-esquerda.gif"><span class="nav"> Nova Consulta</span></a>
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
</div>
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
<br class="clr">
|
|
421
|
+
<input type="hidden" name="metodo" value="buscarCep" id="metodo">
|
|
422
|
+
<input type="hidden" name="numPagina" value="1">
|
|
423
|
+
<input type="hidden" name="regTotal" value="7">
|
|
424
|
+
<input type="hidden" name="cepEntrada" value="rua bento gonçalves novo hamburgo" id="cepEntrada">
|
|
425
|
+
<input type="hidden" name="tipoCep" value="" id="tipoCep">
|
|
426
|
+
<input type="hidden" name="cepTemp" value="" id="cepTemp">
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
</form>
|
|
430
|
+
|
|
431
|
+
</div>
|
|
432
|
+
<script>
|
|
433
|
+
|
|
434
|
+
$('document').ready(function(){
|
|
435
|
+
$('div div.mopcoes span').click(function(){
|
|
436
|
+
$(this).parents().next('div.divopcoes').slideToggle(500);
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
function retornarParaPrecos(pCepSelecionado, pTipoCep)
|
|
441
|
+
{
|
|
442
|
+
var tipoCep=null;
|
|
443
|
+
|
|
444
|
+
if(pTipoCep==null)
|
|
445
|
+
{
|
|
446
|
+
tipoCep=$('#tipoCep').val();
|
|
447
|
+
}
|
|
448
|
+
else
|
|
449
|
+
{
|
|
450
|
+
tipoCep=pTipoCep;
|
|
451
|
+
}
|
|
452
|
+
var cepOrigem;
|
|
453
|
+
var cepDestino;
|
|
454
|
+
if(tipoCep!=null)
|
|
455
|
+
{
|
|
456
|
+
switch(tipoCep)
|
|
457
|
+
{
|
|
458
|
+
case "1":
|
|
459
|
+
cepOrigem=pCepSelecionado;
|
|
460
|
+
cepDestino=$('#cepTemp').val();
|
|
461
|
+
break;
|
|
462
|
+
|
|
463
|
+
case "2":
|
|
464
|
+
cepOrigem=$('#cepTemp').val();
|
|
465
|
+
cepDestino=pCepSelecionado;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
$('#cepOrigem').val(cepOrigem);
|
|
470
|
+
$('#cepDestino').val(cepDestino);
|
|
471
|
+
|
|
472
|
+
$('#calcularPrecos').submit();
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
</script>
|
|
478
|
+
|
|
479
|
+
<form name="precoForm" method="post" action="/movel/precos.do" id="calcularPrecos">
|
|
480
|
+
<input type="hidden" name="cepOrigem" value="" id="cepOrigem">
|
|
481
|
+
<input type="hidden" name="cepDestino" value="" id="cepDestino">
|
|
482
|
+
</form>
|
|
483
|
+
<form name="buscaCepForm" method="post" action="/movel/buscaCep.do" id="buscaCepInicio">
|
|
484
|
+
<input type="hidden" name="cepEntrada" value="rua bento gonçalves novo hamburgo" class="comptotal">
|
|
485
|
+
<input type="hidden" name="tipoCep" value="" id="tipoCep">
|
|
486
|
+
<input type="hidden" name="cepTemp" value="" id="cepTemp">
|
|
487
|
+
</form>
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
<br/>
|
|
491
|
+
</div>
|
|
492
|
+
<div class="rodape">
|
|
493
|
+
|
|
494
|
+
<a href="/movel/faleCorreios.do">
|
|
495
|
+
<img src="images/template/fcc.gif" align="absmiddle">
|
|
496
|
+
<span class="orientacao"> Fale com os Correios</span>
|
|
497
|
+
</a> |
|
|
498
|
+
<a href="http://www.correios.com.br/">
|
|
499
|
+
<span class="orientacao"> Versão clássica</span>
|
|
500
|
+
</a><br>
|
|
501
|
+
|
|
502
|
+
<div class="textorodape">© Copyright 2013 Correios - Todos os direitos reservados</div>
|
|
503
|
+
</div>
|
|
504
|
+
</div>
|
|
505
|
+
</body>
|
|
506
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require 'cep'
|
|
4
|
+
|
|
5
|
+
describe "address search" do
|
|
6
|
+
include RuaBentoGoncalvesNovoHamburgoSearch
|
|
7
|
+
|
|
8
|
+
context "when searching for 'Rua Bento Gonçalves Novo Hamburgo'" do
|
|
9
|
+
subject { Cep.new.search(term) }
|
|
10
|
+
|
|
11
|
+
it "returnes the expected result" do
|
|
12
|
+
subject.should =~ addresses
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "returnes the expected result in the same order" do
|
|
16
|
+
expect(subject).to eq(addresses)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'cep'
|
|
3
|
+
|
|
4
|
+
describe Cep do
|
|
5
|
+
describe "#address with cep" do
|
|
6
|
+
subject { Cep.new.cep('93320220') }
|
|
7
|
+
|
|
8
|
+
it "gets tipo_logradouro" do
|
|
9
|
+
subject[:tipo_logradouro].should eq("Rua")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "gets logradouro" do
|
|
13
|
+
subject[:logradouro].should eq("Rua Guanabara")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "gets bairro" do
|
|
17
|
+
subject[:bairro].should eq("Ouro Branco")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "gets localidade" do
|
|
21
|
+
subject[:localidade].should eq("Novo Hamburgo")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "gets localidade" do
|
|
25
|
+
subject[:uf].should eq("RS")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "gets cep" do
|
|
29
|
+
subject[:cep].should eq("93320220")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "#cep with address" do
|
|
34
|
+
subject { Cep.new.address('Avenida Conde da Boa Vista')[0] }
|
|
35
|
+
|
|
36
|
+
it "gets tipo_logradouro" do
|
|
37
|
+
subject[:tipo_logradouro].should eq("Avenida")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "gets logradouro" do
|
|
41
|
+
subject[:logradouro].should eq("Avenida Conde de Boa Vista")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "gets bairro" do
|
|
45
|
+
subject[:bairro].should eq("Jardim Tijuca")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "gets localidade" do
|
|
49
|
+
subject[:localidade].should eq("Campo Grande")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "gets localidade" do
|
|
53
|
+
subject[:uf].should eq("MS")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "gets cep" do
|
|
57
|
+
subject[:cep].should eq("79094050")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe "#url" do
|
|
62
|
+
it "builds ws url with params" do
|
|
63
|
+
url = Cep.new.url({p1: 'v1', p2: 'v2'})
|
|
64
|
+
url.should eq(Cep::URL + '?p1=v1&p2=v2')
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require 'correios/address_search_response'
|
|
4
|
+
|
|
5
|
+
describe Correios::AddressSearchResponse do
|
|
6
|
+
include RuaBentoGoncalvesNovoHamburgoSearch
|
|
7
|
+
|
|
8
|
+
let(:html) { response_fixture("rua_bento_goncalves_novo_hamburgo") }
|
|
9
|
+
|
|
10
|
+
subject { Correios::AddressSearchResponse.new(html) }
|
|
11
|
+
|
|
12
|
+
its(:body) { should eq(html) }
|
|
13
|
+
|
|
14
|
+
describe "#items" do
|
|
15
|
+
it "returns the Nokogiri nodes that caontains each response item" do
|
|
16
|
+
expect(subject.send(:items).length).to eq(addresses.length)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "#address" do
|
|
21
|
+
it "receives a Nokogiri node and return the address" do
|
|
22
|
+
node = subject.send(:items).first
|
|
23
|
+
expect(subject.send(:address, node)).to eq(address_1)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "#addresses" do
|
|
28
|
+
it "returns the correct hash addresses" do
|
|
29
|
+
subject.addresses.each do |address|
|
|
30
|
+
addresses.should include(address)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "returns in the correct order"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "#set_up_address" do
|
|
38
|
+
it "adds tipo_logradouro key" do
|
|
39
|
+
address = {logradouro: 'Rua One Two'}
|
|
40
|
+
expect(subject.send(:set_up_address, address)).to eq(address.merge(tipo_logradouro: 'Rua'))
|
|
41
|
+
|
|
42
|
+
address = {logradouro: 'Avenida One Two'}
|
|
43
|
+
expect(subject.send(:set_up_address, address)).to eq(address.merge(tipo_logradouro: 'Avenida'))
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "#clean_content" do
|
|
48
|
+
it "removes leading and trailing spaces" do
|
|
49
|
+
content = " con tent "
|
|
50
|
+
expect(subject.send(:clean_content, content)).to eq('con tent')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "removes line breaks" do
|
|
54
|
+
content = "\n\ncon\n \ntent\n\n"
|
|
55
|
+
expect(subject.send(:clean_content, content)).to eq('con tent')
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "#content_to_key" do
|
|
60
|
+
it "converts values to key" do
|
|
61
|
+
expect(subject.send(:content_to_key, "\nEndereço")).to eq(:endereco)
|
|
62
|
+
expect(subject.send(:content_to_key, "\sBairro")).to eq(:bairro)
|
|
63
|
+
expect(subject.send(:content_to_key, "Localidade/UF")).to eq([:localidade, :uf])
|
|
64
|
+
expect(subject.send(:content_to_key, "Localidade\n / UF")).to eq([:localidade, :uf])
|
|
65
|
+
expect(subject.send(:content_to_key, "CEP")).to eq(:cep)
|
|
66
|
+
expect(subject.send(:content_to_key, "Unidade")).to eq(:unidade)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "#content_to_hash" do
|
|
71
|
+
it "converts values to key" do
|
|
72
|
+
content = "\n Novo Hamburgo\n\n /RS\n\n "
|
|
73
|
+
value = subject.send(:content_to_hash, content, [:a, :b])
|
|
74
|
+
expect(value).to eq(a: "Novo Hamburgo", b: "RS")
|
|
75
|
+
|
|
76
|
+
content = "\n Rua Bento Gonçalves - até 999/1000\n\n "
|
|
77
|
+
value = subject.send(:content_to_hash, content, :a)
|
|
78
|
+
expect(value).to eq(a: "Rua Bento Gonçalves - até 999/1000")
|
|
79
|
+
|
|
80
|
+
content = "\n Rua Bento Gonçalves - de 1001/1002 a 1699/1700\n\n "
|
|
81
|
+
value = subject.send(:content_to_hash, content, :a)
|
|
82
|
+
expect(value).to eq(a: "Rua Bento Gonçalves - de 1001/1002 a 1699/1700")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'coveralls'
|
|
2
|
+
Coveralls.wear!
|
|
3
|
+
|
|
4
|
+
require 'simplecov'
|
|
5
|
+
|
|
6
|
+
SimpleCov.start do
|
|
7
|
+
add_filter 'spec'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
12
|
+
config.filter_run focus: true
|
|
13
|
+
config.run_all_when_everything_filtered = true
|
|
14
|
+
|
|
15
|
+
Dir["#{File.realpath('.')}/spec/support/**/*.rb"].each { |f| load f }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def response_fixture(name)
|
|
19
|
+
path = File.realpath("spec/fixtures/responses/#{name}.html")
|
|
20
|
+
File.read(path)
|
|
21
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module RuaBentoGoncalvesNovoHamburgoSearch
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.class_eval do
|
|
5
|
+
let(:address_1) do
|
|
6
|
+
{
|
|
7
|
+
tipo_logradouro: 'Rua',
|
|
8
|
+
logradouro: 'Rua Bento Gonçalves - até 999/1000',
|
|
9
|
+
bairro: 'Centro',
|
|
10
|
+
localidade: 'Novo Hamburgo',
|
|
11
|
+
uf: 'RS',
|
|
12
|
+
cep: '93410001'
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let(:address_2) do
|
|
17
|
+
{
|
|
18
|
+
tipo_logradouro: 'Rua',
|
|
19
|
+
logradouro: 'Rua Bento Gonçalves - de 1001/1002 a 1699/1700',
|
|
20
|
+
bairro: 'Centro',
|
|
21
|
+
localidade: 'Novo Hamburgo',
|
|
22
|
+
uf: 'RS',
|
|
23
|
+
cep: '93410002'
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
let(:address_3) do
|
|
28
|
+
{
|
|
29
|
+
tipo_logradouro: 'Rua',
|
|
30
|
+
logradouro: 'Rua Bento Gonçalves - de 1701/1702 a 2099/2100',
|
|
31
|
+
bairro: 'Centro',
|
|
32
|
+
localidade: 'Novo Hamburgo',
|
|
33
|
+
uf: 'RS',
|
|
34
|
+
cep: '93410003'
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
let(:address_4) do
|
|
40
|
+
{
|
|
41
|
+
tipo_logradouro: 'Rua',
|
|
42
|
+
logradouro: 'Rua Bento Gonçalves - de 2101/2102 a 2499/2500',
|
|
43
|
+
bairro: 'Centro',
|
|
44
|
+
localidade: 'Novo Hamburgo',
|
|
45
|
+
uf: 'RS',
|
|
46
|
+
cep: '93510000'
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
let(:address_5) do
|
|
51
|
+
{
|
|
52
|
+
logradouro: 'Rua Bento Gonçalves - de 2501/2502 a 2949/2950',
|
|
53
|
+
bairro: 'Centro',
|
|
54
|
+
localidade: 'Novo Hamburgo',
|
|
55
|
+
uf: 'RS',
|
|
56
|
+
cep: '93510001'
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
let(:address_6) do
|
|
61
|
+
{
|
|
62
|
+
tipo_logradouro: 'Rua',
|
|
63
|
+
logradouro: 'Rua Bento Gonçalves - de 2951/2952 ao fim',
|
|
64
|
+
bairro: 'Centro',
|
|
65
|
+
localidade: 'Novo Hamburgo',
|
|
66
|
+
uf: 'RS',
|
|
67
|
+
cep: '93520000'
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
let(:address_7) do
|
|
72
|
+
{
|
|
73
|
+
tipo_logradouro: 'Rua',
|
|
74
|
+
logradouro: 'Rua Bento Gonçalves, 2399',
|
|
75
|
+
bairro: 'Centro',
|
|
76
|
+
localidade: 'Novo Hamburgo',
|
|
77
|
+
uf: 'RS',
|
|
78
|
+
cep: '93510970',
|
|
79
|
+
unidade: 'ACF Calçadão'
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
let(:addresses) do
|
|
84
|
+
[address_1, address_2 ,address_3, address_4, address_5, address_6, address_7]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
let(:term) { 'Rua Bento Gonçalves Novo Hamburgo' }
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cep
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcelo Jacobus
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: nokogiri
|
|
@@ -67,6 +67,20 @@ dependencies:
|
|
|
67
67
|
- - '>='
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
69
|
version: '0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: rake
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - '>='
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - '>='
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
70
84
|
- !ruby/object:Gem::Dependency
|
|
71
85
|
name: rspec
|
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -131,7 +145,25 @@ executables: []
|
|
|
131
145
|
extensions: []
|
|
132
146
|
extra_rdoc_files: []
|
|
133
147
|
files:
|
|
148
|
+
- .gitignore
|
|
149
|
+
- .rspec
|
|
150
|
+
- .travis.yml
|
|
151
|
+
- Gemfile
|
|
152
|
+
- Gemfile.lock
|
|
153
|
+
- Guardfile
|
|
154
|
+
- MIT-LICENSE
|
|
155
|
+
- README.md
|
|
156
|
+
- Rakefile
|
|
157
|
+
- cep.gemspec
|
|
134
158
|
- lib/cep.rb
|
|
159
|
+
- lib/cep/version.rb
|
|
160
|
+
- lib/correios/address_search_response.rb
|
|
161
|
+
- spec/fixtures/responses/rua_bento_goncalves_novo_hamburgo.html
|
|
162
|
+
- spec/integration/cep_address_search_spec.rb
|
|
163
|
+
- spec/lib/cep_spec.rb
|
|
164
|
+
- spec/lib/correios/address_search_response_spec.rb
|
|
165
|
+
- spec/spec_helper.rb
|
|
166
|
+
- spec/support/rua_bento_goncalves_novo_hamburgo_search.rb
|
|
135
167
|
homepage: https://github.com/mjacobus/cep.git
|
|
136
168
|
licenses:
|
|
137
169
|
- MIT
|