correios-frete 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ == Versão 1.6.1
2
+ - Melhoria: Encoding de ISO-8859-1 para UTF-8 em toda resposta do Web Service.
3
+
1
4
  == Versão 1.6.0
2
5
  - Correção: Encoding de ISO-8859-1 para UTF-8 na mensagem de erro dos serviços, pois o parser não estava rolando para mensagens com acentos e/ou cedilhas.
3
6
 
@@ -11,7 +11,7 @@ GEM
11
11
  git (>= 1.2.5)
12
12
  rake
13
13
  rdoc
14
- json (1.6.5)
14
+ json (1.6.6)
15
15
  linecache (0.46)
16
16
  rbx-require-relative (> 0.0.4)
17
17
  linecache19 (0.5.12)
@@ -27,7 +27,7 @@ GEM
27
27
  rspec-expectations (~> 2.9.0)
28
28
  rspec-mocks (~> 2.9.0)
29
29
  rspec-core (2.9.0)
30
- rspec-expectations (2.9.0)
30
+ rspec-expectations (2.9.1)
31
31
  diff-lcs (~> 1.1.3)
32
32
  rspec-mocks (2.9.0)
33
33
  ruby-debug (0.10.4)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "correios-frete"
8
- s.version = "1.6.0"
8
+ s.version = "1.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Prodis a.k.a. Fernando Hamasaki"]
12
- s.date = "2012-03-26"
12
+ s.date = "2012-04-21"
13
13
  s.description = "Calculo de frete utilizando o Web Service dos Correios (http://www.correios.com.br/webservices).\nOs servicos de frete suportados sao PAC, SEDEX, SEDEX a Cobrar, SEDEX 10, SEDEX Hoje e e-SEDEX."
14
14
  s.email = "prodis@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  "lib/correios/frete/pacote_item.rb",
33
33
  "lib/correios/frete/parser.rb",
34
34
  "lib/correios/frete/servico.rb",
35
+ "lib/correios/frete/string.rb",
35
36
  "lib/correios/frete/version.rb",
36
37
  "lib/correios/frete/web_service.rb",
37
38
  "spec/correios/frete/calculador_spec.rb",
@@ -50,7 +51,7 @@ Gem::Specification.new do |s|
50
51
  s.licenses = ["MIT"]
51
52
  s.require_paths = ["lib"]
52
53
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
53
- s.rubygems_version = "1.8.17"
54
+ s.rubygems_version = "1.8.16"
54
55
  s.summary = "Calculo de frete dos Correios."
55
56
 
56
57
  if s.respond_to? :specification_version then
@@ -2,9 +2,9 @@
2
2
  require 'rubygems'
3
3
  require 'correios/frete'
4
4
  require 'correios/frete/calculador'
5
- require 'correios/frete/encoding_converter'
6
5
  require 'correios/frete/pacote'
7
6
  require 'correios/frete/pacote_item'
8
7
  require 'correios/frete/parser'
9
8
  require 'correios/frete/servico'
9
+ require 'correios/frete/string'
10
10
  require 'correios/frete/web_service'
@@ -6,22 +6,15 @@ module Correios
6
6
  class Parser
7
7
  def servicos(xml)
8
8
  servicos = {}
9
+ xml = xml.backward_encode("UTF-8", "ISO-8859-1")
9
10
 
10
11
  Nokogiri::XML(xml).root.elements.each do |element|
11
- encode_msg_erro!(element)
12
12
  servico = Correios::Frete::Servico.new.parse(element.to_xml)
13
13
  servicos[servico.tipo] = servico
14
14
  end
15
15
 
16
16
  servicos
17
17
  end
18
-
19
- private
20
-
21
- def encode_msg_erro!(element)
22
- msg_erro_element = element.search("MsgErro").first.children.first
23
- msg_erro_element.content = Correios::Frete::EncodingConverter.from_iso_to_utf8(msg_erro_element.text) if msg_erro_element
24
- end
25
18
  end
26
19
  end
27
20
  end
@@ -0,0 +1,10 @@
1
+ class String
2
+ def backward_encode(to, from)
3
+ if self.respond_to?(:encode)
4
+ self.encode(to, from)
5
+ else
6
+ require 'iconv'
7
+ Iconv.conv(to, from, self)
8
+ end
9
+ end
10
+ end
@@ -4,7 +4,7 @@ module Correios
4
4
  module Version
5
5
  MAJOR = 1
6
6
  MINOR = 6
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR, MINOR, PATCH].join(".")
9
9
  end
10
10
  end
@@ -6,8 +6,8 @@ describe Correios::Frete::Parser do
6
6
  let(:xml) { body_for :success_response_many_services }
7
7
  let(:parser) { Correios::Frete::Parser.new }
8
8
 
9
- it "converts error message to UTF-8" do
10
- Correios::Frete::EncodingConverter.should_receive(:from_iso_to_utf8).with("Somente para teste").and_return("Somente para teste")
9
+ it "encodes from ISO-8859-1 to UTF-8" do
10
+ xml.should_receive(:backward_encode).with("UTF-8", "ISO-8859-1").and_return(xml)
11
11
  parser.servicos(xml)
12
12
  end
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: correios-frete
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000Z
12
+ date: 2012-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: log-me
16
- requirement: &70094024066360 !ruby/object:Gem::Requirement
16
+ requirement: &11817300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.0.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70094024066360
24
+ version_requirements: *11817300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70094024065560 !ruby/object:Gem::Requirement
27
+ requirement: &11817060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.5'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70094024065560
35
+ version_requirements: *11817060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sax-machine
38
- requirement: &70094024064700 !ruby/object:Gem::Requirement
38
+ requirement: &11816820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.1'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70094024064700
46
+ version_requirements: *11816820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fakeweb
49
- requirement: &70094024063680 !ruby/object:Gem::Requirement
49
+ requirement: &11816580 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '1.3'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70094024063680
57
+ version_requirements: *11816580
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70094024062520 !ruby/object:Gem::Requirement
60
+ requirement: &11816340 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '1.8'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70094024062520
68
+ version_requirements: *11816340
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70094024061800 !ruby/object:Gem::Requirement
71
+ requirement: &11816100 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '2.9'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70094024061800
79
+ version_requirements: *11816100
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: ruby-debug
82
- requirement: &70094024058180 !ruby/object:Gem::Requirement
82
+ requirement: &11815860 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70094024058180
90
+ version_requirements: *11815860
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: ruby-debug19
93
- requirement: &70094024057280 !ruby/object:Gem::Requirement
93
+ requirement: &11815620 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70094024057280
101
+ version_requirements: *11815620
102
102
  description: ! 'Calculo de frete utilizando o Web Service dos Correios (http://www.correios.com.br/webservices).
103
103
 
104
104
  Os servicos de frete suportados sao PAC, SEDEX, SEDEX a Cobrar, SEDEX 10, SEDEX
@@ -125,6 +125,7 @@ files:
125
125
  - lib/correios/frete/pacote_item.rb
126
126
  - lib/correios/frete/parser.rb
127
127
  - lib/correios/frete/servico.rb
128
+ - lib/correios/frete/string.rb
128
129
  - lib/correios/frete/version.rb
129
130
  - lib/correios/frete/web_service.rb
130
131
  - spec/correios/frete/calculador_spec.rb
@@ -159,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
160
  version: '0'
160
161
  requirements: []
161
162
  rubyforge_project:
162
- rubygems_version: 1.8.17
163
+ rubygems_version: 1.8.16
163
164
  signing_key:
164
165
  specification_version: 3
165
166
  summary: Calculo de frete dos Correios.