ffaker 2.20.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,8 +38,20 @@ module FFaker
38
38
  end
39
39
  end
40
40
 
41
- def full_address
42
- "#{street}, #{building_number}, #{city}, #{state}, Brazil"
41
+ def complement
42
+ FFaker.numerify(fetch_sample(COMPLEMENT))
43
+ end
44
+
45
+ def neighborhood
46
+ prefix = fetch_sample(NEIGHBORHOOD_PREFIXES)
47
+ "#{prefix} #{NameBR.first_name}"
48
+ end
49
+
50
+ def full_address(with_complement: false)
51
+ base_address_order = [street, building_number, neighborhood, city, state, 'Brazil']
52
+ return base_address_order.join(', ') unless with_complement
53
+
54
+ base_address_order.insert(2, complement).join(', ')
43
55
  end
44
56
  end
45
57
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  module FFaker
4
4
  module AddressIT
5
-
6
5
  extend ModuleUtils
7
6
  extend self
8
7
 
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FFaker
4
+ module AnimalBR
5
+ extend ModuleUtils
6
+ extend self
7
+
8
+ def common_name
9
+ fetch_sample(COMMON_NAMES)
10
+ end
11
+ end
12
+ end
@@ -35,12 +35,9 @@ module FFaker
35
35
 
36
36
  def position
37
37
  case rand(0..2)
38
- when 0 then
39
- [fetch_sample(POSITION_PREFIXES), fetch_sample(POSITIONS)]
40
- when 1 then
41
- [fetch_sample(POSITION_AREAS), fetch_sample(POSITIONS)]
42
- when 2 then
43
- [fetch_sample(POSITION_PREFIXES), fetch_sample(POSITION_AREAS), fetch_sample(POSITIONS)]
38
+ when 0 then [fetch_sample(POSITION_PREFIXES), fetch_sample(POSITIONS)]
39
+ when 1 then [fetch_sample(POSITION_AREAS), fetch_sample(POSITIONS)]
40
+ when 2 then [fetch_sample(POSITION_PREFIXES), fetch_sample(POSITION_AREAS), fetch_sample(POSITIONS)]
44
41
  end.join(' ')
45
42
  end
46
43
  end
