nfse-carioca 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d2a028ac4a3875a23353e4a305af60135c4057f
4
- data.tar.gz: 69cb8c1e1a0dc1f25f0bee9e63e714ece471bb60
3
+ metadata.gz: bb1e8b24538a361b90b79e5eede02041581e806d
4
+ data.tar.gz: 37267c3f1c0818afeadc26680df63926d099f3d4
5
5
  SHA512:
6
- metadata.gz: 0d7e05ad64e7e0d4547ca026338ddea3ad5b69da210b76892abcd5d2006e8631b72582afd187c9f5cd01a23d28fd3d72bb09edced3dbefabbadbbe96a4edb2ad
7
- data.tar.gz: 404c72ce7659ccf961d7de6618766f37624759d68f825edc223a7e626f697b2f5010cad7caed67b7e1b0f7340c6fac2ddedd8001c04fb0f21c81db5e9e63b037
6
+ metadata.gz: 5cec76899bae06a36f9abd216e3fad22f7260100bfc848e2a000624eac7d93a3368772f5f2953518e1b92ed019cc6e334f1b0e048f527e729c447e5cbdbdfd69
7
+ data.tar.gz: ff3e7bb008985b83e4a6d3b9e3b7bacbe5b48a7b7f59e4b6b1afe64d7660bef3c85ebefeef60471af8ad1c8f83d3b92a64b9f4d3343d8a9d9feef3f5c717f361
data/lib/nfse_carioca.rb CHANGED
@@ -3,6 +3,7 @@ require "active_model"
3
3
 
4
4
  require "nfse_carioca/version"
5
5
  require "nfse_carioca/configuration"
6
+ require "nfse_carioca/sanitizer"
6
7
  require "nfse_carioca/client"
7
8
  require "nfse_carioca/response"
8
9
  require "nfse_carioca/gerar_nfse"
@@ -56,6 +56,10 @@ module NfseCarioca
56
56
  )
57
57
  end
58
58
 
59
+ def clear(value)
60
+ NfseCarioca::Sanitizer.new(value).clean
61
+ end
62
+
59
63
  def tributacao
60
64
  tributacao = NfseCarioca.configuration.codigo_tributacao_municipio
61
65
 
@@ -104,15 +108,15 @@ module NfseCarioca
104
108
 
105
109
  if @invoice[:customer][:address].present?
106
110
  xml["Endereco"] = {
107
- "Endereco" => @invoice[:customer][:address][:street],
108
- "Numero" => @invoice[:customer][:address][:number]
111
+ "Endereco" => clear(@invoice[:customer][:address][:street]),
112
+ "Numero" => clear(@invoice[:customer][:address][:number])
109
113
  }
110
114
 
111
115
  if @invoice[:customer][:address][:complement].present?
112
- xml["Endereco"]["Complemento"] = @invoice[:customer][:address][:complement]
116
+ xml["Endereco"]["Complemento"] = clear(@invoice[:customer][:address][:complement])
113
117
  end
114
118
 
115
- xml["Endereco"]["Bairro"] = @invoice[:customer][:address][:neighborhood]
119
+ xml["Endereco"]["Bairro"] = clear(@invoice[:customer][:address][:neighborhood])
116
120
  xml["Endereco"]["CodigoMunicipio"] = @invoice[:customer][:address][:city_ibge_code]
117
121
  xml["Endereco"]["Uf"] = @invoice[:customer][:address][:state_code]
118
122
  xml["Endereco"]["Cep"] = @invoice[:customer][:address][:zipcode].scan(/\d/).join
@@ -0,0 +1,16 @@
1
+ module NfseCarioca
2
+ class Sanitizer
3
+ attr_reader :value
4
+
5
+ def initialize(value)
6
+ @value = value
7
+ end
8
+
9
+ def clear
10
+ temp = I18n.transliterate(value)
11
+ temp.gsub!(/\-/, " ")
12
+ temp.gsub!(/,|\./, "")
13
+ temp.scan(/\w+|\s+/i).join
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module NfseCarioca
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe NfseCarioca::Sanitizer do
4
+ describe "#clear" do
5
+ {
6
+ "Gestimbra-Contabilidade e Gestão, Lda. PT501615725 Rua Padre Estevão Cabral,79 / Sala 313, 3000-317 Co" =>
7
+ "Gestimbra Contabilidade e Gestao Lda PT501615725 Rua Padre Estevao Cabral79 Sala 313 3000 317 Co"
8
+ }.each do |dirty, clean|
9
+ context "when #{dirty}" do
10
+ subject { described_class.new(dirty).clear }
11
+ it { is_expected.to eq clean }
12
+ end
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nfse-carioca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - LUZ Planilhas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -159,6 +159,7 @@ files:
159
159
  - lib/nfse_carioca/gerar_nfse.rb
160
160
  - lib/nfse_carioca/gerar_nfse_xml.rb
161
161
  - lib/nfse_carioca/response.rb
162
+ - lib/nfse_carioca/sanitizer.rb
162
163
  - lib/nfse_carioca/version.rb
163
164
  - nfse_carioca.gemspec
164
165
  - spec/fixtures/nota_carioca/CancelarNfseResposta.xml
@@ -177,6 +178,7 @@ files:
177
178
  - spec/lib/nfse_carioca/cancelar_nfse_spec.rb
178
179
  - spec/lib/nfse_carioca/configuration_spec.rb
179
180
  - spec/lib/nfse_carioca/gerar_nfse_spec.rb
181
+ - spec/lib/nfse_carioca/sanitizer_spec.rb
180
182
  - spec/spec_helper.rb
181
183
  homepage:
182
184
  licenses: