br-cnpj 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,28 +2,28 @@
2
2
 
3
3
  Lib implementada em C (gera uma lib compilada nativamente) que calcula e valida CNPJs.
4
4
 
5
- == Instala��o
5
+ == Instalação
6
6
 
7
- sudo gem install br-cnpj
7
+ sudo gem install br-cnpj
8
8
 
9
9
  == Exemplos
10
10
 
11
- require 'rubygems'
12
- require 'br/cnpj'
11
+ require 'rubygems'
12
+ require 'br/cnpj'
13
13
 
14
- BR::CNPJ.valid? '00000000000191'
15
- => true
14
+ BR::CNPJ.valid? '00000000000191'
15
+ => true
16
16
 
17
- BR::CNPJ.valid? 191
18
- => true
17
+ BR::CNPJ.valid? 191
18
+ => true
19
19
 
20
- BR::CNPJ.valid? 192
21
- => false
20
+ BR::CNPJ.valid? 192
21
+ => false
22
22
 
23
- raiz = 0
24
- filial = 1
25
- BR::CNPJ.new(raiz, filial).to_s
26
- => '00000000000191'
23
+ raiz = 0
24
+ filial = 1
25
+ BR::CNPJ.new(raiz, filial).to_s
26
+ => '00000000000191'
27
27
 
28
28
 
29
29
 
data/spec/br-cnpj_spec.rb CHANGED
@@ -1,7 +1,37 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
- describe "BrCnpj" do
4
- it "fails" do
5
- fail "No specs defined yet"
3
+ describe BR::CNPJ do
4
+
5
+ context "when Fixnum" do
6
+
7
+ it "should return true for valid cnpjs" do
8
+ VALID_CNPJS_INTEGER.each do |valid_cnpj|
9
+ BR::CNPJ.valid?(valid_cnpj).should be_true
10
+ end
11
+ end
12
+
13
+ it "should return false for invalid cnpjs" do
14
+ INVALID_CNPJS_INTEGER.each do |invalid_cnpj|
15
+ BR::CNPJ.valid?(invalid_cnpj).should be_false
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ context "when String" do
22
+
23
+ it "should return true for valid cnpjs" do
24
+ VALID_CNPJS_STRING.each do |valid_cnpj|
25
+ BR::CNPJ.valid?(valid_cnpj).should be_true
26
+ end
27
+ end
28
+
29
+ it "should return false for invalid cnpjs" do
30
+ INVALID_CNPJS_STRING.each do |invalid_cnpj|
31
+ BR::CNPJ.valid?(invalid_cnpj).should be_false
32
+ end
33
+ end
34
+
6
35
  end
36
+
7
37
  end
@@ -0,0 +1,39 @@
1
+ module Faker
2
+ module CNPJ
3
+
4
+ VALID_CNPJS_INTEGER = [
5
+ 398000328, 398000409, 398036780, 398042756, 398644721, 398751803,
6
+ 399000100, 397000464, 397040768, 398000166, 398000247, 397000111,
7
+ 417000316, 417000405, 417195656, 417705794, 418000107, 418000280,
8
+ 418000360, 418000441, 418011990, 418074720, 418278300, 418787794,
9
+ 419000143, 419000224, 419000305, 419000496, 419634827, 420000178,
10
+ 420000259, 420000330, 420000410, 687950767, 688000100, 688000290,
11
+ 688000371, 688000452, 688159729, 688170706, 688397824, 688728600,
12
+ 689000154, 689000235, 689000316, 689000405, 689104790, 689191316,
13
+ 689218109, 689907826, 690000189, 690000260, 690000340, 690000421,
14
+ 690540108, 690846100, 691000123, 691000204, 691000395, 691000476,
15
+ 691174970, 692000178, 99998213000111, 99998205000175, 99998197000167,
16
+ 99998189000110, 99998171000119, 99998163000172, 99998155000126,
17
+ 99998130000122, 99998122000186, 99998114000130, 99998106000193,
18
+ 99998098000185, 99998080000183, 99998072000137, 99998064000190,
19
+ 99998056000144, 99998049000142, 99998031000140, 99998023000102,
20
+ 99998015000158, 99998007000101, 99997991000196, 99997983000140,
21
+ 99997975000101, 99997967000157, 99997959000100, 99997942000153,
22
+ 99997934000107, 99997926000160, 99997918000114, 99997900000112,
23
+ 99997892000104, 99997884000168, 99997876000111, 99997868000175,
24
+ 99997850000173, 99997843000171, 99997835000125, 99997827000189,
25
+ 99997819000132, 99997801000130, 99997793000122, 99997785000186,
26
+ 99997777000130, 99997769000193, 99997751000191, 99997744000190,
27
+ 99997736000143, 99997728000105, 99997710000103, 99997702000159,
28
+ 99997694000140]
29
+
30
+ INVALID_CNPJS_INTEGER = VALID_CNPJS_INTEGER.collect { |cnpj| cnpj + 1}
31
+
32
+ VALID_CNPJS_STRING = VALID_CNPJS_INTEGER.collect { |cnpj| cnpj.to_s }
33
+
34
+ INVALID_CNPJS_STRING = INVALID_CNPJS_INTEGER.collect { |cnpj| cnpj.to_s}
35
+
36
+ end
37
+ end
38
+
39
+ include Faker::CNPJ
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,2 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'br-cnpj'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end
1
+ require File.join(File.dirname(__FILE__), '../lib/br/cnpj')
2
+ require File.join(File.dirname(__FILE__), 'faker_cnpj')
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bruno Coimbra
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-09 00:00:00 -03:00
17
+ date: 2010-04-10 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -41,7 +41,6 @@ extra_rdoc_files:
41
41
  - LICENSE
42
42
  - README.rdoc
43
43
  files:
44
- - ext/CNPJ/CNPJ.so
45
44
  - ext/CNPJ/cnpj.c
46
45
  - ext/CNPJ/cnpj.h
47
46
  - ext/CNPJ/extconf.rb
@@ -82,3 +81,4 @@ summary: Calcules and validates given CNPJ
82
81
  test_files:
83
82
  - spec/spec_helper.rb
84
83
  - spec/br-cnpj_spec.rb
84
+ - spec/faker_cnpj.rb
data/ext/CNPJ/CNPJ.so DELETED
Binary file