faker 2.1.0 → 2.1.2

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
  SHA256:
3
- metadata.gz: c8ec0243e0079d2e81fdf6bfa46e9619a97ce96eb9a0521be7699c36a8408e5a
4
- data.tar.gz: 7e5a20f1d6595b3fcda89a802dbaaa3e97b2027bcd21f1fad6bb164e433b12ea
3
+ metadata.gz: 7462443ac85163e4a2bfaaa60b52b0153d209004c68f498be7796bafdca56bb8
4
+ data.tar.gz: 83792726058a2a4bcae5a9e65faebd7b89271323b04c509c5e85a3ed3dcf87d7
5
5
  SHA512:
6
- metadata.gz: 6de044051ced1eea9bbc6b3a1693e3d9f809195289c0ceb68238459ec9420eccb7cb6eb7761f23f88a3c94e68292cdd42785cc97da9d4e5680e7240afd0dd3a4
7
- data.tar.gz: 0c9e6ad646d0772e3e116b7534940270c1be804c3e231b0aba974cc0f9478750125ac591b18ee4d2f5b851e9df29898c42b69067ec0e9c411b5c96de350d21c2
6
+ metadata.gz: 13e01c3cf5c0f2f4813b4ebd5f47da32f5445234cb0bbc217e7b1b4836c8578b9e32bdafbafe68c9d9c8f85e2a14ec84a9fa13c3b611c3fa7f566b6bdf1176eb
7
+ data.tar.gz: d4ff9c657474b461ed8b4f54ec16e982ba805d3bc5fd815757bcfbb67b3823fba776ba004af140a1afb6d5424990f6819eda943a7b4bdfe24841713b9eb29f4c
@@ -1,5 +1,33 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.1.2](https://github.com/stympy/faker-ruby/faker/tree/2.1.2) (2019-10-08)
4
+
5
+ ## Enhancements
6
+
7
+ - [PR #1495](https://github.com/stympy/faker/pull/1495) Add Brazilian documents generation and documentation [@lucasqueiroz](https://github.com/lucasqueiroz)
8
+
9
+ ## Issues
10
+
11
+ We had to use `bundled with 1.7.3` to avoid some issues.
12
+
13
+ ## [v2.1.1](https://github.com/stympy/faker/tree/2.1.1) (2019-10-08)
14
+
15
+ ## Bug/Fixes
16
+
17
+ - [PR #1685](https://github.com/stympy/faker/pull/1685) Upgrade i18n [@EduardoGHdez](https://github.com/EduardoGHdez)
18
+
19
+ `bundler-audit` has identified that i18 has fix a security vulnerability, that has been fixed in the 0.8 version.
20
+
21
+ - [PR #1683](https://github.com/stympy/faker/pull/1683) Rollback Faker::Time changes [@vbrazo](https://github.com/vbrazo)
22
+
23
+ Rollback Faker::Time changes because we should expect the date format from activesupport's en.yml.
24
+
25
+ ## Documentation
26
+
27
+ - [PR #1677](https://github.com/stympy/faker/pull/1677) Fix docs for Internet#password generator [@ur5us](https://github.com/ur5us)
28
+
29
+ ------------------------------------------------------------------------------
30
+
3
31
  ## [v2.1.0](https://github.com/stympy/faker/tree/2.1.0) (2019-31-07)
4
32
 
5
33
  ## Bug/Fixes
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  ![logotype a happy-07](https://user-images.githubusercontent.com/36028424/40263395-4318481e-5b44-11e8-92e5-3dcc1ce169b3.png)
3
3
 
4
4
  # Faker
5
- [![Build Status](https://travis-ci.org/stympy/faker.svg?branch=master)](https://travis-ci.org/stympy/faker)
5
+ [![Build Status](https://travis-ci.org/faker-ruby/faker.svg?branch=master)](https://travis-ci.org/faker-ruby/faker)
6
6
  [![Gem Version](https://badge.fury.io/rb/faker.svg)](https://badge.fury.io/rb/faker)
7
7
  [![Inline docs](http://inch-ci.org/github/stympy/faker.svg?branch=master)](http://inch-ci.org/github/stympy/faker)
8
8
  [![Test Coverage](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/test_coverage)](https://codeclimate.com/github/stympy/faker/test_coverage)
@@ -12,6 +12,9 @@ module Faker
12
12
  ].freeze
13
13
  ZA_RACE_DIGIT = '8'
14
14
  ZA_CITIZENSHIP_DIGITS = %w[0 1].freeze
15
+ BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])/
16
+ BRAZILIAN_ID_FROM = 10_000_000
17
+ BRAZILIAN_ID_TO = 99_999_999
15
18
 
16
19
  class << self
17
20
  def valid
@@ -83,6 +86,17 @@ module Faker
83
86
  formatted ? format('%s.%s.%s-%s', *number.scan(/\d{2,3}/).flatten) : number
84
87
  end
85
88
 
89
+ alias brazilian_cpf brazilian_citizen_number
90
+
91
+ def brazilian_id(formatted: false)
92
+ digits = Faker::Number.between(to: BRAZILIAN_ID_FROM, from: BRAZILIAN_ID_TO).to_s
93
+ check_digit = brazilian_id_checksum_digit(digits)
94
+ number = [digits, check_digit].join
95
+ formatted ? format('%s.%s.%s-%s', *number.scan(BRAZILIAN_ID_FORMAT).flatten) : number
96
+ end
97
+
98
+ alias brazilian_rg brazilian_id
99
+
86
100
  private
87
101
 
88
102
  def south_african_id_checksum_digit(id_number)
@@ -104,13 +118,36 @@ module Faker
104
118
  end
105
119
 
106
120
  def brazilian_citizen_number_checksum_digit(digits)
107
- digit_sum = digits.chars.each_with_index.inject(0) do |acc, (digit, i)|
121
+ checksum = brazilian_document_checksum(digits)
122
+ brazilian_document_digit(checksum)
123
+ end
124
+
125
+ def brazilian_id_checksum_digit(digits)
126
+ checksum = brazilian_document_checksum(digits)
127
+ brazilian_document_digit(checksum, id: true)
128
+ end
129
+
130
+ def brazilian_document_checksum(digits)
131
+ digits.chars.each_with_index.inject(0) do |acc, (digit, i)|
108
132
  acc + digit.to_i * (digits.size + 1 - i)
109
133
  end * 10
110
- remainder = digit_sum % 11
134
+ end
135
+
136
+ def brazilian_document_digit(checksum, id = false)
137
+ remainder = checksum % 11
138
+ id ? brazilian_id_digit(remainder) : brazilian_citizen_number_digit(remainder)
139
+ end
140
+
141
+ def brazilian_citizen_number_digit(remainder)
111
142
  remainder == 10 ? '0' : remainder.to_s
112
143
  end
113
144
 
145
+ def brazilian_id_digit(remainder)
146
+ subtraction = 11 - remainder.to_i
147
+ digits = { 10 => 'X', 11 => '0' }
148
+ digits.include?(subtraction) ? digits[subtraction] : subtraction.to_s
149
+ end
150
+
114
151
  def _translate(key)
115
152
  parse("id_number.#{key}")
116
153
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faker #:nodoc:
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.2'
5
5
  end
@@ -9,52 +9,3 @@ en:
9
9
  pm: "PM"
10
10
  faker:
11
11
  separator: ' & '
12
- date:
13
- abbr_day_names:
14
- - Sun
15
- - Mon
16
- - Tue
17
- - Wed
18
- - Thu
19
- - Fri
20
- - Sat
21
- abbr_month_names:
22
- -
23
- - Jan
24
- - Feb
25
- - Mar
26
- - Apr
27
- - May
28
- - Jun
29
- - Jul
30
- - Aug
31
- - Sep
32
- - Oct
33
- - Nov
34
- - Dec
35
- day_names:
36
- - Sunday
37
- - Monday
38
- - Tuesday
39
- - Wednesday
40
- - Thursday
41
- - Friday
42
- - Saturday
43
- formats:
44
- default: "%m-%d-%Y"
45
- long: "%B %d, %Y"
46
- short: "%b %d"
47
- month_names:
48
- -
49
- - January
50
- - February
51
- - March
52
- - April
53
- - May
54
- - June
55
- - July
56
- - August
57
- - September
58
- - October
59
- - November
60
- - December
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Curtis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-31 00:00:00.000000000 Z
12
+ date: 2019-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '0.7'
20
+ version: '0.8'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '0.7'
27
+ version: '0.8'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: minitest
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -514,13 +514,13 @@ files:
514
514
  - lib/locales/vi.yml
515
515
  - lib/locales/zh-CN.yml
516
516
  - lib/locales/zh-TW.yml
517
- homepage: https://github.com/stympy/faker
517
+ homepage: https://github.com/faker-ruby/faker
518
518
  licenses:
519
519
  - MIT
520
520
  metadata:
521
- changelog_uri: https://github.com/stympy/faker/blob/master/CHANGELOG.md
522
- source_code_uri: https://github.com/stympy/faker
523
- bug_tracker_uri: https://github.com/stympy/faker/issues
521
+ changelog_uri: https://github.com/faker-ruby/faker/blob/master/CHANGELOG.md
522
+ source_code_uri: https://github.com/faker-ruby/faker
523
+ bug_tracker_uri: https://github.com/faker-ruby/faker/issues
524
524
  post_install_message:
525
525
  rdoc_options: []
526
526
  require_paths: