faker-spanish_document 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2c2ffecbdffe8007b911f5dc2bdd5f28d12199c2
4
+ data.tar.gz: a580f77ca998c5aca9e48417247c1a840990d2d5
5
+ SHA512:
6
+ metadata.gz: d4ff123ddda4e4636a4c31283e2cf91cf409ff99beb0ed782310992d339755311b80746a2eee582fd20f97ef45b8d5224e7ea2d395f66a59652321961b841a4c
7
+ data.tar.gz: 4359ebef559125cd226058c446f0d837cb5cb3c3c4ec626e24f685b37e9df5c88a35485f35585f1b699654d47abf7ddee0220411d6ae1091f633cc04796f2fd1
@@ -0,0 +1,50 @@
1
+ # Faker::SpanishDocument
2
+
3
+ Generates random spanish DNI and NIE numbers. Also generates generic random passport numbers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'faker-spanish_document'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install faker-spanish_document
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ 2.4.1 :001 > Faker::SpanishDocument.dni
25
+ => "49020608H"
26
+ 2.4.1 :002 > Faker::SpanishDocument.nie
27
+ => "Z8579791Z"
28
+ 2.4.1 :003 > Faker::SpanishDocument.passport
29
+ => "PIX823050"
30
+ 2.4.1 :004 > Faker::SpanishDocument.generate(:dni)
31
+ => "80866720P"
32
+ ```
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/podemos-info/faker-spanish_document. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ ## Code of Conduct
49
+
50
+ Everyone interacting in the Faker::SpanishDocument project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/faker-spanish_document/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faker'
4
+ require 'faker/spanish_document/version'
5
+
6
+ module Faker
7
+ module SpanishDocument
8
+ LETTERS = 'TRWAGMYFPDXBNJZSQVHLCKE'.freeze
9
+
10
+ def self.dni
11
+ n = ::Faker::Number.number(8)
12
+ "#{n}#{LETTERS[n.to_i % 23].chr}"
13
+ end
14
+
15
+ def self.nie
16
+ pre = [0, 1, 2].sample
17
+ n = ::Faker::Number.number(7)
18
+ "#{%w[X Y Z][pre]}#{n}#{LETTERS[(pre * 10_000_000 + n.to_i) % 23].chr}"
19
+ end
20
+
21
+ def self.passport
22
+ l, n = [[1, 10], [2, 6], [3, 6]].sample
23
+ [*'A'..'Z'].sample(l).join + ::Faker::Number.number(n)
24
+ end
25
+
26
+ def self.generate(type)
27
+ send type
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ module SpanishDocument
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: faker-spanish_document
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Leonardo Diez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ description: Generates random spanish DNI and NIE numbers. Also generates generic
42
+ random passport numbers.
43
+ email:
44
+ - leiodd@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - README.md
50
+ - Rakefile
51
+ - lib/faker/spanish_document.rb
52
+ - lib/faker/spanish_document/version.rb
53
+ homepage: http://github.com/podemos-info/faker-spanish_document
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.6.13
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Fake document numbers from Spain
77
+ test_files: []