faker 2.4.0 → 2.8.1

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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +159 -0
  3. data/README.md +3 -0
  4. data/lib/faker/default/address.rb +202 -0
  5. data/lib/faker/default/ancient.rb +36 -0
  6. data/lib/faker/default/app.rb +2 -1
  7. data/lib/faker/default/avatar.rb +2 -1
  8. data/lib/faker/default/bank.rb +13 -7
  9. data/lib/faker/default/bossa_nova.rb +18 -0
  10. data/lib/faker/default/business.rb +27 -0
  11. data/lib/faker/default/chuck_norris.rb +12 -2
  12. data/lib/faker/default/coffee.rb +45 -0
  13. data/lib/faker/default/coin.rb +18 -0
  14. data/lib/faker/default/color.rb +48 -1
  15. data/lib/faker/default/crypto.rb +27 -0
  16. data/lib/faker/default/currency.rb +27 -0
  17. data/lib/faker/default/date.rb +83 -2
  18. data/lib/faker/default/demographic.rb +57 -0
  19. data/lib/faker/default/driving_licence.rb +2 -2
  20. data/lib/faker/default/educator.rb +60 -6
  21. data/lib/faker/default/esport.rb +45 -0
  22. data/lib/faker/default/fillmurray.rb +23 -1
  23. data/lib/faker/default/food.rb +65 -1
  24. data/lib/faker/default/id_number.rb +29 -0
  25. data/lib/faker/default/internet.rb +21 -8
  26. data/lib/faker/default/kpop.rb +54 -0
  27. data/lib/faker/default/nation.rb +48 -5
  28. data/lib/faker/default/number.rb +124 -0
  29. data/lib/faker/default/relationship.rb +45 -0
  30. data/lib/faker/default/restaurant.rb +54 -2
  31. data/lib/faker/default/space.rb +127 -0
  32. data/lib/faker/default/team.rb +45 -0
  33. data/lib/faker/default/time.rb +85 -8
  34. data/lib/faker/default/world_cup.rb +50 -0
  35. data/lib/faker/games/zelda.rb +1 -1
  36. data/lib/faker/japanese_media/one_piece.rb +54 -0
  37. data/lib/faker/movies/back_to_the_future.rb +28 -0
  38. data/lib/faker/movies/ghostbusters.rb +28 -0
  39. data/lib/faker/movies/harry_potter.rb +54 -0
  40. data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +69 -0
  41. data/lib/faker/movies/lebowski.rb +27 -0
  42. data/lib/faker/movies/lord_of_the_rings.rb +28 -0
  43. data/lib/faker/movies/princess_bride.rb +19 -0
  44. data/lib/faker/movies/star_wars.rb +94 -0
  45. data/lib/faker/movies/v_for_vendetta.rb +29 -0
  46. data/lib/faker/music/umphreys_mcgee.rb +9 -0
  47. data/lib/faker/sports/basketball.rb +36 -0
  48. data/lib/faker/sports/football.rb +45 -0
  49. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +9 -0
  50. data/lib/faker/tv_shows/bojack_horseman.rb +28 -0
  51. data/lib/faker/tv_shows/buffy.rb +45 -0
  52. data/lib/faker/tv_shows/community.rb +19 -0
  53. data/lib/faker/tv_shows/dr_who.rb +78 -2
  54. data/lib/faker/tv_shows/dumb_and_dumber.rb +28 -0
  55. data/lib/faker/tv_shows/family_guy.rb +28 -0
  56. data/lib/faker/tv_shows/friends.rb +27 -0
  57. data/lib/faker/tv_shows/game_of_thrones.rb +46 -0
  58. data/lib/faker/tv_shows/hey_arnold.rb +27 -0
  59. data/lib/faker/tv_shows/how_i_met_your_mother.rb +37 -0
  60. data/lib/faker/tv_shows/michael_scott.rb +13 -0
  61. data/lib/faker/tv_shows/new_girl.rb +19 -0
  62. data/lib/faker/tv_shows/parks_and_rec.rb +18 -0
  63. data/lib/faker/tv_shows/rick_and_morty.rb +28 -0
  64. data/lib/faker/tv_shows/ru_paul.rb +18 -0
  65. data/lib/faker/tv_shows/seinfeld.rb +28 -0
  66. data/lib/faker/tv_shows/silicon_valley.rb +75 -0
  67. data/lib/faker/tv_shows/simpsons.rb +28 -0
  68. data/lib/faker/tv_shows/south_park.rb +19 -0
  69. data/lib/faker/tv_shows/star_trek.rb +36 -0
  70. data/lib/faker/tv_shows/stargate.rb +28 -0
  71. data/lib/faker/tv_shows/stranger_things.rb +19 -0
  72. data/lib/faker/tv_shows/the_expanse.rb +36 -0
  73. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +28 -0
  74. data/lib/faker/tv_shows/the_it_crowd.rb +37 -0
  75. data/lib/faker/tv_shows/the_thick_of_it.rb +28 -0
  76. data/lib/faker/tv_shows/twin_peaks.rb +28 -0
  77. data/lib/faker/tv_shows/venture_bros.rb +38 -0
  78. data/lib/faker/version.rb +1 -1
  79. data/lib/locales/en-CA.yml +1 -0
  80. data/lib/locales/en-TH.yml +360 -0
  81. data/lib/locales/en/color.yml +1 -1
  82. data/lib/locales/en/dr_who.yml +1 -1
  83. data/lib/locales/en/educator.yml +69 -6
  84. data/lib/locales/en/overwatch.yml +2617 -32
  85. data/lib/locales/en/super_smash_bros.yml +1 -0
  86. data/lib/locales/fr-CA.yml +1 -1
  87. data/lib/locales/ja.yml +6 -2
  88. data/lib/locales/pt-BR.yml +23 -2
  89. data/lib/locales/th.yml +380 -0
  90. metadata +22 -14
@@ -3,6 +3,18 @@
3
3
  module Faker
4
4
  class Date < Base
5
5
  class << self
6
+ ##
7
+ # Produce a random date between two dates.
8
+ #
9
+ # @param from [Date] The start of the usable date range.
10
+ # @param to [Date] The end of the usable date range.
11
+ # @return [Date]
12
+ #
13
+ # @example
14
+ # Faker::Date.between(from: 2.days.ago, to: Date.today)
15
+ # #=> #<Date: 2014-09-24>
16
+ #
17
+ # @faker.version 1.0.0
6
18
  def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:)
7
19
  warn_for_deprecated_arguments do |keywords|
8
20
  keywords << :from if legacy_from != NOT_GIVEN
@@ -16,8 +28,21 @@ module Faker
16
28
  end
17
29
 
18
30
  # rubocop:disable Metrics/ParameterLists
31
+
32
+ ##
33
+ # Produce a random date between two dates.
34
+ #
35
+ # @param from [Date] The start of the usable date range.
36
+ # @param to [Date] The end of the usable date range.
37
+ # @param excepted [Date] A date to exclude.
38
+ # @return [Date]
39
+ #
40
+ # @example
41
+ # Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today)
42
+ # #=> #<Date: 2014-10-03>
43
+ #
44
+ # @faker.version 1.6.2
19
45
  def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:)
20
- # rubocop:enable Metrics/ParameterLists
21
46
  warn_for_deprecated_arguments do |keywords|
22
47
  keywords << :from if legacy_from != NOT_GIVEN
23
48
  end
@@ -37,7 +62,18 @@ module Faker
37
62
  break date.to_date if date != excepted
38
63
  end
39
64
  end
40
-
65
+ # rubocop:enable Metrics/ParameterLists
66
+
67
+ ##
68
+ # Produce a random date in the future (up to N days).
69
+ #
70
+ # @param days [Integer] The maximum number of days to go into the future.
71
+ # @return [Date]
72
+ #
73
+ # @example
74
+ # Faker::Date.forward(days: 23) #=> #<Date: 2014-10-03>
75
+ #
76
+ # @faker.version 1.0.0
41
77
  def forward(legacy_days = NOT_GIVEN, days: 365)
42
78
  warn_for_deprecated_arguments do |keywords|
43
79
  keywords << :days if legacy_days != NOT_GIVEN
@@ -49,6 +85,16 @@ module Faker
49
85
  between(from: from, to: to).to_date
50
86
  end
51
87
 
88
+ ##
89
+ # Produce a random date in the past (up to N days).
90
+ #
91
+ # @param days [Integer] The maximum number of days to go into the past.
92
+ # @return [Date]
93
+ #
94
+ # @example
95
+ # Faker::Date.backward(days: 14) #=> #<Date: 2019-09-12>
96
+ #
97
+ # @faker.version 1.0.0
52
98
  def backward(legacy_days = NOT_GIVEN, days: 365)
53
99
  warn_for_deprecated_arguments do |keywords|
54
100
  keywords << :days if legacy_days != NOT_GIVEN
