bbcoimbra / br-cnpj Goto Github PK
View Code? Open in Web Editor NEWcalcules and validates Brazilian CNPJ
License: MIT License
calcules and validates Brazilian CNPJ
License: MIT License
irb(main):002:0> BR::CNPJ.valid?(100000000000000000191)
RangeError: bignum too big to convert into `long long'
from /usr/local/lib/ruby/gems/2.0.0/gems/br-cnpj-1.0.1/lib/br/cnpj.rb:44:in `valid?'
from /usr/local/lib/ruby/gems/2.0.0/gems/br-cnpj-1.0.1/lib/br/cnpj.rb:44:in `valid?'
from (irb):2
from /usr/local/bin/irb:12:in `<main>'
irb(main):003:0> BR::CNPJ.new(1000000000000000000,1)
RangeError: integer 1000000000000000000 too big to convert to `int'
from (irb):3:in `initialize'
from (irb):3:in `new'
from (irb):3
from /usr/local/bin/irb:12:in `<main>'
The same happens with br-cpf gem.
Somente nos Rubies 1.9 ao chamar BR::CNPJ.new('1',1).to_s ele retorna um número CNPJ aleatório. Aparentemente ligado ao endereço de memória do objeto string passado como radix.
Diferente do Ruby 1.8 no qual ao passar o objeto reclama:
radix should be greater than -1 or lesser than 10_000_000 (ArgumentError)
Tentei instalar em um server aqui e aconteceu o seguinte erro:
Building native extensions. This could take a while...
ERROR: Error installing br-cnpj:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for stdlib.h... yes
creating Makefile
make
cc -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -DHAVE_STDLIB_H -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -c ruby_cnpj.c
ruby_cnpj.c: In function ‘t_init_cnpj’:
ruby_cnpj.c:22: error: ‘lldiv_t’ undeclared (first use in this function)
ruby_cnpj.c:22: error: (Each undeclared identifier is reported only once
ruby_cnpj.c:22: error: for each function it appears in.)
ruby_cnpj.c:22: error: expected ‘;’ before ‘v’
ruby_cnpj.c:32: error: ‘v’ undeclared (first use in this function)
make: *** [ruby_cnpj.o] Error 1
Segundo as informações do sistema: Linux version 2.6.26-2-686 (Debian 2.6.26-19) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.