@@ -0,0 +1,3 @@
1
+ Apartamento ###
2
+ Casa Térrea
3
+ Fundos
@@ -0,0 +1,3 @@
1
+ Vila
2
+ Parque
3
+ Jardim
@@ -0,0 +1,423 @@
1
+ Abelha
2
+ Abutre
3
+ Ácaro
4
+ Águia
5
+ Albatroz
6
+ Alce
7
+ Alpaca
8
+ Anaconda
9
+ Anchova
10
+ Andorinha
11
+ Anta
12
+ Antílope
13
+ Aranha
14
+ Arara
15
+ Asno
16
+ Atum
17
+ Avestruz
18
+ Babuíno
19
+ Bacalhau
20
+ Bacuri
21
+ Badejo
22
+ Bagre
23
+ Baiacu
24
+ Baleia
25
+ Barata
26
+ Barbo
27
+ Barracuda
28
+ Beija Flor
29
+ Besouro
30
+ Bem Te Vi
31
+ Bezerro
32
+ Bicho da Seda
33
+ Bisonte
34
+ Boa
35
+ Bode
36
+ Boi
37
+ Borboleta
38
+ Boto
39
+ Búfalo
40
+ Burro
41
+ Cabra
42
+ Cachalote
43
+ Cachorro
44
+ Cágado
45
+ Camaleão
46
+ Camarão
47
+ Camelo
48
+ Camundongo
49
+ Canário
50
+ Canguru
51
+ Capivara
52
+ Caracol
53
+ Caranguejo
54
+ Carneiro
55
+ Carrapato
56
+ Cascavel
57
+ Castor
58
+ Cavalo
59
+ Cavalo Marinho
60
+ Cegonha
61
+ Centopeia
62
+ Chimpanzé
63
+ Chinchila
64
+ Chita
65
+ Cigarra
66
+ Cisne
67
+ Coala
68
+ Cobra
69
+ Codorna
70
+ Coelho
71
+ Coiote
72
+ Coruja
73
+ Corvo
74
+ Crocodilo
75
+ Cupim
76
+ Cutia
77
+ Damão
78
+ Dançador
79
+ Degolado
80
+ Degu
81
+ Diablotim
82
+ Diabo da Tasmânia
83
+ Diamante de Gould
84
+ Dingo
85
+ Dinossauro
86
+ Dodô
87
+ Doninha
88
+ Dourado
89
+ Dragão de Komodo
90
+ Dragão do Banhado
91
+ Dragão Voador
92
+ Dromedário
93
+ Dugongo
94
+ Égua
95
+ Elefante
96
+ Elefante Marinho
97
+ Ema
98
+ Enchova
99
+ Enferrujado
100
+ Enguia
101
+ Enho
102
+ Escaravelho
103
+ Escorpião
104
+ Escrevedeira
105
+ Esmerilhão
106
+ Espadarte
107
+ Esponja
108
+ Esquilo
109
+ Estorninho
110
+ Estrela do Mar
111
+ Esturjão
112
+ Faisão
113
+ Falcão
114
+ Ferreirinho
115
+ Flamingo
116
+ Flautim
117
+ Foca
118
+ Formiga
119
+ Fossa
120
+ Fraca da Guiné
121
+ Freirinha
122
+ Fuinha
123
+ Furão
124
+ Gafanhoto
125
+ Gaivota
126
+ Galinha
127
+ Galo
128
+ Gambá
129
+ Gamo
130
+ Ganso
131
+ Garça
132
+ Garoupa
133
+ Gato
134
+ Gavião
135
+ Gazela
136
+ Geco
137
+ Gerbo
138
+ Gibão
139
+ Girafa
140
+ Girino
141
+ Gnu
142
+ Golfinho
143
+ Gorila
144
+ Gralha
145
+ Grifo
146
+ Grilo
147
+ Grou
148
+ Guará:
149
+ Guaxinim
150
+ Hadoque
151
+ Hamster
152
+ Harpia
153
+ Hiena
154
+ Hipopótamo
155
+ Hírax
156
+ Iaque
157
+ Íbex
158
+ Íbis
159
+ Iguana
160
+ Iguanara
161
+ Impala
162
+ Indicador
163
+ Indri
164
+ Inhacoso
165
+ Inhala
166
+ Inhambu
167
+ Irapuã
168
+ Irara
169
+ Iratim
170
+ Itapema
171
+ Jabiru
172
+ Jabuti
173
+ Jaçanã
174
+ Jacaré
175
+ Jacu
176
+ Jacupará
177
+ Jaguar
178
+ Jamanta
179
+ Jararaca
180
+ Javali
181
+ Jegue
182
+ Jiboia
183
+ Joaninha
184
+ João de Barro
185
+ Jumento
186
+ Kakapo
187
+ Kea
188
+ Kinguio
189
+ Kiwi
190
+ Koala
191
+ Kookaburra
192
+ Kowari
193
+ Krill
194
+ Kudu
195
+ Lacraia
196
+ Lagarta
197
+ Lagartixa
198
+ Lagarto
199
+ Lagosta
200
+ Lampreia
201
+ Lavadeira
202
+ Lavagante
203
+ Leão
204
+ Leão Marinho
205
+ Lebre
206
+ Lêmure
207
+ Leopardo
208
+ Lesma
209
+ Lhama
210
+ Libélula
211
+ Lince
212
+ Linguado
213
+ Lobo
214
+ Lombriga
215
+ Lontra
216
+ Lula
217
+ Macaco
218
+ Mamute
219
+ Manatim
220
+ Mandril
221
+ Mangangá
222
+ Maracanã
223
+ Marimbondo
224
+ Mariposa
225
+ Marisco
226
+ Marmota
227
+ Marreco
228
+ Marta
229
+ Massarongo
230
+ Medusa
231
+ Melro
232
+ Mergulhão
233
+ Merluza
234
+ Mexilhão
235
+ Mico
236
+ Milhafre
237
+ Mineirinho
238
+ Minhoca
239
+ Mocho
240
+ Mono
241
+ Morcego
242
+ Moreia
243
+ Morsa
244
+ Mosca
245
+ Mosquito
246
+ Muçurana
247
+ Mula
248
+ Musaranho
249
+ Naja
250
+ Nambu
251
+ Nandaia
252
+ Narceja
253
+ Narval
254
+ Náutilo
255
+ Negrinho
256
+ Neon
257
+ Nhacundá
258
+ Nhandiá
259
+ Niala
260
+ Niquim
261
+ Noitibó
262
+ Numbat
263
+ Nútria
264
+ Ocapi
265
+ Olho de Boi
266
+ Onça
267
+ Orangotango
268
+ Orca
269
+ Órix
270
+ Ornitorrinco
271
+ Osga
272
+ Ostra
273
+ Otária
274
+ Ouriço
275
+ Ouriço do Mar
276
+ Ovelha
277
+ Panda
278
+ Pantera
279
+ Papagaio
280
+ Pardal
281
+ Pássaro
282
+ Pato
283
+ Pavão
284
+ Peixe
285
+ Peixe Boi
286
+ Pelicano
287
+ Percevejo
288
+ Perereca
289
+ Periquito
290
+ Pernilongo
291
+ Peru
292
+ Pescada
293
+ Pica Pau
294
+ Pinguim
295
+ Piolho
296
+ Piranha
297
+ Pirarucu
298
+ Polvo
299
+ Pombo
300
+ Pônei
301
+ Porco
302
+ Porco Espinho
303
+ Porquinho da índia
304
+ Preá
305
+ Preguiça
306
+ Pulga
307
+ Quati
308
+ Quatimirim
309
+ Quatipuru
310
+ Quebra Nozes
311
+ Quebra Ossos
312
+ Queixada
313
+ Quem Te Vestiu
314
+ Quero Quero
315
+ Quetzal
316
+ Quiriquiri
317
+
318
+ Rabudinho
319
+ Raia
320
+ Raposa
321
+ Ratazana
322
+ Rato
323
+ Rêmora
324
+ Rena
325
+ Rendeira
326
+ Rinoceronte
327
+ Robalo
328
+ Rouxinol
329
+ Sabiá
330
+ Sagui
331
+ Salamandra
332
+ Salmão
333
+ Sanguessuga
334
+ Sapo
335
+ Sardão
336
+ Sardinha
337
+ Saúva
338
+ Seriema
339
+ Serpente
340
+ Siri
341
+ Suçuarana
342
+ Sucuri
343
+ Suiriri
344
+ Suricate
345
+ Surubi
346
+ Surucucu
347
+ Tainha
348
+ Tamanduá
349
+ Tamboril
350
+ Tapir
351
+ Tarântula
352
+ Tartaruga
353
+ Tatu
354
+ Tatuí
355
+ Tentilhão
356
+ Tetra
357
+ Texugo
358
+ Tico Tico
359
+ Tigre
360
+ Tilápia
361
+ Tordo
362
+ Tororó
363
+ Toupeira
364
+ Touro
365
+ Tritão
366
+ Truta
367
+ Tubarão
368
+ Tucano
369
+ Tucuxi
370
+ Uacari
371
+ Unau
372
+ Unha Longa
373
+ Unicórnio
374
+ Urso
375
+ Panda
376
+ Urso
377
+ Uru
378
+ Urubu
379
+ Urutaurana
380
+ Urutu
381
+ Vaca
382
+ Vaca Marinha
383
+ Vaga Lume
384
+ Veado
385
+ Verdilhão
386
+ Verdinho
387
+ Vespa
388
+ Víbora
389
+ Vieira
390
+ Vira Bosta
391
+ Vison
392
+ Vitela
393
+ Viúva
394
+ Viúva Negra
395
+ Wallaby
396
+ Weimaraner
397
+ Wombat
398
+ Xajá
399
+ Xangó
400
+ Xará
401
+ Xarelete
402
+ Xaréu
403
+ Xaru
404
+ Xauim
405
+ Xero
406
+ Xexéu
407
+ Ximango
408
+ Ximburé
409
+ Xixarro
410
+ Xofrango
411
+ Xuri
412
+ Yak
413
+ Ynambu
414
+ Yorkshire
415
+ Zabelê
416
+ Zangão
417
+ Zaragateiro
418
+ Zarro
419
+ Zebra
420
+ Zebu
421
+ Zidedê
422
+ Zombeteiro
423
+ Zorrilho
@@ -134,9 +134,15 @@ module FFaker
134
134
  a = k([
135
135
  content_tag_for(:strong, words(2).capitalize!),
136
136
  content_tag_for(:em, paragraph),
137
+ content_tag_for(:mark, paragraph),
138
+ content_tag_for(:del, words(2)),
139
+ content_tag_for(:ins, words(2)),
140
+ content_tag_for(:sub, words(2)),
141
+ content_tag_for(:sup, words(2)),
137
142
  content_tag_for(:code, words(2)),
143
+ content_tag_for(:small, words(2)),
138
144
  (a 2).to_s
139
- ] + FFaker::Lorem.paragraphs(count))
145
+ ] + FFaker::Lorem.paragraphs(count - 1))
140
146
  fetch_sample(a, count: count).join(sep)
141
147
  end
142
148
 
@@ -5,7 +5,8 @@ module FFaker
5
5
  extend ModuleUtils
6
6
  extend self
7
7
 
8
- AREA_CODE = { a: 10, b: 11, c: 12, d: 13, e: 14, f: 15, g: 16, h: 17, i: 34, j: 18, k: 19, l: 20, m: 21, n: 22, o: 35, p: 23, q: 24, r: 25, s: 26, t: 27, u: 28, v: 29, w: 30, x: 31, y: 32, z: 33 }.freeze
8
+ AREA_CODE = { a: 10, b: 11, c: 12, d: 13, e: 14, f: 15, g: 16, h: 17, i: 34, j: 18, k: 19, l: 20, m: 21, n: 22,
9
+ o: 35, p: 23, q: 24, r: 25, s: 26, t: 27, u: 28, v: 29, w: 32, x: 30, y: 31, z: 33 }.freeze
9
10
 
10
11
  # Identity Card Number
11
12
  # https://en.wikipedia.org/wiki/National_identification_card_(Taiwan)#Identity_card_number
@@ -14,7 +15,7 @@ module FFaker
14
15
  code = AREA_CODE[letter.to_sym]
15
16
  gender = fetch_sample([1, 2])
16
17
  serial = FFaker.numerify('#######')
17
- a, b, c, d, e, f, g, h, i, j = "#{code}#{gender}#{serial}".split(//).map(&:to_i)
18
+ a, b, c, d, e, f, g, h, i, j = "#{code}#{gender}#{serial}".chars.map(&:to_i)
18
19
 
19
20
  checksum = (9 * a + b + 2 * c + 3 * d + 4 * e + 5 * f + 6 * g + 7 * h + 8 * i + 9 * j) % 10
20
21
  "#{letter.upcase}#{gender}#{serial}#{checksum}"
data/lib/ffaker/string.rb CHANGED
@@ -53,15 +53,15 @@ module FFaker
53
53
  when '?'
54
54
  # TODO: Let ? generate nothing
55
55
  '' # We already printed its target
56
- when '+' then
56
+ when '+'
57
57
  tokens.unshift(token) if rand(0..1) == 1 # Leave the `+` on to run again
58
58
  process_token(@last_token) # Run the last one at least once
59
- when '*' then
59
+ when '*'
60
60
  tokens.unshift(token) if rand(0..1) == 1 # Leave the `*` on to run again
61
61
  return '' if rand(0..1) == 1 # Or maybe do nothing
62
62
 
63
63
  process_token(@last_token) # Else run the last one again
64
- when '{' then
64
+ when '{'
65
65
  number = +''
66
66
  while (ch = tokens.shift) != '}'
67
67
  number << ch
@@ -76,14 +76,14 @@ module FFaker
76
76
 
77
77
  def generate_token(token, tokens)
78
78
  case token
79
- when /\w/ then
79
+ when /\w/
80
80
  @last_token = [token]
81
81
  token
82
- when BACKSLASH then
82
+ when BACKSLASH
83
83
  token = tokens.shift
84
84
  @last_token = ['\\', token]
85
85
  special(token)
86
- when '[' then
86
+ when '['
87
87
  set = []
88
88
  while (ch = tokens.shift) != ']'
89
89
  set << ch
data/lib/ffaker/time.rb CHANGED
@@ -22,7 +22,7 @@ module FFaker
22
22
 
23
23
  def datetime(params = {})
24
24
  years_back = params[:year_range] || 5
25
- latest_year = params [:year_latest] || 0
25
+ latest_year = params[:year_latest] || 0
26
26
  year = (rand * years_back).ceil + (::DateTime.now.year - latest_year - years_back)
27
27
  month = rand(1..12)
28
28
  day = rand(1..Date.new(year, month, -1).day)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'set'
2
3
 
3
4
  module FFaker
4
5
  class UniqueUtils
@@ -2,6 +2,68 @@
2
2
 
3
3
  module FFaker
4
4
  module Vehicle
5
+ module VIN
6
+ extend ModuleUtils
7
+ extend self
8
+
9
+ # https://en.wikibooks.org/wiki/Vehicle_Identification_Numbers_(VIN_codes)/World_Manufacturer_Identifier_(WMI)
10
+ VALID_WMI_REGIONS = [*'A'..'C', *'J'..'Z', *'1'..'9'].freeze
11
+
12
+ VALID_YEAR_CHARS = %w[
13
+ 5 6 7 8 9 A B C D E F G H J K L M N P R S T V W X Y 1 2 3 4 5 6 7 8 9
14
+ ].freeze # 2005-2039
15
+
16
+ # https://en.wikibooks.org/wiki/Vehicle_Identification_Numbers_(VIN_codes)/Check_digit
17
+ TRANSLITERATION_VALUES = {
18
+ 'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8,
19
+ 'J' => 1, 'K' => 2, 'L' => 3, 'M' => 4, 'N' => 5, 'P' => 7, 'R' => 9,
20
+ 'S' => 2, 'T' => 3, 'U' => 4, 'V' => 5, 'W' => 6, 'X' => 7, 'Y' => 8, 'Z' => 9
21
+ }.freeze
22
+ POSITION_WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2].freeze
23
+
24
+ VALID_ALPHA = TRANSLITERATION_VALUES.keys
25
+ VALID_ALPHANUMERIC = [*VALID_ALPHA, *'1'..'9'].freeze
26
+
27
+ # Generate a VIN that is compliant with specifications of US Title 49 Section 565.15
28
+ # https://www.govinfo.gov/content/pkg/CFR-2019-title49-vol6/xml/CFR-2019-title49-vol6-part565.xml#seqnum565.15
29
+ #
30
+ # Position Meaning
31
+ # 1-3 Manufacturer ID aka WMI (alpha and digits)
32
+ # 4-8 Vehicle Description ("For passenger cars ..[position 7].. shall be alphabetic")
33
+ # 9 Check Digit (0-9 or "X")
34
+ # 10 Year (see VIN_VALID_YEARS)
35
+ # 11 Plant of manufacture (alpha and digits)
36
+ # 12-17 Serial number (digits only)
37
+ #
38
+ # I, O and Q are NOT allowed. VIN_VALID_ALPHA has valid alpha characters.
39
+ def vin
40
+ generated_vin = [
41
+ # Manufacturer ID / WMI
42
+ fetch_sample(VALID_WMI_REGIONS),
43
+ fetch_sample(VALID_ALPHANUMERIC, count: 2),
44
+ # Vehicle Description
45
+ fetch_sample(VALID_ALPHANUMERIC, count: 3),
46
+ fetch_sample(VALID_ALPHA),
47
+ fetch_sample(VALID_ALPHANUMERIC),
48
+ '0', # check digit placeholder
49
+ fetch_sample(VALID_YEAR_CHARS), # Year of Manufacture
50
+ fetch_sample(VALID_ALPHANUMERIC), # Plant ID
51
+ FFaker.numerify('######') # Serial Number
52
+ ].join
53
+
54
+ # Calculate the Check Digit
55
+ weighted_sum = generated_vin.chars.each_with_index.sum do |char, idx|
56
+ (TRANSLITERATION_VALUES[char.to_sym] || char).to_i * POSITION_WEIGHTS[idx]
57
+ end
58
+
59
+ check_digit = weighted_sum % 11
60
+ check_digit = 'X' if check_digit == 10
61
+ generated_vin[8] = check_digit.to_s
62
+
63
+ generated_vin
64
+ end
65
+ end
66
+
5
67
  extend ModuleUtils
6
68
  extend self
7
69
 
@@ -37,7 +99,7 @@ module FFaker
37
99
  end
38
100
 
39
101
  def vin
40
- FFaker.bothify('1#???#####?######').upcase
102
+ VIN.vin
41
103
  end
42
104
 
43
105
  def year
data/lib/ffaker.rb CHANGED
@@ -57,6 +57,7 @@ module FFaker
57
57
  autoload :AddressUS, 'ffaker/address_us'
58
58
  autoload :Airline, 'ffaker/airline'
59
59
  autoload :Animal, 'ffaker/animal'
60
+ autoload :AnimalBR, 'ffaker/animal_br'
60
61
  autoload :AnimalCN, 'ffaker/animal_cn'
61
62
  autoload :AnimalES, 'ffaker/animal_es'
62
63
  autoload :AnimalPL, 'ffaker/animal_pl'
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FFaker
4
- VERSION = '2.20.0'
4
+ VERSION = '2.21.0'
5
5
  end