faker 2.2.2 → 2.3.0

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/README.md +0 -1
  4. data/lib/faker/blockchain/bitcoin.rb +26 -0
  5. data/lib/faker/blockchain/ethereum.rb +10 -0
  6. data/lib/faker/blockchain/tezos.rb +56 -0
  7. data/lib/faker/books/book.rb +36 -0
  8. data/lib/faker/books/culture_series.rb +49 -0
  9. data/lib/faker/books/dune.rb +56 -3
  10. data/lib/faker/books/lovecraft.rb +172 -0
  11. data/lib/faker/creature/animal.rb +9 -0
  12. data/lib/faker/creature/cat.rb +27 -0
  13. data/lib/faker/creature/dog.rb +72 -0
  14. data/lib/faker/creature/horse.rb +18 -0
  15. data/lib/faker/default/alphanumeric.rb +23 -6
  16. data/lib/faker/default/app.rb +45 -0
  17. data/lib/faker/default/artist.rb +9 -0
  18. data/lib/faker/default/avatar.rb +31 -0
  19. data/lib/faker/default/boolean.rb +12 -1
  20. data/lib/faker/default/gender.rb +18 -0
  21. data/lib/faker/default/hacker.rb +59 -1
  22. data/lib/faker/default/house.rb +18 -0
  23. data/lib/faker/default/internet.rb +15 -10
  24. data/lib/faker/default/lorem.rb +8 -7
  25. data/lib/faker/default/omniauth.rb +42 -0
  26. data/lib/faker/default/programming_language.rb +18 -0
  27. data/lib/faker/default/source.rb +43 -2
  28. data/lib/faker/games/elder_scrolls.rb +72 -0
  29. data/lib/faker/games/fallout.rb +37 -0
  30. data/lib/faker/games/game.rb +27 -0
  31. data/lib/faker/games/half_life.rb +27 -0
  32. data/lib/faker/games/overwatch.rb +27 -0
  33. data/lib/faker/games/super_smash_bros.rb +18 -0
  34. data/lib/faker/games/zelda.rb +36 -0
  35. data/lib/faker/tv_shows/breaking_bad.rb +18 -0
  36. data/lib/faker/version.rb +1 -1
  37. data/lib/locales/en-CA.yml +1 -1
  38. data/lib/locales/ja.yml +1 -1
  39. metadata +19 -3
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class House < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a piece of furniture.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::House.furniture #=> "chair"
13
+ #
14
+ # @faker.version 1.9.2
6
15
  def furniture
7
16
  fetch('house.furniture')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the name of a room in a house.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::House.room #=> "kitchen"
26
+ #
27
+ # @faker.version 1.9.2
10
28
  def room
11
29
  fetch('house.rooms')
12
30
  end
@@ -74,20 +74,25 @@ module Faker
74
74
  end
75
75
 
76
76
  ##
77
- # Produces a randomized string of characters
77
+ # Produces a randomized string of characters suitable for passwords
78
78
  #
79
- # @param [Integer] min_length
80
- # @param [Integer] max_length
81
- # @param [Boolean] mix_case
82
- # @param [Boolean] special_characters
79
+ # @param min_length [Integer] The minimum length of the password
80
+ # @param max_length [Integer] The maximum length of the password
81
+ # @param mix_case [Boolean] Toggles if uppercased letters are allowed. If true, at least one will be added.
82
+ # @param special_characters [Boolean] Toggles if special characters are allowed. If true, at least one will be added.
83
83
  #
84
84
  # @return [String]
85
85
  #
86
- # @example Faker::Internet.password #=> "Vg5mSvY1UeRg7"
87
- # @example Faker::Internet.password(min_length: 8) #=> "YfGjIk0hGzDqS0"
88
- # @example Faker::Internet.password(min_length: 10, max_length: 20) #=> "EoC9ShWd1hWq4vBgFw"
89
- # @example Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k5qS15aNmG"
90
- # @example Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4"
86
+ # @example
87
+ # Faker::Internet.password #=> "Vg5mSvY1UeRg7"
88
+ # @example
89
+ # Faker::Internet.password(min_length: 8) #=> "YfGjIk0hGzDqS0"
90
+ # @example
91
+ # Faker::Internet.password(min_length: 10, max_length: 20) #=> "EoC9ShWd1hWq4vBgFw"
92
+ # @example
93
+ # Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k5qS15aNmG"
94
+ # @example
95
+ # Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4"
91
96
  #
