br_documents 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/br_documents/ie/mt.rb +9 -1
- data/lib/br_documents/ie/rj.rb +1 -1
- data/lib/br_documents/version.rb +1 -1
- data/spec/ie/mt_spec.rb +6 -5
- data/spec/ie/rj_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9bb58e73c2ffeeb543165040e7e6e51e21d8f1e
|
4
|
+
data.tar.gz: 79b96cbdc6e69c33a6f6738f7972ab2303d887ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3de3927c7117bc94acbf2edbb6f235bb188e7e1782cb425c0c73c3063d217930a054d84b8708d99bc50bee53ce7242a6b86f65afdc34d9462ec6826934406703
|
7
|
+
data.tar.gz: 3ad7723c2eb9c82d0f55009ae2002ca245a77b2acdce8e448377c7491f0fb24aa49f3ccaf921d88f8de4335669213a0e869ea61426ba7c26299c5e042f6aaf66
|
data/README.md
CHANGED
@@ -120,6 +120,8 @@ pj.valid? # => false
|
|
120
120
|
#### CNPJ
|
121
121
|
|
122
122
|
```ruby
|
123
|
+
require "br_documents"
|
124
|
+
|
123
125
|
cnpj = BrDocuments::CnpjCpf::Cnpj.new("04001155000101")
|
124
126
|
cnpj.formatted # => "04.001.155/0001-01"
|
125
127
|
cnpj.valid? # => true
|
@@ -128,6 +130,8 @@ cnpj.valid? # => true
|
|
128
130
|
#### CPF
|
129
131
|
|
130
132
|
```ruby
|
133
|
+
require "br_documents"
|
134
|
+
|
131
135
|
cpf = BrDocuments::CnpjCpf::Cpf.new("11144477735")
|
132
136
|
cpf.formatted # => "111.444.777-35"
|
133
137
|
cpf.valid? # => true
|
@@ -136,6 +140,8 @@ cpf.valid? # => true
|
|
136
140
|
#### IE
|
137
141
|
|
138
142
|
```ruby
|
143
|
+
require "br_documents"
|
144
|
+
|
139
145
|
ie = BrDocuments::IE::Factory.create("SC", "254062407")
|
140
146
|
ie.formatted # => "254.062.407"
|
141
147
|
ie.valid? # => true
|
data/lib/br_documents/ie/mt.rb
CHANGED
@@ -4,12 +4,20 @@ module BrDocuments
|
|
4
4
|
module IE
|
5
5
|
class MT < Pattern1
|
6
6
|
def initialize(number)
|
7
|
+
complete_with_zeros(number) { |completted| number = completted }
|
8
|
+
|
7
9
|
super
|
8
|
-
@mask =
|
10
|
+
@mask = /^\d{4}\.?\d{3}\.?\d{3}\-?\d{1}$/
|
9
11
|
@weight = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
10
12
|
end
|
11
13
|
|
12
14
|
private
|
15
|
+
def complete_with_zeros(number)
|
16
|
+
just_numbers = number.gsub(/[\.\/-]/, "")
|
17
|
+
zeros = ("0" * 11).slice(just_numbers.length, 11)
|
18
|
+
yield "#{zeros}#{number}" if block_given?
|
19
|
+
end
|
20
|
+
|
13
21
|
def format_ie(number)
|
14
22
|
number.sub(/(\d{10})(\d{1})/, "\\1-\\2")
|
15
23
|
end
|
data/lib/br_documents/ie/rj.rb
CHANGED
data/lib/br_documents/version.rb
CHANGED
data/spec/ie/mt_spec.rb
CHANGED
@@ -16,10 +16,11 @@ describe BrDocuments::IE::MT do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
context "when the number is greater than 11" do
|
20
|
+
subject { BrDocuments::IE::MT.new("123456789012") }
|
21
|
+
|
22
|
+
it "is invalid " do
|
23
|
+
expect(subject).to_not be_valid
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -31,7 +32,7 @@ describe BrDocuments::IE::MT do
|
|
31
32
|
end
|
32
33
|
|
33
34
|
it "is valid with valid number" do
|
34
|
-
["
|
35
|
+
["0013000001-9", "82060187373", "132631946", "13.263.194-6"].each do |number|
|
35
36
|
ie = BrDocuments::IE::MT.new(number)
|
36
37
|
expect(ie).to be_valid
|
37
38
|
end
|
data/spec/ie/rj_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_documents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ASSEINFO - Sistemas de Informação
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03
|
11
|
+
date: 2015-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|