@@ -60,6 +106,17 @@ module Faker
60
106
  between(from: from, to: to).to_date
61
107
  end
62
108
 
109
+ ##
110
+ # Produce a random date in the past (up to N days).
111
+ #
112
+ # @param min_age [Integer] The minimum age that the birthday would imply.
113
+ # @param max_age [Integer] The maximum age that the birthday would imply.
114
+ # @return [Date]
115
+ #
116
+ # @example
117
+ # Faker::Date.birthday(min_age: 18, max_age: 65) #=> #<Date: 1986-03-28>
118
+ #
119
+ # @faker.version 1.4.3
63
120
  def birthday(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
64
121
  warn_for_deprecated_arguments do |keywords|
65
122
  keywords << :min_age if legacy_min_age != NOT_GIVEN
@@ -76,6 +133,30 @@ module Faker
76
133
  between(from: from, to: to).to_date
77
134
  end
78
135
 
136
+ ##
137
+ # Produces a date in the year and/or month specified.
138
+ #
139
+ # @param month [Integer] represents the month of the date
140
+ # @param year [Integer] represents the year of the date
141
+ # @return [Date]
142
+ #
143
+ # @example
144
+ # Faker::Date.in_date_period #=> #<Date: 2019-09-01>
145
+ #
146
+ # @example
147
+ # Faker::Date.in_date_period(year: 2018, month: 2) #=> #<Date: 2018-02-26>
148
+ #
149
+ # @example
150
+ # Faker::Date.in_date_period(month: 2) #=> #<Date: 2019-02-26>
151
+ #
152
+ # @faker.version next
153
+ def in_date_period(month: nil, year: ::Date.today.year)
154
+ from = ::Date.new(year, month || 1, 1)
155
+ to = ::Date.new(year, month || 12, ::Date.civil(year, month || 12, -1).day)
156
+
157
+ between(from: from, to: to).to_date
158
+ end
159
+
79
160
  private
80
161
 
81
162
  def birthday_date(date, age)
@@ -3,26 +3,83 @@
3
3
  module Faker
4
4
  class Demographic < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a race.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Demographic.race #=> "Native Hawaiian or Other Pacific Islander"
13
+ #
14
+ # @faker.version 1.7.3
6
15
  def race
7
16
  fetch('demographic.race')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a level of educational attainment.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Demographic.educational_attainment #=> "GED or alternative credential"
26
+ #
27
+ # @faker.version 1.7.3
10
28
  def educational_attainment
11
29
  fetch('demographic.educational_attainment')
12
30
  end
13
31
 
32
+ ##
33
+ # Produces a denonym.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::Demographic.denonym #=> "Panamanian"
39
+ #
40
+ # @faker.version 1.7.3
14
41
  def demonym
15
42
  fetch('demographic.demonym')
16
43
  end
17
44
 
45
+ ##
46
+ # Produces a marital status.
47
+ #
48
+ # @return [String]
49
+ #
50
+ # @example
51
+ # Faker::Demographic.marital_status #=> "Widowed"
52
+ #
53
+ # @faker.version 1.7.3
18
54
  def marital_status
19
55
  fetch('demographic.marital_status')
20
56
  end
21
57
 
58
+ ##
59
+ # Produces a sex for demographic purposes.
60
+ #
61
+ # @return [String]
62
+ #
63
+ # @example
64
+ # Faker::Demographic.sex #=> "Female"
65
+ #
66
+ # @faker.version 1.7.3
22
67
  def sex
23
68
  fetch('demographic.sex')
24
69
  end
25
70
 
71
+ ##
72
+ # Produces a height as a string.
73
+ #
74
+ # @param unit [Symbol] either `:metric` or `imperial`.
75
+ # @return [String]
76
+ #
77
+ # @example
78
+ # Faker::Demographic.height #=> "1.61"
79
+ # @example
80
+ # Faker::Demographic.height(unit: :imperial) #=> "6 ft, 2 in"
81
+ #
82
+ # @faker.version 1.7.3
26
83
  def height(legacy_unit = NOT_GIVEN, unit: :metric)
27
84
  warn_for_deprecated_arguments do |keywords|
28
85
  keywords << :unit if legacy_unit != NOT_GIVEN
@@ -52,9 +52,9 @@ module Faker
52
52
  year = dob.year % 10
53
53
  month = gender == :female ? dob.month + 50 : dob.month
54
54
  # Rubocop's preferred formatting is pretty gory
55
- # rubocop:disable FormatString
55
+ # rubocop:disable Style/FormatString
56
56
  "#{decade}#{'%02d' % month}#{'%02d' % dob.day}#{year}"
57
- # rubocop:enable FormatString
57
+ # rubocop:enable Style/FormatString
58
58
  end
59
59
 
60
60
  def gb_licence_checksum
@@ -5,30 +5,84 @@ module Faker
5
5
  flexible :educator
6
6
 
7
7
  class << self
8
+ ##
9
+ # Produces a university name.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Educator.university #=> "Mallowtown Technical College"
15
+ #
16
+ # @faker.version 1.6.4
8
17
  def university
9
- "#{parse('educator.name')} #{fetch('educator.tertiary.type')}"
18
+ parse('educator.university')
10
19
  end
11
20
 
21
+ ##
22
+ # Produces a university degree.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Educator.degree #=> "Associate Degree in Criminology"
28
+ #
29
+ # @faker.version 1.9.2
12
30
  def degree
13
- "#{fetch('educator.tertiary.degree.type')} #{fetch('educator.tertiary.degree.subject')}"
31
+ parse('educator.degree')
14
32
  end
15
33
 
16
34
  alias course degree
17
35
 
36
+ ##
37
+ # Produces a university subject.
38
+ #
39
+ # @return [String]
40
+ #
41
+ # @example
42
+ # Faker::Educator.subject #=> "Criminology"
43
+ #
44
+ # @faker.version 1.9.2
18
45
  def subject
19
- fetch('educator.tertiary.degree.subject')
46
+ fetch('educator.subject')
20
47
  end
21
48
 
49
+ ##
50
+ # Produces a course name.
51
+ #
52
+ # @return [String]
53
+ #
54
+ # @example
55
+ # Faker::Educator.course_name #=> "Criminology 101"
56
+ #
57
+ # @faker.version 1.9.2
22
58
  def course_name
23
- "#{fetch('educator.tertiary.degree.subject')} #{numerify(fetch('educator.tertiary.degree.course_number'))}"
59
+ numerify(parse('educator.course_name'))
24
60
  end
25
61
 
62
+ ##
63
+ # Produces a secondary school.
64
+ #
65
+ # @return [String]
66
+ #
67
+ # @example
68
+ # Faker::Educator.secondary_school #=> "Iceborough Secondary College"
69
+ #
70
+ # @faker.version 1.6.4
26
71
  def secondary_school
27
- "#{parse('educator.name')} #{fetch('educator.secondary')}"
72
+ parse('educator.secondary_school')
28
73
  end
29
74
 
75
+ ##
76
+ # Produces a campus name.
77
+ #
78
+ # @return [String]
79
+ #
80
+ # @example
81
+ # Faker::Educator.campus #=> "Vertapple Campus"
82
+ #
83
+ # @faker.version 1.6.4
30
84
  def campus
31
- "#{parse('educator.name')} Campus"
85
+ parse('educator.campus')
32
86
  end
33
87
  end
34
88
  end
@@ -3,22 +3,67 @@
3
3
  module Faker
4
4
  class Esport < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a professional eSports player.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Esport.player #=> "Crimsix"
13
+ #
14
+ # @faker.version 1.7.0
6
15
  def player
7
16
  fetch('esport.players')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the name of an eSports team.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Esport.team #=> "CLG"
26
+ #
27
+ # @faker.version 1.7.0
10
28
  def team
11
29
  fetch('esport.teams')
12
30
  end
13
31
 
32
+ ##
33
+ # Produces the name of an eSports league.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::Esport.league #=> "IEM"
39
+ #
40
+ # @faker.version 1.7.0
14
41
  def league
15
42
  fetch('esport.leagues')
16
43
  end
17
44
 
45
+ ##
46
+ # Produces the name of an eSports event.
47
+ #
48
+ # @return [String]
49
+ #
50
+ # @example
51
+ # Faker::Esport.event #=> "ESL Cologne"
52
+ #
53
+ # @faker.version 1.7.0
18
54
  def event
19
55
  fetch('esport.events')
20
56
  end
21
57
 
58
+ ##
59
+ # Produces the name of a game played as an eSport.
60
+ #
61
+ # @return [String]
62
+ #
63
+ # @example
64
+ # Faker::Esport.game #=> "Dota 2"
65
+ #
66
+ # @faker.version 1.7.0
22
67
  def game
23
68
  fetch('esport.games')
24
69
  end
@@ -4,8 +4,29 @@ module Faker
4
4
  class Fillmurray < Base
5
5
  class << self
6
6
  # rubocop:disable Metrics/ParameterLists
7
+
8
+ ##
9
+ # Produces the URL of an image from Fill Murray, a site which hosts
10
+ # exclusively photographs of actor Bill Murray.
11
+ #
12
+ # @param grayscale [Boolean] Whether to return a grayscale image.
13
+ # @param width [Integer] The iamage width.
14
+ # @param height [Integer] The image height.
15
+ # @return [String]
16
+ #
17
+ # @example
18
+ # Faker::Fillmurray.image #=> "https://www.fillmurray.com/300/300"
19
+ #
20
+ # @example
21
+ # Faker::Fillmurray.image(grayscale: true)
22
+ # #=> "https://fillmurray.com/g/300/300"
23
+ #
24
+ # @example
25
+ # Faker::Fillmurray.image(grayscale: false, width: 200, height: 400)
26
+ # #=> "https://fillmurray.com/200/400"
27
+ #
28
+ # @faker.version 1.7.1
7
29
  def image(legacy_grayscale = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_height = NOT_GIVEN, grayscale: false, width: 200, height: 200)
8
- # rubocop:enable Metrics/ParameterLists
9
30
  warn_for_deprecated_arguments do |keywords|
10
31
  keywords << :grayscale if legacy_grayscale != NOT_GIVEN
11
32
  keywords << :width if legacy_width != NOT_GIVEN
@@ -18,6 +39,7 @@ module Faker
18
39
 
19
40
  "https://www.fillmurray.com#{'/g' if grayscale == true}/#{width}/#{height}"
20
41
  end
42
+ # rubocop:enable Metrics/ParameterLists
21
43
  end
22
44
  end
23
45
  end
@@ -5,42 +5,106 @@ module Faker
5
5
  flexible :food
6
6
 
7
7
  class << self
8
- # Retrieves a typical dish from each country
8
+ ##
9
+ # Retrieves a typical dish from each country.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Food.dish #=> "Feijoada"
15
+ #
16
+ # @faker.version 1.8.0
9
17
  def dish
10
18
  fetch('food.dish')
11
19
  end
12
20
 
21
+ ##
13
22
  # Retrieves a description about some dish
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Food.description #=> "Breaded fried chicken with waffles. Served with maple syrup."
28
+ #
29
+ # @faker.version 1.9.0
14
30
  def description
15
31
  fetch('food.descriptions')
16
32
  end
17
33
 
34
+ ##
18
35
  # Retrieves an ingredient
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::Food.ingredient #=> "Olives"
41
+ #
42
+ # @faker.version 1.7.0
19
43
  def ingredient
20
44
  fetch('food.ingredients')
21
45
  end
22
46
 
47
+ ##
23
48
  # Retrieves a fruit
49
+ #
50
+ # @return [String]
51
+ #
52
+ # @example
53
+ # Faker::Food.fruits #=> "Papaya"
54
+ #
55
+ # @faker.version 1.9.0
24
56
  def fruits
25
57
  fetch('food.fruits')
26
58
  end
27
59
 
60
+ ##
28
61
  # Retrieves a vegetable
62
+ #
63
+ # @return [String]
64
+ #
65
+ # @example
66
+ # Faker::Food.vegetables #=> "Broccolini"
67
+ #
68
+ # @faker.version 1.9.0
29
69
  def vegetables
30
70
  fetch('food.vegetables')
31
71
  end
32
72
 
73
+ ##
33
74
  # Retrieves some random spice
75
+ #
76
+ # @return [String]
77
+ #
78
+ # @example
79
+ # Faker::Food.spice #=> "Garlic Chips"
80
+ #
81
+ # @faker.version 1.7.0
34
82
  def spice
35
83
  fetch('food.spices')
36
84
  end
37
85
 
86
+ ##
38
87
  # Retrieves cooking measures
88
+ #
89
+ # @return [String]
90
+ #
91
+ # @example
92
+ # Faker::Food.measurement #=> "1/3"
93
+ #
94
+ # @faker.version 1.7.0
39
95
  def measurement
40
96
  fetch('food.measurement_sizes') + ' ' + fetch('food.measurements')
41
97
  end
42
98
 
99
+ ##
43
100
  # Retrieves metric mesurements
101
+ #
102
+ # @return [String]
103
+ #
104
+ # @example
105
+ # Faker::Food.metric_measurement #=> "centiliter"
106
+ #
107
+ # @faker.version 1.8.3
44
108
  def metric_measurement
45
109
  fetch('food.metric_measurements')
46
110
  end