92
97
  # @faker.version 2.1.3
93
98
  # rubocop:disable Metrics/ParameterLists
@@ -30,16 +30,17 @@ module Faker
30
30
  ##
31
31
  # Produces a random string of alphanumeric characters
32
32
  #
33
- # @param [Integer] number
34
- # @param [Integer] min_alpha
35
- # @param [Integer] min_numeric
33
+ # @param number [Integer] The number of characters to generate
34
+ # @param min_alpha [Integer] The minimum number of alphabetic to add to the string
35
+ # @param min_numeric [Integer] The minimum number of numbers to add to the string
36
36
  #
37
37
  # @return [String]
38
38
  #
39
- # @example Faker::Lorem.characters #=> "uw1ep04lhs0c4d931n1jmrspprf5wrj85fefue0y7y6m56b6omquh7br7dhqijwlawejpl765nb1716idmp3xnfo85v349pzy2o9rir23y2qhflwr71c1585fnynguiphkjm8p0vktwitcsm16lny7jzp9t4drwav3qmhz4yjq4k04x14gl6p148hulyqioo72tf8nwrxxcclfypz2lc58lsibgfe5w5p0xv95peafjjmm2frkhdc6duoky0aha"
40
- # @example Faker::Lorem.characters(number: 10) #=> "ang9cbhoa8"
41
- # @example Faker::Lorem.characters(number: 10, min_alpha: 4) #=> "ang9cbhoa8"
42
- # @example Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8"
39
+ # @example
40
+ # Faker::Lorem.characters #=> "uw1ep04lhs0c4d931n1jmrspprf5w..."
41
+ # Faker::Lorem.characters(number: 10) #=> "ang9cbhoa8"
42
+ # Faker::Lorem.characters(number: 10, min_alpha: 4) #=> "ang9cbhoa8"
43
+ # Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8"
43
44
  #
44
45
  # @faker.version 2.1.3
45
46
  def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric: 0)
@@ -341,6 +341,48 @@ module Faker
341
341
  }
342
342
  end
343
343
 
344
+ ##
345
+ # Generate a mock Omniauth response from Apple
346
+ #
347
+ # @param name [String] A specific name to return in the response
348
+ # @param email [String] A specific email to return in the response
349
+ # @param uid [String] A specific UID to return in the response
350
+ #
351
+ # @return [Hash] An auth hash in the format provided by omniauth-apple
352
+ def apple(name: nil, email: nil, uid: nil)
353
+ uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}"
354
+ auth = Omniauth.new(name: name, email: email)
355
+ {
356
+ provider: 'apple',
357
+ uid: uid,
358
+ info: {
359
+ sub: uid,
360
+ email: auth.email,
361
+ first_name: auth.first_name,
362
+ last_name: auth.last_name
363
+ },
364
+ credentials: {
365
+ token: Crypto.md5,
366
+ refresh_token: Crypto.md5,
367
+ expires_at: Time.forward.to_i,
368
+ expires: true
369
+ },
370
+ extra: {
371
+ raw_info: {
372
+ iss: 'https://appleid.apple.com',
373
+ aud: 'CLIENT_ID',
374
+ exp: Time.forward.to_i,
375
+ iat: Time.forward.to_i,
376
+ sub: uid,
377
+ at_hash: Crypto.md5,
378
+ auth_time: Time.forward.to_i,
379
+ email: auth.email,
380
+ email_verified: true
381
+ }
382
+ }
383
+ }
384
+ end
385
+
344
386
  private
345
387
 
346
388
  def gender
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class ProgrammingLanguage < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a programming language.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::ProgrammingLanguage.name #=> "Ruby"
13
+ #
14
+ # @faker.version 1.8.5
6
15
  def name
7
16
  fetch('programming_language.name')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the name of a programming language's creator.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::ProgrammingLanguage.creator #=> "Yukihiro Matsumoto"
26
+ #
27
+ # @faker.version 1.8.5
10
28
  def creator
11
29
  fetch('programming_language.creator')
12
30
  end
@@ -3,6 +3,20 @@
3
3
  module Faker
4
4
  class Source < Base
5
5
  class << self
6
+ ##
7
+ # Produces source code for Hello World in a given language.
8
+ #
9
+ # @param lang [Symbol] The programming language to use
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::Source.hello_world #=> "puts 'Hello World!'"
14
+ #
15
+ # @example
16
+ # Faker::Source.hello_world(lang: :javascript)
17
+ # #=> "alert('Hello World!');"
18
+ #
19
+ # @faker.version 1.9.0
6
20
  def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby)
7
21
  warn_for_deprecated_arguments do |keywords|
8
22
  keywords << :lang if legacy_lang != NOT_GIVEN
@@ -11,6 +25,20 @@ module Faker
11
25
  fetch("source.hello_world.#{lang}")
12
26
  end
13
27
 
28
+ ##
29
+ # Produces source code for printing a string in a given language.
30
+ #
31
+ # @param str [String] The string to print
32
+ # @param lang [Symbol] The programming language to use
33
+ # @return [String]
34
+ #
35
+ # @example
36
+ # Faker::Source.print #=> "puts 'faker_string_to_print'"
37
+ # @example
38
+ # Faker::Source.print(str: 'foo bar', lang: :javascript)
39
+ # #=> "console.log('foo bar');"
40
+ #
41
+ # @faker.version 1.9.0
14
42
  def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', lang: :ruby)
15
43
  warn_for_deprecated_arguments do |keywords|
16
44
  keywords << :str if legacy_str != NOT_GIVEN
@@ -18,16 +46,29 @@ module Faker
18
46
  warn_for_deprecated_arguments do |keywords|
19
47
  keywords << :lang if legacy_lang != NOT_GIVEN
20
48
  end
21
-
22
49
  code = fetch("source.print.#{lang}")
23
50
  code.gsub('faker_string_to_print', str)
24
51
  end
25
52
 
53
+ ##
54
+ # Produces source code for printing 1 through 10 in a given language.
55
+ #
56
+ # @param lang [Symbol] The programming language to use
57
+ # @return [String]
58
+ #
59
+ # @example
60
+ # Faker::Source.print_1_to_10 #=> "(1..10).each { |i| puts i }"
61
+ # @example
62
+ # Faker::Source.print_1_to_10(lang: :javascript)
63
+ # # => "for (let i=0; i<10; i++) {
64
+ # # console.log(i);
65
+ # # }"
66
+ #
67
+ # @faker.version 1.9.0
26
68
  def print_1_to_10(legacy_lang = NOT_GIVEN, lang: :ruby)
27
69
  warn_for_deprecated_arguments do |keywords|
28
70
  keywords << :lang if legacy_lang != NOT_GIVEN
29
71
  end
30
-
31
72
  fetch("source.print_1_to_10.#{lang}")
32
73
  end
33
74
  end
@@ -4,34 +4,106 @@ module Faker
4
4
  class Games
5
5
  class ElderScrolls < Base
6
6
  class << self
7
+ ##
8
+ # Produces the name of a race from the Elder Scrolls universe.
9
+ #
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::Games::ElderScrolls.race #=> "Argonian"
14
+ #
15
+ # @faker.version 1.9.2
7
16
  def race
8
17
  fetch('games.elder_scrolls.race')
9
18
  end
10
19
 
20
+ ##
21
+ # Produces the name of a city from the Elder Scrolls universe.
22
+ #
23
+ # @return [String]
24
+ #
25
+ # @example
26
+ # Faker::Games::ElderScrolls.city #=> "Whiterun"
27
+ #
28
+ # @faker.version 1.9.2
11
29
  def city
12
30
  fetch('games.elder_scrolls.city')
13
31
  end
14
32
 
33
+ ##
34
+ # Produces the name of a creature from the Elder Scrolls universe.
35
+ #
36
+ # @return [String]
37
+ #
38
+ # @example
39
+ # Faker::Games::ElderScrolls.creature #=> "Frost Troll"
40
+ #
41
+ # @faker.version 1.9.2
15
42
  def creature
16
43
  fetch('games.elder_scrolls.creature')
17
44
  end
18
45
 
46
+ ##
47
+ # Produces the name of a region from the Elder Scrolls universe.
48
+ #
49
+ # @return [String]
50
+ #
51
+ # @example
52
+ # Faker::Games::ElderScrolls.region #=> "Cyrodiil"
53
+ #
54
+ # @faker.version 1.9.2
19
55
  def region
20
56
  fetch('games.elder_scrolls.region')
