br_documents 0.0.3 → 0.0.4

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: 71a40dc24757c42093a691afada5c00f96e319e7
4
- data.tar.gz: 2f1e071e941aff2e34f0fe4adecdef3bcb7af3a9
3
+ metadata.gz: 1965ccaaf6c4d64308cc6cc533e0d074edfb6566
4
+ data.tar.gz: ade8e62331140d9103b4b4763c38fa4d428e2e4f
5
5
  SHA512:
6
- metadata.gz: adc59f3e79da033de6367a72d02ca2de0e0fcb94b868c787a2eb9a4df3d83a3e7479caa3b2b12e2d12ebc0de9129f126465ddb059a0114eab5be8dd45bc1d58f
7
- data.tar.gz: df57b4665393c260415ba44adf428b3fcdb92e2bb24e60ce228043577c48019f8509d1bd2c5e4f2a8301fadf8b87ca1a42460f13051a5381913412c960a1c2ad
6
+ metadata.gz: 6ab6b906a9bf27ad17dd224c0c257017d4bb3f8196433db00d0e83666041443e89dfe24f156c664d1d5d217e9f8f103d02f2b9243ca4cfb9984a450e037a8ed0
7
+ data.tar.gz: 71ad23081b998135bc6d764b77f73022fc7f038fcd89ceb289852e4dd0ba4df787979d5f75376c4e776dce51467c797c4f161d37673f65ae0e21617eb2a8eef4
data/README.md CHANGED
@@ -118,14 +118,16 @@ pj.valid? # => false
118
118
  #### CNPJ
119
119
 
120
120
  ```ruby
121
- cnpj = BrDocuments::CnpjCpf::Cnpj.new("04.001.155/0001-01")
121
+ cnpj = BrDocuments::CnpjCpf::Cnpj.new("04001155000101")
122
+ cnpj.formatted # => "04.001.155/0001-01"
122
123
  cnpj.valid? # => true
123
124
  ```
124
125
 
125
126
  #### CPF
126
127
 
127
128
  ```ruby
128
- cpf = BrDocuments::CnpjCpf::Cpf.new("111.444.777-35")
129
+ cpf = BrDocuments::CnpjCpf::Cpf.new("11144477735")
130
+ cpf.formatted # => "111.444.777-35"
129
131
  cpf.valid? # => true
130
132
  ```
131
133
 
@@ -16,6 +16,10 @@ module BrDocuments
16
16
 
17
17
  valid_number?(@number, regex, weight13, weight14)
18
18
  end
19
+
20
+ def formatted
21
+ @number.sub(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, "\\1.\\2.\\3/\\4-\\5")
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -16,6 +16,10 @@ module BrDocuments
16
16
 
17
17
  valid_number?(@number, regex, weight10, weight11)
18
18
  end
19
+
20
+ def formatted
21
+ @number.sub(/(\d{3})(\d{3})(\d{3})(\d{2})/, "\\1.\\2.\\3-\\4")
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -1,3 +1,3 @@
1
1
  module BrDocuments
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,6 +1,13 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe BrDocuments::CnpjCpf::Cnpj do
4
+ describe "#formatted" do
5
+ it "returns a formatted number" do
6
+ cnpj = BrDocuments::CnpjCpf::Cnpj.new("04001155000101")
7
+ expect(cnpj.formatted).to eq "04.001.155/0001-01"
8
+ end
9
+ end
10
+
4
11
  it "is invalid with malformed number" do
5
12
  ["242.2818/50001-54", "35.611.011/000192"].each do |number|
6
13
  cnpj = BrDocuments::CnpjCpf::Cnpj.new(number)
@@ -1,6 +1,13 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe BrDocuments::CnpjCpf::Cpf do
4
+ describe "#formatted" do
5
+ it "returns a formatted number" do
6
+ cpf = BrDocuments::CnpjCpf::Cpf.new("11144477735")
7
+ expect(cpf.formatted).to eq "111.444.777-35"
8
+ end
9
+ end
10
+
4
11
  it "is invalid with malformed number" do
5
12
  ["111.126.491.07", "482.261.15-663", "111444.777-35"].each do |number|
6
13
  cpf = BrDocuments::CnpjCpf::Cpf.new(number)
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.3
4
+ version: 0.0.4
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: 2014-04-07 00:00:00.000000000 Z
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler