correios-frete 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/Gemfile +5 -5
- data/Gemfile.lock +15 -15
- data/correios-frete.gemspec +19 -18
- data/lib/correios-frete.rb +1 -0
- data/lib/correios/frete/encoding_converter.rb +13 -0
- data/lib/correios/frete/parser.rb +8 -0
- data/lib/correios/frete/version.rb +2 -2
- data/spec/correios/frete/parser_spec.rb +5 -0
- metadata +74 -78
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
== Versão 1.6.0
|
2
|
+
- 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
|
+
|
1
4
|
== Versão 1.5.2
|
2
5
|
- Correção: {Issue #9: Bundler as dependency}[https://github.com/prodis/correios-frete/pull/9] - Remoção da gem bundler das dependências de ambiente de desenvolvimento.
|
3
6
|
- Atualização: Refatorações de testes.
|
data/Gemfile
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
gem "log-me", "~> 0.0.2"
|
4
|
-
gem "nokogiri", "~> 1.5
|
5
|
-
gem "sax-machine", "~> 0.1
|
4
|
+
gem "nokogiri", "~> 1.5"
|
5
|
+
gem "sax-machine", "~> 0.1"
|
6
6
|
|
7
7
|
group :development do
|
8
|
-
gem "fakeweb", "~> 1.3
|
9
|
-
gem "jeweler", "~> 1.8
|
10
|
-
gem "rspec", "~> 2.
|
8
|
+
gem "fakeweb", "~> 1.3"
|
9
|
+
gem "jeweler", "~> 1.8"
|
10
|
+
gem "rspec", "~> 2.9"
|
11
11
|
gem "ruby-debug", :platforms => :ruby_18
|
12
12
|
gem "ruby-debug19", :require => "ruby-debug", :platforms => :ruby_19
|
13
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -17,19 +17,19 @@ GEM
|
|
17
17
|
linecache19 (0.5.12)
|
18
18
|
ruby_core_source (>= 0.1.4)
|
19
19
|
log-me (0.0.2)
|
20
|
-
nokogiri (1.5.
|
20
|
+
nokogiri (1.5.2)
|
21
21
|
rake (0.9.2.2)
|
22
|
-
rbx-require-relative (0.0.
|
22
|
+
rbx-require-relative (0.0.9)
|
23
23
|
rdoc (3.12)
|
24
24
|
json (~> 1.4)
|
25
|
-
rspec (2.
|
26
|
-
rspec-core (~> 2.
|
27
|
-
rspec-expectations (~> 2.
|
28
|
-
rspec-mocks (~> 2.
|
29
|
-
rspec-core (2.
|
30
|
-
rspec-expectations (2.
|
31
|
-
diff-lcs (~> 1.1.
|
32
|
-
rspec-mocks (2.
|
25
|
+
rspec (2.9.0)
|
26
|
+
rspec-core (~> 2.9.0)
|
27
|
+
rspec-expectations (~> 2.9.0)
|
28
|
+
rspec-mocks (~> 2.9.0)
|
29
|
+
rspec-core (2.9.0)
|
30
|
+
rspec-expectations (2.9.0)
|
31
|
+
diff-lcs (~> 1.1.3)
|
32
|
+
rspec-mocks (2.9.0)
|
33
33
|
ruby-debug (0.10.4)
|
34
34
|
columnize (>= 0.1)
|
35
35
|
ruby-debug-base (~> 0.10.4.0)
|
@@ -52,11 +52,11 @@ PLATFORMS
|
|
52
52
|
ruby
|
53
53
|
|
54
54
|
DEPENDENCIES
|
55
|
-
fakeweb (~> 1.3
|
56
|
-
jeweler (~> 1.8
|
55
|
+
fakeweb (~> 1.3)
|
56
|
+
jeweler (~> 1.8)
|
57
57
|
log-me (~> 0.0.2)
|
58
|
-
nokogiri (~> 1.5
|
59
|
-
rspec (~> 2.
|
58
|
+
nokogiri (~> 1.5)
|
59
|
+
rspec (~> 2.9)
|
60
60
|
ruby-debug
|
61
61
|
ruby-debug19
|
62
|
-
sax-machine (~> 0.1
|
62
|
+
sax-machine (~> 0.1)
|
data/correios-frete.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "correios-frete"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.6.0"
|
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-
|
12
|
+
s.date = "2012-03-26"
|
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 = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"lib/correios-frete.rb",
|
28
28
|
"lib/correios/frete.rb",
|
29
29
|
"lib/correios/frete/calculador.rb",
|
30
|
+
"lib/correios/frete/encoding_converter.rb",
|
30
31
|
"lib/correios/frete/pacote.rb",
|
31
32
|
"lib/correios/frete/pacote_item.rb",
|
32
33
|
"lib/correios/frete/parser.rb",
|
@@ -49,7 +50,7 @@ Gem::Specification.new do |s|
|
|
49
50
|
s.licenses = ["MIT"]
|
50
51
|
s.require_paths = ["lib"]
|
51
52
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
52
|
-
s.rubygems_version = "1.8.
|
53
|
+
s.rubygems_version = "1.8.17"
|
53
54
|
s.summary = "Calculo de frete dos Correios."
|
54
55
|
|
55
56
|
if s.respond_to? :specification_version then
|
@@ -57,30 +58,30 @@ Gem::Specification.new do |s|
|
|
57
58
|
|
58
59
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
60
|
s.add_runtime_dependency(%q<log-me>, ["~> 0.0.2"])
|
60
|
-
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5
|
61
|
-
s.add_runtime_dependency(%q<sax-machine>, ["~> 0.1
|
62
|
-
s.add_development_dependency(%q<fakeweb>, ["~> 1.3
|
63
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.8
|
64
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.
|
61
|
+
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5"])
|
62
|
+
s.add_runtime_dependency(%q<sax-machine>, ["~> 0.1"])
|
63
|
+
s.add_development_dependency(%q<fakeweb>, ["~> 1.3"])
|
64
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
|
65
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.9"])
|
65
66
|
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
66
67
|
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
67
68
|
else
|
68
69
|
s.add_dependency(%q<log-me>, ["~> 0.0.2"])
|
69
|
-
s.add_dependency(%q<nokogiri>, ["~> 1.5
|
70
|
-
s.add_dependency(%q<sax-machine>, ["~> 0.1
|
71
|
-
s.add_dependency(%q<fakeweb>, ["~> 1.3
|
72
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8
|
73
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
70
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5"])
|
71
|
+
s.add_dependency(%q<sax-machine>, ["~> 0.1"])
|
72
|
+
s.add_dependency(%q<fakeweb>, ["~> 1.3"])
|
73
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
74
|
+
s.add_dependency(%q<rspec>, ["~> 2.9"])
|
74
75
|
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
75
76
|
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
76
77
|
end
|
77
78
|
else
|
78
79
|
s.add_dependency(%q<log-me>, ["~> 0.0.2"])
|
79
|
-
s.add_dependency(%q<nokogiri>, ["~> 1.5
|
80
|
-
s.add_dependency(%q<sax-machine>, ["~> 0.1
|
81
|
-
s.add_dependency(%q<fakeweb>, ["~> 1.3
|
82
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8
|
83
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
80
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5"])
|
81
|
+
s.add_dependency(%q<sax-machine>, ["~> 0.1"])
|
82
|
+
s.add_dependency(%q<fakeweb>, ["~> 1.3"])
|
83
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
84
|
+
s.add_dependency(%q<rspec>, ["~> 2.9"])
|
84
85
|
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
85
86
|
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
86
87
|
end
|
data/lib/correios-frete.rb
CHANGED
@@ -8,12 +8,20 @@ module Correios
|
|
8
8
|
servicos = {}
|
9
9
|
|
10
10
|
Nokogiri::XML(xml).root.elements.each do |element|
|
11
|
+
encode_msg_erro!(element)
|
11
12
|
servico = Correios::Frete::Servico.new.parse(element.to_xml)
|
12
13
|
servicos[servico.tipo] = servico
|
13
14
|
end
|
14
15
|
|
15
16
|
servicos
|
16
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
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -6,6 +6,11 @@ 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")
|
11
|
+
parser.servicos(xml)
|
12
|
+
end
|
13
|
+
|
9
14
|
{ :pac => { :tipo => :pac,
|
10
15
|
:codigo => "41106",
|
11
16
|
:valor => 15.70,
|
metadata
CHANGED
@@ -1,116 +1,114 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: correios-frete
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.0
|
4
5
|
prerelease:
|
5
|
-
version: 1.5.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Prodis a.k.a. Fernando Hamasaki
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-03-26 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: log-me
|
17
|
-
requirement: &
|
16
|
+
requirement: &70094024066360 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
|
-
requirements:
|
18
|
+
requirements:
|
20
19
|
- - ~>
|
21
|
-
- !ruby/object:Gem::Version
|
20
|
+
- !ruby/object:Gem::Version
|
22
21
|
version: 0.0.2
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
- !ruby/object:Gem::Dependency
|
24
|
+
version_requirements: *70094024066360
|
25
|
+
- !ruby/object:Gem::Dependency
|
27
26
|
name: nokogiri
|
28
|
-
requirement: &
|
27
|
+
requirement: &70094024065560 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
|
-
requirements:
|
29
|
+
requirements:
|
31
30
|
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.5
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.5'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *70094024065560
|
36
|
+
- !ruby/object:Gem::Dependency
|
38
37
|
name: sax-machine
|
39
|
-
requirement: &
|
38
|
+
requirement: &70094024064700 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
|
-
requirements:
|
40
|
+
requirements:
|
42
41
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: 0.1
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.1'
|
45
44
|
type: :runtime
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
48
|
-
- !ruby/object:Gem::Dependency
|
46
|
+
version_requirements: *70094024064700
|
47
|
+
- !ruby/object:Gem::Dependency
|
49
48
|
name: fakeweb
|
50
|
-
requirement: &
|
49
|
+
requirement: &70094024063680 !ruby/object:Gem::Requirement
|
51
50
|
none: false
|
52
|
-
requirements:
|
51
|
+
requirements:
|
53
52
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 1.3
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
56
55
|
type: :development
|
57
56
|
prerelease: false
|
58
|
-
version_requirements: *
|
59
|
-
- !ruby/object:Gem::Dependency
|
57
|
+
version_requirements: *70094024063680
|
58
|
+
- !ruby/object:Gem::Dependency
|
60
59
|
name: jeweler
|
61
|
-
requirement: &
|
60
|
+
requirement: &70094024062520 !ruby/object:Gem::Requirement
|
62
61
|
none: false
|
63
|
-
requirements:
|
62
|
+
requirements:
|
64
63
|
- - ~>
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 1.8
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '1.8'
|
67
66
|
type: :development
|
68
67
|
prerelease: false
|
69
|
-
version_requirements: *
|
70
|
-
- !ruby/object:Gem::Dependency
|
68
|
+
version_requirements: *70094024062520
|
69
|
+
- !ruby/object:Gem::Dependency
|
71
70
|
name: rspec
|
72
|
-
requirement: &
|
71
|
+
requirement: &70094024061800 !ruby/object:Gem::Requirement
|
73
72
|
none: false
|
74
|
-
requirements:
|
73
|
+
requirements:
|
75
74
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.9'
|
78
77
|
type: :development
|
79
78
|
prerelease: false
|
80
|
-
version_requirements: *
|
81
|
-
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: *70094024061800
|
80
|
+
- !ruby/object:Gem::Dependency
|
82
81
|
name: ruby-debug
|
83
|
-
requirement: &
|
82
|
+
requirement: &70094024058180 !ruby/object:Gem::Requirement
|
84
83
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version:
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
89
88
|
type: :development
|
90
89
|
prerelease: false
|
91
|
-
version_requirements: *
|
92
|
-
- !ruby/object:Gem::Dependency
|
90
|
+
version_requirements: *70094024058180
|
91
|
+
- !ruby/object:Gem::Dependency
|
93
92
|
name: ruby-debug19
|
94
|
-
requirement: &
|
93
|
+
requirement: &70094024057280 !ruby/object:Gem::Requirement
|
95
94
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version:
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
100
99
|
type: :development
|
101
100
|
prerelease: false
|
102
|
-
version_requirements: *
|
103
|
-
description:
|
104
|
-
|
105
|
-
Os servicos de frete suportados sao PAC, SEDEX, SEDEX a Cobrar, SEDEX 10, SEDEX
|
101
|
+
version_requirements: *70094024057280
|
102
|
+
description: ! 'Calculo de frete utilizando o Web Service dos Correios (http://www.correios.com.br/webservices).
|
103
|
+
|
104
|
+
Os servicos de frete suportados sao PAC, SEDEX, SEDEX a Cobrar, SEDEX 10, SEDEX
|
105
|
+
Hoje e e-SEDEX.'
|
106
106
|
email: prodis@gmail.com
|
107
107
|
executables: []
|
108
|
-
|
109
108
|
extensions: []
|
110
|
-
|
111
|
-
extra_rdoc_files:
|
109
|
+
extra_rdoc_files:
|
112
110
|
- README.rdoc
|
113
|
-
files:
|
111
|
+
files:
|
114
112
|
- .document
|
115
113
|
- .rspec
|
116
114
|
- CHANGELOG.rdoc
|
@@ -122,6 +120,7 @@ files:
|
|
122
120
|
- lib/correios-frete.rb
|
123
121
|
- lib/correios/frete.rb
|
124
122
|
- lib/correios/frete/calculador.rb
|
123
|
+
- lib/correios/frete/encoding_converter.rb
|
125
124
|
- lib/correios/frete/pacote.rb
|
126
125
|
- lib/correios/frete/pacote_item.rb
|
127
126
|
- lib/correios/frete/parser.rb
|
@@ -140,31 +139,28 @@ files:
|
|
140
139
|
- spec/support/responses/success-response-many-services.xml
|
141
140
|
- spec/support/responses/success-response-one-service.xml
|
142
141
|
homepage: http://prodis.blog.br/correios-frete-gem-para-calculo-de-frete-dos-correios
|
143
|
-
licenses:
|
142
|
+
licenses:
|
144
143
|
- MIT
|
145
144
|
post_install_message:
|
146
145
|
rdoc_options: []
|
147
|
-
|
148
|
-
require_paths:
|
146
|
+
require_paths:
|
149
147
|
- lib
|
150
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
149
|
none: false
|
152
|
-
requirements:
|
153
|
-
- -
|
154
|
-
- !ruby/object:Gem::Version
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
155
153
|
version: 1.8.7
|
156
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
155
|
none: false
|
158
|
-
requirements:
|
159
|
-
- -
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version:
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
162
160
|
requirements: []
|
163
|
-
|
164
161
|
rubyforge_project:
|
165
|
-
rubygems_version: 1.8.
|
162
|
+
rubygems_version: 1.8.17
|
166
163
|
signing_key:
|
167
164
|
specification_version: 3
|
168
165
|
summary: Calculo de frete dos Correios.
|
169
166
|
test_files: []
|
170
|
-
|