nis_faker 0.0.1
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 +7 -0
- data/.gitignore +5 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +22 -0
- data/README.md +27 -0
- data/Rakefile +1 -0
- data/lib/faker/nis.rb +64 -0
- data/lib/nis_faker.rb +1 -0
- data/nis_faker.gemspec +17 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1e8265a9bdaeb9cad1e2ddcba0782082b4140c43
|
4
|
+
data.tar.gz: 6b748ba162357ebce6651ad4cbfbed3c2b657558
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01b5f033e0528f01d0c3aa2bb11329e1b843ab18aaee0d185b3c022bb225aa01e14bae8585835a0561975d491626359c88716faea13391886d1922b84e82cb5e
|
7
|
+
data.tar.gz: d8a773fd513d231f37d8e7277d3dda5135aa8e3f066d1215f62d59e8f71180059ef58bdd865840af94bad32055578a3708a2c8f697e2576d2c04d37acb0f0b60
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 William Weckl
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# NIS Faker
|
2
|
+
|
3
|
+
Gerador de NIS (PIS / PASEP / NIT) para ruby.
|
4
|
+
|
5
|
+
Generates Brazilian NIS (PIS / PASEP / NIT) numbers for ruby.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
Use rubygems:
|
10
|
+
|
11
|
+
gem install nis_faker
|
12
|
+
|
13
|
+
Or add it to your Gemfile
|
14
|
+
|
15
|
+
group :development, :test do
|
16
|
+
# ...
|
17
|
+
gem 'nis_faker'
|
18
|
+
end
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Faker::Nis.number #=> "12073822829"
|
23
|
+
Faker::Nis.pretty #=> "120.7382.282-9"
|
24
|
+
|
25
|
+
## License
|
26
|
+
|
27
|
+
NIS Faker is released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/faker/nis.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
module Faker
|
2
|
+
class Nis
|
3
|
+
class << self
|
4
|
+
def number
|
5
|
+
generate_numbers
|
6
|
+
|
7
|
+
@numbers.join
|
8
|
+
end
|
9
|
+
|
10
|
+
def pretty
|
11
|
+
generate_numbers
|
12
|
+
|
13
|
+
new_numbers_array = []
|
14
|
+
@numbers.each_with_index do |number, index|
|
15
|
+
new_numbers_array << '.' if index == 3 || index == 8
|
16
|
+
new_numbers_array << '-' if index == 10
|
17
|
+
new_numbers_array << number
|
18
|
+
end
|
19
|
+
|
20
|
+
new_numbers_array.join
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def generate_numbers
|
26
|
+
@numbers = []
|
27
|
+
10.times do
|
28
|
+
@numbers << Random.new.rand(1..9)
|
29
|
+
end
|
30
|
+
|
31
|
+
last_digit = (11 - (sum_products % 11))
|
32
|
+
last_digit = 0 if last_digit > 9
|
33
|
+
@numbers << last_digit
|
34
|
+
|
35
|
+
generate_numbers if black_list.include?(@numbers.join)
|
36
|
+
|
37
|
+
@numbers
|
38
|
+
end
|
39
|
+
|
40
|
+
def multiply_weights
|
41
|
+
@x = []
|
42
|
+
i = 0
|
43
|
+
[3, 2, 9, 8, 7, 6, 5, 4, 3, 2].each do |weight|
|
44
|
+
@x << @numbers[i] * weight
|
45
|
+
i += 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def sum_products
|
50
|
+
multiply_weights
|
51
|
+
sum = 0
|
52
|
+
10.times do |n|
|
53
|
+
sum += @x[n]
|
54
|
+
end
|
55
|
+
sum
|
56
|
+
end
|
57
|
+
|
58
|
+
def black_list
|
59
|
+
%w(000.0000.000-0)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/nis_faker.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'faker/nis'
|
data/nis_faker.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = "nis_faker"
|
4
|
+
s.version = "0.0.1"
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
s.authors = ["William Weckl"]
|
7
|
+
s.email = ["william.weckl@gmail.com"]
|
8
|
+
s.homepage = "https://github.com/williamweckl/nis_faker"
|
9
|
+
s.summary = %q{Generate fake brazilian pis/pasep/nit numbers}
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
|
16
|
+
s.add_development_dependency 'rake', '>= 0.8.7'
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nis_faker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- William Weckl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.7
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.7
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- william.weckl@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- MIT-LICENSE
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/faker/nis.rb
|
40
|
+
- lib/nis_faker.rb
|
41
|
+
- nis_faker.gemspec
|
42
|
+
homepage: https://github.com/williamweckl/nis_faker
|
43
|
+
licenses: []
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.4.5
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: Generate fake brazilian pis/pasep/nit numbers
|
65
|
+
test_files: []
|