21
57
  end
22
58
 
59
+ ##
60
+ # Produces the name of a dragon from the Elder Scrolls universe.
61
+ #
62
+ # @return [String]
63
+ #
64
+ # @example
65
+ # Faker::Games::ElderScrolls.dragon #=> "Blood Dragon"
66
+ #
67
+ # @faker.version 1.9.2
23
68
  def dragon
24
69
  fetch('games.elder_scrolls.dragon')
25
70
  end
26
71
 
72
+ ##
73
+ # Produces a randomly generated name from the Elder Scrolls universe.
74
+ #
75
+ # @return [String]
76
+ #
77
+ # @example
78
+ # Faker::Games::ElderScrolls.name #=> "Balgruuf The Old"
79
+ #
80
+ # @faker.version 1.9.2
27
81
  def name
28
82
  "#{fetch('games.elder_scrolls.first_name')} #{fetch('games.elder_scrolls.last_name')}"
29
83
  end
30
84
 
85
+ ##
86
+ # Produces a first name from the Elder Scrolls universe.
87
+ #
88
+ # @return [String]
89
+ #
90
+ # @example
91
+ # Faker::Games::ElderScrolls.first_name #=> "Balgruuf"
92
+ #
93
+ # @faker.version 1.9.2
31
94
  def first_name
32
95
  fetch('games.elder_scrolls.first_name')
33
96
  end
34
97
 
98
+ ##
99
+ # Produces a last name from the Elder Scrolls universe.
100
+ #
101
+ # @return [String]
102
+ #
103
+ # @example
104
+ # Faker::Games::ElderScrolls.last_name #=> "The Old"
105
+ #
106
+ # @faker.version 1.9.2
35
107
  def last_name
36
108
  fetch('games.elder_scrolls.last_name')
37
109
  end
@@ -4,18 +4,55 @@ module Faker
4
4
  class Games
5
5
  class Fallout < Base
6
6
  class << self
7
+ ##
8
+ # Produces the name of a character from the Fallout games.
9
+ #
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::Games::Fallout.character #=> "Liberty Prime"
14
+ #
15
+ # @faker.version 1.9.2
7
16
  def character
8
17
  fetch('games.fallout.characters')
9
18
  end
10
19
 
20
+ ##
21
+ # Produces the name of a faction from the Fallout games.
22
+ #
23
+ # @return [String]
24
+ #
25
+ # @example
26
+ # Faker::Games::Fallout.faction #=> "Brotherhood of Steel"
27
+ #
28
+ # @faker.version 1.9.2
11
29
  def faction
12
30
  fetch('games.fallout.factions')
13
31
  end
14
32
 
33
+ ##
34
+ # Produces the name of a location from the Fallout games.
35
+ #
36
+ # @return [String]
37
+ #
38
+ # @example
39
+ # Faker::Games::Fallout.location #=> "New Vegas"
40
+ #
41
+ # @faker.version 1.9.2
15
42
  def location
16
43
  fetch('games.fallout.locations')
17
44
  end
18
45
 
46
+ ##
47
+ # Produces a quote from the Fallout games.
48
+ #
49
+ # @return [String]
50
+ #
51
+ # @example
52
+ # Faker::Games::Fallout.quote
53
+ # #=> "Democracy is non-negotiable"
54
+ #
55
+ # @faker.version 1.9.2
19
56
  def quote
20
57
  fetch('games.fallout.quotes')
21
58
  end
@@ -5,14 +5,41 @@ module Faker
5
5
  flexible :game
6
6
 
7
7
  class << self
8
+ ##
9
+ # Produces the name of a video game.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Game.title #=> "Half-Life 2"
15
+ #
16
+ # @faker.version 1.9.4
8
17
  def title
9
18
  fetch('game.title')
10
19
  end
11
20
 
21
+ ##
22
+ # Produces the name of a video game genre.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Game.genre #=> "Real-time strategy"
28
+ #
29
+ # @faker.version 1.9.4
12
30
  def genre
13
31
  fetch('game.genre')
14
32
  end
15
33
 
34
+ ##
35
+ # Produces the name of a video game console or platform.
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::Game.platform #=> "Nintendo Switch"
41
+ #
42
+ # @faker.version 1.9.4
16
43
  def platform
17
44
  fetch('game.platform')
18
45
  end