go_maps 0.3.1 → 0.3.2
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 +2 -2
- data/lib/go_maps/cep.rb +4 -4
- data/spec/data/cep_error +23 -1
- data/spec/data/cep_success +33 -1
- data/spec/go_maps/cep_spec.rb +3 -3
- metadata +4 -4
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.3.
|
10
|
+
gem.version = "0.3.2"
|
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
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{go_maps}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.2"
|
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{2010-
|
12
|
+
s.date = %q{2010-08-25}
|
13
13
|
s.description = %q{Ruby API to geographic operations}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.markdown"
|
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://www.
|
5
|
-
raise GoMaps::AddressNotFoundException if element('
|
4
|
+
@response = Nokogiri::XML(open("http://www.bronzebusiness.com.br/webservices/wscep.asmx/cep?strcep=#{cep}"))
|
5
|
+
raise GoMaps::AddressNotFoundException if element('tbCEP').blank?
|
6
6
|
end
|
7
7
|
|
8
8
|
def street
|
9
|
-
"#{element('
|
9
|
+
"#{element('logradouro')} #{element('nome')}"
|
10
10
|
end
|
11
11
|
|
12
12
|
def city
|
@@ -16,7 +16,7 @@ module GoMaps
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def element(name)
|
19
|
-
@response.
|
19
|
+
@response.xpath("//#{name}").inner_text
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/spec/data/cep_error
CHANGED
@@ -1 +1,23 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
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
|
+
</DataSet>
|
data/spec/data/cep_success
CHANGED
@@ -1 +1,33 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
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>
|
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://www.
|
6
|
+
map_url_to_file 'http://www.bronzebusiness.com.br/webservices/wscep.asmx/cep?strcep=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('Sao 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://www.
|
25
|
+
map_url_to_file 'http://www.bronzebusiness.com.br/webservices/wscep.asmx/cep?strcep=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,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_maps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gonow
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-08-25 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|