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 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.1"
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.1"
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-07-19}
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.buscarcep.com.br?formato=xml&cep=#{cep}"))
5
- raise GoMaps::AddressNotFoundException if element('resultado') != '1'
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('tipo_logradouro')} #{element('logradouro')}"
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.css(name).inner_text
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="iso-8859-1" ?><webservicecep><quantidade>1</quantidade><retorno><resultado>-1</resultado><local_busca>loc</local_busca><resultado_txt>cep nao encontrado</resultado_txt><cep>12345678</cep><codigo_ibge>codigo ibge nao encontrado</codigo_ibge></retorno></webservicecep>
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>
@@ -1 +1,33 @@
1
- <?xml version="1.0" encoding="iso-8859-1" ?><webservicecep><quantidade>1</quantidade><retorno><cep>01310000</cep><uf>SP</uf><cidade>S�o Paulo</cidade><bairro>Bela Vista</bairro><tipo_logradouro>Avenida</tipo_logradouro><logradouro>Paulista</logradouro><complemento>- at� 0610 - lado par</complemento><data>2010-06-02 08:05:23</data><resultado>1</resultado><resultado_txt>sucesso. cep encontrado local</resultado_txt><limite_buscas>5</limite_buscas><ibge_uf>35</ibge_uf><ibge_municipio>355030</ibge_municipio><ibge_municipio_verificador>3550308</ibge_municipio_verificador></retorno></webservicecep>
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>
@@ -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.buscarcep.com.br/?formato=xml&cep=01310-000', 'cep_success'
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('São Paulo')
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.buscarcep.com.br/?formato=xml&cep=12345-678', 'cep_error'
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: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
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-07-19 00:00:00 -03:00
18
+ date: 2010-08-25 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency