faker 2.11.0 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -0
  3. data/README.md +8 -2
  4. data/lib/faker.rb +14 -9
  5. data/lib/faker/default/address.rb +1 -1
  6. data/lib/faker/default/bank.rb +79 -0
  7. data/lib/faker/default/blood.rb +48 -0
  8. data/lib/faker/default/business.rb +1 -1
  9. data/lib/faker/default/commerce.rb +73 -10
  10. data/lib/faker/default/company.rb +39 -0
  11. data/lib/faker/default/compass.rb +135 -0
  12. data/lib/faker/default/computer.rb +63 -0
  13. data/lib/faker/default/construction.rb +54 -0
  14. data/lib/faker/default/cosmere.rb +90 -0
  15. data/lib/faker/default/crypto_coin.rb +45 -0
  16. data/lib/faker/default/driving_licence.rb +42 -0
  17. data/lib/faker/default/file.rb +49 -0
  18. data/lib/faker/default/finance.rb +24 -0
  19. data/lib/faker/default/hipster.rb +94 -0
  20. data/lib/faker/default/invoice.rb +32 -5
  21. data/lib/faker/default/json.rb +55 -0
  22. data/lib/faker/default/measurement.rb +90 -0
  23. data/lib/faker/default/name.rb +83 -0
  24. data/lib/faker/default/phone_number.rb +88 -5
  25. data/lib/faker/default/placeholdit.rb +21 -0
  26. data/lib/faker/default/slack_emoji.rb +81 -0
  27. data/lib/faker/default/south_africa.rb +90 -0
  28. data/lib/faker/default/string.rb +19 -3
  29. data/lib/faker/default/stripe.rb +61 -0
  30. data/lib/faker/default/twitter.rb +35 -0
  31. data/lib/faker/default/types.rb +80 -0
  32. data/lib/faker/default/university.rb +45 -0
  33. data/lib/faker/default/vehicle.rb +184 -4
  34. data/lib/faker/default/verb.rb +45 -0
  35. data/lib/faker/games/control.rb +113 -0
  36. data/lib/faker/games/dnd.rb +61 -0
  37. data/lib/faker/games/warhammer_fantasy.rb +74 -0
  38. data/lib/faker/movies/departed.rb +49 -0
  39. data/lib/faker/music/pearl_jam.rb +50 -0
  40. data/lib/faker/music/phish.rb +27 -1
  41. data/lib/faker/music/show.rb +49 -0
  42. data/lib/faker/quotes/quote.rb +54 -1
  43. data/lib/faker/quotes/shakespeare.rb +36 -0
  44. data/lib/faker/tv_shows/suits.rb +37 -0
  45. data/lib/faker/version.rb +1 -1
  46. data/lib/helpers/char.rb +2 -1
  47. data/lib/locales/de-CH.yml +1693 -0
  48. data/lib/locales/en-AU.yml +44 -10
  49. data/lib/locales/en-CA.yml +2 -0
  50. data/lib/locales/en-US.yml +29 -3
  51. data/lib/locales/en/address.yml +2 -0
  52. data/lib/locales/en/blood.yml +13 -0
  53. data/lib/locales/en/computer.yml +36 -0
  54. data/lib/locales/en/control.yml +247 -0
  55. data/lib/locales/en/departed.yml +50 -0
  56. data/lib/locales/en/dnd.yml +54 -0
  57. data/lib/locales/en/heroes_of_the_storm.yml +1 -1
  58. data/lib/locales/en/house.yml +1 -1
  59. data/lib/locales/en/one_piece.yml +2 -2
  60. data/lib/locales/en/pearl_jam.yml +213 -0
  61. data/lib/locales/en/phish.yml +392 -1
  62. data/lib/locales/en/show.yml +597 -0
  63. data/lib/locales/en/star_wars.yml +568 -221
  64. data/lib/locales/en/suits.yml +45 -0
  65. data/lib/locales/en/warhammer_fantasy.yml +582 -0
  66. data/lib/locales/fr-CA.yml +2 -0
  67. data/lib/locales/ko.yml +82 -0
  68. data/lib/locales/pt-BR.yml +1 -0
  69. metadata +29 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27cbbd0c4b8240d56d669ed3edc77e0200a484b138415f17dcfb864977b162b6
4
- data.tar.gz: 9abedbe42209cca1d53bc5b545716f4c14479c065d9b7d069844b1312648048a
3
+ metadata.gz: 2e07357f193be20c639621339c209b48ee1a99bb64528e2f3d2c4b61afed8b8b
4
+ data.tar.gz: 39d54382315e2fd6abe4b8275b5bee60c832ef2b045ae16bba46e82233ab7697
5
5
  SHA512:
6
- metadata.gz: 4b29c27dddb232b1a27cf3829d724b14e45cf5628128b61be2566ff9ec235fc4d4a145f4e537c6fbfdd727b982f23325df4645d37d251cfb5cb59f7b7de73317
7
- data.tar.gz: edea4ce978458ad1332d768d23cc988013b3b3e7c5e58d134da42a72c142ef7de77925efb4156fa7e1a32cd1e70820a654b038533abf72a048b419eb523396ea
6
+ metadata.gz: 16d0fdaf172d74ffa7c1cd1ae88e55801313f779e1d2be385941ec7dfa9b2922dacd104406eaa5f060545bbd3b33c840fa9f72f90637e3dc045d70706ab57a61
7
+ data.tar.gz: 5589900168ed8cb068fc6682751f1bc8edf6cbe6d8afc191aaf8668af05ee08edfeebb02e446748a18104623fe09f4205206dbc1b2600c732f3a7abc1d46d556
@@ -1,5 +1,94 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.12.0](https://github.com/faker-ruby/faker/tree/v2.12.0) (2020-05-31)
4
+
5
+ This version:
6
+ - adds several YARD docs
7
+ - fixes some locale issues
8
+ - fixes a few bugs in Faker generators
9
+ - improves code quality
10
+ - adds a few generators for Movies, Music and TV Shows
11
+ - updates local dependencies
12
+
13
+ ## Bug/Fixes
14
+
15
+ - [PR #2019](https://github.com/faker-ruby/faker/pull/2019) Update 'prepare' regexp to allow hyphen [@jbergenson](https://github.com/jbergenson)
16
+ - [PR #2012](https://github.com/faker-ruby/faker/pull/2012) Add else condition to prevent false positive [@jbergenson](https://github.com/jbergenson)
17
+ - [PR #1985](https://github.com/faker-ruby/faker/pull/1985) Fix an error for `Faker::Computer.os` [@koic](https://github.com/koic)
18
+ - [PR #1971](https://github.com/faker-ruby/faker/pull/1971) Fixing the CI failure by fixing the infinite loop in Commerce [@amatsuda](https://github.com/amatsuda)
19
+
20
+ ## Chores
21
+
22
+ - [PR #1988](https://github.com/faker-ruby/faker/pull/1988) Removing meaningless begin and end [@amatsuda](https://github.com/amatsuda)
23
+ - [PR #1979](https://github.com/faker-ruby/faker/pull/1979) Reuse the `lvar` instead of calling `File.dirname(__FILE__)` again and again [@amatsuda](https://github.com/amatsuda)
24
+
25
+ ## Documentation
26
+
27
+ - [PR #2022](https://github.com/faker-ruby/faker/pull/2022) Add YARD docs to `Faker::Invoice` [@danielTiringer](https://github.com/danielTiringer)
28
+ - [PR #2021](https://github.com/faker-ruby/faker/pull/2021) Add YARD docs to `Faker::Hipster` [@danielTiringer](https://github.com/danielTiringer)
29
+ - [PR #2020](https://github.com/faker-ruby/faker/pull/2020) Add YARD docs to `Faker::Measurement` [@danielTiringer](https://github.com/danielTiringer)
30
+ - [PR #2017](https://github.com/faker-ruby/faker/pull/2017) Fix docs for `Faker::Games::Control.altered_world_event` [@Zeragamba](https://github.com/Zeragamba)
31
+ - [PR #2016](https://github.com/faker-ruby/faker/pull/2016) Fix yard documentation issues [@danielTiringer](https://github.com/danielTiringer)
32
+ - [PR #2015](https://github.com/faker-ruby/faker/pull/2015) Add YARD docs to `Faker::Quotes` [@danielTiringer](https://github.com/danielTiringer)
33
+ - [PR #2011](https://github.com/faker-ruby/faker/pull/2011) Update `star_wars.yml` [@garrettmichaelgeorge](https://github.com/garrettmichaelgeorge)
34
+ - [PR #2010](https://github.com/faker-ruby/faker/pull/2010) Add missing links in README.md [@Naokimi](https://github.com/Naokimi)
35
+ - [PR #2009](https://github.com/faker-ruby/faker/pull/2009) Add YARD docs to `Faker::Placeholdit` [@danielTiringer](https://github.com/danielTiringer)
36
+ - [PR #2008](https://github.com/faker-ruby/faker/pull/2008) Add YARD docs to `Faker::Verb` [@danielTiringer](https://github.com/danielTiringer)
37
+ - [PR #2007](https://github.com/faker-ruby/faker/pull/2007) Add YARD docs to `Faker::Phone_Number` [@danielTiringer](https://github.com/danielTiringer)
38
+ - [PR #2004](https://github.com/faker-ruby/faker/pull/2004) Add YARD docs to `Faker::String` [@danielTiringer](https://github.com/danielTiringer)
39
+ - [PR #2001](https://github.com/faker-ruby/faker/pull/2001) Add YARD docs to `Faker::South_Africa` [@danielTiringer](https://github.com/danielTiringer)
40
+ - [PR #2000](https://github.com/faker-ruby/faker/pull/2000) Add YARD docs to `Faker::JSON` [@danielTiringer](https://github.com/danielTiringer)
41
+ - [PR #1999](https://github.com/faker-ruby/faker/pull/1999) Add YARD docs to `Faker::Types` [@danielTiringer](https://github.com/danielTiringer)
42
+ - [PR #1998](https://github.com/faker-ruby/faker/pull/1998) Add YARD docs to `Faker::Finance` [@danielTiringer](https://github.com/danielTiringer)
43
+ - [PR #1997](https://github.com/faker-ruby/faker/pull/1997) Add YARD docs to `Faker::Driving_Licence` [@danielTiringer](https://github.com/danielTiringer)
44
+ - [PR #1996](https://github.com/faker-ruby/faker/pull/1996) Add YARD docs to `Crypto Coin` [@danielTiringer](https://github.com/danielTiringer)
45
+ - [PR #1995](https://github.com/faker-ruby/faker/pull/1995) Add YARD docs to `Faker::Commerce` [@danielTiringer](https://github.com/danielTiringer)
46
+ - [PR #1993](https://github.com/faker-ruby/faker/pull/1993) Add YARD docs to `Faker::Vehicle` [@danielTiringer](https://github.com/danielTiringer)
47
+ - [PR #1990](https://github.com/faker-ruby/faker/pull/1990) Add YARD docs to `Faker::File` [@danielTiringer](https://github.com/danielTiringer)
48
+ - [PR #1989](https://github.com/faker-ruby/faker/pull/1989) Add YARD docs to `Faker::Bank` [@danielTiringer](https://github.com/danielTiringer)
49
+ - [PR #1984](https://github.com/faker-ruby/faker/pull/1984) Minor documentation fix for `Faker::University` [@Zeragamba](https://github.com/Zeragamba)
50
+ - [PR #1983](https://github.com/faker-ruby/faker/pull/1983) Add YARD docs to `Faker::Twitter` [@danielTiringer](https://github.com/danielTiringer)
51
+ - [PR #1982](https://github.com/faker-ruby/faker/pull/1982) Add YARD docs to `Faker::Cosmere` [@danielTiringer](https://github.com/danielTiringer)
52
+ - [PR #1981](https://github.com/faker-ruby/faker/pull/1981) Add YARD docs to `Faker::Stripe` [@danielTiringer](https://github.com/danielTiringer)
53
+ - [PR #1980](https://github.com/faker-ruby/faker/pull/1980) Add YARD docs to `Faker::Construction` [@danielTiringer](https://github.com/danielTiringer)
54
+ - [PR #1976](https://github.com/faker-ruby/faker/pull/1976) Add YARD docs to `Faker::Name` [@danielTiringer](https://github.com/danielTiringer)
55
+ - [PR #1975](https://github.com/faker-ruby/faker/pull/1975) Add YARD docs to `Faker::Compass` [@danielTiringer](https://github.com/danielTiringer)
56
+ - [PR #1959](https://github.com/faker-ruby/faker/pull/1959) Add YARD docs to `Faker::University` [@danielTiringer](https://github.com/danielTiringer)
57
+ - [PR #1956](https://github.com/faker-ruby/faker/pull/1956) Add YARD docs to `Faker::SlackEmoji` [@rutger-t](https://github.com/rutger-t)
58
+ - [PR #1943](https://github.com/faker-ruby/faker/pull/1943) Update documentation for unique.exclude [@mtancoigne](https://github.com/mtancoigne)
59
+ - [PR #1925](https://github.com/faker-ruby/faker/pull/1925) AdD `Faker::Game::WarhammerFantasy` [@sotek222](https://github.com/sotek222)
60
+
61
+ ## Feature Request
62
+
63
+ - [PR #2025](https://github.com/faker-ruby/faker/pull/2025) Add `Faker::TvShows::Suits` [@ash-elangovan](https://github.com/ash-elangovan)
64
+ - [PR #2024](https://github.com/faker-ruby/faker/pull/2024) Added Phish Albums and Musicians [@zfine416](https://github.com/zfine416)
65
+ - [PR #2013](https://github.com/faker-ruby/faker/pull/2013) Add `Faker::Games::Control` [@Zeragamba](https://github.com/Zeragamba)
66
+ - [PR #1994](https://github.com/faker-ruby/faker/pull/1994) Enable Ruby testing github workflow [@Zeragamba](https://github.com/Zeragamba)
67
+ - [PR #1966](https://github.com/faker-ruby/faker/pull/1966) Add `Faker::Games:DnD` [@Naokimi](https://github.com/Naokimi)
68
+ - [PR #1962](https://github.com/faker-ruby/faker/pull/1962) Adding Pearl Jam to the Music module [@briri](https://github.com/briri)
69
+ - [PR #1960](https://github.com/faker-ruby/faker/pull/1960) Added `Faker::Blood` [@suraj32](https://github.com/suraj32)
70
+ - [PR #1931](https://github.com/faker-ruby/faker/pull/1931) Add `Faker::Movies::Departed` Class [@jaebradley](https://github.com/jaebradley)
71
+ - [PR #1696](https://github.com/faker-ruby/faker/pull/1696) Add Bibles class with King James subclass [@jbergenson](https://github.com/jbergenson)
72
+ - [PR #1485](https://github.com/faker-ruby/faker/pull/1485) Plays and musicals [@armandofox](https://github.com/armandofox)
73
+
74
+ ## Update locales
75
+
76
+ - [PR #2014](https://github.com/faker-ruby/faker/pull/2014) Make locale self-contained [@psibi](https://github.com/psibi)
77
+ - [PR #1986](https://github.com/faker-ruby/faker/pull/1986) Added quotations to Shirahoshi [@iavivai](https://github.com/iavivai)
78
+ - [PR #1973](https://github.com/faker-ruby/faker/pull/1973) Fix mis-quotations [@kayhide](https://github.com/kayhide)
79
+ - [PR #1967](https://github.com/faker-ruby/faker/pull/1967) ko locale updates [@jae57](https://github.com/jae57)
80
+ - [PR #1964](https://github.com/faker-ruby/faker/pull/1964) en-AU locale updates [@mattman](https://github.com/mattman)
81
+ - [PR #1948](https://github.com/faker-ruby/faker/pull/1948) Add `Faker::Computer` [@cmcramer](https://github.com/cmcramer)
82
+
83
+ ## Update local dependencies
84
+
85
+ - Update minitest requirement from = 5.14.0 to = 5.14.1 (#1987)
86
+ - Update rubocop requirement from = 0.80.1 to = 0.81.0 (#1955)
87
+ - Update pry requirement from = 0.13.0 to = 0.13.1 (#1963)
88
+ - Update yard requirement from = 0.9.24 to = 0.9.25 (#1970)
89
+
90
+ ------------------------------------------------------------------------------
91
+
3
92
  ## [v2.11.0](https://github.com/faker-ruby/faker/tree/v2.11.0) (2020-03-24)
4
93
 
5
94
  ## 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/faker-ruby/faker.svg?branch=master)](https://travis-ci.org/faker-ruby/faker)
5
+ [![Tests](https://github.com/faker-ruby/faker/workflows/Tests/badge.svg)](https://github.com/faker-ruby/faker/actions?query=workflow%3ATests)
6
6
  [![Gem Version](https://badge.fury.io/rb/faker.svg)](https://badge.fury.io/rb/faker)
7
7
  [![Inline docs](https://inch-ci.org/github/faker-ruby/faker.svg?branch=master)](https://inch-ci.org/github/faker-ruby/faker)
8
8
  [![Test Coverage](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/test_coverage)](https://codeclimate.com/github/stympy/faker/test_coverage)
@@ -95,7 +95,7 @@ manually set values).
95
95
  # Faker::<generator>.unique.exclude(method, arguments, list)
96
96
 
97
97
  # Add 'azerty' and 'wxcvbn' to the string generator with 6 char length
98
- Faker::Lorem.unique.exclude :string, [6], %w[azerty wxcvbn]
98
+ Faker::Lorem.unique.exclude :string, [number: 6], %w[azerty wxcvbn]
99
99
  ```
100
100
 
101
101
  ### Deterministic Random
@@ -131,6 +131,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
131
131
  - [Faker::Avatar](doc/default/avatar.md)
132
132
  - [Faker::Bank](doc/default/bank.md)
133
133
  - [Faker::Beer](doc/default/beer.md)
134
+ - [Faker::Blood](doc/default/blood.md)
134
135
  - [Faker::Boolean](doc/default/boolean.md)
135
136
  - [Faker::BossaNova](doc/default/bossa_nova.md)
136
137
  - [Faker::Business](doc/default/business.md)
@@ -144,6 +145,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
144
145
  - [Faker::Commerce](doc/default/commerce.md)
145
146
  - [Faker::Company](doc/default/company.md)
146
147
  - [Faker::Compass](doc/default/compass.md)
148
+ - [Faker::Computer](doc/default/computer.md)
147
149
  - [Faker::Construction](doc/default/construction.md)
148
150
  - [Faker::Cosmere](doc/default/cosmere.md)
149
151
  - [Faker::Crypto](doc/default/crypto.md)
@@ -231,6 +233,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
231
233
 
232
234
  ### Games
233
235
  - [Faker::Game](doc/games/game.md)
236
+ - [Faker::Games::DnD](doc/games/dnd.md)
234
237
  - [Faker::Games::Dota](doc/games/dota.md)
235
238
  - [Faker::Games::ElderScrolls](doc/games/elder_scrolls.md)
236
239
  - [Faker::Games::Fallout](doc/games/fallout.md)
@@ -243,6 +246,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
243
246
  - [Faker::Games::Pokemon](doc/games/pokemon.md)
244
247
  - [Faker::Games::SonicTheHedgehog](doc/games/sonic_the_hedgehog.md)
245
248
  - [Faker::Games::SuperSmashBros](doc/games/super_smash_bros.md)
249
+ - [Faker::Games::WarhammerFantasy](doc/games/warhammer_fantasy.md)
246
250
  - [Faker::Games::Witcher](doc/games/witcher.md)
247
251
  - [Faker::Games::WorldOfWarcraft](doc/games/world_of_warcraft.md)
248
252
  - [Faker::Games::Zelda](doc/games/zelda.md)
@@ -255,6 +259,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
255
259
  ### Movies
256
260
  - [Faker::Movie](doc/movies/movie.md)
257
261
  - [Faker::Movies::BackToTheFuture](doc/movies/back_to_the_future.md)
262
+ - [Faker::Movies::Departed](doc/movies/departed.md)
258
263
  - [Faker::Movies::Ghostbusters](doc/movies/ghostbusters.md)
259
264
  - [Faker::Movies::HarryPotter](doc/movies/harry_potter.md)
260
265
  - [Faker::Movies::HitchhikersGuideToTheGalaxy](doc/movies/hitchhikers_guide_to_the_galaxy.md)
@@ -309,6 +314,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
309
314
  - [Faker::TvShows::StarTrek](doc/tv_shows/star_trek.md)
310
315
  - [Faker::TvShows::Stargate](doc/tv_shows/stargate.md)
311
316
  - [Faker::TvShows::StrangerThings](doc/tv_shows/stranger_things.md)
317
+ - [Faker::TvShows::Suits](doc/tv_shows/suits.md)
312
318
  - [Faker::TvShows::TheExpanse](doc/tv_shows/the_expanse.md)
313
319
  - [Faker::TvShows::TheFreshPrinceOfBelAir](doc/tv_shows/the_fresh_prince_of_bel_air.md)
314
320
  - [Faker::TvShows::TheITCrowd](doc/tv_shows/the_it_crowd.md)
@@ -2,14 +2,11 @@
2
2
 
3
3
  mydir = __dir__
4
4
 
5
- begin
6
- require 'psych'
7
- end
8
-
5
+ require 'psych'
9
6
  require 'i18n'
10
7
  require 'set' # Fixes a bug in i18n 0.6.11
11
8
 
12
- Dir.glob(File.join(File.dirname(__FILE__), 'helpers', '*.rb')).sort.each { |file| require file }
9
+ Dir.glob(File.join(mydir, 'helpers', '*.rb')).sort.each { |file| require file }
13
10
 
14
11
  I18n.load_path += Dir[File.join(mydir, 'locales', '**/*.yml')]
15
12
  I18n.reload! if I18n.backend.initialized?
@@ -132,7 +129,7 @@ module Faker
132
129
  # In either case the information will be retained for reconstruction of the string.
133
130
  text = prefix
134
131
 
135
- # If the class has the method, call it, otherwise fetch the transation
132
+ # If the class has the method, call it, otherwise fetch the translation
136
133
  # (e.g., faker.phone_number.area_code)
137
134
  text += if cls.respond_to?(meth)
138
135
  cls.send(meth)
@@ -225,8 +222,16 @@ module Faker
225
222
  @unique ||= UniqueGenerator.new(self, max_retries)
226
223
  end
227
224
 
228
- def sample(list)
229
- list.respond_to?(:sample) ? list.sample(random: Faker::Config.random) : list
225
+ def sample(list, num = nil)
226
+ if list.respond_to?(:sample)
227
+ if num
228
+ list.sample(num, random: Faker::Config.random)
229
+ else
230
+ list.sample(random: Faker::Config.random)
231
+ end
232
+ else
233
+ list
234
+ end
230
235
  end
231
236
 
232
237
  def shuffle(list)
@@ -307,4 +312,4 @@ module Faker
307
312
  end
308
313
 
309
314
  # require faker objects
310
- Dir.glob(File.join(File.dirname(__FILE__), 'faker', '/**/*.rb')).sort.each { |file| require file }
315
+ Dir.glob(File.join(mydir, 'faker', '/**/*.rb')).sort.each { |file| require file }
@@ -102,7 +102,7 @@ module Faker
102
102
  # @return [String]
103
103
  #
104
104
  # @example
105
- # Faker::Address.mail_box #=> "PO Box 123"
105
+ # Faker::Address.mail_box #=> "PO Box 123"
106
106
  #
107
107
  # @faker.version 2.9.1
108
108
  def mail_box
@@ -5,6 +5,17 @@ module Faker
5
5
  flexible :bank
6
6
 
7
7
  class << self
8
+ ##
9
+ # Produces a bank account number.
10
+ #
11
+ # @param digits [Integer] Number of digits that the generated account number should have.
12
+ # @return [String]
13
+ #
14
+ # @example
15
+ # Faker::Bank.account_number #=> 6738582379
16
+ # Faker::Bank.account_number(digits: 13) #=> 673858237902
17
+ #
18
+ # @faker.version 1.9.1
8
19
  def account_number(legacy_digits = NOT_GIVEN, digits: 10)
9
20
  warn_for_deprecated_arguments do |keywords|
10
21
  keywords << :digits if legacy_digits != NOT_GIVEN
@@ -17,6 +28,17 @@ module Faker
17
28
  output[0...digits]
18
29
  end
19
30
 
31
+ ##
32
+ # Produces a bank iban number.
33
+ #
34
+ # @param country_code [String] Specifies what country prefix is used to generate the iban code.
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::Bank.iban #=> "GB76DZJM33188515981979"
39
+ # Faker::Bank.iban(country_code: "be") #=> "BE6375388567752043"
40
+ #
41
+ # @faker.version 1.7.0
20
42
  def iban(legacy_country_code = NOT_GIVEN, country_code: 'GB')
21
43
  # Each country has its own format for bank accounts
22
44
  # Many of them use letters in certain parts of the account
@@ -38,22 +60,72 @@ module Faker
38
60
  country_code.upcase + iban_checksum(country_code, account) + account
39
61
  end
40
62
 
63
+ ##
64
+ # Produces a bank name.
65
+ #
66
+ # @return [String]
67
+ #
68
+ # @example
69
+ # Faker::Bank.name #=> "ABN AMRO CORPORATE FINANCE LIMITED"
70
+ #
71
+ # @faker.version 1.7.0
41
72
  def name
42
73
  fetch('bank.name')
43
74
  end
44
75
 
76
+ ##
77
+ # Produces a routing number.
78
+ #
79
+ # @return [String]
80
+ #
81
+ # @example
82
+ # Faker::Bank.routing_number #=> "729343831"
83
+ #
84
+ # @faker.version 1.9.1
45
85
  def routing_number
46
86
  valid_routing_number
47
87
  end
48
88
 
89
+ ##
90
+ # Produces a valid routing number.
91
+ #
92
+ # @return [String]
93
+ #
94
+ # @example
95
+ # Faker::Bank.routing_number #=> "729343831"
96
+ #
97
+ # @faker.version 1.9.1
49
98
  def routing_number_with_format
50
99
  compile_fraction(valid_routing_number)
51
100
  end
52
101
 
102
+ ##
103
+ # Produces a swift / bic number.
104
+ #
105
+ # @return [String]
106
+ #
107
+ # @example
108
+ # Faker::Bank.swift_bic #=> "AAFMGB21"
109
+ #
110
+ # @faker.version 1.7.0
53
111
  def swift_bic
54
112
  fetch('bank.swift_bic')
55
113
  end
56
114
 
115
+ ##
116
+ # Produces an Australian BSB (Bank-State-Branch) number
117
+ #
118
+ # @return [String]
119
+ #
120
+ # @example
121
+ # Faker::Bank.bsb_number
122
+ # #=> "036616"
123
+ #
124
+ # @faker.version next
125
+ def bsb_number
126
+ compile_bsb_number
127
+ end
128
+
57
129
  private
58
130
 
59
131
  def checksum(num_string)
@@ -72,6 +144,13 @@ module Faker
72
144
  routing_num
73
145
  end
74
146
 
147
+ def compile_bsb_number
148
+ digit_one_two = %w[01 03 06 08 11 12 73 76 78 30]
149
+ state = (2..7).to_a.map(&:to_s).sample
150
+ bsb_num = digit_one_two.sample + state + rand_numstring + rand_numstring + rand_numstring
151
+ bsb_num
152
+ end
153
+
75
154
  # Calculates the mandatory checksum in 3rd and 4th characters in IBAN format
76
155
  # source: https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN
77
156
  def iban_checksum(country_code, account)
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Blood < Base
5
+ flexible :blood
6
+
7
+ class << self
8
+ ##
9
+ # Produces a random blood type.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Blood.type #=> "AB"
15
+ #
16
+ # @faker.version next
17
+ def type
18
+ fetch('blood.type')
19
+ end
20
+
21
+ ##
22
+ # Produces a random blood RH-Factor.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Blood.rh_factor #=> "-"
28
+ #
29
+ # @faker.version next
30
+ def rh_factor
31
+ fetch('blood.rh_factor')
32
+ end
33
+
34
+ ##
35
+ # Produces a random blood group name.
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::Blood.group #=> "AB-"
41
+ #
42
+ # @faker.version next
43
+ def group
44
+ parse('blood.group')
45
+ end
46
+ end
47
+ end
48
+ end
@@ -26,7 +26,7 @@ module Faker
26
26
  # @return [Date]
27
27
  #
28
28
  # @example
29
- # Faker::Business.credit_card_number #=> <Date: 2015-11-11 ((2457338j,0s,0n),+0s,2299161j)>
29
+ # Faker::Business.credit_card_expiry_date #=> <Date: 2015-11-11 ((2457338j,0s,0n),+0s,2299161j)>
30
30
  #
31
31
  # @faker.version 1.2.0
32
32
  def credit_card_expiry_date
@@ -3,10 +3,30 @@
3
3
  module Faker
4
4
  class Commerce < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random color.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Commerce.color #=> "lavender"
13
+ #
14
+ # @faker.version 1.2.0
6
15
  def color
7
16
  fetch('color.name')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a random promotion code.
21
+ #
22
+ # @param digits [Integer] Updates the number of numerical digits used to generate the promotion code.
23
+ # @return [String]
24
+ #
25
+ # @example
26
+ # Faker::Commerce.promotion_code #=> "AmazingDeal829102"
27
+ # Faker::Commerce.promotion_code(digits: 2) #=> "AmazingPrice57"
28
+ #
29
+ # @faker.version 1.7.0
10
30
  def promotion_code(legacy_digits = NOT_GIVEN, digits: 6)
11
31
  warn_for_deprecated_arguments do |keywords|
12
32
  keywords << :digits if legacy_digits != NOT_GIVEN
@@ -19,6 +39,19 @@ module Faker
19
39
  ].join
20
40
  end
21
41
 
42
+ ##
43
+ # Produces a random department.
44
+ #
45
+ # @param max [Integer] Updates the maximum number of names used to generate the department name.
46
+ # @param fixed_amount [Boolean] Fixes the amount of departments to use instead of using a range.
47
+ # @return [String]
48
+ #
49
+ # @example
50
+ # Faker::Commerce.department #=> "Grocery, Health & Beauty"
51
+ # Faker::Commerce.department(max: 5) #=> "Grocery, Books, Health & Beauty"
52
+ # Faker::Commerce.department(max: 2, fixed_amount: true) #=> "Books & Tools"
53
+ #
54
+ # @faker.version 1.2.0
22
55
  def department(legacy_max = NOT_GIVEN, legacy_fixed_amount = NOT_GIVEN, max: 3, fixed_amount: false)
23
56
  warn_for_deprecated_arguments do |keywords|
24
57
  keywords << :max if legacy_max != NOT_GIVEN
@@ -30,19 +63,55 @@ module Faker
30
63
 
31
64
  categories = categories(num)
32
65
 
33
- return merge_categories(categories) if num > 1
34
-
35
- categories[0]
66
+ if categories.is_a?(Array)
67
+ if categories.length > 1
68
+ merge_categories(categories)
69
+ else
70
+ categories[0]
71
+ end
72
+ else
73
+ categories
74
+ end
36
75
  end
37
76
 
77
+ ##
78
+ # Produces a random product name.
79
+ #
80
+ # @return [String]
81
+ #
82
+ # @example
83
+ # Faker::Commerce.product_name #=> "Practical Granite Shirt"
84
+ #
85
+ # @faker.version 1.2.0
38
86
  def product_name
39
87
  "#{fetch('commerce.product_name.adjective')} #{fetch('commerce.product_name.material')} #{fetch('commerce.product_name.product')}"
40
88
  end
41
89
 
90
+ ##
91
+ # Produces a random material.
92
+ #
93
+ # @return [String]
94
+ #
95
+ # @example
96
+ # Faker::Commerce.material #=> "Plastic"
97
+ #
98
+ # @faker.version 1.5.0
42
99
  def material
43
100
  fetch('commerce.product_name.material')
44
101
  end
45
102
 
103
+ ##
104
+ # Produces a random product price.
105
+ #
106
+ # @param range [Range] A range to generate the random number within.
107
+ # @param as_string [Boolean] Changes the return value to [String].
108
+ # @return [Float]
109
+ #
110
+ # @example
111
+ # Faker::Commerce.price #=> 44.6
112
+ # Faker::Commerce.price(range: 0..10.0, as_string: true) #=> "2.18"
113
+ #
114
+ # @faker.version 1.2.0
46
115
  def price(legacy_range = NOT_GIVEN, legacy_as_string = NOT_GIVEN, range: 0..100.0, as_string: false)
47
116
  warn_for_deprecated_arguments do |keywords|
48
117
  keywords << :range if legacy_range != NOT_GIVEN
@@ -60,13 +129,7 @@ module Faker
60
129
  private
61
130
 
62
131
  def categories(num)
63
- categories = []
64
- while categories.length < num
65
- category = fetch('commerce.department')
66
- categories << category unless categories.include?(category)
67
- end
68
-
69
- categories
132
+ sample(fetch_all('commerce.department'), num)
70
133
  end
71
134
 
72
135
  def merge_categories(categories)