go_maps 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/go_maps.gemspec +29 -32
- data/lib/go_maps/cep.rb +3 -3
- data/spec/data/cep_error +10 -23
- data/spec/data/cep_success +1 -33
- data/spec/go_maps/cep_spec.rb +3 -3
- metadata +8 -8
- data/.gitignore +0 -11
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ begin
|
|
7
7
|
require 'jeweler'
|
8
8
|
Jeweler::Tasks.new do |gem|
|
9
9
|
gem.name = "go_maps"
|
10
|
-
gem.version = "0.4"
|
10
|
+
gem.version = "0.4.1"
|
11
11
|
gem.summary = %Q{Ruby API to geographic operations}
|
12
12
|
gem.description = %Q{Ruby API to geographic operations}
|
13
13
|
gem.homepage = "http://github.com/gonow/go_maps"
|
data/go_maps.gemspec
CHANGED
@@ -1,58 +1,55 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{go_maps}
|
8
|
-
s.version = "0.4"
|
8
|
+
s.version = "0.4.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gonow"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-04-14}
|
13
13
|
s.description = %q{Ruby API to geographic operations}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.markdown"
|
16
16
|
]
|
17
17
|
s.files = [
|
18
|
-
".
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
"spec/spec_helper.rb"
|
18
|
+
"README.markdown",
|
19
|
+
"Rakefile",
|
20
|
+
"go_maps.gemspec",
|
21
|
+
"lib/go_maps.rb",
|
22
|
+
"lib/go_maps/address.rb",
|
23
|
+
"lib/go_maps/address_not_found_exception.rb",
|
24
|
+
"lib/go_maps/cep.rb",
|
25
|
+
"lib/go_maps/direction.rb",
|
26
|
+
"spec/data/address_error",
|
27
|
+
"spec/data/address_success",
|
28
|
+
"spec/data/cep_error",
|
29
|
+
"spec/data/cep_success",
|
30
|
+
"spec/data/direction_error",
|
31
|
+
"spec/data/direction_success",
|
32
|
+
"spec/data/direction_success_pt-BR",
|
33
|
+
"spec/data/distance_error",
|
34
|
+
"spec/data/distance_success_10.8",
|
35
|
+
"spec/go_maps/address_spec.rb",
|
36
|
+
"spec/go_maps/cep_spec.rb",
|
37
|
+
"spec/go_maps/direction_spec.rb",
|
38
|
+
"spec/spec.opts",
|
39
|
+
"spec/spec_helper.rb"
|
41
40
|
]
|
42
41
|
s.homepage = %q{http://github.com/gonow/go_maps}
|
43
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
44
42
|
s.require_paths = ["lib"]
|
45
|
-
s.rubygems_version = %q{1.
|
43
|
+
s.rubygems_version = %q{1.5.0}
|
46
44
|
s.summary = %q{Ruby API to geographic operations}
|
47
45
|
s.test_files = [
|
48
46
|
"spec/go_maps/address_spec.rb",
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
"spec/go_maps/cep_spec.rb",
|
48
|
+
"spec/go_maps/direction_spec.rb",
|
49
|
+
"spec/spec_helper.rb"
|
52
50
|
]
|
53
51
|
|
54
52
|
if s.respond_to? :specification_version then
|
55
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
53
|
s.specification_version = 3
|
57
54
|
|
58
55
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/lib/go_maps/cep.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module GoMaps
|
2
2
|
class CEP
|
3
3
|
def initialize(cep)
|
4
|
-
@response = Nokogiri::XML(open("http://
|
5
|
-
raise GoMaps::AddressNotFoundException if element('
|
4
|
+
@response = Nokogiri::XML(open("http://cep.republicavirtual.com.br/web_cep.php?cep=#{cep}"))
|
5
|
+
raise GoMaps::AddressNotFoundException if element('resultado') == "0"
|
6
6
|
end
|
7
7
|
|
8
8
|
def street
|
9
|
-
"#{element('
|
9
|
+
"#{element('tipo_logradouro')} #{element('logradouro')}"
|
10
10
|
end
|
11
11
|
|
12
12
|
def city
|
data/spec/data/cep_error
CHANGED
@@ -1,23 +1,10 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<xs:element name="nome" type="xs:string" minOccurs="0" />
|
12
|
-
<xs:element name="bairro" type="xs:string" minOccurs="0" />
|
13
|
-
<xs:element name="UF" type="xs:string" minOccurs="0" />
|
14
|
-
<xs:element name="cidade" type="xs:string" minOccurs="0" />
|
15
|
-
</xs:sequence>
|
16
|
-
</xs:complexType>
|
17
|
-
</xs:element>
|
18
|
-
</xs:choice>
|
19
|
-
</xs:complexType>
|
20
|
-
</xs:element>
|
21
|
-
</xs:schema>
|
22
|
-
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" />
|
23
|
-
</DataSet>
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1" ?>
|
2
|
+
<webservicecep>
|
3
|
+
<resultado>0</resultado>
|
4
|
+
<resultado_txt>serviço indisponível/cep inválido</resultado_txt>
|
5
|
+
<uf></uf>
|
6
|
+
<cidade></cidade>
|
7
|
+
<bairro></bairro>
|
8
|
+
<tipo_logradouro></tipo_logradouro>
|
9
|
+
<logradouro></logradouro>
|
10
|
+
</webservicecep>
|
data/spec/data/cep_success
CHANGED
@@ -1,33 +1 @@
|
|
1
|
-
|
2
|
-
<DataSet xmlns="http://tempuri.org/">
|
3
|
-
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
4
|
-
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
|
5
|
-
<xs:complexType>
|
6
|
-
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
7
|
-
<xs:element name="tbCEP">
|
8
|
-
<xs:complexType>
|
9
|
-
<xs:sequence>
|
10
|
-
<xs:element name="logradouro" type="xs:string" minOccurs="0" />
|
11
|
-
<xs:element name="nome" type="xs:string" minOccurs="0" />
|
12
|
-
<xs:element name="bairro" type="xs:string" minOccurs="0" />
|
13
|
-
<xs:element name="UF" type="xs:string" minOccurs="0" />
|
14
|
-
<xs:element name="cidade" type="xs:string" minOccurs="0" />
|
15
|
-
</xs:sequence>
|
16
|
-
</xs:complexType>
|
17
|
-
</xs:element>
|
18
|
-
</xs:choice>
|
19
|
-
</xs:complexType>
|
20
|
-
</xs:element>
|
21
|
-
</xs:schema>
|
22
|
-
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
|
23
|
-
<NewDataSet xmlns="">
|
24
|
-
<tbCEP diffgr:id="tbCEP1" msdata:rowOrder="0">
|
25
|
-
<logradouro>Avenida</logradouro>
|
26
|
-
<nome>Paulista</nome>
|
27
|
-
<bairro>Bela Vista</bairro>
|
28
|
-
<UF>SP</UF>
|
29
|
-
<cidade>Sao Paulo</cidade>
|
30
|
-
</tbCEP>
|
31
|
-
</NewDataSet>
|
32
|
-
</diffgr:diffgram>
|
33
|
-
</DataSet>
|
1
|
+
<webservicecep><resultado>1</resultado><resultado_txt>sucesso - cep completo</resultado_txt><uf>SP</uf><cidade>São Paulo</cidade><bairro>Bela Vista</bairro><tipo_logradouro>Avenida</tipo_logradouro><logradouro>Paulista</logradouro></webservicecep>
|
data/spec/go_maps/cep_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe GoMaps::CEP do
|
4
4
|
context 'given valid cep' do
|
5
5
|
before :each do
|
6
|
-
map_url_to_file 'http://
|
6
|
+
map_url_to_file 'http://cep.republicavirtual.com.br/web_cep.php?cep=01310-000', 'cep_success'
|
7
7
|
@cep = GoMaps::CEP.new('01310-000')
|
8
8
|
end
|
9
9
|
|
@@ -15,14 +15,14 @@ describe GoMaps::CEP do
|
|
15
15
|
|
16
16
|
context 'on #city' do
|
17
17
|
it 'should return the city' do
|
18
|
-
@cep.city.should eql('
|
18
|
+
@cep.city.should eql('São Paulo')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'given invalid cep' do
|
24
24
|
it 'should raise AddressNotFoundException' do
|
25
|
-
map_url_to_file 'http://
|
25
|
+
map_url_to_file 'http://cep.republicavirtual.com.br/web_cep.php?cep=12345-678', 'cep_error'
|
26
26
|
lambda { @cep = GoMaps::CEP.new('12345-678') }.should raise_error(GoMaps::AddressNotFoundException)
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_maps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 13
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Gonow
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-04-14 00:00:00 -03:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -90,7 +91,6 @@ extensions: []
|
|
90
91
|
extra_rdoc_files:
|
91
92
|
- README.markdown
|
92
93
|
files:
|
93
|
-
- .gitignore
|
94
94
|
- README.markdown
|
95
95
|
- Rakefile
|
96
96
|
- go_maps.gemspec
|
@@ -118,8 +118,8 @@ homepage: http://github.com/gonow/go_maps
|
|
118
118
|
licenses: []
|
119
119
|
|
120
120
|
post_install_message:
|
121
|
-
rdoc_options:
|
122
|
-
|
121
|
+
rdoc_options: []
|
122
|
+
|
123
123
|
require_paths:
|
124
124
|
- lib
|
125
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
requirements: []
|
144
144
|
|
145
145
|
rubyforge_project:
|
146
|
-
rubygems_version: 1.
|
146
|
+
rubygems_version: 1.5.0
|
147
147
|
signing_key:
|
148
148
|
specification_version: 3
|
149
149
|
summary: Ruby API to geographic operations
|