faker 2.12.0 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +71 -0
- data/README.md +3 -0
- data/lib/faker.rb +2 -1
- data/lib/faker/default/address.rb +30 -0
- data/lib/faker/default/bank.rb +1 -1
- data/lib/faker/default/blood.rb +3 -3
- data/lib/faker/default/chile_rut.rb +44 -1
- data/lib/faker/default/company.rb +1 -3
- data/lib/faker/default/computer.rb +4 -4
- data/lib/faker/default/date.rb +16 -12
- data/lib/faker/default/gender.rb +1 -1
- data/lib/faker/default/id_number.rb +86 -0
- data/lib/faker/default/internet.rb +35 -7
- data/lib/faker/default/internet_http.rb +48 -0
- data/lib/faker/default/lorem_flickr.rb +65 -0
- data/lib/faker/default/lorem_pixel.rb +22 -0
- data/lib/faker/default/markdown.rb +89 -0
- data/lib/faker/default/name.rb +15 -0
- data/lib/faker/default/nhs.rb +19 -0
- data/lib/faker/default/number.rb +5 -7
- data/lib/faker/default/omniauth.rb +58 -5
- data/lib/faker/default/world_cup.rb +4 -4
- data/lib/faker/games/control.rb +8 -8
- data/lib/faker/games/dnd.rb +4 -4
- data/lib/faker/games/heroes_of_the_storm.rb +16 -5
- data/lib/faker/games/minecraft.rb +48 -0
- data/lib/faker/games/warhammer_fantasy.rb +5 -5
- data/lib/faker/movies/departed.rb +3 -3
- data/lib/faker/movies/movie.rb +13 -0
- data/lib/faker/music/pearl_jam.rb +3 -3
- data/lib/faker/music/phish.rb +2 -2
- data/lib/faker/music/prince.rb +64 -0
- data/lib/faker/music/rush.rb +37 -0
- data/lib/faker/music/show.rb +3 -3
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +13 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
- data/lib/faker/tv_shows/dr_who.rb +1 -1
- data/lib/faker/tv_shows/futurama.rb +65 -0
- data/lib/faker/tv_shows/simpsons.rb +14 -0
- data/lib/faker/tv_shows/suits.rb +2 -2
- data/lib/faker/version.rb +1 -1
- data/lib/helpers/base58.rb +1 -1
- data/lib/helpers/char.rb +20 -26
- data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
- data/lib/locales/en/bank.yml +1 -1
- data/lib/locales/en/big_bang_theory.yml +38 -0
- data/lib/locales/en/futurama.yml +344 -0
- data/lib/locales/en/heroes_of_the_storm.yml +1 -1
- data/lib/locales/en/minecraft.yml +390 -0
- data/lib/locales/en/movie.yml +192 -1
- data/lib/locales/en/name.yml +3 -2
- data/lib/locales/en/prince.yml +227 -0
- data/lib/locales/en/rush.yml +32 -0
- data/lib/locales/en/simpsons.yml +668 -0
- data/lib/locales/en/star_wars.yml +1 -0
- metadata +21 -10
@@ -9,11 +9,14 @@ module Faker
|
|
9
9
|
keywords << :separators if legacy_separators != NOT_GIVEN
|
10
10
|
end
|
11
11
|
|
12
|
-
if separators
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
local_part = if separators
|
13
|
+
username(specifier: name, separators: separators)
|
14
|
+
else
|
15
|
+
username(specifier: name)
|
16
|
+
end
|
17
|
+
|
18
|
+
sanitized_local_part = sanitize_email_local_part(local_part)
|
19
|
+
construct_email(sanitized_local_part, domain_name(domain: domain))
|
17
20
|
end
|
18
21
|
|
19
22
|
def free_email(legacy_name = NOT_GIVEN, name: nil)
|
@@ -21,7 +24,10 @@ module Faker
|
|
21
24
|
keywords << :name if legacy_name != NOT_GIVEN
|
22
25
|
end
|
23
26
|
|
24
|
-
|
27
|
+
construct_email(
|
28
|
+
sanitize_email_local_part(username(specifier: name)),
|
29
|
+
fetch('internet.free_email')
|
30
|
+
)
|
25
31
|
end
|
26
32
|
|
27
33
|
def safe_email(legacy_name = NOT_GIVEN, name: nil)
|
@@ -29,7 +35,10 @@ module Faker
|
|
29
35
|
keywords << :name if legacy_name != NOT_GIVEN
|
30
36
|
end
|
31
37
|
|
32
|
-
|
38
|
+
construct_email(
|
39
|
+
sanitize_email_local_part(username(specifier: name)),
|
40
|
+
'example.' + sample(%w[org com net])
|
41
|
+
)
|
33
42
|
end
|
34
43
|
|
35
44
|
def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _])
|
@@ -325,6 +334,25 @@ module Faker
|
|
325
334
|
end
|
326
335
|
|
327
336
|
alias user_name username
|
337
|
+
|
338
|
+
private
|
339
|
+
|
340
|
+
def sanitize_email_local_part(local_part)
|
341
|
+
char_range = [
|
342
|
+
Array('0'..'9'),
|
343
|
+
Array('A'..'Z'),
|
344
|
+
Array('a'..'z'),
|
345
|
+
"!#$%&'*+-/=?^_`{|}~.".split(//)
|
346
|
+
].flatten
|
347
|
+
|
348
|
+
local_part.split(//).map do |char|
|
349
|
+
char_range.include?(char) ? char : '#'
|
350
|
+
end.join
|
351
|
+
end
|
352
|
+
|
353
|
+
def construct_email(local_part, domain_name)
|
354
|
+
[local_part, domain_name].join('@')
|
355
|
+
end
|
328
356
|
end
|
329
357
|
end
|
330
358
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class Internet
|
5
|
+
class HTTP < Base
|
6
|
+
STATUS_CODES = {
|
7
|
+
information: [100, 101, 102, 103],
|
8
|
+
successful: [200, 201, 202, 203, 204, 205, 206, 207, 208, 226],
|
9
|
+
redirect: [300, 301, 302, 303, 304, 305, 306, 307, 308],
|
10
|
+
client_error: [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412,
|
11
|
+
413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428,
|
12
|
+
429, 431, 451],
|
13
|
+
server_error: [500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511]
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
STATUS_CODES_GROUPS = STATUS_CODES.keys.freeze
|
17
|
+
|
18
|
+
class << self
|
19
|
+
##
|
20
|
+
# Produces an HTTP status code
|
21
|
+
#
|
22
|
+
# @return [Integer]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Internet::HTTP.status_code #=> 418
|
26
|
+
# @example
|
27
|
+
# Faker::Internet::HTTP.status_code(group: :information) #=> 102
|
28
|
+
# @example
|
29
|
+
# Faker::Internet::HTTP.status_code(group: :successful) #=> 200
|
30
|
+
# @example
|
31
|
+
# Faker::Internet::HTTP.status_code(group: :redirect) #=> 306
|
32
|
+
# @example
|
33
|
+
# Faker::Internet::HTTP.status_code(group: :client_error) #=> 451
|
34
|
+
# @example
|
35
|
+
# Faker::Internet::HTTP.status_code(group: :server_error) #=> 502
|
36
|
+
#
|
37
|
+
# @faker.version 2.13.0
|
38
|
+
def status_code(group: nil)
|
39
|
+
return STATUS_CODES[STATUS_CODES_GROUPS.sample].sample unless group
|
40
|
+
|
41
|
+
raise ArgumentError, 'Invalid HTTP status code group' unless STATUS_CODES_GROUPS.include?(group)
|
42
|
+
|
43
|
+
STATUS_CODES[group].sample
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -5,6 +5,22 @@ module Faker
|
|
5
5
|
class << self
|
6
6
|
SUPPORTED_COLORIZATIONS = %w[red green blue].freeze
|
7
7
|
|
8
|
+
##
|
9
|
+
# Produces a random image URL from loremflickr.com.
|
10
|
+
#
|
11
|
+
# @param size [String] Specifies the size of image to generate.
|
12
|
+
# @param search_terms [Array<String>] Adds search terms to the image URL.
|
13
|
+
# @param match_all [Boolean] Add "all" as part of the URL.
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# Faker::LoremFlickr.image #=> "https://loremflickr.com/300/300"
|
18
|
+
# Faker::LoremFlickr.image(size: "50x60") #=> "https://loremflickr.com/50/60"
|
19
|
+
# Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/50/60/sports"
|
20
|
+
# Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/50/60/sports,fitness"
|
21
|
+
# Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/50/60/sports,fitness/all"
|
22
|
+
#
|
23
|
+
# @faker.version 1.9.0
|
8
24
|
# rubocop:disable Metrics/ParameterLists
|
9
25
|
def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false)
|
10
26
|
# rubocop:enable Metrics/ParameterLists
|
@@ -17,6 +33,22 @@ module Faker
|
|
17
33
|
build_url(size, nil, search_terms, match_all)
|
18
34
|
end
|
19
35
|
|
36
|
+
##
|
37
|
+
# Produces a random grayscale image URL from loremflickr.com.
|
38
|
+
#
|
39
|
+
# @param size [String] Specifies the size of image to generate.
|
40
|
+
# @param search_terms [Array<String>] Adds search terms to the image URL.
|
41
|
+
# @param match_all [Boolean] Add "all" as part of the URL.
|
42
|
+
# @return [String]
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# Faker::LoremFlickr.grayscale_image #=> "https://loremflickr.com/g/300/300/all"
|
46
|
+
# Faker::LoremFlickr.grayscale_image(size: "50x60") #=> "https://loremflickr.com/g/50/60/all"
|
47
|
+
# Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/g/50/60/sports"
|
48
|
+
# Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/50/60/g/sports,fitness"
|
49
|
+
# Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/g/50/60/sports,fitness/all"
|
50
|
+
#
|
51
|
+
# @faker.version 1.9.0
|
20
52
|
# rubocop:disable Metrics/ParameterLists
|
21
53
|
def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
|
22
54
|
# rubocop:enable Metrics/ParameterLists
|
@@ -31,6 +63,22 @@ module Faker
|
|
31
63
|
build_url(size, 'g', search_terms, match_all)
|
32
64
|
end
|
33
65
|
|
66
|
+
##
|
67
|
+
# Produces a random pixelated image URL from loremflickr.com.
|
68
|
+
#
|
69
|
+
# @param size [String] Specifies the size of image to generate.
|
70
|
+
# @param search_terms [Array<String>] Adds search terms to the image URL.
|
71
|
+
# @param match_all [Boolean] Add "all" as part of the URL.
|
72
|
+
# @return [String]
|
73
|
+
#
|
74
|
+
# @example
|
75
|
+
# Faker::LoremFlickr.pixelated_image #=> "https://loremflickr.com/p/300/300/all"
|
76
|
+
# Faker::LoremFlickr.pixelated_image(size: "50x60") #=> "https://loremflickr.com/p/50/60/all"
|
77
|
+
# Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/p/50/60/sports"
|
78
|
+
# Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/p/50/60/sports,fitness"
|
79
|
+
# Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/p/50/60/sports,fitness/all"
|
80
|
+
#
|
81
|
+
# @faker.version 1.9.0
|
34
82
|
# rubocop:disable Metrics/ParameterLists
|
35
83
|
def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
|
36
84
|
# rubocop:enable Metrics/ParameterLists
|
@@ -45,6 +93,23 @@ module Faker
|
|
45
93
|
build_url(size, 'p', search_terms, match_all)
|
46
94
|
end
|
47
95
|
|
96
|
+
##
|
97
|
+
# Produces a random colorized image URL from loremflickr.com.
|
98
|
+
#
|
99
|
+
# @param size [String] Specifies the size of image to generate.
|
100
|
+
# @param color [String] Specifies the color of image to generate.
|
101
|
+
# @param search_terms [Array<String>] Adds search terms to the image URL.
|
102
|
+
# @param match_all [Boolean] Add "all" as part of the URL.
|
103
|
+
# @return [String]
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
# Faker::LoremFlickr.image #=> "https://loremflickr.com/red/300/300/all"
|
107
|
+
# Faker::LoremFlickr.image(size: "50x60", color: 'blue') #=> "https://loremflickr.com/blue/50/60/all"
|
108
|
+
# Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports']) #=> "https://loremflickr.com/blue/50/60/sports"
|
109
|
+
# Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/blue/50/60/sports,fitness"
|
110
|
+
# Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/blue/50/60/sports,fitness/all"
|
111
|
+
#
|
112
|
+
# @faker.version 1.9.0
|
48
113
|
# rubocop:disable Metrics/ParameterLists
|
49
114
|
def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
|
50
115
|
# rubocop:enable Metrics/ParameterLists
|
@@ -17,6 +17,28 @@ module Faker
|
|
17
17
|
technics
|
18
18
|
transport].freeze
|
19
19
|
|
20
|
+
##
|
21
|
+
# Produces a random image URL from lorempixel.com.
|
22
|
+
#
|
23
|
+
# @param size [String] Specifies the size of image to generate.
|
24
|
+
# @param is_gray [Boolean] Determines if the image is gray.
|
25
|
+
# @param category [Symbol] Adds the category of the generated image to the URL.
|
26
|
+
# @param number [Integer] Adds a number as part of the URL.
|
27
|
+
# @param text [Integer] Adds dummy text as part of the URL.
|
28
|
+
# @param secure [Boolean] Changes the image URL between http and https.
|
29
|
+
# @return [String]
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# Faker::LoremPixel.image #=> "https://lorempixel.com/300/300"
|
33
|
+
# Faker::LoremPixel.image(size: "50x60") #=> "https://lorempixel.com/50/60"
|
34
|
+
# Faker::LoremPixel.image(size: "50x60", is_gray: true) #=> "https://lorempixel.com/g/50/60"
|
35
|
+
# Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports') #=> "https://lorempixel.com/50/60/sports"
|
36
|
+
# Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: 3) #=> "https://lorempixel.com/50/60/sports/3"
|
37
|
+
# Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: 3, text: 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/3/Dummy-text"
|
38
|
+
# Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: nil, text: 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/Dummy-text"
|
39
|
+
# Faker::LoremPixel.image(secure: false) #=> "http://lorempixel.com/300/300"
|
40
|
+
#
|
41
|
+
# @faker.version 1.7.0
|
20
42
|
# rubocop:disable Metrics/ParameterLists
|
21
43
|
def image(legacy_size = NOT_GIVEN, legacy_is_gray = NOT_GIVEN, legacy_category = NOT_GIVEN, legacy_number = NOT_GIVEN, legacy_text = NOT_GIVEN, legacy_secure = NOT_GIVEN, size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true)
|
22
44
|
warn_for_deprecated_arguments do |keywords|
|
@@ -3,10 +3,28 @@
|
|
3
3
|
module Faker
|
4
4
|
class Markdown < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a random header format.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Markdown.headers #=> "##### Autem"
|
13
|
+
#
|
14
|
+
# @faker.version 1.8.0
|
6
15
|
def headers
|
7
16
|
"#{fetch('markdown.headers')} #{Lorem.word.capitalize}"
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces a random emphasis formatting on a random word in two sentences.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Markdown.emphasis #=> "_Incidunt atque quis repellat id impedit. Quas numquam quod incidunt dicta non. Blanditiis delectus laudantium atque reiciendis qui._"
|
26
|
+
#
|
27
|
+
# @faker.version 1.8.0
|
10
28
|
def emphasis
|
11
29
|
paragraph = Faker::Lorem.paragraph(sentence_count: 3)
|
12
30
|
words = paragraph.split(' ')
|
@@ -16,6 +34,15 @@ module Faker
|
|
16
34
|
words.join(' ')
|
17
35
|
end
|
18
36
|
|
37
|
+
##
|
38
|
+
# Produces a random ordered list of items between 1 and 10 randomly.
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# Faker::Markdown.ordered_list #=> "1. Qui reiciendis non consequatur atque.\n2. Quo doloremque veritatis tempora aut.\n3. Aspernatur.\n4. Ea ab.\n5. Qui.\n6. Sit pariatur nemo eveniet.\n7. Molestiae aut.\n8. Nihil molestias iure placeat.\n9. Dolore autem quisquam."
|
44
|
+
#
|
45
|
+
# @faker.version 1.8.0
|
19
46
|
def ordered_list
|
20
47
|
number = rand(1..10)
|
21
48
|
|
@@ -26,6 +53,15 @@ module Faker
|
|
26
53
|
result.join('')
|
27
54
|
end
|
28
55
|
|
56
|
+
##
|
57
|
+
# Produces a random unordered list of items between 1 and 10 randomly.
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
# Faker::Markdown.unordered_list #=> "* Voluptatum aliquid tempora molestiae facilis non sed.\n* Nostrum omnis iste impedit voluptatum dolor.\n* Esse quidem et facere."
|
63
|
+
#
|
64
|
+
# @faker.version 1.8.0
|
29
65
|
def unordered_list
|
30
66
|
number = rand(1..10)
|
31
67
|
|
@@ -36,14 +72,41 @@ module Faker
|
|
36
72
|
result.join('')
|
37
73
|
end
|
38
74
|
|
75
|
+
##
|
76
|
+
# Produces a random inline code snippet between two sentences.
|
77
|
+
#
|
78
|
+
# @return [String]
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# Faker::Markdown.inline_code #=> "Aut eos quis suscipit. `Dignissimos voluptatem expedita qui.` Quo doloremque veritatis tempora aut."
|
82
|
+
#
|
83
|
+
# @faker.version 1.8.0
|
39
84
|
def inline_code
|
40
85
|
"`#{Faker::Lorem.sentence(word_count: 1)}`"
|
41
86
|
end
|
42
87
|
|
88
|
+
##
|
89
|
+
# Produces a random code block formatted in Ruby.
|
90
|
+
#
|
91
|
+
# @return [String]
|
92
|
+
#
|
93
|
+
# @example
|
94
|
+
# Faker::Markdown.block_code #=> "```ruby\nEos quasi qui.\n```"
|
95
|
+
#
|
96
|
+
# @faker.version 1.8.0
|
43
97
|
def block_code
|
44
98
|
"```ruby\n#{Lorem.sentence(word_count: 1)}\n```"
|
45
99
|
end
|
46
100
|
|
101
|
+
##
|
102
|
+
# Produces a random 3x4 table with a row of headings, a row of hyphens and two rows of data
|
103
|
+
#
|
104
|
+
# @return [String]
|
105
|
+
#
|
106
|
+
# @example
|
107
|
+
# Faker::Markdown.table #=> "ad | similique | voluptatem\n---- | ---- | ----\ncorrupti | est | rerum\nmolestiae | quidem | et"
|
108
|
+
#
|
109
|
+
# @faker.version 1.8.0
|
47
110
|
def table
|
48
111
|
table = []
|
49
112
|
3.times do
|
@@ -53,12 +116,38 @@ module Faker
|
|
53
116
|
table.join("\n")
|
54
117
|
end
|
55
118
|
|
119
|
+
##
|
120
|
+
# Produces a random method from the methods above or the methods listed in the arguments.
|
121
|
+
#
|
122
|
+
# @param methods [Symbol] Specify which methods to use.
|
123
|
+
# @return [String, Array<String>]
|
124
|
+
#
|
125
|
+
# @example
|
126
|
+
# Faker::Markdown.random #=> returns output from a single method outlined above
|
127
|
+
# Faker::Markdown.random("table") #=> returns output from any single method outlined above except for "table"
|
128
|
+
# Faker::Markdown.random("ordered_list", "unordered_list") #=> returns output from any single method outlined above except for either ordered_list and unordered_list
|
129
|
+
#
|
130
|
+
# @faker.version 1.8.0
|
56
131
|
def random(*args)
|
57
132
|
method_list = available_methods
|
58
133
|
args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
|
59
134
|
send(method_list[rand(0..method_list.length - 1)])
|
60
135
|
end
|
61
136
|
|
137
|
+
##
|
138
|
+
# Produces a simulated blog-esque text-heavy block in markdown
|
139
|
+
#
|
140
|
+
# Keyword arguments: sentences, repeat
|
141
|
+
# @param sentences [Integer] Specifies how many sentences make a text block.
|
142
|
+
# @param repeat [Integer] Specifies how many times the text block repeats.
|
143
|
+
# @return [String]
|
144
|
+
#
|
145
|
+
# @example
|
146
|
+
# Faker::Markdown.sandwich #=> returns newline separated content of 1 header, 1 default lorem paragraph, and 1 random markdown element
|
147
|
+
# Faker::Markdown.sandwich(sentences: 5) #=> returns newline separated content of 1 header, 1 5-sentence lorem paragraph, and 1 random markdown element
|
148
|
+
# Faker::Markdown.sandwich(sentences: 6, repeat: 3) #=> returns newline separated content of 1 header, and then 3 sections consisting of, here, 1 6-sentence lorem paragraph and 1 random markdown element. The random markdown element is chosen at random in each iteration of the paragraph-markdown pairing.
|
149
|
+
#
|
150
|
+
# @faker.version 1.8.0
|
62
151
|
def sandwich(legacy_sentences = NOT_GIVEN, legacy_repeat = NOT_GIVEN, sentences: 3, repeat: 1)
|
63
152
|
warn_for_deprecated_arguments do |keywords|
|
64
153
|
keywords << :sentences if legacy_sentences != NOT_GIVEN
|
data/lib/faker/default/name.rb
CHANGED
@@ -78,6 +78,21 @@ module Faker
|
|
78
78
|
alias first_name_women female_first_name
|
79
79
|
alias feminine_name female_first_name
|
80
80
|
|
81
|
+
##
|
82
|
+
# Produces a random gender neutral first name.
|
83
|
+
#
|
84
|
+
# @return [String]
|
85
|
+
#
|
86
|
+
# @example
|
87
|
+
# Faker::Name.neutral_first_name #=> "Casey"
|
88
|
+
#
|
89
|
+
# @faker.version 2.13.0
|
90
|
+
def neutral_first_name
|
91
|
+
fetch('name.neutral_first_name')
|
92
|
+
end
|
93
|
+
alias first_name_neutral neutral_first_name
|
94
|
+
alias gender_neutral_first_name neutral_first_name
|
95
|
+
|
81
96
|
##
|
82
97
|
# Produces a random last name.
|
83
98
|
#
|
data/lib/faker/default/nhs.rb
CHANGED
@@ -3,6 +3,15 @@
|
|
3
3
|
module Faker
|
4
4
|
class NationalHealthService < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a random British NHS number.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::NationalHealthService.british_number #=> "403 958 5577"
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.2
|
6
15
|
def british_number
|
7
16
|
base_number = rand(400_000_001...499_999_999)
|
8
17
|
# If the check digit is equivalent to 10, the number is invalid.
|
@@ -15,6 +24,16 @@ module Faker
|
|
15
24
|
.join('')
|
16
25
|
end
|
17
26
|
|
27
|
+
##
|
28
|
+
# Produces a random British NHS number's check digit.
|
29
|
+
#
|
30
|
+
# @param number [Integer] Specifies the NHS number the check digit belongs to.
|
31
|
+
# @return [Integer]
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6
|
35
|
+
#
|
36
|
+
# @faker.version 1.9.2
|
18
37
|
def check_digit(legacy_number = NOT_GIVEN, number: 0)
|
19
38
|
warn_for_deprecated_arguments do |keywords|
|
20
39
|
keywords << :number if legacy_number != NOT_GIVEN
|
data/lib/faker/default/number.rb
CHANGED
@@ -85,13 +85,11 @@ module Faker
|
|
85
85
|
end
|
86
86
|
|
87
87
|
l_d = number(digits: l_digits)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
generate(r_digits - 1).join + non_zero_digit.to_s
|
94
|
-
end
|
88
|
+
|
89
|
+
# Ensure the last digit is not zero
|
90
|
+
# so it does not get truncated on converting to float
|
91
|
+
r_d = generate(r_digits - 1).join + non_zero_digit.to_s
|
92
|
+
|
95
93
|
"#{l_d}.#{r_d}".to_f
|
96
94
|
end
|
97
95
|
|