repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/omniauth.rb
lib/faker/default/omniauth.rb
# frozen_string_literal: true module Faker class Omniauth < Base require 'time' attr_reader :name, :first_name, :last_name, :email def initialize(name: nil, email: nil) super() @name = name || "#{Name.first_name} #{Name.last_name}" @email = email || Internet.email(name: self.name) @first_name, @last_name = self.name.split end class << self ## # Generate a mock Omniauth response from Google. # # @param name [String] A specific name to return in the response. # @param email [String] A specific email to return in the response. # @param uid [String] A specific UID to return in the response. # # @return [Hash] An auth hash in the format provided by omniauth-google. # # @faker.version 1.8.0 def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s) auth = Omniauth.new(name: name, email: email) { provider: 'google_oauth2', uid: uid, info: { name: auth.name, first_name: auth.first_name, last_name: auth.last_name, email: auth.email, image: image }, credentials: { token: Crypto.md5, refresh_token: Crypto.md5, expires_at: Time.forward.to_i, expires: true }, extra: { raw_info: { sub: uid, email: auth.email, email_verified: random_boolean.to_s, name: auth.name, given_name: auth.first_name, family_name: auth.last_name, profile: "https://plus.google.com/#{uid}", picture: image, gender: gender, birthday: Date.backward(days: 36_400).strftime('%Y-%m-%d'), locale: 'en', hd: "#{Company.name.downcase}.com" }, id_info: { iss: 'accounts.google.com', at_hash: Crypto.md5, email_verified: true, sub: Number.number(digits: 28).to_s, azp: 'APP_ID', email: auth.email, aud: 'APP_ID', iat: Time.forward.to_i, exp: Time.forward.to_i, openid_id: "https://www.google.com/accounts/o8/id?id=#{uid}" } } } end ## # Generate a mock Omniauth response from Facebook. # # @param name [String] A specific name to return in the response. # @param email [String] A specific email to return in the response. # @param username [String] A specific username to return in the response. # @param uid [String] A specific UID to return in the response. # # @return [Hash] An auth hash in the format provided by omniauth-facebook. # # @faker.version 1.8.0 def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s) auth = Omniauth.new(name: name, email: email) username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}" { provider: 'facebook', uid: uid, info: { email: auth.email, name: auth.name, first_name: auth.first_name, last_name: auth.last_name, image: image, verified: random_boolean }, credentials: { token: Crypto.md5, expires_at: Time.forward.to_i, expires: true }, extra: { raw_info: { id: uid, name: auth.name, first_name: auth.first_name, last_name: auth.last_name, link: "http://www.facebook.com/#{username}", username: username, location: { id: Number.number(digits: 9).to_s, name: city_state }, gender: gender, email: auth.email, timezone: timezone, locale: 'en_US', verified: random_boolean, updated_time: Time.backward.iso8601 } } } end ## # Generate a mock Omniauth response from Twitter. # # @param name [String] A specific name to return in the response. # @param nickname [String] A specific nickname to return in the response. # @param uid [String] A specific UID to return in the response. # # @return [Hash] An auth hash in the format provided by omniauth-twitter. # # @faker.version 1.8.0 def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s) auth = Omniauth.new(name: name) nickname ||= auth.name.downcase.delete(' ') location = city_state description = Lorem.sentence { provider: 'twitter', uid: uid, info: { nickname: nickname, name: auth.name, location: location, image: image, description: description, urls: { Website: nil, Twitter: "https://twitter.com/#{nickname}" } }, credentials: { token: Crypto.md5, secret: Crypto.md5 }, extra: { access_token: '', raw_info: { name: auth.name, listed_count: random_number_from_range(1..10), profile_sidebar_border_color: Color.hex_color, url: nil, lang: 'en', statuses_count: random_number_from_range(1..1000), profile_image_url: image, profile_background_image_url_https: image, location: location, time_zone: Address.city, follow_request_sent: random_boolean, id: uid, profile_background_tile: random_boolean, profile_sidebar_fill_color: Color.hex_color, followers_count: random_number_from_range(1..10_000), default_profile_image: random_boolean, screen_name: '', following: random_boolean, utc_offset: timezone, verified: random_boolean, favourites_count: random_number_from_range(1..10), profile_background_color: Color.hex_color, is_translator: random_boolean, friends_count: random_number_from_range(1..10_000), notifications: random_boolean, geo_enabled: random_boolean, profile_background_image_url: image, protected: random_boolean, description: description, profile_link_color: Color.hex_color, created_at: Time.backward.strftime('%a %b %d %H:%M:%S %z %Y'), id_str: uid, profile_image_url_https: image, default_profile: random_boolean, profile_use_background_image: random_boolean, entities: { description: { urls: [] } }, profile_text_color: Color.hex_color, contributors_enabled: random_boolean } } } end ## # Generate a mock Omniauth response from LinkedIn. # # @param name [String] A specific name to return in the response. # @param email [String] A specific email to return in the response. # @param uid [String] A specific UID to return in the response. # # @return [Hash] An auth hash in the format provided by omniauth-linkedin. # # @faker.version 1.8.0 def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s) auth = Omniauth.new(name: name, email: email) first_name = auth.first_name.downcase last_name = auth.last_name.downcase location = city_state description = Lorem.sentence token = Crypto.md5 secret = Crypto.md5 industry = Commerce.department url = "http://www.linkedin.com/in/#{first_name}#{last_name}" { provider: 'linkedin', uid: uid, info: { name: auth.name, email: auth.email, nickname: auth.name, first_name: auth.first_name, last_name: auth.last_name, location: location, description: description, image: image, phone: PhoneNumber.phone_number, headline: description, industry: industry, urls: { public_profile: url } }, credentials: { token: token, secret: secret }, extra: { access_token: { token: token, secret: secret, consumer: nil, params: { oauth_token: token, oauth_token_secret: secret, oauth_expires_in: Time.forward.to_i, oauth_authorization_expires_in: Time.forward.to_i }, response: nil }, raw_info: { firstName: auth.first_name, headline: description, id: uid, industry: industry, lastName: auth.last_name, location: { country: { code: Address.country_code.downcase }, name: city_state.split(', ').first }, pictureUrl: image, publicProfileUrl: url } } } end ## # Generate a mock Omniauth response from Github. # # @param name [String] A specific name to return in the response. # @param email [String] A specific email to return in the response. # @param uid [String] A specific UID to return in the response. # # @return [Hash] An auth hash in the format provided by omniauth-github. # # @faker.version 1.8.0 def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s) auth = Omniauth.new(name: name, email: email) login = auth.name.downcase.tr(' ', '-') html_url = "https://github.com/#{login}" api_url = "https://api.github.com/users/#{login}" { provider: 'github', uid: uid, info: { nickname: login, email: auth.email, name: auth.name, image: image, urls: { GitHub: html_url } }, credentials: { token: Crypto.md5, expires: false }, extra: { raw_info: { login: login, id: uid, avatar_url: image, gravatar_id: '', url: api_url, html_url: html_url, followers_url: "#{api_url}/followers", following_url: "#{api_url}/following{/other_user}", gists_url: "#{api_url}/gists{/gist_id}", starred_url: "#{api_url}/starred{/owner}{/repo}", subscriptions_url: "#{api_url}/subscriptions", organizations_url: "#{api_url}/orgs", repos_url: "#{api_url}/repos", events_url: "#{api_url}/events{/privacy}", received_events_url: "#{api_url}/received_events", type: 'User', site_admin: random_boolean, name: auth.name, company: nil, blog: nil, location: city_state, email: auth.email, hireable: nil, bio: nil, public_repos: random_number_from_range(1..1000), public_gists: random_number_from_range(1..1000), followers: random_number_from_range(1..1000), following: random_number_from_range(1..1000), created_at: Time.backward(days: 36_400).iso8601, updated_at: Time.backward(days: 2).iso8601 } } } end ## # Generate a mock Omniauth response from Apple. # # @param name [String] A specific name to return in the response. # @param email [String] A specific email to return in the response. # @param uid [String] A specific UID to return in the response. # # @return [Hash] An auth hash in the format provided by omniauth-apple. # # @faker.version 2.3.0 def apple(name: nil, email: nil, uid: nil) uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}" auth = Omniauth.new(name: name, email: email) { provider: 'apple', uid: uid, info: { sub: uid, email: auth.email, first_name: auth.first_name, last_name: auth.last_name }, credentials: { token: Crypto.md5, refresh_token: Crypto.md5, expires_at: Time.forward.to_i, expires: true }, extra: { raw_info: { iss: 'https://appleid.apple.com', aud: 'CLIENT_ID', exp: Time.forward.to_i, iat: Time.forward.to_i, sub: uid, at_hash: Crypto.md5, auth_time: Time.forward.to_i, email: auth.email, email_verified: true } } } end ## # Generate a mock Omniauth response from Auth0. # # @param name [String] A specific name to return in the response. # @param email [String] A specific email to return in the response. # @param uid [String] A specific UID to return in the response. # # @return [Hash] An auth hash in the format provided by omniauth-auth0. # # @faker.version next def auth0(name: nil, email: nil, uid: nil) uid ||= "auth0|#{Number.hexadecimal(digits: 24)}" auth = Omniauth.new(name: name, email: email) { provider: 'auth0', uid: uid, info: { name: uid, nickname: auth.name, email: auth.email, image: image }, credentials: { expires_at: Time.forward.to_i, expires: true, token_type: 'Bearer', id_token: Crypto.sha256, token: Crypto.md5, refresh_token: Crypto.md5 }, extra: { raw_info: { email: auth.email, email_verified: true, iss: 'https://auth0.com/', sub: uid, aud: 'Auth012345', iat: Time.forward.to_i, exp: Time.forward.to_i } } } end private def gender sample(%w[male female]) end def timezone sample((-12..12).to_a) end def image Placeholdit.image end def city_state "#{Address.city}, #{Address.state}" end def random_number_from_range(range) sample(range.to_a) end def random_boolean sample([true, false]) end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/hobby.rb
lib/faker/default/hobby.rb
# frozen_string_literal: true module Faker class Hobby < Base flexible :hobby class << self ## # Retrieves a typical hobby activity. # # @return [String] # # @example # Faker::Hobby.activity #=> "Cooking" # # @faker.version next def activity fetch('hobby.activity') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/name.rb
lib/faker/default/name.rb
# frozen_string_literal: true module Faker class Name < Base flexible :name class << self ## # Produces a random name. # # @return [String] # # @example # Faker::Name.name #=> "Tyshawn Johns Sr." # # @faker.version 0.9.0 def name parse('name.name') end ## # Produces a random name with middle name. # # @return [String] # # @example # Faker::Name.name_with_middle #=> "Aditya Elton Douglas" # # @faker.version 1.6.4 def name_with_middle parse('name.name_with_middle') end ## # Produces a random first name. # # @return [String] # # @example # Faker::Name.first_name #=> "Kaci" # # @faker.version 0.9.0 def first_name if parse('name.first_name').empty? fetch('name.first_name') else parse('name.first_name') end end ## # Produces a random male first name. # # @return [String] # # @example # Faker::Name.male_first_name #=> "Edward" # # @faker.version 1.9.1 def male_first_name fetch('name.male_first_name') end alias first_name_men male_first_name alias masculine_name male_first_name ## # Produces a random female first name. # # @return [String] # # @example # Faker::Name.female_first_name #=> "Natasha" # # @faker.version 1.9.1 def female_first_name fetch('name.female_first_name') end alias first_name_women female_first_name alias feminine_name female_first_name ## # Produces a random gender neutral first name. # # @return [String] # # @example # Faker::Name.neutral_first_name #=> "Casey" # # @faker.version 2.13.0 def neutral_first_name fetch('name.neutral_first_name') end alias first_name_neutral neutral_first_name alias gender_neutral_first_name neutral_first_name ## # Produces a random last name. # # @return [String] # # @example # Faker::Name.last_name #=> "Ernser" # # @faker.version 0.9.0 def last_name parse('name.last_name') end alias middle_name last_name ## # Produces a random name prefix. # # @return [String] # # @example # Faker::Name.prefix #=> "Mr." # # @faker.version 0.9.0 def prefix fetch('name.prefix') end ## # Produces a random name suffix. # # @return [String] # # @example # Faker::Name.suffix #=> "IV" # # @faker.version 0.9.0 def suffix fetch('name.suffix') end ## # Produces random initials. # # @param number [Integer] Number of digits that the generated initials should have. # @return [String] # # @example # Faker::Name.initials #=> "NJM" # Faker::Name.initials(number: 2) #=> "NM" # # @faker.version 1.8.5 def initials(number: 3) (0...number).map { rand(65..90).chr }.join end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/number.rb
lib/faker/default/number.rb
# frozen_string_literal: true module Faker class Number < Base class << self ## # Produce a random number. # # @param digits [Integer] Number of digits that the generated number should have. # @return [Integer] # # @example # Faker::Number.number(digits: 10) #=> 1968353479 # # @faker.version 1.0.0 def number(digits: 10) return if digits < 1 return rand(0..9).round if digits == 1 # Ensure the first digit is not zero ([non_zero_digit] + generate(digits - 1)).join.to_i end ## # Produce a random number with a leading zero. # # @param digits [Integer] Number of digits that the generated number should have. # @return [String] # # @example # Faker::Number.leading_zero_number(digits: 10) #=> "0669336915" # # @faker.version 1.0.0 def leading_zero_number(digits: 10) "0#{(2..digits).collect { digit }.join}" end ## # Produce a number with a number of digits, preserves leading zeroes. # # @param digits [Integer] Number of digits that the generated number should have. # @return [String] # # @example # Faker::Number.decimal_part(digits: 2) #=> "09" # # @faker.version 1.0.0 def decimal_part(digits: 10) num = '' if digits > 1 num = non_zero_digit digits -= 1 end leading_zero_number(digits: digits) + num.to_s end ## # Produces a float. # # @param l_digits [Integer] Number of digits that the generated decimal should have to the left of the decimal point. # @param r_digits [Integer] Number of digits that the generated decimal should have to the right of the decimal point. # @return [Float] # # @example # Faker::Number.decimal(l_digits: 2) #=> 11.88 # Faker::Number.decimal(l_digits: 3, r_digits: 3) #=> 181.843 # # @faker.version 1.0.0 def decimal(l_digits: 5, r_digits: 2) l_d = number(digits: l_digits) # Ensure the last digit is not zero # so it does not get truncated on converting to float r_d = generate(r_digits - 1).join + non_zero_digit.to_s "#{l_d}.#{r_d}".to_f end ## # Produces a non-zero single-digit integer. # # @return [Integer] # # @example # Faker::Number.non_zero_digit #=> 8 # # @faker.version 1.0.0 def non_zero_digit rand(1..9) end ## # Produces a single-digit integer. # # @return [Integer] # # @example # Faker::Number.digit #=> 1 # # @faker.version 1.0.0 def digit rand(10) end ## # Produces a number in hexadecimal format. # # @param digits [Integer] Number of digits in the he # @return [String] # # @example # Faker::Number.hexadecimal(digits: 3) #=> "e74" # # @faker.version 1.0.0 def hexadecimal(digits: 6) hex = '' digits.times { hex += rand(16).to_s(16) } hex end # Produces a number in binary format. # # @param digits [Integer] Number of digits to generate the binary as string # @return [String] # # @example # Faker::Number.binary(digits: 4) #=> "1001" # # @faker.version next def binary(digits: 4) bin = '' digits.times { bin += rand(2).to_s(2) } bin end ## # Produces a float given a mean and standard deviation. # # @param mean [Integer] # @param standard_deviation [Numeric] # @return [Float] # # @example # Faker::Number.normal(mean: 50, standard_deviation: 3.5) #=> 47.14669604069156 # # @faker.version 1.0.0 def normal(mean: 1, standard_deviation: 1) theta = 2 * Math::PI * rand rho = Math.sqrt(-2 * Math.log(1 - rand)) scale = standard_deviation * rho mean + scale * Math.cos(theta) end ## # Produces a number between two provided values. Boundaries are inclusive. # # @param from [Numeric] The lowest number to include. # @param to [Numeric] The highest number to include. # @return [Numeric] # # @example # Faker::Number.between(from: 1, to: 10) #=> 7 # Faker::Number.between(from: 0.0, to: 1.0) #=> 0.7844640543957383 # # @faker.version 1.0.0 def between(from: 1.00, to: 5000.00) Faker::Base.rand_in_range(from, to) end ## # Produces a number within two provided values. Boundaries are inclusive or exclusive depending on the range passed. # # @param range [Range] The range from which to generate a number. # @return [Numeric] # # @example # Faker::Number.within(range: 1..10) #=> 7 # Faker::Number.within(range: 0.0..1.0) #=> 0.7844640543957383 # # @faker.version 1.0.0 def within(range: 1.00..5000.00) between(from: range.min, to: range.max) end ## # Produces a positive float. # # @param from [Integer] The lower boundary. # @param to [Integer] The higher boundary. # @return [Float] # # @example # Faker::Number.positive #=> 235.59238499107653 # # @faker.version 1.0.0 def positive(from: 1.00, to: 5000.00) random_number = between(from: from, to: to) greater_than_zero(random_number) end ## # Produces a negative float. # # @param from [Integer] The lower boundary. # @param to [Integer] The higher boundary. # @return [Float] # # @example # Faker::Number.negative #=> -4480.042585669558 # # @faker.version 1.0.0 def negative(from: -5000.00, to: -1.00) random_number = between(from: from, to: to) less_than_zero(random_number) end private def generate(count) return [] if count.zero? Array.new(count) { digit } end def greater_than_zero(number) should_be(number, :>) end def less_than_zero(number) should_be(number, :<) end def should_be(number, method_to_compare) if number.send(method_to_compare, 0) number else number * -1 end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/ancient.rb
lib/faker/default/ancient.rb
# frozen_string_literal: true module Faker class Ancient < Base class << self ## # Produces a god from ancient mythology. # # @return [String] # # @example # Faker::Ancient.god #=> "Zeus" # # @faker.version 1.7.0 def god fetch('ancient.god') end ## # Produces a primordial from ancient mythology. # # @return [String] # # @example # Faker::Ancient.primordial #=> "Gaia" # # @faker.version 1.7.0 def primordial fetch('ancient.primordial') end ## # Produces a titan from ancient mythology. # # @return [String] # # @example # Faker::Ancient.titan #=> "Atlas" # # @faker.version 1.7.0 def titan fetch('ancient.titan') end ## # Produces a hero from ancient mythology. # # @return [String] # # @example # Faker::Ancient.hero #=> "Achilles" # # @faker.version 1.7.0 def hero fetch('ancient.hero') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/gender.rb
lib/faker/default/gender.rb
# frozen_string_literal: true module Faker class Gender < Base class << self ## # Produces the name of a gender identity. # # @return [String] # # @example # Faker::Gender.type #=> "Non-binary" # # @faker.version 1.9.0 def type fetch('gender.types') end ## # Produces either 'Male' or 'Female'. # # @return [String] # # @example # Faker::Gender.binary_type #=> "Female" # # @faker.version 1.9.0 def binary_type fetch('gender.binary_types') end ## # Produces either 'f' or 'm'. # # @return [String] # # @example # Faker::Gender.short_binary_type #=> "f" # # @faker.version 2.13.0 def short_binary_type fetch('gender.short_binary_types') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/string.rb
lib/faker/default/string.rb
# frozen_string_literal: true module Faker class String < Base class << self ## # Produces a random UTF-8 string with optional nested length selectors. # # @param length [Integer, Range, Array<Integer, Range, nil>] The length of produced string and/or specific UTF-8 characters to use. # @return [String] # # @example # Faker::String.random #=> "3 뇦\u0017&y\u{3A109}$8^4* 녹豿4좘툢ꔾ쉙6ɉ\uA6 8TN畀챵|\"3쇤Ŵ" # Faker::String.random(length: 4) #=> "⼨%0*" # Faker::String.random(length: 3..12) #=> "\u{69FDC};秨툫" # Faker::String.random(length: [0, 6]) #=> "I轤𣴒P溟L" # Faker::String.random(length: [1, (2..5), [3, 6], nil]) #=> "葓L#ћ" # # @faker.version 1.9.0 def random(length: 32) utf8string select_a length end private def select_a(length) if length.class.included_modules.include? Enumerable select_a sample(length.to_enum.to_a) else length # recursive base case end end def utf8string(length) ratio = char_space_ratio (1..length.to_i).map do space_or_utf8_char ratio end.join end def space_or_utf8_char(ratio) sample [32.chr(Encoding::UTF_8), [utf8character] * ratio].flatten end def char_space_ratio sample [2, [3] * 5, [5] * 17, [7] * 11, 11, 191].flatten end def utf8character sample([ rand(32..90), # latin alphabet rand(128), # 7-bit ASCII rand(0xd800), # utf-8 codepoints below utf-16 surrogate halves rand(57_344..1_114_111) # utf-8 codepoints above utf-16 surrogate halves ]).chr(Encoding::UTF_8) end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/appliance.rb
lib/faker/default/appliance.rb
# frozen_string_literal: true module Faker class Appliance < Base class << self ## # Produces the name of an appliance brand. # # @return [String] # # @example # Faker::Appliance.brand #=> "Bosch" # # @faker.version 1.9.0 def brand fetch('appliance.brand') end ## # Produces the name of a type of appliance equipment. # # @return [String] # # @example # Faker::Appliance.equipment #=> "Appliance plug" # # @faker.version 1.9.0 def equipment fetch('appliance.equipment') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/cosmere.rb
lib/faker/default/cosmere.rb
# frozen_string_literal: true module Faker class Cosmere < Base flexible :cosmere class << self ## # Produces a random aon. # # @return [String] # # @example # Faker::Cosmere.aon #=> "Rao" # # @faker.version 1.9.2 def aon sample(aons) end ## # Produces a random shard world. # # @return [String] # # @example # Faker::Cosmere.shard_world #=> "Yolen" # # @faker.version 1.9.2 def shard_world sample(shard_worlds) end ## # Produces a random shard. # # @return [String] # # @example # Faker::Cosmere.shard #=> "Ambition" # # @faker.version 1.9.2 def shard sample(shards) end ## # Produces a random surge. # # @return [String] # # @example # Faker::Cosmere.surge #=> "Progression" # # @faker.version 1.9.2 def surge sample(surges) end ## # Produces a random knight radiant. # # @return [String] # # @example # Faker::Cosmere.knight_radiant #=> "Truthwatcher" # # @faker.version 1.9.2 def knight_radiant sample(knights_radiant) end ## # Produces a random metal. # # @return [String] # # @example # Faker::Cosmere.metal #=> "Brass" # # @faker.version 1.9.2 def metal sample(metals) end ## # Produces a random allomancer. # # @return [String] # # @example # Faker::Cosmere.allomancer #=> "Coinshot" # # @faker.version 1.9.2 def allomancer sample(allomancers) end ## # Produces a random feruchemist. # # @return [String] # # @example # Faker::Cosmere.feruchemist #=> "Archivist" # # @faker.version 1.9.2 def feruchemist sample(feruchemists) end ## # Produces a random herald. # # @return [String] # # @example # Faker::Cosmere.herald #=> "Ishar" # # @faker.version 1.9.2 def herald sample(heralds) end ## # Produces a random spren. # # @return [String] # # @example # Faker::Cosmere.spren #=> "Flamespren" # # @faker.version 1.9.2 def spren sample(sprens) end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/driving_licence.rb
lib/faker/default/driving_licence.rb
# frozen_string_literal: true module Faker class DrivingLicence < Base GB_PADDING = '9999' NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population class << self ## # Produces a random British driving licence number. # # @param last_name [String] The last name of the driving licence's owner. # @param initials [String] The initials of the driving licence's owner. # @param gender [String] The gender of the driving licence's owner. # @param date_of_birth [String] The date of birth of the driving licence's owner. # @return [String] # # @example # Faker::DrivingLicence.british_driving_licence #=> "MCDER712081VF7EK" # Faker::DrivingLicence.british_driving_licence(last_name: "O'Carroll", # initials: "J", # gender: :female, # date_of_birth: Date.parse("1986-10-24")) #=> "OCARR815246J91HT" # # @faker.version 1.9.2 def british_driving_licence(last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65)) [ gb_licence_padding(last_name, 5), gb_licence_year(date_of_birth, gender), gb_licence_padding(initials, 2), gb_licence_checksum ].join end ## # Produces a random Northern Irish licence number. # # @return [String] # # @example # Faker::DrivingLicence.northern_irish_driving_licence #=> "70702548" # # @faker.version 1.9.2 def northern_irish_driving_licence Faker::Number.number(digits: 8).to_s end ## # Produces a random UK driving licence number in either GB or NI format, at a rate consistent with their relative populations # # @overload uk_driving_licence(last_name, initials, gender, date_of_birth) # @param last_name [String] The last name of the driving licence's owner. # @param initials [String] The initials of the driving licence's owner. # @param gender [String] The gender of the driving licence's owner. # @param date_of_birth [String] The date of birth of the driving licence's owner. # @overload uk_driving_licence() # @return [String] # # @example # Faker::DrivingLicence.uk_driving_licence #=> "OCARR815246J91HT" # Faker::DrivingLicence.uk_driving_licence #=> "70702548" # # @faker.version 1.9.2 def uk_driving_licence(*args) if Faker::Config.random.rand < NI_CHANCE northern_irish_driving_licence else british_driving_licence(*args) end end ## # Produces a random USA driving licence number by state code passed. # # @return [String] # # @example # Faker::DrivingLicence.usa_driving_licence #=> "V5598249" # Faker::DrivingLicence.usa_driving_licence('new mexico') #=> "270692028" # Faker::DrivingLicence.usa_driving_licence('New Mexico') #=> "68178637" # # @faker.version 2.14.0 def usa_driving_licence(state = 'California') bothify(fetch("driving_licence.usa.#{state.to_s.strip.downcase.gsub(' ', '_')}")) rescue I18n::MissingTranslationData => _e raise InvalidStatePassed, "Invalid state code passed for USA, '#{state}'" end private def random_gender %i[male female].sample(random: Faker::Config.random) end def gb_licence_padding(str, num_chars) prepped = str.upcase.gsub(%r{[^A-Z]}, '') + GB_PADDING prepped[0..(num_chars - 1)] end def gb_licence_year(dob, gender) generate(:string) do |g| g.computed do (dob.year / 10) % 10 end g.computed do gender_marker = gender == :female ? 50 : 0 format('%02d', dob.month + gender_marker) end g.computed do format('%02d', dob.day) end g.computed do dob.year % 10 end end end def gb_licence_checksum generate(:string) do |g| g.int g.letter(ranges: ['A'..'Z'], length: 2) end end end end class InvalidStatePassed < StandardError def initialize(msg = 'Invalid state code passed') super end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/crypto.rb
lib/faker/default/crypto.rb
# frozen_string_literal: true require 'openssl' module Faker class Crypto < Base class << self # Setting the lorem character number lower than the default of # 255 reduces the time complexity of each hash algorithm while # still returning deterministically unique values. See # https://github.com/faker-ruby/faker/pull/2938 for more info. MD5_MIN_NUMBER_OF_CHARACTERS = 25 SHA1_MIN_NUMBER_OF_CHARACTERS = 31 SHA256_MIN_NUMBER_OF_CHARACTERS = 50 SHA512_MIN_NUMBER_OF_CHARACTERS = 100 ## # Produces an MD5 hash. # # @return [String] # # @example # Faker::Crypto.md5 #=> "6b5ed240042e8a65c55ddb826c3408e6" # # @faker.version 1.6.4 def md5 OpenSSL::Digest::MD5.hexdigest(Lorem.characters(number: MD5_MIN_NUMBER_OF_CHARACTERS)) end ## # Produces a SHA1 hash. # # @return [String] # # @example # Faker::Crypto.sha1 #=> "4e99e31c51eef8b2d290e709f757f92e558a503f" # # @faker.version 1.6.4 def sha1 OpenSSL::Digest::SHA1.hexdigest(Lorem.characters(number: SHA1_MIN_NUMBER_OF_CHARACTERS)) end ## # Produces a SHA256 hash. # # @return [String] # # @example # Faker::Crypto.sha256 #=> "51e4dbb424cd9db1ec5fb989514f2a35652ececef33f21c8dd1fd61bb8e3929d" # # @faker.version 1.6.4 def sha256 OpenSSL::Digest::SHA256.hexdigest(Lorem.characters(number: SHA256_MIN_NUMBER_OF_CHARACTERS)) end ## # Produces a SHA512 hash. # # @return [String] # # @example # Faker::Crypto.sha512 #=> "7b9fc82a6642874833d01b74a7b4fae3d15373193b55cfba47327f8f0afdc8d0ea155b58639a03a887009ef997dab8dd8d36767620d430f6e787e5996e26da80" # # @faker.version next def sha512 OpenSSL::Digest::SHA512.hexdigest(Lorem.characters(number: SHA512_MIN_NUMBER_OF_CHARACTERS)) end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/university.rb
lib/faker/default/university.rb
# frozen_string_literal: true module Faker class University < Base flexible :university class << self ## # Produces a random university name. # # @return [String] # # @example # Faker::University.name #=> "Eastern Mississippi Academy" # # @faker.version 1.5.0 def name parse('university.name') end ## # Produces a random university prefix. # # @return [String] # # @example # Faker::University.prefix #=> "Western" # # @faker.version 1.5.0 def prefix fetch('university.prefix') end ## # Produces a random university suffix. # # @return [String] # # @example # Faker::University.suffix #=> "Academy" # # @faker.version 1.5.0 def suffix fetch('university.suffix') end ## # Produces a random greek organization. # # @return [String] # # @example # Faker::University.greek_organization #=> "BEX" # # @faker.version 1.5.0 def greek_organization Array.new(3) { |_| sample(greek_alphabet) }.join end ## # Produces a greek alphabet. # # @return [Array] # # @example # Faker::University.greek_alphabet #=> ["Α", "B", "Γ", "Δ", ...] # # @faker.version 1.5.0 def greek_alphabet %w[Α B Γ Δ E Z H Θ I K Λ M N Ξ O Π P Σ T Y Φ X Ψ Ω] end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/markdown.rb
lib/faker/default/markdown.rb
# frozen_string_literal: true module Faker class Markdown < Base class << self ## # Produces a random header format. # # @return [String] # # @example # Faker::Markdown.headers #=> "##### Autem" # # @faker.version 1.8.0 def headers "#{fetch('markdown.headers')} #{Lorem.word.capitalize}" end ## # Produces a random emphasis formatting on a random word in two sentences. # # @return [String] # # @example # Faker::Markdown.emphasis #=> "_Incidunt atque quis repellat id impedit. Quas numquam quod incidunt dicta non. Blanditiis delectus laudantium atque reiciendis qui._" # # @faker.version 1.8.0 def emphasis paragraph = Faker::Lorem.paragraph(sentence_count: 3) words = paragraph.split position = rand(0..(words.length - 1)) formatting = fetch('markdown.emphasis') words[position] = "#{formatting}#{words[position]}#{formatting}" words.join(' ') end ## # Produces a random ordered list of items between 1 and 10 randomly. # # @return [String] # # @example # 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." # # @faker.version 1.8.0 def ordered_list number = rand(1..10) result = [] number.times do |i| result << "#{i}. #{Faker::Lorem.sentence(word_count: 1)} \n" end result.join end ## # Produces a random unordered list of items between 1 and 10 randomly. # # @return [String] # # @example # Faker::Markdown.unordered_list #=> "* Voluptatum aliquid tempora molestiae facilis non sed.\n* Nostrum omnis iste impedit voluptatum dolor.\n* Esse quidem et facere." # # @faker.version 1.8.0 def unordered_list number = rand(1..10) result = [] number.times do |_i| result << "* #{Faker::Lorem.sentence(word_count: 1)} \n" end result.join end ## # Produces a random inline code snippet between two sentences. # # @return [String] # # @example # Faker::Markdown.inline_code #=> "Aut eos quis suscipit. `Dignissimos voluptatem expedita qui.` Quo doloremque veritatis tempora aut." # # @faker.version 1.8.0 def inline_code "`#{Faker::Lorem.sentence(word_count: 1)}`" end ## # Produces a random code block formatted in Ruby. # # @return [String] # # @example # Faker::Markdown.block_code #=> "```ruby\nEos quasi qui.\n```" # # @faker.version 1.8.0 def block_code "```ruby\n#{Lorem.sentence(word_count: 1)}\n```" end ## # Produces a random 3x4 table with a row of headings, a row of hyphens and two rows of data # # @return [String] # # @example # Faker::Markdown.table #=> "ad | similique | voluptatem\n---- | ---- | ----\ncorrupti | est | rerum\nmolestiae | quidem | et" # # @faker.version 1.8.0 def table table = [] 3.times do table << "#{Lorem.word} | #{Lorem.word} | #{Lorem.word}" end table.insert(1, '---- | ---- | ----') table.join("\n") end ## # Produces a random method from the methods above, excluding the methods listed in the arguments. # # @overload random(methods) # @param methods [Symbol] Specify which methods to exclude. # # @return [String, Array<String>] # # @example # Faker::Markdown.random #=> returns output from a single method outlined above # Faker::Markdown.random("table") #=> returns output from any single method outlined above except for "table" # Faker::Markdown.random("ordered_list", "unordered_list") #=> returns output from any single method outlined above except for either ordered_list and unordered_list # # @faker.version 1.8.0 def random(*args) method_list = available_methods args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } } send(method_list[Faker::Config.random.rand(0..(method_list.length - 1))]) end ## # Produces a simulated blog-esque text-heavy block in markdown # # Keyword arguments: sentences, repeat # @param sentences [Integer] Specifies how many sentences make a text block. # @param repeat [Integer] Specifies how many times the text block repeats. # @return [String] # # @example # Faker::Markdown.sandwich #=> returns newline separated content of 1 header, 1 default lorem paragraph, and 1 random markdown element # Faker::Markdown.sandwich(sentences: 5) #=> returns newline separated content of 1 header, 1 5-sentence lorem paragraph, and 1 random markdown element # 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. # # @faker.version 1.8.0 def sandwich(sentences: 3, repeat: 1) text_block = [] text_block << headers repeat.times do text_block << Faker::Lorem.paragraph(sentence_count: sentences) text_block << random end text_block.join("\n") end private def available_methods (Markdown.public_methods(false) - Base.methods).sort end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/religion.rb
lib/faker/default/religion.rb
# frozen_string_literal: true module Faker module Religion end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/verb.rb
lib/faker/default/verb.rb
# frozen_string_literal: true module Faker class Verb < Base class << self ## # Produces the base form of a random verb. # # @return [String] # # @example # Faker::Verb.base #=> "hurt" # # @faker.version 1.9.0 def base fetch('verbs.base') end ## # Produces a random verb in past tense. # # @return [String] # # @example # Faker::Verb.past #=> "completed" # # @faker.version 1.9.0 def past fetch('verbs.past') end ## # Produces a random verb in past participle. # # @return [String] # # @example # Faker::Verb.past_participle #=> "digested" # # @faker.version 1.9.0 def past_participle fetch('verbs.past_participle') end ## # Produces a random verb in simple present. # # @return [String] # # @example # Faker::Verb.simple_present #=> "climbs" # # @faker.version 1.9.0 def simple_present fetch('verbs.simple_present') end ## # Produces a random verb in the .ing form. # # @return [String] # # @example # Faker::Verb.ing_form #=> "causing" # # @faker.version 1.9.0 def ing_form fetch('verbs.ing_form') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/types.rb
lib/faker/default/types.rb
# frozen_string_literal: true module Faker class Types < Base CHARACTERS = ('0'..'9').to_a + ('a'..'z').to_a SIMPLE_TYPES = %i[string fixnum].freeze COMPLEX_TYPES = %i[hash array].freeze class << self ## # Produces a random String created from word (Faker::Lorem.word) # # @return [String] # # @example # Faker::Types.rb_string #=> "foobar" # # @faker.version 1.8.6 def rb_string(words: 1) resolved_num = resolve(words) word_list = translate('faker.lorem.words') word_list *= ((resolved_num / word_list.length) + 1) sample(word_list, resolved_num).join(' ') end ## # Produces a random character from the a-z, 0-9 ranges. # # @return [String] # # @example # Faker::Types.character #=> "n" # # @faker.version 1.8.6 def character sample(CHARACTERS) end ## # Produces a random integer. # # @return [Integer] # # @example # Faker::Types.rb_integer #=> 1 # # @faker.version 1.8.6 def rb_integer(from: 0, to: 100) rand(from..to).to_i end ## # Produces a random hash with random keys and values. # # @param number [Integer] Specifies the number of key-value pairs. # @return [Hash] # # @example # Faker::Types.rb_hash #=> {name: "bob"} # Faker::Types.rb_hash(number: 1) #=> {name: "bob"} # Faker::Types.rb_hash(number: 2) #=> {name: "bob", last: "marley"} # # @faker.version 1.8.6 def rb_hash(number: 1, type: -> { random_type }) {}.tap do |hsh| Lorem.words(number: number * 2).uniq.first(number).each do |s| value = type.is_a?(Proc) ? type.call : type hsh.merge!(s.to_sym => value) end end end ## # Produces a random complex hash with random keys and values where the values may include other hashes and arrays. # # @param number [Integer] Specifies the number of key-value pairs. # @return [Hash] # # @example # Faker::Types.complex_rb_hash #=> {user: {first: "bob", last: "marley"}} # Faker::Types.complex_rb_hash(number: 1) #=> {user: {first: "bob", last: "marley"}} # Faker::Types.complex_rb_hash(number: 2) #=> {user: {first: "bob", last: "marley"}, son: ["damien", "marley"]} # # @faker.version 1.8.6 def complex_rb_hash(number: 1) rb_hash(number: number, type: -> { random_complex_type }) end ## # Produces a random array. # # @param len [Integer] Specifies the number of elements in the array. # @return [Array] # # @example # Faker::Types.rb_array #=> ["a"] # Faker::Types.rb_array(len: 4) #=> ["a", 1, 2, "bob"] # Faker::Types.rb_array(len: 2, type: -> { Faker::Types.rb_string }) #=> ["cat", "foo"] # # @faker.version 1.8.6 def rb_array(len: 1, type: -> { random_type }) [].tap do |ar| len.times do ar.push type.is_a?(Proc) ? type.call : type end end end ## # Produces a random type that's either a String or an Integer. # # @return [String, Integer] # # @example # Faker::Types.random_type #=> 1 or "a" or "bob" # # @faker.version 1.8.6 def random_type type_to_use = SIMPLE_TYPES[rand(0..(SIMPLE_TYPES.length - 1))] case type_to_use when :string rb_string when :fixnum rb_integer end end ## # Produces a random complex type that's either a String, an Integer, an array or a hash. # # @return [String, Integer] # # @example # Faker::Types.random_complex_type #=> 1 or "a" or "bob" or {foo: "bar"} # # @faker.version 1.8.6 def random_complex_type types = SIMPLE_TYPES + COMPLEX_TYPES type_to_use = types[rand(0..(types.length - 1))] case type_to_use when :string rb_string when :fixnum rb_integer when :hash rb_hash when :array rb_array end end private def titleize(word) word.split(/(\W)/).map(&:capitalize).join end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/phone_number.rb
lib/faker/default/phone_number.rb
# frozen_string_literal: true module Faker class PhoneNumber < Base class << self ## # Produces a phone number in a random format without the country code and it can have different dividers. # # @return [String] # # @example # Faker::PhoneNumber.phone_number #=> "(504) 113-1705" # Faker::PhoneNumber.phone_number #=> "662.291.7201" # Faker::PhoneNumber.phone_number #=> "9415283713" # # @faker.version 0.3.0 def phone_number parse('phone_number.formats') end ## # Produces a random cell phone number in a random format without the country code and it can have different dividers. # # @return [String] # # @example # Faker::PhoneNumber.cell_phone #=> "(836) 115-8995" # Faker::PhoneNumber.cell_phone #=> "382-597-5739" # Faker::PhoneNumber.cell_phone #=> "316.828.1822" # # @faker.version 1.0.0 def cell_phone parse('cell_phone.formats') end ## # Produces a random country code. # # @return [String] # # @example # Faker::PhoneNumber.country_code #=> "+20" # Faker::PhoneNumber.country_code #=> "+39" # Faker::PhoneNumber.country_code #=> "+852" # # @faker.version 1.9.2 def country_code "+#{fetch('phone_number.country_code')}" end ## # Produces a random phone number with country code. # # @return [String] # # @example # Faker::PhoneNumber.phone_number_with_country_code #=> "+55 466-746-6882" # Faker::PhoneNumber.phone_number_with_country_code #=> "+81 3718219558" # Faker::PhoneNumber.phone_number_with_country_code #=> "+49 140 957 9846" # # @faker.version 1.9.2 def phone_number_with_country_code "#{country_code} #{phone_number}" end ## # Produces a random cell phone number with country code. # # @return [String] # # @example # Faker::PhoneNumber.cell_phone_with_country_code #=> "+852 (190) 987-9034" # Faker::PhoneNumber.cell_phone_with_country_code #=> "+64 (820) 583-6474" # Faker::PhoneNumber.cell_phone_with_country_code #=> "+1 591.871.7985" # # @faker.version 1.9.2 def cell_phone_with_country_code "#{country_code} #{cell_phone}" end ## # Produces a random phone number in e164 format, i.e., without any dividers. # # @return [String] # # @example # Faker::PhoneNumber.cell_phone_in_e164 #=> "+542024834991" # Faker::PhoneNumber.cell_phone_in_e164 #=> "+8522846847703" # Faker::PhoneNumber.cell_phone_in_e164 #=> "+649477546575" # # @faker.version 1.9.2 def cell_phone_in_e164 cell_phone_with_country_code.delete('^+0-9') end ## # Produces a random area code. # # @return [String] # # @example # Faker::PhoneNumber.area_code #=> "201" # Faker::PhoneNumber.area_code #=> "613" # Faker::PhoneNumber.area_code #=> "321" # # @faker.version 1.3.0 def area_code fetch('phone_number.area_code') end ## # Produces a random exchange code. # # @return [String] # # @example # Faker::PhoneNumber.exchange_code #=> "208" # Faker::PhoneNumber.exchange_code #=> "415" # Faker::PhoneNumber.exchange_code #=> "652" # # @faker.version 1.3.0 def exchange_code fetch('phone_number.exchange_code') end ## # Produces a random extension / subscriber number. Can be used for both extensions and last four digits of phone number. # # @param length [Integer] Specifies the length of the return value. Defaults to 4. # @return [String] # # @example # Faker::PhoneNumber.subscriber_number #=> "3873" # Faker::PhoneNumber.subscriber_number(length: 2) #=> "39" # Faker::PhoneNumber.extension #=> "3764" # Faker::PhoneNumber.extension(length: 2) => "37" # # @faker.version 1.3.0 def subscriber_number(length: 4) if !length.is_a?(Integer) || length > 10 raise ArgumentError, 'length must be an Integer and be lesser than 10' end generate(:string) do |g| g.int(length: length) end end alias extension subscriber_number end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/invoice.rb
lib/faker/default/invoice.rb
# frozen_string_literal: true module Faker class Invoice < Base flexible :invoice class << self ## # Produces a random amount between values with 2 decimals # # @param from [Integer] Specifies lower limit. # @param to [Integer] Specifies upper limit. # @return [Integer] # # @example # Faker::Invoice.amount_between #=> 0 # Faker::Invoice.amount_between(from: 0, to: 10) #=> 4.33 # # @faker.version 1.9.0 def amount_between(from: 0, to: 0) Faker::Base.rand_in_range(from, to).round(2) end ## # Produces a random valid reference according to the International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference # # @param ref [String] Specifies reference base. # @return [String] # # @example # Faker::Invoice.creditor_reference #=> "RF34118592570724925498" # # @faker.version 1.9.0 def creditor_reference(ref: '') ref = reference if ref.empty? "RF#{iban_checksum('RF', ref)}#{ref}" end ## # Produces a random valid reference. # # @param ref [String] Specifies reference base. # @return [String] # # @example # Faker::Invoice.reference #=> "45656646957845" # # @faker.version 1.9.0 def reference(ref: '') pattern = fetch('invoice.reference.pattern') ref = Base.regexify(/#{pattern}/) if ref.empty? # If reference contains reserved '#' characters we need to calculate check_digits as well check_digit_match = ref.match(/#+/) if check_digit_match # Get the method for selected language check_digit_method = fetch('invoice.reference.check_digit_method') # Calculate the check digit with matching method name # Trim all '#' from the reference before calculating that check_digit = send(check_digit_method, ref.tr('#', '')) # Make sure that our check digit is as long as all of the '###' we found check_digit = check_digit.to_s.rjust(check_digit_match[0].length, '0') # Replace all of the ref = ref.sub(check_digit_match[0], check_digit) end ref end private # Calculates the mandatory checksum in 3rd and 4th characters in IBAN format # source: https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN def iban_checksum(country_code, account) # Converts letters to numbers according the iban rules, A=10..Z=35 account_to_number = "#{account}#{country_code}00".upcase.chars.map do |d| d =~ /[A-Z]/ ? (d.ord - 55).to_s : d end.join.to_i # This is answer to (iban_to_num + checksum) % 97 == 1 checksum = (1 - account_to_number) % 97 # Use leftpad to make the size always to 2 checksum.to_s.rjust(2, '0') end # 731 Method # Source: https://wiki.xmldation.com/support/fk/finnish_reference_number def method_731(base) weighted_sum = calculate_weighted_sum(base, [7, 3, 1]) mod10_remainder(weighted_sum) end # Norsk Modulus 10 - KIDMOD10 def kidmod10(base) weighted_sum = calculate_weighted_sum(base, [1, 2]) mod10_remainder(weighted_sum) end # Calculates weighted sum # # For example with 12345678, [1,2] # Ref.num. 1 2 3 4 5 6 7 8 # Multipl. 1 2 1 2 1 2 1 2 # Total 1+ 4+ 3+ 8+ 5+1+2+ 7+1+6 = 38 def calculate_weighted_sum(base, weight_factors) base.to_s.reverse.each_char.with_index.map do |digit, index| digit.to_i * weight_factors.at(index % weight_factors.length) end.reduce(:+) # reduce(:+) = sum() but with better ruby version support end # MOD-10 - remainder def mod10_remainder(number) -number % 10 end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/id_number.rb
lib/faker/default/id_number.rb
# frozen_string_literal: true module Faker class IdNumber < Base CHECKS = 'TRWAGMYFPDXBNJZSQVHLCKE' INVALID_SSN = [ /0{3}-\d{2}-\d{4}/, /\d{3}-0{2}-\d{4}/, /\d{3}-\d{2}-0{4}/, /666-\d{2}-\d{4}/, /9\d{2}-\d{2}-\d{4}/ ].freeze ZA_RACE_DIGIT = '8' ZA_CITIZENSHIP_DIGITS = %w[0 1].freeze BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])/ BRAZILIAN_ID_FROM = 10_000_000 BRAZILIAN_ID_TO = 99_999_999 CHILEAN_MODULO = 11 class << self ## # Produces a random valid US Social Security number. # # @return [String] # # @example # Faker::IdNumber.valid #=> "552-56-3593" # # @faker.version 1.6.0 def valid _translate('valid') end ## # Produces a random invalid US Social Security number. # # @return [String] # # @example # Faker::IdNumber.invalid #=> "311-72-0000" # # @faker.version 1.6.0 def invalid _translate('invalid') end def ssn_valid generate(:string) do |g| g.computed(name: :first) do range = [1..665, 667..899].sample(random: Faker::Config.random) n = Faker::Base.rand(range) format('%03d', n) end g.lit('-') g.computed(name: :second) do n = Faker::Base.rand(1..99) format('%02d', n) end g.lit('-') g.computed(name: :third) do n = Faker::Base.rand(1..9999) format('%04d', n) end end end ## # Produces a random Spanish citizen identifier (DNI). # # @return [String] # # @example # Faker::IdNumber.spanish_citizen_number #=> "53290236-H" # # @faker.version 1.9.0 def spanish_citizen_number num = Faker::Number.number(digits: 8) mod = num.to_i % 23 check = CHECKS[mod] "#{num}-#{check}" end ## # Produces a random Spanish foreign born citizen identifier (NIE). # # @return [String] # # @example # Faker::IdNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y" # # @faker.version 1.9.0 def spanish_foreign_citizen_number code = 'XYZ' digits = Faker::Number.number(digits: 7) prefix = code[rand(code.length)] prefix_val = 'XYZ'.index(prefix).to_s mod = "#{prefix_val}#{digits}".to_i % 23 check = CHECKS[mod] "#{prefix}-#{digits}-#{check}" end ## # Produces a random valid South African ID Number. # # @return [String] # # @example # Faker::IdNumber.south_african_id_number #=> "8105128870184" # Faker::IdNumber.valid_south_african_id_number #=> "8105128870184" # # @faker.version 1.9.2 def valid_south_african_id_number id_number = [ Faker::Date.birthday.strftime('%y%m%d'), Faker::Number.number(digits: 4), ZA_CITIZENSHIP_DIGITS.sample(random: Faker::Config.random), ZA_RACE_DIGIT ].join [id_number, south_african_id_checksum_digit(id_number)].join end alias south_african_id_number valid_south_african_id_number ## # Produces a random invalid South African ID Number. # # @return [String] # # @example # Faker::IdNumber.invalid_south_african_id_number #=> "1642972065088" # # @faker.version 1.9.2 def invalid_south_african_id_number invalid_date_of_birth = [ Faker::Number.number(digits: 2), Faker::Number.between(from: 13, to: 99), Faker::Number.between(from: 32, to: 99) ].map(&:to_s).join id_number = [ invalid_date_of_birth, Faker::Number.number(digits: 4), ZA_CITIZENSHIP_DIGITS.sample(random: Faker::Config.random), ZA_RACE_DIGIT ].join [id_number, south_african_id_checksum_digit(id_number)].join end ## # Produces a random Brazilian Citizen Number (CPF). # # @param formatted [Boolean] Specifies if the number is formatted with dividers. # @return [String] # # @example # Faker::IdNumber.brazilian_citizen_number #=> "53540542221" # Faker::IdNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21" # # @faker.version 1.9.2 def brazilian_citizen_number(formatted: false) digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/) first_digit = brazilian_citizen_number_checksum_digit(digits) second_digit = brazilian_citizen_number_checksum_digit(digits + first_digit) number = [digits, first_digit, second_digit].join formatted ? format('%s.%s.%s-%s', *number.scan(/\d{2,3}/).flatten) : number end alias brazilian_cpf brazilian_citizen_number ## # Produces a random Brazilian ID Number (RG). # # @param formatted [Boolean] Specifies if the number is formatted with dividers. # @return [String] # # @example # Faker::IdNumber.brazilian_id #=> "493054029" # Faker::IdNumber.brazilian_id(formatted: true) #=> "49.305.402-9" # # @faker.version 2.1.2 def brazilian_id(formatted: false) digits = Faker::Number.between(to: BRAZILIAN_ID_FROM, from: BRAZILIAN_ID_TO).to_s check_digit = brazilian_id_checksum_digit(digits) number = [digits, check_digit].join formatted ? format('%s.%s.%s-%s', *number.scan(BRAZILIAN_ID_FORMAT).flatten) : number end alias brazilian_rg brazilian_id ## # Produces a random Chilean ID (Rut with 8 digits). # # @return [String] # # @example # Faker::IdNumber.chilean_id #=> "15620613-K" # # @faker.version 2.1.2 def chilean_id digits = Faker::Number.number(digits: 8) verification_code = chilean_verification_code(digits) "#{digits}-#{verification_code}" end ## # Produces a random Croatian ID number (OIB). # # @param international [Boolean] Specifies whether to add international prefix. # @return [String] # # @example # Faker::IdNumber.croatian_id #=> "88467617508" # Faker::IdNumber.croatian_id(international: true) #=> "HR88467617508" # # @faker.version next def croatian_id(international: false) prefix = international ? 'HR' : '' digits = Faker::Number.number(digits: 10).to_s checksum_digit = croatian_id_checksum_digit(digits) "#{prefix}#{digits}#{checksum_digit}" end ## # Produces a random Danish ID Number (CPR number). # CPR number is 10 digits. Digit 1-6 is the birthdate (format "DDMMYY"). # Digit 7-10 is a sequence number. # Digit 7 digit is a control digit that determines the century of birth. # Digit 10 reveals the gender: # even is female, odd is male. # # @param formatted [Boolean] Specifies if the number is formatted with dividers. # @param birthday [Date] Specifies the birthday for the id number. # @param gender [Symbol] Specifies the gender for the id number. Must be one :male or :female if present. # @return [String] # # @example # Faker::IdNumber.danish_id_number #=> "0503909980" # Faker::IdNumber.danish_id_number(formatted: true) #=> "050390-9980" # Faker::IdNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "0503909980" # Faker::IdNumber.danish_id_number(gender: :female) #=> "0503909980" # # @faker.version next def danish_id_number(formatted: false, birthday: Faker::Date.birthday, gender: nil) valid_control_digits = danish_control_digits(birthday) control_digit = sample(valid_control_digits) digits = (0..9).to_a gender = gender.to_sym if gender.respond_to?(:to_sym) gender_digit = case gender when nil sample(digits) when :male sample(digits.select(&:odd?)) when :female sample(digits.select(&:even?)) else raise ArgumentError, "Invalid gender #{gender}. Must be one of male, female, or be omitted." end [ birthday.strftime('%d%m%y'), formatted ? '-' : '', control_digit, Faker::Number.number(digits: 2), gender_digit ].join end ## # Produces a random French social security number (INSEE number). # # @return [String] # # @example # Faker::IdNumber.french_insee_number #=> "53290236-H" # # @faker.version next def french_insee_number num = [ [1, 2].sample(random: Faker::Config.random), # gender Faker::Number.between(from: 0, to: 99).to_s.rjust(2, '0'), # year of birth Faker::Number.between(from: 1, to: 12).to_s.rjust(2, '0'), # month of birth Faker::Number.number(digits: 5), # place of birth Faker::Number.number(digits: 3) # order number ].join mod = num.to_i % 97 check = (97 - mod).to_s.rjust(2, '0') "#{num}#{check}" end private def croatian_id_checksum_digit(digits) control_sum = 10 digits.chars.map(&:to_i).each do |digit| control_sum += digit control_sum %= 10 control_sum = 10 if control_sum.zero? control_sum *= 2 control_sum %= 11 end control_sum = 11 - control_sum control_sum % 10 end def chilean_verification_code(digits) # First digit is multiplied by 3, second by 2, and so on multiplication_rule = [3, 2, 7, 6, 5, 4, 3, 2] digits_splitted = digits.to_s.chars.map(&:to_i) sum = digits_splitted.map.with_index { |digit, index| digit * multiplication_rule[index] }.reduce(:+) modulo = sum.modulo(CHILEAN_MODULO) difference = CHILEAN_MODULO - modulo case difference when 0..9 difference when 10 'K' when 11 0 end end def south_african_id_checksum_digit(id_number) value_parts = id_number.chars even_digits = value_parts .select .with_index { |_, i| (i + 1).even? } odd_digits_without_last_character = value_parts[0...-1] .select .with_index { |_, i| (i + 1).odd? } sum_of_odd_digits = odd_digits_without_last_character.map(&:to_i).reduce(:+) even_digits_times_two = (even_digits.join.to_i * 2).to_s sum_of_even_digits = even_digits_times_two.chars.map(&:to_i).reduce(:+) total_sum = sum_of_odd_digits + sum_of_even_digits ((10 - (total_sum % 10)) % 10).to_s end def brazilian_citizen_number_checksum_digit(digits) checksum = brazilian_document_checksum(digits) brazilian_document_digit(checksum) end def brazilian_id_checksum_digit(digits) checksum = brazilian_document_checksum(digits) brazilian_document_digit(checksum, id: true) end def brazilian_document_checksum(digits) digits.chars.each_with_index.inject(0) do |acc, (digit, i)| acc + digit.to_i * (digits.size + 1 - i) end * 10 end def brazilian_document_digit(checksum, id: false) remainder = checksum % 11 id ? brazilian_id_digit(remainder) : brazilian_citizen_number_digit(remainder) end def brazilian_citizen_number_digit(remainder) remainder == 10 ? '0' : remainder.to_s end def brazilian_id_digit(remainder) subtraction = 11 - remainder.to_i digits = { 10 => 'X', 11 => '0' } digits.include?(subtraction) ? digits[subtraction] : subtraction.to_s end def danish_control_digits(birthday) year = birthday.year century = year.to_s.slice(0, 2).to_i year_digits = year.to_s.slice(2, 2).to_i error_message = "Invalid birthday: #{birthday}. Danish CPR numbers are only distributed to persons born between 1858 and 2057." case century when 18 # If 5, 6, 7 or 8 and the year numbers are greater than or equal to 58, you were born in 18XX. case year_digits when 58..99 [5, 6, 7, 8] else raise ArgumentError, error_message end when 19 # If 0, 1, 2 or 3, you are always born in 19XX. # If 4 or 9, you are born in 19XX if the year digits are greater than 36. case year_digits when 0..36 [0, 1, 2, 3] else # 37..99 [0, 1, 2, 3, 4, 9] end else # If 4, 5, 6, 7, 8 or 9 and the year digits are less than or equal to 36, you were born in 20XX. # 5, 6, 7 and 8 are not distributed to persons, with year digits from and including 37 to and including 57. case year_digits when 0..36 [4, 5, 6, 7, 8, 9] when 37..57 [5, 6, 7, 8] else raise ArgumentError, error_message end end end def _translate(key) parse("id_number.#{key}") end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/coffee.rb
lib/faker/default/coffee.rb
# frozen_string_literal: true module Faker class Coffee < Base flexible :coffee class << self ## # Produces a random blend name. # # @return [String] # # @example # Faker::Coffee.blend_name #=> "Major Java" # # @faker.version 1.9.0 def blend_name parse('coffee.blend_name') end ## # Produces a random coffee origin place. # # @return [String] # # @example # Faker::Coffee.origin #=> "Oaxaca, Mexico" # # @faker.version 1.9.0 def origin country = fetch('coffee.country') region = fetch("coffee.regions.#{search_format(country)}") "#{region}, #{country}" end ## # Produces a random coffee variety. # # @return [String] # # @example # Faker::Coffee.variety #=> "Red Bourbon" # # @faker.version 1.9.0 def variety fetch('coffee.variety') end ## # Produces a string containing a random description of a coffee's taste. # # @return [String] # # @example # Faker::Coffee.notes #=> "dull, tea-like, cantaloupe, soy sauce, marshmallow" # # @faker.version 1.9.0 def notes parse('coffee.notes') end ## # Produces a random coffee taste intensity. # # @return [String] # # @example # Faker::Coffee.intensifier #=> "mild" # # @faker.version 1.9.0 def intensifier fetch('coffee.intensifier') end private def search_format(key) key.split.length > 1 ? key.split.join('_').downcase : key.downcase end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/chile_rut.rb
lib/faker/default/chile_rut.rb
# frozen_string_literal: true module Faker class ChileRut < Base class << self @last_rut = nil ## # Produces a random Chilean RUT (Rol Unico Tributario, ID with 8 digits). # # @param min_rut [Integer] Specifies the minimum value of the RUT. # @param max_rut [Integer] Specifies the maximum value of the RUT. # @param fixed [Boolean] Determines if the RUT is fixed (returns the min_rut value). # @return [Number] # # @example # Faker::ChileRut.rut #=> 11235813 # Faker::ChileRut.rut(min_rut: 10_000_000, max_rut: 30_000_000) #=> 21853211 # Faker::ChileRut.rut(min_rut: 20_890_156, fixed: true) #=> 20890156 # # @faker.version next def rut(min_rut: 1, max_rut: 99_999_999, fixed: false) @last_rut = fixed ? min_rut : rand_in_range(min_rut, max_rut) end ## # Produces a random Chilean digito verificador (check-digit). # # @return [String] # # @example # Faker::ChileRut.dv #=> "k" # # @faker.version 1.9.2 def dv split_reversed_rut = @last_rut.to_s.reverse.chars seq = [2, 3, 4, 5, 6, 7] i = 0 digit_sum = split_reversed_rut.reduce(0) do |sum, n| partial_result = sum.to_i + (n.to_i * seq[i]) i = i == 5 ? 0 : i + 1 partial_result end partial_check_digit = 11 - (digit_sum % 11) case partial_check_digit when 11 '0' when 10 'k' else partial_check_digit.to_s end end ## # Produces a random Chilean digito verificador (check-digit). # Alias for english speaking devs. # # @return [String] # # @example # Faker::ChileRut.check_digit #=> "5" # # @faker.version 1.9.2 def check_digit dv end ## # Produces a random Chilean RUT (Rol Unico Tributario, ID with 8 digits) with a dv (digito verificador, check-digit). # # @param min_rut [Integer] Specifies the minimum value of the RUT. # @param max_rut [Integer] Specifies the maximum value of the RUT. # @param fixed [Boolean] Determines if the RUT is fixed (returns the min_rut value). # @return [String] # # @example # Faker::ChileRut.full_rut #=> "30686957-4" # Faker::ChileRut.full_rut(min_rut: 10_000_000, max_rut: 30_000_000) #=> "20686957-4" # Faker::ChileRut.full_rut(min_rut: 30_686_957, fixed: true) #=> "30686957-4" # # @faker.version next def full_rut(min_rut: 1, max_rut: 99_999_999, fixed: false, formatted: false) this_rut = rut(min_rut: min_rut, max_rut: max_rut, fixed: fixed) this_rut = format_rut(this_rut) if formatted "#{this_rut}-#{dv}" end attr_reader :last_rut private def format_rut(rut) rut.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1.').reverse end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/educator.rb
lib/faker/default/educator.rb
# frozen_string_literal: true module Faker class Educator < Base flexible :educator class << self ## # Produces a university name. # # @return [String] # # @example # Faker::Educator.university #=> "Mallowtown Technical College" # # @faker.version 1.6.4 def university parse('educator.university') end ## # Produces a university degree. # # @return [String] # # @example # Faker::Educator.degree #=> "Associate Degree in Criminology" # # @faker.version 1.9.2 def degree parse('educator.degree') end alias course degree ## # Produces a university subject. # # @return [String] # # @example # Faker::Educator.subject #=> "Criminology" # # @faker.version 1.9.2 def subject fetch('educator.subject') end ## # Produces a course name. # # @return [String] # # @example # Faker::Educator.course_name #=> "Criminology 101" # # @faker.version 1.9.2 def course_name numerify(parse('educator.course_name')) end ## # Produces a secondary school. # # @return [String] # # @example # Faker::Educator.secondary_school #=> "Iceborough Secondary College" # # @faker.version 1.6.4 def secondary_school parse('educator.secondary_school') end ## # Produces a primary school. # # @return [String] # # @example # Faker::Educator.primary_school #=> "Brighthurst Elementary School" # # @faker.version next def primary_school parse('educator.primary_school') end ## # Produces a campus name. # # @return [String] # # @example # Faker::Educator.campus #=> "Vertapple Campus" # # @faker.version 1.6.4 def campus parse('educator.campus') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/theater.rb
lib/faker/default/theater.rb
# frozen_string_literal: true module Faker class Theater < Base class << self ## # Produces the name of a musical for an older audience # # @return [String] # # @example # Faker::Theater.adult_musical # #=> "Mamma Mia!" # # @faker.version 2.13.0 def adult_musical fetch('theater.adult_musical') end ## # Produces the name of a musical for a younger audience # # @return [String] # # @example # Faker::Theater.kids_musical # #=> "Into the Woods JR." # # @faker.version 2.13.0 def kids_musical fetch('theater.kids_musical') end ## # Produces the name of a play # # @return [String] # # @example # Faker::Theater.play # #=> "Death of a Salesman" # # @faker.version 2.13.0 def play fetch('theater.play') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/team.rb
lib/faker/default/team.rb
# frozen_string_literal: true module Faker class Team < Base flexible :team class << self ## # Produces a team name from a state and a creature. # # @return [String] # # @example # Faker::Team.name #=> "Oregon vixens" # # @faker.version 1.3.0 def name parse('team.name') end ## # Produces a team creature. # # @return [String] # # @example # Faker::Team.creature #=> "geese" # # @faker.version 1.3.0 def creature fetch('team.creature') end ## # Produces a team state. # # @return [String] # # @example # Faker::Team.state #=> "Oregon" # # @faker.version 1.3.0 def state fetch('address.state') end ## # Produces a team sport. # # @return [String] # # @example # Faker::Team.sport #=> "Lacrosse" # # @faker.version 1.5.0 def sport fetch('team.sport') end ## # Produces the name of a team mascot. # # @return [String] # # @example # Faker::Team.mascot #=> "Hugo" # # @faker.version 1.8.1 def mascot fetch('team.mascot') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/hipster.rb
lib/faker/default/hipster.rb
# frozen_string_literal: true module Faker class Hipster < Base class << self ## # Produces a random hipster word. # # @return [String] # # @example # Faker::Hipster.word #=> "irony" # # @faker.version 1.6.0 def word random_word = sample(translate('faker.hipster.words')) random_word =~ /\s/ ? word : random_word end ## # Produces a random hipster word. # # @param number [Integer] Specifies the number of words returned # @param supplemental [Boolean] Specifies if the words are supplemental # @param spaces_allowed [Boolean] Specifies if the words may contain spaces # @return [Array<String>] # # @example # Faker::Hipster.words #=> ["pug", "pitchfork", "chia"] # Faker::Hipster.words(number: 4) #=> ["ugh", "cardigan", "poutine", "stumptown"] # Faker::Hipster.words(number: 4, supplemental: true) #=> ["iste", "seitan", "normcore", "provident"] # Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"] # # @faker.version 1.6.0 def words(number: 3, supplemental: false, spaces_allowed: false) resolved_num = resolve(number) word_list = ( translate('faker.hipster.words') + (supplemental ? translate('faker.lorem.words') : []) ) word_list *= ((resolved_num / word_list.length) + 1) words = sample(word_list, resolved_num) return words if spaces_allowed words.each_with_index { |w, i| words[i] = word if w =~ /\s/ } end ## # Produces a random hipster sentence. # # @param word_count [Integer] Specifies the number of words in the sentence # @param supplemental [Boolean] Specifies if the words are supplemental # @param random_words_to_add [Integer] Specifies the number of random words to add # @param open_compounds_allowed [Boolean] Specifies if the generated sentence can contain words having additional spaces # @return [String] # # @example # Faker::Hipster.sentence #=> "Park iphone leggings put a bird on it." # Faker::Hipster.sentence(word_count: 3) #=> "Pour-over swag godard." # Faker::Hipster.sentence(word_count: 3, supplemental: true) #=> "Beard laboriosam sequi celiac." # Faker::Hipster.sentence(word_count: 3, supplemental: false, random_words_to_add: 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit." # Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 4) #=> "Occaecati deleniti messenger bag meh crucifix autem." # Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: true) #=> "Kale chips nihil eos." # Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie." # # @faker.version 1.6.0 def sentence(word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true) "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}." end ## # Produces random hipster sentences. # # @param number [Integer] Specifies the number of sentences returned # @param supplemental [Boolean] Specifies if the words are supplemental # @return [Array<String>] # # @example # Faker::Hipster.sentences #=> ["Godard pitchfork vinegar chillwave everyday 90's whatever.", "Pour-over artisan distillery street waistcoat.", "Salvia yr leggings franzen blue bottle."] # Faker::Hipster.sentences(number: 1) #=> ["Before they sold out pinterest venmo umami try-hard ugh hoodie artisan."] # Faker::Hipster.sentences(number: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."] # # @faker.version 1.6.0 def sentences(number: 3, supplemental: false) [].tap do |sentences| 1.upto(resolve(number)) do sentences << sentence(word_count: 3, supplemental: supplemental) end end end ## # Produces a random hipster paragraph. # # @param sentence_count [Integer] Specifies the number of sentences in the paragraph # @param supplemental [Boolean] Specifies if the words are supplemental # @param random_sentences_to_add [Boolean] Specifies the number of random sentences to add # @return [String] # # @example # Faker::Hipster.paragraph #=> "Migas fingerstache pbr&b tofu. Polaroid distillery typewriter echo tofu actually. Slow-carb fanny pack pickled direct trade scenester mlkshk plaid. Banjo venmo chambray cold-pressed typewriter. Fap skateboard intelligentsia." # Faker::Hipster.paragraph(sentence_count: 2) #=> "Yolo tilde farm-to-table hashtag. Lomo kitsch disrupt forage +1." # Faker::Hipster.paragraph(sentence_count: 2, supplemental: true) #=> "Typewriter iste ut viral kombucha voluptatem. Sint voluptates saepe. Direct trade irony chia excepturi yuccie. Biodiesel esse listicle et quam suscipit." # Faker::Hipster.paragraph(sentence_count: 2, supplemental: false, random_sentences_to_add: 4) #=> "Selvage vhs chartreuse narwhal vinegar. Authentic vinyl truffaut carry vhs pop-up. Hammock everyday iphone locavore thundercats bitters vegan goth. Fashion axe banh mi shoreditch whatever artisan." # Faker::Hipster.paragraph(sentence_count: 2, supplemental: true, random_sentences_to_add: 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics." # # @faker.version 1.6.0 def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3) sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ') end ## # Produces random hipster paragraphs. # # @param number [Integer] Specifies the number of paragraphs # @param supplemental [Boolean] Specifies if the words are supplemental # @return [Array<String>] # # @example # Faker::Hipster.paragraphs #=> ["Tilde microdosing blog cliche meggings. Intelligentsia five dollar toast forage yuccie. Master kitsch knausgaard. Try-hard everyday trust fund mumblecore.", "Normcore viral pickled. Listicle humblebrag swag tote bag. Taxidermy street hammock neutra butcher cred kale chips. Blog portland humblebrag trust fund irony.", "Single-origin coffee fixie cleanse tofu xoxo. Post-ironic tote bag ramps gluten-free locavore mumblecore hammock. Umami loko twee. Ugh kitsch before they sold out."] # Faker::Hipster.paragraphs(number: 1) #=> ["Skateboard cronut synth +1 fashion axe. Pop-up polaroid skateboard asymmetrical. Ennui fingerstache shoreditch before they sold out. Tattooed pitchfork ramps. Photo booth yr messenger bag raw denim bespoke locavore lomo synth."] # Faker::Hipster.paragraphs(number: 1, supplemental: true) #=> ["Quae direct trade pbr&b quo taxidermy autem loko. Umami quas ratione migas cardigan sriracha minima. Tenetur perspiciatis pickled sed eum doloribus truffaut. Excepturi dreamcatcher meditation."] # # @faker.version 1.6.0 def paragraphs(number: 3, supplemental: false) [].tap do |paragraphs| 1.upto(resolve(number)) do paragraphs << paragraph(sentence_count: 3, supplemental: supplemental) end end end ## # Produces a random hipster paragraph by characters. # # @param characters [Integer] Specifies the number of characters in the paragraph # @param supplemental [Boolean] Specifies if the words are supplemental # @return [String] # # @example # Faker::Hipster.paragraph_by_chars #=> "Truffaut stumptown trust fund 8-bit messenger bag portland. Meh kombucha selvage swag biodiesel. Lomo kinfolk jean shorts asymmetrical diy. Wayfarers portland twee stumptown. Wes anderson biodiesel retro 90's pabst. Diy echo 90's mixtape semiotics. Cornho." # Faker::Hipster.paragraph_by_chars(characters: 256, supplemental: false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green." # # @faker.version 1.6.0 def paragraph_by_chars(characters: 256, supplemental: false) paragraph = paragraph(sentence_count: 3, supplemental: supplemental) paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters "#{paragraph[0...(characters - 1)]}." end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/camera.rb
lib/faker/default/camera.rb
# frozen_string_literal: true module Faker class Camera < Base class << self ## # Produces a brand of a camera # # @return [String] # # @example # Faker::Camera.brand #=> "Canon" # # @faker.version next def brand fetch('camera.brand') end ## # Produces a model of camera # # @return [String] # # @example # Faker::Camera.model #=> "450D" # # @faker.version next def model fetch('camera.model') end ## # Produces a brand with model # # @return [String] # # @example # Faker::Camera.brand_with_model #=> "Canon 450D" # # @faker.version next def brand_with_model fetch('camera.brand_with_model') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/national_health_service.rb
lib/faker/default/national_health_service.rb
# frozen_string_literal: true module Faker class NationalHealthService < Base class << self ## # Produces a random British NHS number. # # The NHS sets aside a range of numbers from 999 000 0000 to 999 999 9999 # for test purposes. # # @return [String] # # @example # Faker::NationalHealthService.british_number #=> "999 464 0232" # # @faker.version 1.9.2 def british_number base_number = rand(999_000_001...999_999_999) # If the check digit is equivalent to 10, the number is invalid. # See https://en.wikipedia.org/wiki/NHS_number base_number -= 1 if check_digit(number: base_number) == 10 "#{base_number}#{check_digit(number: base_number)}".chars .insert(3, ' ') .insert(7, ' ') .join end private ## # Produces a random British NHS number's check digit. # # @param number [Integer] Specifies the NHS number the check digit belongs to. # @return [Integer] # # @example # Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6 # # @faker.version 1.9.2 def check_digit(number: 0) sum = 0 number.to_s.chars.each_with_index do |digit, idx| position = idx + 1 sum += (digit.to_i * (11 - position)) end result = 11 - (sum % 11) # A value of 11 is considered the same as 0 # See https://en.wikipedia.org/wiki/NHS_number return 0 if result == 11 result end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/coin.rb
lib/faker/default/coin.rb
# frozen_string_literal: true module Faker class Coin < Base class << self ## # Retrieves a random coin from any country. # # @return [String] # # @example # Faker::Coin.name #=> "Brazilian Real" # # @faker.version 1.9.2 def name fetch('currency.name') end ## # Retrieves a face to a flipped coin # # @return [String] # # @example # Faker::Coin.flip #=> "Heads" # # @faker.version 1.9.2 def flip fetch('coin.flip') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/job.rb
lib/faker/default/job.rb
# frozen_string_literal: true module Faker class Job < Base flexible :job class << self ## # Produces a random job title. # # @return [String] # # @example # Faker::Job.title #=> "Construction Manager" # # @faker.version 1.7.0 def title parse('job.title') end ## # Produces a random job position. # # @return [String] # # @example # Faker::Job.position #=> "Strategist" # # @faker.version 1.8.7 def position fetch('job.position') end ## # Produces a random job field. # # @return [String] # # @example # Faker::Job.field #=> "Banking" # # @faker.version 1.7.0 def field fetch('job.field') end ## # Produces a random job skill. # # @return [String] # # @example # Faker::Job.key_skill #=> "Leadership" # # @faker.version 1.7.0 def key_skill fetch('job.key_skills') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/chuck_norris.rb
lib/faker/default/chuck_norris.rb
# frozen_string_literal: true module Faker class ChuckNorris < Base flexible :chuck_norris class << self ## # Produces a Chuck Norris Fact. # Original list of facts: # https://github.com/jenkinsci/chucknorris-plugin/blob/master/src/main/java/hudson/plugins/chucknorris/FactGenerator.java # # @return [String] # # @example # Faker::ChuckNorris.fact # #=> "Chuck Norris can solve the Towers of Hanoi in one move." # # @faker.version 1.6.4 def fact fetch('chuck_norris.fact') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/space.rb
lib/faker/default/space.rb
# frozen_string_literal: true module Faker class Space < Base flexible :space class << self ## # Produces the name of a planet. # # @return [String] # # @example # Faker::Space.planet #=> "Venus" # # @faker.version 1.6.4 def planet fetch('space.planet') end ## # Produces the name of a moon. # # @return [String] # # @example # Faker::Space.moon #=> "Europa" # # @faker.version 1.6.4 def moon fetch('space.moon') end ## # Produces the name of a galaxy. # # @return [String] # # @example # Faker::Space.galaxy #=> "Andromeda" # # @faker.version 1.6.4 def galaxy fetch('space.galaxy') end ## # Produces the name of a nebula. # # @return [String] # # @example # Faker::Space.nebula #=> "Triffid Nebula" # # @faker.version 1.6.4 def nebula fetch('space.nebula') end ## # Produces the name of a star cluster. # # @return [String] # # @example # Faker::Space.star_cluster #=> "Messier 70" # # @faker.version 1.6.4 def star_cluster fetch('space.star_cluster') end ## # Produces the name of a constellation. # # @return [String] # # @example # Faker::Space.constellation #=> "Orion" # # @faker.version 1.6.4 def constellation fetch('space.constellation') end ## # Produces the name of a star. # # @return [String] # # @example # Faker::Space.star #=> "Proxima Centauri" # # @faker.version 1.6.4 def star fetch('space.star') end ## # Produces the name of a space agency. # # @return [String] # # @example # Faker::Space.agency #=> "Japan Aerospace Exploration Agency" # # @faker.version 1.6.4 def agency fetch('space.agency') end ## # Produces a space agency abbreviation. # # @return [String] # # @example # Faker::Space.agency_abv #=> "NASA" # # @faker.version 1.6.4 def agency_abv fetch('space.agency_abv') end ## # Produces the name of a NASA spacecraft. # # @return [String] # # @example # Faker::Space.nasa_space_craft #=> "Endeavour" # # @faker.version 1.6.4 def nasa_space_craft fetch('space.nasa_space_craft') end ## # Produces the name of a space company. # # @return [String] # # @example # Faker::Space.company #=> "SpaceX" # # @faker.version 1.6.4 def company fetch('space.company') end ## # Produces a distance measurement. # # @return [String] # # @example # Faker::Space.distance_measurement #=> "15 parsecs" # # @faker.version 1.6.4 def distance_measurement "#{rand(10..100)} #{fetch('space.distance_measurement')}" end ## # Produces the name of a meteorite. # # @return [String] # # @example # Faker::Space.meteorite #=> "Ensisheim" # # @faker.version 1.7.0 def meteorite fetch('space.meteorite') end ## # Produces the name of a launch vehicle. # # @return [String] # # @example # Faker::Space.launch_vehicle #=> "Saturn IV" # # @faker.version 1.9.0 def launch_vehicle fetch('space.launch_vehicle') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/stripe.rb
lib/faker/default/stripe.rb
# frozen_string_literal: true module Faker class Stripe < Base class << self ## # Produces a random valid card number. # # @param card_type [String] Specific valid card type. # @return [String] # # @example # Faker::Stripe.valid_card #=> "4242424242424242" # Faker::Stripe.valid_card(card_type: "visa_debit") #=> "4000056655665556" # # @faker.version 1.9.0 def valid_card(card_type: nil) valid_cards = translate('faker.stripe.valid_cards').keys if card_type.nil? card_type = sample(valid_cards).to_s else unless valid_cards.include?(card_type.to_sym) raise ArgumentError, "Valid credit cards argument can be left blank or include #{valid_cards.join(', ')}" end end fetch("stripe.valid_cards.#{card_type}") end ## # Produces a random valid Stripe token. # # @param card_type [String] Specific valid card type. # @return [String] # # @example # Faker::Stripe.valid_token #=> "tok_visa" # Faker::Stripe.valid_token(card_type: "mc_debit") #=> "tok_mastercard_debit" # # @faker.version 1.9.0 def valid_token(card_type: nil) valid_tokens = translate('faker.stripe.valid_tokens').keys if card_type.nil? card_type = sample(valid_tokens).to_s else unless valid_tokens.include?(card_type.to_sym) raise ArgumentError, "Valid credit cards argument can be left blank or include #{valid_tokens.join(', ')}" end end fetch("stripe.valid_tokens.#{card_type}") end ## # Produces a random invalid card number. # # @return [String] # # @example # Faker::Stripe.invalid_card #=> "4000000000000002" # Faker::Stripe.invalid_card(card_error: "addressZipFail") #=> "4000000000000010" # # @faker.version 1.9.0 def invalid_card(card_error: nil) invalid_cards = translate('faker.stripe.invalid_cards').keys if card_error.nil? card_error = sample(invalid_cards).to_s else unless invalid_cards.include?(card_error.to_sym) raise ArgumentError, "Invalid credit cards argument can be left blank or include #{invalid_cards.join(', ')}" end end fetch("stripe.invalid_cards.#{card_error}") end ## # Produces a random month in two digits format. # # @return [String] # # @example # Faker::Stripe.month #=> "10" # # @faker.version 1.9.0 def month format('%02d', rand_in_range(1, 12)) end ## # Produces a random year that is always in the future. # # @return [String] # # @example # Faker::Stripe.year #=> "2018" # This will always be a year in the future # # @faker.version 1.9.0 def year start_year = ::Time.new.year + 1 rand_in_range(start_year, start_year + 5).to_s end ## # Produces a random ccv number. # # @param card_type [String] Specific valid card type. # @return [String] # # @example # Faker::Stripe.ccv #=> "123" # Faker::Stripe.ccv(card_type: "amex") #=> "1234" # # @faker.version 1.9.0 def ccv(card_type: nil) (card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/tea.rb
lib/faker/default/tea.rb
# frozen_string_literal: true module Faker class Tea < Base flexible :tea class << self ## # Produces a random variety or blend of tea. # # @param type [String, nil] the type of tea to query for (valid types: 'Black', 'Green', 'Oolong', 'White', and 'Herbal') # @return [String] a variety of tea # # @example # Faker::Tea.variety # #=> "Earl Grey" # # @example # Faker::Tea.variety(type: 'Green') # #=> "Jasmine" # @faker.version next def variety(type: nil) type ||= fetch('tea.type') fetch "tea.variety.#{type.downcase}" end ## # Produces a random type of tea. # # @return [String] a type of tea # # @example # Faker::Tea.type # #=> "Green" # @faker.version next def type fetch 'tea.type' end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/device.rb
lib/faker/default/device.rb
# frozen_string_literal: true module Faker class Device < Base class << self ## # Produces a build number between 1 and 500. # # @return [Integer] # # @example # Faker::Device.build_number #=> 5 # # @faker.version 1.9.0 def build_number Faker::Number.between(from: 1, to: 500) end ## # Produces the name of a manufacturer for a device. # # @return [String] # # @example # Faker::Device.manufacturer #=> "Apple" # # @faker.version 1.9.0 def manufacturer fetch('device.manufacturer') end ## # Produces a model name for a device. # # @return [String] # # @example # Faker::Device.model_name #=> "iPhone 4" # # @faker.version 1.9.0 def model_name fetch('device.model_name') end ## # Produces the name of a platform for a device. # # @return [String] # # @example # Faker::Device.platform #=> "webOS" # # @faker.version 1.9.0 def platform fetch('device.platform') end ## # Produces a serial code for a device. # # @return [String] # # @example # Faker::Device.serial #=> "ejfjnRNInxh0363JC2WM" # # @faker.version 1.9.0 def serial fetch('device.serial') end ## # Produces a version number between 1 and 1000. # # @return [Integer] # # @example # Faker::Device.version #=> 42 # # @faker.version 1.9.0 def version Faker::Number.between(from: 1, to: 1000) end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/crypto_coin.rb
lib/faker/default/crypto_coin.rb
# frozen_string_literal: true module Faker class CryptoCoin < Base class << self COIN_NAME = 0 ACRONYM = 1 URL_LOGO = 2 ## # Produces a random crypto coin name. # # @return [String] # # @example # Faker::CryptoCoin.coin_name #=> "Bitcoin" # # @faker.version 1.9.2 def coin_name(coin: coin_array) coin[COIN_NAME] end ## # Produces a random crypto coin acronym. # # @return [String] # # @example # Faker::CryptoCoin.acronym #=> "BTC" # # @faker.version 1.9.2 def acronym(coin: coin_array) coin[ACRONYM] end ## # Produces a random crypto coin logo url. # # @return [String] # # @example # Faker::CryptoCoin.url_logo #=> "https://i.imgur.com/EFz61Ei.png" # # @faker.version 1.9.2 def url_logo(coin: coin_array) coin[URL_LOGO] end ## # Produces a random crypto coin's name, acronym and logo in an array. # # @return [Array<String>] # # @example # Faker::CryptoCoin.coin_array #=> ["Dash", "DASH", "https://i.imgur.com/2uX91cb.png"] # # @faker.version 1.9.2 def coin_array fetch('crypto_coin.coin').split(',').map(&:strip) end ## # Produces a random crypto coin's name, acronym and logo in a hash. # # @return [Hash] # # @example # Faker::CryptoCoin.coin_hash {:name=>"Ethereum", :acronym=>"ETH", :url_logo=>"https://i.imgur.com/uOPFCXj.png"} # # @faker.version 1.9.2 def coin_hash coin = coin_array { name: coin_name(coin: coin), acronym: acronym(coin: coin), url_logo: url_logo(coin: coin) } end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/marketing.rb
lib/faker/default/marketing.rb
# frozen_string_literal: true module Faker class Marketing < Base flexible :marketing class << self ## # Produces a few marketing buzzwords. # # @return [String] # # @example # Faker::Marketing.buzzwords #=> "rubber meets the road" # # @faker.version 1.9.4 def buzzwords fetch('marketing.buzzwords') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/date.rb
lib/faker/default/date.rb
# frozen_string_literal: true module Faker class Date < Base DAYS_OF_WEEK = %i[sunday monday tuesday wednesday thursday friday saturday].freeze class << self ## # Produce a random date between two dates. # # @param from [Date, String] The start of the usable date range. # @param to [Date, String] The end of the usable date range. # @return [Date] # # @example if used with or without Rails (Active Support) # Faker::Date.between(from: '2014-09-23', to: '2014-09-25') #=> #<Date: 2014-09-24> # # @example if used with Rails (Active Support) # Faker::Date.between(from: 2.days.ago, to: Date.today) #=> #<Date: 2014-09-24> # # @faker.version 1.0.0 def between(from:, to:) from = get_date_object(from) to = get_date_object(to) Faker::Base.rand_in_range(from, to) end ## # Produce a random date between two dates. # # @param from [Date, String] The start of the usable date range. # @param to [Date, String] The end of the usable date range. # @param excepted [Date, String] A date to exclude. # @return [Date] # # @example if used with or without Rails (Active Support) # Faker::Date.between_except(from: '2014-09-23', to: '2015-09-25', excepted: '2015-01-24') #=> #<Date: 2014-10-03> # # @example if used with Rails (Active Support) # Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today) #=> #<Date: 2014-10-03> # # @faker.version 1.6.2 def between_except(from:, to:, excepted:) raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted excepted = get_date_object(excepted) loop do date = between(from: from, to: to) break date.to_date if date != excepted end end ## # Produce a random date in the future (up to N days). # # @param from [Integer] The start of the usable forward date range. # @param days [Integer] The maximum number of days to go into the future. # @return [Date] # # @example if used with or without Rails (Active Support) # Faker::Date.forward(days: 23) #=> #<Date: 2014-10-03> # # @example if used with Rails (Active Support) # Faker::Date.forward(from: Date.current, days: 17) #=> #<Date: 2022-06-22> # # @example if used with or without Rails (Active Support) # Faker::Date.forward(from: '2022-06-03', days: 10) #=> #<Date: 2022-10-13> # # @faker.version 1.0.0 def forward(from: ::Date.today, days: 365) start_date = get_date_object(from) since = start_date + 1 to = start_date + days between(from: since, to: to).to_date end ## # Produce a random date in the past (up to N days). # # @param days [Integer] The maximum number of days to go into the past. # @return [Date] # # @example # Faker::Date.backward(days: 14) #=> #<Date: 2019-09-12> # # @faker.version 1.0.0 def backward(days: 365) from = ::Date.today - days to = ::Date.today - 1 between(from: from, to: to).to_date end ## # Produce a random date in the past (up to N days). # # @param min_age [Integer] The minimum age that the birthday would imply. # @param max_age [Integer] The maximum age that the birthday would imply. # @return [Date] # # @example # Faker::Date.birthday(min_age: 18, max_age: 65) #=> #<Date: 1986-03-28> # # @faker.version 1.4.3 def birthday(min_age: 18, max_age: 65) t = ::Date.today from = birthday_date(t, max_age) to = birthday_date(t, min_age) between(from: from, to: to).to_date end ## # Produces a date in the year and/or month specified. # # @param month [Integer] represents the month of the date # @param year [Integer] represents the year of the date # @return [Date] # # @example # Faker::Date.in_date_period #=> #<Date: 2019-09-01> # # @example # Faker::Date.in_date_period(year: 2018, month: 2) #=> #<Date: 2018-02-26> # # @example # Faker::Date.in_date_period(month: 2) #=> #<Date: 2019-02-26> # # @faker.version 2.13.0 def in_date_period(month: nil, year: ::Date.today.year) from = ::Date.new(year, month || 1, 1) to = ::Date.new(year, month || 12, ::Date.civil(year, month || 12, -1).day) between(from: from, to: to).to_date end ## # Produce a random date at given day(s) of the week between two dates. # # @param day [Symbol, Array<Symbol>] # The day(s) of the week. See {DAYS_OF_WEEK}. # @param from [Date, String] The start of the usable date range. # @param to [Date, String] The end of the usable date range. # @return [Date] # # @example if used with or without Rails (Active Support) # Faker::Date.on_day_of_week_between(day: :tuesday, from: '2023-01-01', to: '2023-02-01') #=> #<Date: 2032-01-10> # # @example if used with Rails (Active Support) # Faker::Date.on_day_of_week_between(day: [:saturday, :sunday], from: 1.month.ago, to: Date.today) #=> #<Date: 2014-09-24> # # @faker.version next def on_day_of_week_between(day:, from:, to:) days = [day].flatten raise ArgumentError, 'Day of week cannot be empty' if days.empty? # Convert given days of the week to numbers used by `Date#wday` method numeric_weekdays = days.map do |d| DAYS_OF_WEEK.index(d.to_sym.downcase) || raise(ArgumentError, "#{d} is not a valid day of the week") end from = get_date_object(from) to = get_date_object(to) date = Faker::Base.rand_in_range(from, to) # If the initial date is not on one of the wanted days of the week... unless numeric_weekdays.include? date.wday # ...pick a date nearby that is on one of the wanted days of the week instead date += sample(numeric_weekdays) - date.wday # Move date 1 week earlier or later if the adjusted date is now outside the date range date += 7 if date < from date -= 7 if date > to if date > to || date < from raise ArgumentError, "There is no #{DAYS_OF_WEEK[date.wday].capitalize} between #{from} and #{to}. Increase the from/to date range or choose a different day of the week." end end date end private def birthday_date(date, age) year = date.year - age day = if date.day == 29 && date.month == 2 && !::Date.leap?(year) 28 else date.day end ::Date.new(year, date.month, day) end def get_date_object(date) date = ::Date.parse(date) if date.is_a?(::String) date = date.to_date if date.respond_to?(:to_date) date end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/lorem.rb
lib/faker/default/lorem.rb
# frozen_string_literal: true module Faker # Based on Perl's Text::Lorem class Lorem < Base class << self ## # Returs the random word # @return [String] # # @example # Faker::Lorem.word #=> "soluto" # Faker::Lorem.word(exclude_words: 'error') #=> "nisi" # Faker::Lorem.word(exclude_words: 'id, error') #=> "et" # Faker::Lorem.word(exclude_words: ['id', 'error']) #=> "consequatur" # # @faker.version 2.1.3 def word(exclude_words: nil) words(number: 1, exclude_words: exclude_words).first end ## # Generates random 3 words # # @param number [Integer] Number of words to be generated # @param supplemental [Boolean] Whether to attach supplemental words at the end, default is false # # @return [Array] Array for words # # @example # Faker::Lorem.words #=> ["hic", "quia", "nihil"] # Faker::Lorem.words(number: 4) #=> ["est", "temporibus", "et", "quaerat"] # Faker::Lorem.words(number: 4, supplemental: true) #=> ["nisi", "sit", "allatus", "consequatur"] # Faker::Lorem.words(number: 4, supplemental: true, exclude_words: 'sit') #=> ["nisi", "allatus", "consequatur", "aut"] # # @faker.version 2.1.3 def words(number: 3, supplemental: false, exclude_words: nil) resolved_num = resolve(number) word_list = ( translate('faker.lorem.words') + (supplemental ? translate('faker.lorem.supplemental') : []) ) if exclude_words exclude_words = exclude_words.split(', ') if exclude_words.instance_of?(::String) word_list -= exclude_words end word_list *= ((resolved_num / word_list.length) + 1) sample(word_list, resolved_num) end ## # Generates single character # # @return [String] # # @example # Faker::Lorem.character #=> "e" # # @faker.version 2.1.3 def character sample(Types::CHARACTERS) end ## # Produces a random string of alphanumeric characters # # @param number [Integer] The number of characters to generate # @param min_alpha [Integer] The minimum number of alphabetic to add to the string # @param min_numeric [Integer] The minimum number of numbers to add to the string # # @return [String] # # @example # Faker::Lorem.characters #=> "uw1ep04lhs0c4d931n1jmrspprf5w..." # Faker::Lorem.characters(number: 10) #=> "ang9cbhoa8" # Faker::Lorem.characters(number: 10, min_alpha: 4) #=> "ang9cbhoa8" # Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8" # # @faker.version 2.1.3 def characters(number: 255, min_alpha: 0, min_numeric: 0) Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric) end ## # Generates the emoji # # @return [String] # # @example # Faker::Lorem.multibyte #=> "😀" # Faker::Lorem.multibyte #=> "❤" # # @faker.version 2.1.3 def multibyte sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8') end ## # Generates sentence # # @param word_count [Integer] How many words should be there in a sentence, default to 4 # @param supplemental [Boolean] Add supplemental words, default to false # @param random_words_to_add [Integer] Add any random words, default to 0 # # @return [String] # # @example # Faker::Lorem.sentence #=> "Magnam qui aut quidem." # Faker::Lorem.sentence(word_count: 5) #=> "Voluptas rerum aut aliquam velit." # Faker::Lorem.sentence(word_count: 5, supplemental: true) #=> "Aut viscus curtus votum iusto." # Faker::Lorem.sentence(word_count: 5, supplemental: true, random_words_to_add:2) #=> "Crinis quo cruentus velit animi vomer." # # @faker.version 2.1.3 def sentence(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil) words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space).capitalize + locale_period end ## # Generates three sentences # # @param number [Integer] How many sentences to be generated, default to 3 # @param supplemental [Boolean] Should add supplemental words, defaults to false # # @return [Array] Returns array for sentences. # # @example # Faker::Lorem.sentences #=> ["Possimus non tenetur.", "Nulla non excepturi.", "Quisquam rerum facilis."] # Faker::Lorem.sentences(number: 2) #=> ["Nulla est natus.", "Perferendis autem cum."] # Faker::Lorem.sentences(number: 2, supplemental: true) #=> ["Cito cena ad.", "Solvo animus allatus."] # # @faker.version 2.1.3 def sentences(number: 3, supplemental: false, exclude_words: nil) 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) } end ## # Generates three sentence paragraph # # @param sentence_count [Integer] Number of sentences in the paragraph # @param supplemental [Boolean] # @param random_sentences_to_add [Integer] # # @return [String] # # @example # Faker::Lorem.paragraph # #=> "Impedit et est. Aliquid deleniti necessitatibus. Et aspernatur minima." # Faker::Lorem.paragraph(sentence_count: 2) # #=> "Rerum fugit vitae. Et atque autem." # Faker::Lorem.paragraph(sentence_count: 2, supplemental: true) # #=> "Terreo coerceo utor. Vester sunt cogito." # Faker::Lorem.paragraph(sentence_count: 2, supplemental: true, random_sentences_to_add: 2) # #=> "Texo tantillus tamisium. Tribuo amissio tamisium. Facere aut canis." # # @faker.version 2.1.3 def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0, exclude_words: nil) sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space) end ## # Generates three paragraphs # # @param number [Integer] # @param supplemental [Boolean] # # @return [Array] # # @example # Faker::Lorem.paragraphs # Faker::Lorem.paragraphs(number:2) # Faker::Lorem.paragraphs(number:2, supplemental: true) # # @faker.version 2.1.3 def paragraphs(number: 3, supplemental: false, exclude_words: nil) 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental, exclude_words: exclude_words) } end ## # Generates paragraph with 256 characters # # @param number [Integer] # @param supplemental [Boolean] # # @return [String] # # @example # Faker::Lorem.paragraph_by_chars # Faker::Lorem.paragraph_by_chars(number: 20) #=> "Sit modi alias. Imp." # Faker::Lorem.paragraph_by_chars(number: 20, supplemental: true) #=> "Certus aveho admove." # # @faker.version 2.1.3 def paragraph_by_chars(number: 256, supplemental: false) paragraph = paragraph(sentence_count: 3, supplemental: supplemental) paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number "#{paragraph[0...(number - 1)]}." end ## # Returns the question with 4 words # # @param word_count [Integer] # @param supplemental [Boolean] # @param random_words_to_add [Integer] # # @return [String] # # @example # Faker::Lorem.question #=> "Natus deleniti sequi laudantium?" # Faker::Lorem.question(word_count: 2) #=> "Quo ut?" # Faker::Lorem.question(word_count: 2, supplemental: true) #=> "Terga consequatur?" # Faker::Lorem.question(word_count: 2, supplemental: true, random_words_to_add: 2) #=> "Depulso uter ut?" # # @faker.version 2.1.3 def question(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil) words(number: word_count + rand(random_words_to_add), supplemental: supplemental, exclude_words: exclude_words).join(' ').capitalize + locale_question_mark end ## # Generates array of three questions # # @param number [Integer] # @param supplemental [Boolean] # # @return [Array] # # @example # Faker::Lorem.questions #=> ["Amet culpa enim?", "Voluptatem deleniti numquam?", "Veniam non cum?"] # Faker::Lorem.questions(number: 2) #=> ["Minus occaecati nobis?", "Veniam et alias?"] # Faker::Lorem.questions(number: 2, supplemental: true) #=> ["Acceptus subito cetera?", "Aro sulum cubicularis?"] # # @faker.version 2.1.3 def questions(number: 3, supplemental: false, exclude_words: nil) 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) } end private def locale_period translate('faker.lorem.punctuation.period') || '.' end def locale_space translate('faker.lorem.punctuation.space') || ' ' end def locale_question_mark translate('faker.lorem.punctuation.question_mark') || '?' end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/barcode.rb
lib/faker/default/barcode.rb
# frozen_string_literal: true module Faker class Barcode < Base class << self ## # Returns a EAN 8 or 13 digit format barcode number with check digit # @return [String] # # @example # Faker::Barcode.ean => "85657526" # Faker::Barcode.ean(8) => "30152700" # Faker::Barcode.ean(13) => "2115190480285" # # @faker.version 2.14.0 def ean(length = 8) generate_barcode("barcode.ean_#{Integer(length)}") end ## # Returns a EAN 8 or 13 digit format barcode number with composite string attached with check digit # @return [String] # # @example # Faker::Barcode.ean_with_composite_sumbology => "41007624|JHOC6649" # Faker::Barcode.ean_with_composite_sumbology(8) => "38357961|XUYJ3266" # Faker::Barcode.ean_with_composite_sumbology(13) => "9530722443911|CKHWQHID" # # @faker.version 2.14.0 def ean_with_composite_symbology(length = 8) "#{ean(length)}|#{bothify(parse('barcode.composite_symbol'))}" end ## # Returns a UPC_A format barcode number with check digit # @return [String] # # @example # Faker::Barcode.upc_a => "766807541831" # # @faker.version 2.14.0 def upc_a generate_barcode('barcode.upc_a') end ## # Returns a UPC_E format barcode number with check digit # @return [String] # # @example # Faker::Barcode.upc_e => "03746820" # # @faker.version 2.14.0 def upc_e generate_barcode('barcode.upc_e') end ## # Returns a UPC_A format barcode number with composite string attached with check digit # @return [String] # # @example # Faker::Barcode.upc_a_with_composite_symbology => "790670155765|JOVG6208" # # @faker.version 2.14.0 def upc_a_with_composite_symbology "#{upc_a}|#{bothify(parse('barcode.composite_symbol'))}" end ## # Returns a UPC_E format barcode number with composite string attached with check digit # @return [String] # # @example # Faker::Barcode.upc_e_with_composite_symbology => "05149247|BKZX9722" # # @faker.version 2.14.0 def upc_e_with_composite_symbology "#{upc_e}|#{bothify(parse('barcode.composite_symbol'))}" end ## # Returns a ISBN format barcode number with check digit # @return [String] # # @example # Faker::Barcode.isbn => "9798363807732" # # @faker.version 2.14.0 def isbn generate_barcode('barcode.isbn') end ## # Returns a ISMN format barcode number with check digit # @return [String] # # @example # Faker::Barcode.ismn => "9790527672897" # # @faker.version 2.14.0 def ismn generate_barcode('barcode.ismn') end ## # Returns a ISSN format barcode number with check digit # @return [String] # # @example # Faker::Barcode.issn => "9775541703338" # # @faker.version 2.14.0 def issn generate_barcode('barcode.issn') end private def generate_barcode(key) barcode = parse(key) check_digit = generate_check_digit(*sum_even_odd(barcode)) "#{barcode}#{check_digit}" end ## # Returns the sum of even and odd numbers from value passed # # @return [Array] # # @example # Faker::Barcode.send(:sum_even_odd, 12345) => [9, 5] # Faker::Barcode.send(:sum_even_odd, 87465) => [17, 13] # # @faker.version 2.14.0 def sum_even_odd(fake_num) number = fake_num.to_i sum_even, sum_odd = 0, 0, index = 1 while number != 0 index.even? ? sum_even += number % 10 : sum_odd += number % 10 number /= 10 index += 1 end [sum_odd, sum_even] end ## # Generates the check digits from sum passed # # @return [Integer] # # @example # Faker::Barcode.send(:generate_check_digit, 12, 4) => 0 # Faker::Barcode.send(:generate_check_digit, 23, 5) => 6 # # @faker.version 2.14.0 def generate_check_digit(odd_sum, even_sum) (10 - (odd_sum * 3 + even_sum) % 10) % 10 end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/internet.rb
lib/faker/default/internet.rb
# frozen_string_literal: true module Faker class Internet < Base # Private, Host, and Link-Local network address blocks as defined in https://en.wikipedia.org/wiki/IPv4#Special-use_addresses PRIVATE_IPV4_ADDRESS_RANGES = [ [10..10, 0..255, 0..255, 1..255], # 10.0.0.0/8 - Used for local communications within a private network [100..100, 64..127, 0..255, 1..255], # 100.64.0.0/10 - Shared address space for communications between an ISP and its subscribers [127..127, 0..255, 0..255, 1..255], # 127.0.0.0/8 - Used for loopback addresses to the local host [169..169, 254..254, 0..255, 1..255], # 169.254.0.0/16 - Used for link-local addresses between two hosts on a single link when [172..172, 16..31, 0..255, 1..255], # 172.16.0.0/12 - Used for local communications within a private network [192..192, 0..0, 0..0, 1..255], # 192.0.0.0/24 - IETF Protocol Assignments [192..192, 168..168, 0..255, 1..255], # 192.168.0.0/16 - Used for local communications within a private network [198..198, 18..19, 0..255, 1..255] # 198.18.0.0/15 - Used for benchmark testing of inter-network communications between subnets ].each(&:freeze).freeze class << self ## # Returns the email address # # @return [String] # # @param name [String] # @param separators [Array] # @param domain [String] # # @example # Faker::Internet.email #=> "renee@zieme.test" # Faker::Internet.email(name: 'smith') #=> "smith@bergnaum.test" # Faker::Internet.email(name: 'sam smith', separators: ['-']) #=> "smith-sam@tromp.example" # Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'test') #=> "sam-smith@test.example" # Faker::Internet.email(domain: 'gmail.com') #=> "foo@gmail.com" def email(name: nil, separators: nil, domain: nil) local_part = if separators username(specifier: name, separators: separators) else username(specifier: name) end sanitized_local_part = sanitize_email_local_part(local_part) generate_domain = if domain.nil? domain_name else domain_name(domain: domain) end construct_email(sanitized_local_part, generate_domain) end ## # Returns the username # # @return [String] # # @param specifier [Integer, Range, String] When int value passed it returns the username longer than specifier. Max value can be 10^6 # @param separators [Array] # # @example # Faker::Internet.username(specifier: 10) #=> "lulu.goodwin" # Faker::Internet.username(specifier: 5..10) #=> "morris" # Faker::Internet.username(specifier: 5..10) #=> "berryberry" # Faker::Internet.username(specifier: 20, separators: ['_']) #=> "nikki_sawaynnikki_saway" def username(specifier: nil, separators: %w[. _]) with_locale(:en) do case specifier when ::String names = specifier.gsub("'", '').scan(/[[:word:]]+/) shuffled_names = shuffle(names) return shuffled_names.join(sample(separators)).downcase when Integer # If specifier is Integer and has large value, Argument error exception is raised to overcome memory full error raise ArgumentError, 'Given argument is too large' if specifier > 10**6 tries = 0 # Don't try forever in case we get something like 1_000_000. result = nil loop do result = username(specifier: nil, separators: separators) tries += 1 break unless result.length < specifier && tries < 7 end return result * (specifier / result.length + 1) if specifier.positive? when Range tries = 0 result = nil loop do result = username(specifier: specifier.min, separators: separators) tries += 1 break unless !specifier.include?(result.length) && tries < 7 end return result[0...specifier.max] end sample([ Char.prepare(Name.first_name), [Name.first_name, Name.last_name].map do |name| Char.prepare(name) end.join(sample(separators)) ]) end end ## # Produces a randomized string of characters suitable for passwords # # @param min_length [Integer] The minimum length of the password # @param max_length [Integer] The maximum length of the password # @param mix_case [Boolean] Toggles if uppercased letters are allowed. If true, at least one will be added. # @param special_characters [Boolean] Toggles if special characters are allowed. If true, at least one will be added. # # @return [String] # # @example # Faker::Internet.password #=> "Vg5mSvY1UeRg7" # @example # Faker::Internet.password(min_length: 8) #=> "YfGjIk0hGzDqS0" # @example # Faker::Internet.password(min_length: 10, max_length: 20) #=> "EoC9ShWd1hWq4vBgFw" # @example # Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k5qS15aNmG" # @example # Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4" # # @faker.version 2.1.3 def password(min_length: 8, max_length: 16, mix_case: true, special_characters: false) raise ArgumentError, 'min_length and max_length must be greater than or equal to one' if min_length < 1 || max_length < 1 raise ArgumentError, 'min_length must be smaller than or equal to max_length' unless min_length <= max_length character_types = [] required_min_length = 0 if mix_case character_types << :mix_case required_min_length += 2 end if special_characters character_types << :special_characters required_min_length += 1 end raise ArgumentError, "min_length should be at least #{required_min_length} to enable #{character_types.join(', ')} configuration" if min_length < required_min_length target_length = rand(min_length..max_length) password = [] character_bag = [] # use lower_chars by default and add upper_chars if mix_case lower_chars = self::LLetters password << sample(lower_chars) character_bag += lower_chars digits = ('0'..'9').to_a password << sample(digits) character_bag += digits if mix_case upper_chars = self::ULetters password << sample(upper_chars) character_bag += upper_chars end if special_characters special_chars = %w[! @ # $ % ^ & *] password << sample(special_chars) character_bag += special_chars end password << sample(character_bag) while password.length < target_length shuffle(password).join end ## # Returns the domain name # # @return [String] # # @param subdomain [Bool] If true passed adds a subdomain in response # @param domain [String] # # @example # Faker::Internet.domain_name #=> "altenwerth-gerhold.example" # Faker::Internet.domain_name(subdomain: true) #=> "metz.mclaughlin-brekke.test" # Faker::Internet.domain_name(subdomain: true, domain: 'faker') #=> "foo.faker.test" # Faker::Internet.domain_name(domain: 'faker-ruby.org') #=> "faker-ruby.org" # Faker::Internet.domain_name(subdomain: true, domain: 'faker-ruby.org') #=> "foo.faker-ruby.org" # Faker::Internet.domain_name(subdomain: true, domain: 'faker.faker-ruby.org') #=> "faker.faker-ruby.org" def domain_name(subdomain: false, domain: nil) with_locale(:en) do if domain domain .split('.') .map { |domain_part| Char.prepare(domain_part) } .tap do |domain_elements| if domain_elements.length < 2 domain_elements << domain_suffix(safe: true) end if subdomain && domain_elements.length < 3 domain_elements.unshift(Char.prepare(domain_word)) end end.join('.') else [domain_word, domain_suffix(safe: true)].tap do |domain_elements| if subdomain domain_elements.unshift(Char.prepare(domain_word)) end end.join('.') end end end ## # Fixes ä, ö, ü, ß characters in string passed with ae, oe, ue, ss resp. # # @return [String] # # @param string [String] # # @example # Faker::Internet.fix_umlauts #=> "" # Faker::Internet.fix_umlauts(string: 'faker') #=> "faker" # Faker::Internet.fix_umlauts(string: 'faküer') #=> "fakueer" def fix_umlauts(string: '') Char.fix_umlauts(string) end ## # Returns the domain word for internet # # @return [String] # # @example # Faker::Internet.domain_word #=> "senger" def domain_word with_locale(:en) { Char.prepare(Company.name.split.first) } end ## Returns the domain suffix e.g. com, org, co, biz, info etc. # # @return [String] # # @example # Faker::Internet.domain_suffix #=> "com" # Faker::Internet.domain_suffix #=> "biz" # Faker::Internet.domain_suffix(safe: true) #=> "example" # Faker::Internet.domain_suffix(safe: true) #=> "test" def domain_suffix(safe: nil) if safe fetch('internet.safe_domain_suffix') else fetch('internet.domain_suffix') end end ## # Returns the MAC address # # @return [String] # # @example # Faker::Internet.mac_address #=> "74:d0:c9:22:95:12" # Faker::Internet.mac_address(prefix: 'a') #=> "0a:91:ce:24:89:3b" # Faker::Internet.mac_address(prefix: 'aa') #=> "aa:38:a0:3e:e8:41" # Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95" def mac_address(prefix: '') prefix_digits = prefix.split(':').map { |d| d.to_i(16) } address_digits = Array.new(6 - prefix_digits.size) { rand(256) } (prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':') end ## # Returns the IPv4 address # # @return [String] # # @example # Faker::Internet.ip_v4_address #=> "97.117.128.93" def ip_v4_address [rand_in_range(0, 255), rand_in_range(0, 255), rand_in_range(0, 255), rand_in_range(0, 255)].join('.') end ## # Returns the private IPv4 address # # @return [String] # # @example # Faker::Internet.private_ip_v4_address #=> "127.120.80.42" def private_ip_v4_address sample(PRIVATE_IPV4_ADDRESS_RANGES).map { |range| rand(range) }.join('.') end ## # Returns the public IPv4 address # # @return [String] # # @example # Faker::Internet.public_ip_v4_address #=> "127.120.80.42" def public_ip_v4_address addr = nil loop do addr = ip_v4_address break unless reserved_net_checker[addr] end addr end ## # Returns the private network regular expressions # # @return [Array] # # @example # Faker::Internet.private_nets_regex #=> [/^10\./, /^100\.(6[4-9]|[7-9]\d|1[0-1]\d|12[0-7])\./, /^127\./, /^169\.254\./, /^172\.(1[6-9]|2\d|3[0-1])\./, /^192\.0\.0\./, /^192\.168\./, /^198\.(1[8-9])\./] def private_nets_regex [ /^10\./, # 10.0.0.0 - 10.255.255.255 /^100\.(6[4-9]|[7-9]\d|1[0-1]\d|12[0-7])\./, # 100.64.0.0 - 100.127.255.255 /^127\./, # 127.0.0.0 - 127.255.255.255 /^169\.254\./, # 169.254.0.0 - 169.254.255.255 /^172\.(1[6-9]|2\d|3[0-1])\./, # 172.16.0.0 - 172.31.255.255 /^192\.0\.0\./, # 192.0.0.0 - 192.0.0.255 /^192\.168\./, # 192.168.0.0 - 192.168.255.255 /^198\.(1[8-9])\./ # 198.18.0.0 - 198.19.255.255 ] end ## # Returns lambda to check if address passed is private or not # # @return [Lambda] # # @example # Faker::Internet.private_net_checker.call("127.120.80.42") #=> true # Faker::Internet.private_net_checker.call("148.120.80.42") #=> false def private_net_checker ->(addr) { private_nets_regex.any? { |net| net =~ addr } } end ## # Returns the reserved network regular expressions # # @return [Array] # # @example # Faker::Internet.reserved_nets_regex #=> [/^0\./, /^192\.0\.2\./, /^192\.88\.99\./, /^198\.51\.100\./, /^203\.0\.113\./, /^(22[4-9]|23\d)\./, /^(24\d|25[0-5])\./] def reserved_nets_regex [ /^0\./, # 0.0.0.0 - 0.255.255.255 /^192\.0\.2\./, # 192.0.2.0 - 192.0.2.255 /^192\.88\.99\./, # 192.88.99.0 - 192.88.99.255 /^198\.51\.100\./, # 198.51.100.0 - 198.51.100.255 /^203\.0\.113\./, # 203.0.113.0 - 203.0.113.255 /^(22[4-9]|23\d)\./, # 224.0.0.0 - 239.255.255.255 /^(24\d|25[0-5])\./ # 240.0.0.0 - 255.255.255.254 and 255.255.255.255 ] end ## # Returns lambda function to check address passed is reserved or not # # @return [Lambda] # # @example # Faker::Internet.reserved_net_checker.call('192.88.99.255') #=> true # Faker::Internet.reserved_net_checker.call('192.88.199.255') #=> false def reserved_net_checker ->(addr) { (private_nets_regex + reserved_nets_regex).any? { |net| net =~ addr } } end ## # Returns Ipv4 address with CIDR, range from 1 to 31 # # @return [String] # # @example # Faker::Internet.ip_v4_cidr #=> "129.162.99.74/16" # Faker::Internet.ip_v4_cidr #=> "129.162.99.74/24" def ip_v4_cidr "#{ip_v4_address}/#{rand(1..31)}" end ## # Returns Ipv6 address # # @return [String] # # @example # Faker::Internet.ip_v6_address #=> "7754:76d4:c7aa:7646:ea68:1abb:4055:4343" def ip_v6_address (1..8).map { rand(65_536).to_s(16) }.join(':') end ## # Returns Ipv6 address with CIDR, range between 1 to 127 # # @return [String] # # @example # Faker::Internet.ip_v6_cidr #=> "beca:9b99:4bb6:9712:af2f:516f:8507:96e1/99" def ip_v6_cidr "#{ip_v6_address}/#{rand(1..127)}" end ## # Returns URL # # @return [String] # # @param host [String] # @param path [String] # @param scheme [String] # # @example # Faker::Internet.url #=> "http://treutel.test/demarcus" # Faker::Internet.url(host: 'faker') #=> "http://faker/shad" # Faker::Internet.url(host: 'faker', path: '/docs') #=> "http://faker/docs" # Faker::Internet.url(host: 'faker', path: '/docs', scheme: 'https') #=> "https://faker/docs" def url(host: domain_name, path: "/#{username}", scheme: 'http') "#{scheme}://#{host}#{path}" end ## # Returns unique string in URL # # @return [String] # # @param words [String] Comma or period separated words list # @param glue [String] Separator to add between words passed, default used are '-' or '_' # # @example # Faker::Internet.slug #=> "repudiandae-sed" # Faker::Internet.slug(words: 'test, faker') #=> "test-faker" # Faker::Internet.slug(words: 'test. faker') #=> "test-faker" # Faker::Internet.slug(words: 'test. faker', glue: '$') #=> "test$faker" def slug(words: nil, glue: nil) glue ||= sample(%w[- _]) return words.delete(',.').gsub(' ', glue).downcase unless words.nil? sample(translate('faker.internet.slug'), 2).join(glue) end ## # Generates random token # # @return[String] # # @example # Faker::Internet.device_token #=> "749f535671cf6b34d8e794d212d00c703b96274e07161b18b082d0d70ef1052f" def device_token shuffle(rand(16**64).to_s(16).rjust(64, '0').chars.to_a).join end ## # Generates the random browser identifier # # @return [String] # # @param vendor [String] Name of vendor, supported vendors are aol, chrome, firefox, internet_explorer, netscape, opera, safari # # @example # Faker::Internet.user_agent #=> "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" # Faker::Internet.user_agent(vendor: 'chrome') #=> "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" # Faker::Internet.user_agent(vendor: 'safari') #=> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A" # Faker::Internet.user_agent(vendor: 'faker') #=> "Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285" def user_agent(vendor: nil) agent_hash = translate('faker.internet.user_agent') agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)] sample(agents) end ## # Generate Web Crawler's user agents # # @return [String] # # @param vendor [String] Name of vendor, supported vendors are googlebot, bingbot, duckduckbot, baiduspider, yandexbot # # @example # Faker::Internet.bot_user_agent #=> "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)" # Faker::Internet.bot_user_agent(vendor: 'googlebot') #=> "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/99.0.4844.84 Safari/537.36" # Faker::Internet.bot_user_agent(vendor: 'bingbot') #=> "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/86.0.4240.68 Safari/537.36 Edg/86.0.622.31" def bot_user_agent(vendor: nil) agent_hash = translate('faker.internet.bot_user_agent') agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)] sample(agents) end ## # Generated universally unique identifier # # @return [String] # # @example # Faker::Internet.uuid #=> "8a6cdd40-6d78-4fdb-912b-190e3057197f" def uuid # borrowed from: https://github.com/ruby/ruby/blob/d48783bb0236db505fe1205d1d9822309de53a36/lib/securerandom.rb#L250 ary = Faker::Config.random.bytes(16).unpack('NnnnnN') ary[2] = (ary[2] & 0x0fff) | 0x4000 ary[3] = (ary[3] & 0x3fff) | 0x8000 '%08x-%04x-%04x-%04x-%04x%08x' % ary # rubocop:disable Style/FormatString end ## # Produces a random string of alphabetic characters, (no digits) # # @param length [Integer] The length of the string to generate # @param padding [Boolean] Toggles if a final equal '=' will be added. # @param urlsafe [Boolean] Toggles charset to '-' and '_' instead of '+' and '/'. # # @return [String] # # @example # Faker::Internet.base64 # #=> "r_hbZ2DSD-ZACzZT" # @example # Faker::Internet.base64(length: 4, padding: true, urlsafe: false) # #=> "x1/R=" # # @faker.version 2.11.0 def base64(length: 16, padding: false, urlsafe: true) char_range = [ Array('0'..'9'), Array('A'..'Z'), Array('a'..'z'), urlsafe ? %w[- _] : %w[+ /] ].flatten s = Array.new(length) { sample(char_range) }.join s += '=' if padding s end ## # Produces a randomized hash of internet user details # @example # Faker::Internet.user #=> { username: 'alexie', email: 'trudie@grant.test' } # # @example # Faker::Internet.user('username', 'email', 'password') #=> { username: 'alexie', email: 'gayle@kohler.test', password: 'DtEf9P8wS31iMyC' } # # @return [hash] # # @faker.version next def user(*args) user_hash = {} args = %w[username email] if args.empty? args.each { |arg| user_hash[:"#{arg}"] = send(arg) } user_hash end alias user_name username private def sanitize_email_local_part(local_part) char_range = [ Array('0'..'9'), Array('A'..'Z'), Array('a'..'z'), "!#$%&'*+-/=?^_`{|}~.".chars ].flatten local_part.chars.map do |char| char_range.include?(char) ? char : '#' end.join end def construct_email(local_part, domain_name) [local_part, domain_name].join('@') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/company.rb
lib/faker/default/company.rb
# frozen_string_literal: true module Faker class Company < Base flexible :company class << self ## # Produces a company name. # # @return [String] # # @example # Faker::Company.name #=> "Roberts Inc" # # @faker.version 1.6.0 def name parse('company.name') end ## # Produces a company suffix. # # @return [String] # # @example # Faker::Company.suffix #=> "LLC" # # @faker.version 1.6.0 def suffix fetch('company.suffix') end ## # Produces a company industry. # # @return [String] # # @example # Faker::Company.industry #=> "Food & Beverages" # # @faker.version 1.6.0 def industry fetch('company.industry') end ## # Produces a company catch phrase. # # @return [String] # # @example # Faker::Company.catch_phrase #=> "Grass-roots grid-enabled portal" # # @faker.version 1.6.0 def catch_phrase translate('faker.company.buzzwords').collect { |list| sample(list) }.join(' ') end ## # Produces a company buzzword. # # @return [String] # # @example # Faker::Company.buzzword #=> "flexibility" # # @faker.version 1.8.7 def buzzword sample(translate('faker.company.buzzwords').flatten) end ## # Produces some company BS. # # @return [String] # # @example # Faker::Company.bs #=> "empower customized functionalities" # # @faker.version 1.6.0 # When a straight answer won't do, BS to the rescue! def bs translate('faker.company.bs').collect { |list| sample(list) }.join(' ') end ## # Produces a company EIN (Employer Identification Number). # # @return [String] # # @example # Faker::Company.ein #=> "07-4009024" # # @faker.version 1.6.0 def ein format('%09d', rand(10**9)).gsub(/(\d{2})(\d{7})/, '\\1-\\2') end ## # Produces a company duns number. # # @return [String] # # @example # Faker::Company.duns_number #=> "70-655-5105" # # @faker.version 1.6.0 def duns_number format('%09d', rand(10**9)).gsub(/(\d{2})(\d{3})(\d{4})/, '\\1-\\2-\\3') end ## # Produces a company logo. # # @return [String] # # @example # Faker::Company.logo #=> "https://pigment.github.io/fake-logos/logos/medium/color/12.png" # # @faker.version 1.8.7 # Get a random company logo url in PNG format. def logo rand_num = rand(1..13) "https://pigment.github.io/fake-logos/logos/medium/color/#{rand_num}.png" end ## # Produces a company type. # # @return [String] # # @example # Faker::Company.type #=> "Partnership" # # @faker.version 1.8.7 def type fetch('company.type') end ## # Produces a company profession. # # @return [String] # # @example # Faker::Company.profession #=> "factory worker" # # @faker.version 1.6.0 def profession fetch('company.profession') end ## # Produces a company department. # # @return [String] # # @example # Faker::Company.department #=> "Information Technology" # # @faker.version next def department fetch('company.department') end ## # Produces a company spanish organisation number. # # @return [String] # # @example # Faker::Company.spanish_organisation_number #=> "D6819358" # # @faker.version 1.8.5 # # Get a random Spanish organization number. See more here https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal def spanish_organisation_number(organization_type: nil) # Valid leading character: A, B, C, D, E, F, G, H, J, N, P, Q, R, S, U, V, W # format: 1 digit letter (organization type) + 7 digit numbers + 1 digit control (letter or number based on # organization type) letters = %w[A B C D E F G H J N P Q R S U V W] organization_type = sample(letters) unless letters.include?(organization_type) code = format('%07d', rand(10**7)) control = spanish_cif_control_digit(organization_type, code) [organization_type, code, control].join end ## # Produces a company swedish organisation number. # # @return [String] # # @example # Faker::Company.swedish_organisation_number #=> "3866029808" # # @faker.version 1.7.0 # Get a random Swedish organization number. See more here https://sv.wikipedia.org/wiki/Organisationsnummer def swedish_organisation_number # Valid leading digit: 1, 2, 3, 5, 6, 7, 8, 9 # Valid third digit: >= 2 # Last digit is a control digit base = [sample([1, 2, 3, 5, 6, 7, 8, 9]), sample((0..9).to_a), sample((2..9).to_a), format('%06d', rand(10**6))].join base + luhn_algorithm(base).to_s end ## # Produces a company czech organisation number. # # @return [String] # # @example # Faker::Company.czech_organisation_number #=> "90642741" # # @faker.version 1.9.1 def czech_organisation_number sum = 0 base = [] [8, 7, 6, 5, 4, 3, 2].each do |weight| base << sample((0..9).to_a) sum += (weight * base.last) end base << (11 - (sum % 11)) % 10 base.join end ## # Produces a company french siren number. # # @return [String] # # @example # Faker::Company.french_siren_number #=> "163417827" # # @faker.version 1.8.5 # Get a random French SIREN number. See more here https://fr.wikipedia.org/wiki/Syst%C3%A8me_d%27identification_du_r%C3%A9pertoire_des_entreprises def french_siren_number base = (1..8).map { rand(10) }.join base + luhn_algorithm(base).to_s end ## # Produces a company french siret number. # # @return [String] # # @example # Faker::Company.french_siret_number #=> "76430067900496" # # @faker.version 1.8.5 def french_siret_number location = rand(100).to_s.rjust(4, '0') org_no = french_siren_number + location org_no + luhn_algorithm(org_no).to_s end ## # Produces a company norwegian organisation number. # # @return [String] # # @example # Faker::Company.norwegian_organisation_number #=> "842457173" # # @faker.version 1.8.0 # Get a random Norwegian organization number. Info: https://www.brreg.no/om-oss/samfunnsoppdraget-vart/registera-vare/einingsregisteret/organisasjonsnummeret/ def norwegian_organisation_number # Valid leading digit: 8, 9 mod11_check = nil while mod11_check.nil? base = [sample([8, 9]), format('%07d', rand(10**7))].join mod11_check = mod11(base) end base + mod11_check.to_s end ## # Produces a company australian business number. # # @return [String] # # @example # Faker::Company.australian_business_number #=> "93579396170" # # @faker.version 1.6.4 def australian_business_number base = format('%09d', rand(10**9)) abn = "00#{base}" (99 - (abn_checksum(abn) % 89)).to_s + base end ## # Produces a company polish taxpayer identification_number. # # @return [String] # # @example # Faker::Company.polish_taxpayer_identification_number #=> "2767549463" # # @faker.version 1.9.1 # Get a random Polish taxpayer identification number More info https://pl.wikipedia.org/wiki/NIP def polish_taxpayer_identification_number result = [] weights = [6, 5, 7, 2, 3, 4, 5, 6, 7] loop do result = Array.new(3) { rand(1..9) } + Array.new(7) { rand(10) } break if (weight_sum(result, weights) % 11) == result[9] end result.join end ## # Produces a company polish register of national economy. # # @return [String] # # @example # Faker::Company.polish_register_of_national_economy #=> "788435970" # # @faker.version 1.9.1 # Get a random Polish register of national economy number. More info https://pl.wikipedia.org/wiki/REGON def polish_register_of_national_economy(length: 9) raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length random_digits = [] loop do random_digits = Array.new(length) { rand(10) } break if collect_regon_sum(random_digits) == random_digits.last end random_digits.join end ## # Produces a company south african pty ltd registration number. # # @return [String] # # @example # Faker::Company.south_african_pty_ltd_registration_number #=> "7043/2400717902/07" # # @faker.version 1.9.2 def south_african_pty_ltd_registration_number generate(:string) do |g| g.int(length: 4) g.lit('/') g.int(ranges: [1000..9_999_999_999]) g.lit('/07') end end ## # Produces a company south african close corporation registration number. # # @return [String] # # @example # Faker::Company.south_african_close_corporation_registration_number #=> "CK38/5739937418/23" # # @faker.version 1.9.2 def south_african_close_corporation_registration_number generate(:string) do |g| g.oneof do |one| one.group do |g_| g_.lit('CK') g_.int(length: 2) end one.int(length: 4) end g.lit('/') g.int(ranges: [1000..9_999_999_999]) g.lit('/23') end end ## # Produces a company south african listed company registration number. # # @return [String] # # @example # Faker::Company.south_african_listed_company_registration_number #=> "2512/87676/06" # # @faker.version 1.9.2 def south_african_listed_company_registration_number generate(:string) do |g| g.int(length: 4) g.lit('/') g.int(ranges: [1000..9_999_999_999]) g.lit('/06') end end ## # Produces a company south african trust registration number. # # @return [String] # # @example # Faker::Company.south_african_trust_registration_number #=> "IT5673/937519896" # # @faker.version 1.9.2 def south_african_trust_registration_number generate(:string) do |g| g.lit('IT') g.int(ranges: [10..9999]) g.lit('/') g.int(ranges: [10..9_999_999_999]) end end ## # Produces a company brazilian company number. # # @return [String] # # @example # Faker::Company.brazilian_company_number #=> "37205322000500" # # @faker.version 1.9.2 def brazilian_company_number(formatted: false) digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i] factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 6].cycle 2.times do checksum = digits.inject(0) { |acc, digit| acc + digit * factors.next } % 11 digits << (checksum < 2 ? 0 : 11 - checksum) end number = digits.join formatted ? format('%s.%s.%s/%s-%s', *number.scan(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/).flatten) : number end ## # Get a random Russian tax number. # @param region [String] Any region string # @param type [Symbol] Legeal or not, defaults to :legal # # @return [String] # @example # Faker::Company.russian_tax_number #=> "0415584064" # Faker::Company.russian_tax_number(region: 'AZ') #=> "AZ50124562" # Faker::Company.russian_tax_number(region: 'AZ', type: false) #=> "AZ8802315465" # # @faker.version 1.9.4 def russian_tax_number(region: nil, type: :legal) inn_number(region, type) end ## # Produces a company sic code. # # @return [String] # # @example # Faker::Company.sic_code #=> "7383" # # @faker.version 1.9.4 def sic_code fetch('company.sic_code') end ## # Get a random Indian Goods and Services Tax (GST) number. # For more on Indian tax number here: # https://simple.wikipedia.org/wiki/GSTIN # @params state code [String] Any state code. # # @return [String] # @example # Faker::Company.indian_gst_number #=> "15VQPNZ2126J2ZU" # Faker::Company.indian_gst_number(state_code: "22") #=> "22ZVWEY6632K0ZN" # # @faker.version 3.2.1 def indian_gst_number(state_code: nil) # Check if state code is valid state_code_ranges = [('02'..'38'), ['98']] if state_code && !(state_code_ranges[0].include?(state_code) || state_code == '98') raise ArgumentError, 'state code must be in a range of 02 to 38 or 98' end PositionalGenerator.new(:string) do |gen| # Generate a state code if not given if state_code gen.lit(state_code, name: :state_code_param) else gen.letter(name: :state_code_param, length: 1, ranges: state_code_ranges) end # Construct taxpayer number gen.group(name: :taxpayer_number) do |g_| g_.letter(length: 3, ranges: ['A'..'Z']) g_.letter(length: 1, ranges: [%w[A B C F G H L J P T K]]) g_.letter(length: 1, ranges: ['A'..'Z']) g_.int(length: 4, ranges: [0..9999]) g_.letter(length: 1, ranges: ['A'..'Z']) end gen.int(name: :registration_number, length: 1, ranges: [0..9]) gen.letter(name: :z_char, length: 1, ranges: [['Z']]) gen.computed(deps: %i[state_code_param taxpayer_number registration_number]) do |state_code_param, taxpayer_number, registration_number| gst_base = "#{state_code_param}#{taxpayer_number}#{registration_number}" chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars values = gst_base.chars sum = values.map.with_index do |char, index| product = chars.index(char) * (index.odd? ? 2 : 1) (product / chars.length).floor + (product % chars.length) end.reduce(:+) checksum = (chars.length - (sum % chars.length)) % chars.length chars[checksum] end end.generate end private # Mod11 functionality from https://github.com/badmanski/mod11/blob/master/lib/mod11.rb def mod11(number) weight = [2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7] sum = 0 number.to_s.reverse.chars.each_with_index do |char, i| sum += char.to_i * weight[i] end remainder = sum % 11 case remainder when 0 then remainder when 1 then nil else 11 - remainder end end def luhn_algorithm(number) multiplications = [] number.to_s.reverse.chars.each_with_index do |digit, i| multiplications << if i.even? digit.to_i * 2 else digit.to_i end end sum = 0 multiplications.each do |num| num.to_s.each_byte do |character| sum += character.chr.to_i end end if (sum % 10).zero? 0 else (sum / 10 + 1) * 10 - sum end end def abn_checksum(abn) abn_weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19] sum = 0 abn_weights.each_with_index do |weight, i| sum += weight * abn[i].to_i end sum end def collect_regon_sum(array) weights = if array.size == 9 [8, 9, 2, 3, 4, 5, 6, 7] else [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8] end sum = weight_sum(array, weights) % 11 sum == 10 ? 0 : sum end def weight_sum(array, weights) sum = 0 (0..(weights.size - 1)).each do |index| sum += (array[index] * weights[index]) end sum end # # For more on Russian tax number algorithm here: # https://ru.wikipedia.org/wiki/Идентификационный_номер_налогоплательщика#Вычисление_контрольных_цифр # # Range of regions: # https://ru.wikipedia.org/wiki/Коды_субъектов_Российской_Федерации # region [String] Any region string # @param type [Symbol] Legeal or not, defaults to :legal # # @return [String] # @example # Faker::Comnpany.russian_tax_number # Faker::Comnpany.russian_tax_number(region: 'AZ') # Faker::Comnpany.russian_tax_number(region: 'AZ', type: false) def inn_number(region, type) n10 = [2, 4, 10, 3, 5, 9, 4, 6, 8] n11 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8] n12 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8] region = format('%.2d', rand(0o1..92)) if region.nil? checksum = if type == :legal number = region.to_s + rand(1_000_000..9_999_999).to_s inn_checksum(n10, number) else number = region.to_s + rand(10_000_000..99_999_999).to_s inn_checksum(n11, number) + inn_checksum(n12, number + inn_checksum(n11, number)) end number + checksum end def inn_checksum(factor, number) ( factor.map.with_index.reduce(0) do |v, i| v + i[0] * number[i[1]].to_i end % 11 % 10 ).to_s end def spanish_cif_control_digit(organization_type, code) letters = %w[J A B C D E F G H I] control = code.chars.each_with_index.inject(0) do |sum, (value, index)| if (index + 1).even? sum + value.to_i else sum + spanish_b_algorithm(value.to_i) end end control = control.to_s[-1].to_i control = 10 - control unless control.zero? %w[A B C D E F G H J U V].include?(organization_type) ? control : letters[control] end def spanish_b_algorithm(value) result = value.to_i * 2 return result if result < 10 result.to_s[0].to_i + result.to_s[1].to_i end def calculate_gst_checksum(state_code, taxpayer_number, registration_number) gst_base = "#{state_code}#{taxpayer_number}#{registration_number}" chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars values = gst_base.upcase.chars sum = values.map.with_index do |char, index| product = chars.index(char) * (index.odd? ? 2 : 1) (product / chars.length).floor + (product % chars.length) end.reduce(:+) checksum = (chars.length - (sum % chars.length)) % chars.length chars[checksum] end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/default/html.rb
lib/faker/default/html.rb
# frozen_string_literal: true module Faker class HTML < Base class << self ## # Produces a random HTML header format. # # @return [String] # # @example # Faker::HTML.heading #=> "<h5>Autem</h5>" # # @faker.version 3.2.1 def heading level = rand(1..6) "<h#{level}>#{Lorem.word.capitalize}</h#{level}>" end ## # Produces a random HTML paragraph format. # # @param sentence_count [Integer] The number of sentences in the paragraph. # @param supplemental [Boolean] Include supplemental text. # @param random_sentences_to_add [Integer] The number of random sentences to add to the paragraph. # @param exclude_words [Array<String>] Words to exclude from the generated paragraph. # @return [String] # # @example # Faker::HTML.paragraph #=> "<p>Incidunt atque quis</p>" # # @faker.version 3.2.1 def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0, exclude_words: nil) "<p>#{Faker::Lorem.paragraph(sentence_count: sentence_count, supplemental: supplemental, random_sentences_to_add: random_sentences_to_add, exclude_words: exclude_words)}</p>" end ## # Produces a random emphasis formatting on a random word in two HTML paragraphs. # # @return [String] # # @example # Faker::HTML.emphasis #=> "<em>repellat id impedit</em>" # # @faker.version 3.2.1 def emphasis "<em>#{Faker::Lorem.paragraph(sentence_count: 1)}</em>" end ## # Produces a random ordered list in HTML format, with at least one element. # # @return [String] # # @example # Faker::HTML.ordered_list #=> "<ol>\n<li>Qui reiciendis non consequatur atque.</li>\n<li>Quo doloremque veritatis tempora aut.</li>\n<li>Aspernatur.</li>\n<li>Ea ab.</li>\n<li>Qui.</li>\n<li>Sit pariatur nemo eveniet.</li>\n<li>Molestiae aut.</li>\n<li>Nihil molestias iure placeat.</li>\n<li>Dolore autem quisquam.</li>\n</ol>" # # @faker.version 3.2.1 def ordered_list number = rand(1..10) items = [] number.times do items << "<li>#{Faker::Lorem.sentence(word_count: 1)}</li>" end "<ol>\n#{items.join("\n")}\n</ol>" end ## # Produces a random unordered list of items between 1 and 10 randomly in HTML format. # # @return [String] # # @example # Faker::HTML.unordered_list #=> "<ul>\n<li>Voluptatum aliquid tempora molestiae facilis non sed.</li>\n<li>Nostrum omnis iste impedit voluptatum dolor.</li>\n<li>Esse quidem et facere.</li>\n</ul>" # # @faker.version 3.2.1 def unordered_list number = rand(1..10) items = [] number.times do items << "<li>#{Faker::Lorem.sentence(word_count: 1)}</li>" end "<ul>\n#{items.join("\n")}\n</ul>" end ## # Produces a random code block formatted in HTML. # # @return [String] # # @example # Faker::HTML.code #=> "<code>Eos quasi qui.</code>" # # @faker.version 3.2.1 def code "<code>#{Lorem.sentence(word_count: 1)}</code>" end ## # Produces a random HTML table. # # @return [String] # # @example # Faker::HTML.table #=> "<table>\n<thead>\n<th>ad</th>\n<th>similique</th>\n<th>voluptatem</th>\n</thead>\n<tbody>\n<td>corrupti</td>\n<td>est</td>\n<td>rerum</td>\n<td>molestiae</td>\n<td>quidem</td>\n<td>et</td>\n<td>in</td>\n<td>tempora</td>\n<td>at</td>\n<\tbody>\n<tfoot>\n<td>voluptatem</td>\n<td>debitis</td>\n<td>rem</td>\n</tfoot>\n</table>" # # @faker.version 3.2.1 def table header_row = generate_table_row('th', 3) footer_row = generate_table_row('td', 3) body_rows = [] 3.times do row = generate_table_row('td', 3) body_rows << row end thead = "<thead>\n#{header_row}</thead>" tbody = "<tbody>\n#{body_rows.join("\n")}</tbody>" tfoot = "<tfoot>\n#{footer_row}</tfoot>" "<table>\n#{thead}\n#{tbody}\n#{tfoot}\n</table>" end ## # Generates a random <script> tag with the `src` attribute set to a random URL. # # @return [String] # # @example # Faker::HTML.script #=> "<script src=\"http://gulgowski.name/jordan.weimann.js\"></script>" # # @faker.version 3.2.1 def script "<script src=\"#{Faker::Internet.url}.js\"></script>" end ## # Generates a random <link> tag with the `rel` attribute set to "stylesheet" and the `href` attribute set to a random URL. # # @param rel [String] The rel of the link tag. # @return [String] # # @example # Faker::HTML.link #=> "<link rel=\"stylesheet\" href=\"http://fay.io/darryl.barrows.css\">" # # @faker.version 3.2.1 def link(rel: 'stylesheet') "<link rel=\"#{rel}\" href=\"#{Faker::Internet.url}.css\">" end ## # Generates HTML content with customizable attributes for any HTML tag. # # @param tag [String] The HTML tag to generate. # @param content [String] The Content of the HTML tag. # @param attributes [Hash] The attributes to include in the tag. # @return [String] # # @example # Faker::HTML.element(tag: 'div', content: "This is a div with XSS attributes.", attributes: {class: 'xss', onclick: "alert('XSS')"}) #=> "<div class=\"xss\" onclick=\"alert('XSS')\">This is a div with XSS attributes.</div>" # # @faker.version 3.2.1 def element(tag: 'div', content: Lorem.sentence(word_count: 3), attributes: { class: Lorem.word, onclick: "#{Lorem.word}()" }) attribute_string = attributes.map { |key, value| "#{key}=\"#{value}\"" }.join(' ') "<#{tag} #{attribute_string}>#{content}</#{tag}>" end ## # Produces a random method from the methods above, excluding the methods listed in the arguments. # # @overload random(methods) # @param methods [Symbol] Specify which methods to exclude. # # @return [String] # # @example # Faker::HTML.random #=> returns output from a single method outlined above # Faker::HTML.random(exclude: [:table]) #=> returns output from any single method outlined above except for "table" # Faker::HTML.random(exclude: [:ordered_list, :unordered_list]) #=> returns output from any single method outlined above except for either ordered_list and unordered_list # # @faker.version 3.2.1 def random(exclude: []) method_list = available_methods exclude.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } } send(method_list[Faker::Config.random.rand(0..(method_list.length - 1))]) end ## # Generates a random HTML content sandwich, starting with a header, followed by paragraphs, and random elements. # # @param sentences [Integer] The number of sentences in each paragraph. # @param repeat [Integer] The number of times to repeat the pattern (header, paragraph, random). # @return [String] # # @example # Faker::HTML.sandwich(sentences: 3, repeat: 2) #=> returns a sandwich of HTML content with 2 repetitions, each having a header, paragraph, and random element # # @faker.version 3.2.1 def sandwich(sentences: 3, repeat: 1) text_block = [] text_block << heading repeat.times do text_block << paragraph(sentence_count: sentences) text_block << random(exclude: %i[script link]) end text_block.join("\n") end private def available_methods (HTML.public_methods(false) - Base.methods).sort end def generate_table_row(tag, cell_count) row = "<tr>\n" cell_count.times do row += "<#{tag == 'th' ? 'th' : 'td'}>#{Lorem.word}</#{tag == 'th' ? 'th' : 'td'}>\n" end row += "</tr>\n" row end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/sword_art_online.rb
lib/faker/japanese_media/sword_art_online.rb
# frozen_string_literal: true module Faker class JapaneseMedia class SwordArtOnline < Base class << self ## # Produces the real name of a character from Sword Art Online. # # @return [String] # # @example # Faker::JapaneseMedia::SwordArtOnline.real_name #=> "Kirigaya Kazuto" # # @faker.version 1.9.0 def real_name fetch('sword_art_online.real_name') end ## # Produces the in-game name of a character from Sword Art Online. # # @return [String] # # @example # Faker::JapaneseMedia::SwordArtOnline.game_name #=> "Silica" # # @faker.version 1.9.0 def game_name fetch('sword_art_online.game_name') end ## # Produces the name of a location from Sword Art Online. # # @return [String] # # @example # Faker::JapaneseMedia::SwordArtOnline.location #=> "Ruby Palace" # # @faker.version 1.9.0 def location fetch('sword_art_online.location') end ## # Produces the name of an item from Sword Art Online. # # @return [String] # # @example # Faker::JapaneseMedia::SwordArtOnline.item #=> "Blackwyrm Coat" # # @faker.version 1.9.0 def item fetch('sword_art_online.item') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/one_piece.rb
lib/faker/japanese_media/one_piece.rb
# frozen_string_literal: true module Faker class JapaneseMedia class OnePiece < Base class << self ## # Produces a character from One Piece. # # @return [String] # # @example # Faker::JapaneseMedia::OnePiece.character #=> "Monkey D. Luffy" # # @faker.version 1.8.5 def character fetch('one_piece.characters') end ## # Produces a sea from One Piece. # # @return [String] # # @example # Faker::JapaneseMedia::OnePiece.sea #=> "East Blue" # # @faker.version 1.8.5 def sea fetch('one_piece.seas') end ## # Produces an island from One Piece. # # @return [String] # # @example # Faker::JapaneseMedia::OnePiece.island #=> "Laftel" # # @faker.version 1.8.5 def island fetch('one_piece.islands') end ## # Produces a location from One Piece. # # @return [String] # # @example # Faker::JapaneseMedia::OnePiece.location #=> "Foosha Village" # # @faker.version 1.8.5 def location fetch('one_piece.locations') end ## # Produces a quote from One Piece. # # @return [String] # # @example # Faker::JapaneseMedia::OnePiece.quote #=> "ONE PIECE IS REAL!" # # @faker.version 1.8.5 def quote fetch('one_piece.quotes') end ## # Produces an akuma no mi from One Piece. # # @return [String] # # @example # Faker::JapaneseMedia::OnePiece.akuma_no_mi #=> "Gomu Gomu no Mi" # # @faker.version 1.8.5 def akuma_no_mi fetch('one_piece.akuma_no_mi') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/studio_ghibli.rb
lib/faker/japanese_media/studio_ghibli.rb
# frozen_string_literal: true module Faker class JapaneseMedia class StudioGhibli < Base class << self ## # Produces a character from the Studio Ghibli. # # @return [String] # # @example # Faker::JapaneseMedia::StudioGhibli.character #=> "Chihiro" # # @faker.version next def character fetch('studio_ghibli.characters') end ## # Produces a quote from Studio Ghibli's movies. # # @return [String] # # @example # Faker::JapaneseMedia::StudioGhibli.quote #=> "One thing you can always count on is that hearts change." # # @faker.version next def quote fetch('studio_ghibli.quotes') end ## # Produces a movie from Studio Ghibli. # # @return [String] # # @example # Faker::JapaneseMedia::StudioGhibli.movie #=> "Kiki's Delivery Service" # # @faker.version next def movie fetch('studio_ghibli.movies') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb
lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb
# frozen_string_literal: true module Faker class JapaneseMedia class FullmetalAlchemistBrotherhood < Base class << self ## # Produces a character from FullmetalAlchemistBrotherhood. # # @return [String] # # @example # Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.character #=> "Edward Elric" # # @faker.version next def character fetch('fullmetal_alchemist_brotherhood.characters') end ## # Produces a cities from FullmetalAlchemistBrotherhood. # # @return [String] # # @example # Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.city #=> "Central City" # # @faker.version next def city fetch('fullmetal_alchemist_brotherhood.cities') end ## # Produces a country from FullmetalAlchemistBrotherhood. # # @return [String] # # @example # Faker::JapaneseMedia::FullmetalAlchemistBrotherhood.country #=> "Xing" # # @faker.version next def country fetch('fullmetal_alchemist_brotherhood.countries') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/kamen_rider.rb
lib/faker/japanese_media/kamen_rider.rb
# frozen_string_literal: true module Faker class JapaneseMedia class KamenRider < Base class << self ERAS = %i[showa heisei reiwa].freeze def eras=(new_eras) selected_eras = ERAS & new_eras @eras = selected_eras.empty? ? ERAS : selected_eras end ## # Produces the name of a Kamen Rider from a series in the given era. # # @return [String] # # @example # Faker::JapaneseMedia::KamenRider.kamen_rider #=> "Kamen Rider Revice" # # @faker.version next def kamen_rider(*eras) from_eras(*eras, field: :kamen_riders) end ## # Produces the name of a main user of Kamen Rider. # # @return [String] # # @example # Faker::JapaneseMedia::KamenRider.user #=> "Ikki Igarashi" # # @faker.version next def user(*eras) from_eras(*eras, field: :users) end ## # Produces the name of a Kamen Rider series. # # @return [String] # # @example # Faker::JapaneseMedia::KamenRider.series #=> "Kamen Rider Revice" # # @faker.version next def series(*eras) from_eras(*eras, field: :series) end ## # Produces the name of a collectible device from a Kamen Rider series. # # @return [String] # # @example # Faker::JapaneseMedia::KamenRider.collectible_device #=> "Vistamp" # # @faker.version next def collectible_device(*eras) from_eras(*eras, field: :collectible_devices) { |e| e.delete(:showa) } end # Produces the name of a transformation device used by a Kamen Rider # from the given eras. # # @return [String] # # @example Faker::JapaneseMedia::KamenRider.transformation_device #=> # "Revice Driver" # # @faker.version next def transformation_device(*eras) from_eras(*eras, field: :transformation_devices) end private def eras @eras ||= ERAS end def from_eras(*input_eras, field:) selected_eras = (ERAS & input_eras).then do |selected| selected.empty? ? eras : selected end.dup yield(selected_eras) if block_given? raise UnavailableInEra, "#{field} is unavailable in the selected eras." if selected_eras.empty? selected_eras.sample.then do |era| fetch("kamen_rider.#{era}.#{field}") end end class UnavailableInEra < StandardError; end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/conan.rb
lib/faker/japanese_media/conan.rb
# frozen_string_literal: true module Faker class JapaneseMedia class Conan < Base class << self ## # Produces a character from Conan. # # @return [String] # # @example # Faker::JapaneseMedia::Conan.character #=> "Conan Edogawa" # # @faker.version next def character fetch('conan.characters') end ## # Produces a gadget from Conan. # # @return [String] # # @example # Faker::JapaneseMedia::Conan.gadget #=> "Voice-Changing Bowtie" # # @faker.version next def gadget fetch('conan.gadgets') end ## # Produces a vehicle from Conan. # # @return [String] # # @example # Faker::JapaneseMedia::Conan.vehicle #=> "Agasa's Volkswagen Beetle" # # @faker.version next def vehicle fetch('conan.vehicles') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/naruto.rb
lib/faker/japanese_media/naruto.rb
# frozen_string_literal: true module Faker class JapaneseMedia class Naruto < Base class << self ## # Produces a character from Naruto. # # @return [String] # # @example # Faker::JapaneseMedia::Naruto.character #=> "Naruto Uzumaki" # # @faker.version next def character fetch('naruto.characters') end ## # Produces a village from Naruto. # # @return [String] # # @example # Faker::JapaneseMedia::Naruto.village #=> "Konohagakure (Leaf Village)" # # @faker.version next def village fetch('naruto.villages') end ## # Produces a eye from Naruto. # # @return [String] # # @example # Faker::JapaneseMedia::Naruto.eye #=> "Konohagakure (Byakugan)" # # @faker.version next def eye fetch('naruto.eyes') end ## # Produces a demon from Naruto. # # @return [String] # # @example # Faker::JapaneseMedia::Naruto.demon #=> "Nine-Tails (Kurama)" # # @faker.version next def demon fetch('naruto.demons') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/doraemon.rb
lib/faker/japanese_media/doraemon.rb
# frozen_string_literal: true module Faker class JapaneseMedia class Doraemon < Base class << self ## # Produces a character from Doraemon. # # @return [String] # # @example # Faker::JapaneseMedia::Doraemon.character #=> "Nobita" # # @faker.version next def character fetch('doraemon.characters') end ## # Produces a gadget from Doraemon. # # @return [String] # # @example # Faker::JapaneseMedia::Doraemon.gadget #=> "Anywhere Door" # # @faker.version next def gadget fetch('doraemon.gadgets') end ## # Produces a location from Doraemon. # # @return [String] # # @example # Faker::JapaneseMedia::Doraemon.location #=> "Tokyo" # # @faker.version next def location fetch('doraemon.locations') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/dragon_ball.rb
lib/faker/japanese_media/dragon_ball.rb
# frozen_string_literal: true module Faker class JapaneseMedia class DragonBall < Base class << self ## # Produces the name of a character from Dragon Ball. # # @return [String] # # @example # Faker::Games::DragonBall.character #=> "Goku" # # @faker.version 1.8.0 def character fetch('dragon_ball.characters') end ## # Produces the name of a race from Dragon Ball. # # @return [String] # # @example # Faker::Games::DragonBall.race #=> "Saiyan" # # @faker.version next def race fetch('dragon_ball.races') end ## # Produces the name of a planet from Dragon Ball. # # @return [String] # # @example # Faker::Games::DragonBall.planet #=> "Namek" # # @faker.version next def planet fetch('dragon_ball.planets') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/japanese_media/cowboy_bebop.rb
lib/faker/japanese_media/cowboy_bebop.rb
# frozen_string_literal: true module Faker class JapaneseMedia class CowboyBebop < Base class << self ## # Produces a character from Cowboy Bebop. # # @return [String] # # @example # Faker::JapaneseMedia::CowboyBebop.character #=> "Spike Spiegel" # # @faker.version next def character fetch('cowboy_bebop.character') end ## # Produces an episode from Cowboy Bebop. # # @return [String] # # @example # Faker::JapaneseMedia::CowboyBebop.episode #=> "Honky Tonk Women" # # @faker.version next def episode fetch('cowboy_bebop.episode') end ## # Produces a song title from Cowboy Bebop. # # @return [String] # # @example # Faker::JapaneseMedia::CowboyBebop.songs #=> "Live in Baghdad" # # @faker.version next def song fetch('cowboy_bebop.song') end ## # Produces a quote from Cowboy Bebop. # # @return [String] # # @example # Faker::JapaneseMedia::CowboyBebop.quote #=> "Bang!!!" # # @faker.version next def quote fetch('cowboy_bebop.quote') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/religion/bible.rb
lib/faker/religion/bible.rb
# frozen_string_literal: true module Faker module Religion class Bible < Base flexible :bible class << self ## # Returns a random bible character. # # @return [String] # # @example # Faker::Religion::Bible.character #=> "Jesus" # # @faker.version next def character fetch('bible.character') end ## # Returns a random location(city or town) from the bible # # @return [String] # # @example # Faker::Religion::Bible.location #=> "Nasareth" # # @faker.version next def location fetch('bible.location') end ## # Returns a random quote from the location. # # @return [String] # # @example # Faker::Religion::Bible.quote #=> "Seek first the kingdom of God " # # @faker.version next def quote fetch('bible.quote') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/fantasy/tolkien.rb
lib/faker/fantasy/tolkien.rb
# frozen_string_literal: true module Faker class Fantasy class Tolkien < Base flexible :tolkien class << self ## # Produces a character from Tolkien's legendarium # # @return [String] # # @example # Faker::Fantasy::Tolkien.character # #=> "Goldberry" # # @faker.version next def character fetch('tolkien.characters') end ## # Produces a location from Tolkien's legendarium # # @return [String] # # @example # Faker::Fantasy::Tolkien.location # #=> "Helm's Deep" # # @faker.version next def location fetch('tolkien.locations') end ## # Produces a race from Tolkien's legendarium # # @return [String] # # @example # Faker::Fantasy::Tolkien.race # #=> "Uruk-hai" # # @faker.version next def race fetch('tolkien.races') end ## # Produces the name of a poem from Tolkien's legendarium # # @return [String] # # @example # Faker::Fantasy::Tolkien.poem # #=> "Chip the glasses and crack the plates" # # @faker.version next def poem fetch('tolkien.poems') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/sports/volleyball.rb
lib/faker/sports/volleyball.rb
# frozen_string_literal: true module Faker class Sports class Volleyball < Base class << self ## # Produces the name of a volleyball team. # # @return [String] # # @example # Faker::Sports::Volleyball.team #=> "Leo Shoes Modena" # # @faker.version next def team fetch('volleyball.team') end ## # Produces the name of a volleyball player. # # @return [String] # # @example # Faker::Sports::Volleyball.player #=> "Saeid Marouf" # # @faker.version next def player fetch('volleyball.player') end ## # Produces the name of a volleyball coach. # # @return [String] # # @example # Faker::Sports::Volleyball.coach #=> "Russ Rose" # # @faker.version next def coach fetch('volleyball.coach') end ## # Produces a position in volleyball. # # @return [String] # # @example # Faker::Sports::Volleyball.position #=> "Middle blocker" # # @faker.version next def position fetch('volleyball.position') end ## # Produces a formation in volleyball. # # @return [String] # # @example # Faker::Sports::Volleyball.formation #=> "4-2" # # @faker.version next def formation fetch('volleyball.formation') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/sports/chess.rb
lib/faker/sports/chess.rb
# frozen_string_literal: true module Faker class Sports class Chess < Base class << self ## # Produces the name of a chess player name. # # @return [String] # # @example # Faker::Sports::Chess.player #=> "Golden State Warriors" # # @faker.version next def player fetch('chess.players') end ## # Produces a long (alpha-3) ISO 3166 country code. # # @return [String] # # @example # Faker::Chess.federation #=> "COL" # # @faker.version next def federation Faker::Address.country_code_long end def tournament ## # Produces the name of a famous chess tournament name. # # @return [String] # # @example # Faker::Chess.tournament #=> "Khanty-Mansisyk (Candidates Tournament)" # # @faker.version next fetch('chess.tournaments') end def rating(from: 2000, to: 2900) ## # Produces a rating between two provided values. Boundaries are inclusive. # # @param from [Numeric] The lowest number to include. # @param to [Numeric] The highest number to include. # @return [Numeric] # # @example # Faker::Sports::Chess.rating #=> 2734 # Faker::Sports::Chess.rating(from: 2400, to: 2700) #=> 2580 # # @faker.version next Faker::Base.rand_in_range(from, to) end ## # Produces the name of a chess opening. # # @return [String] # # @example # Faker::Sports::Chess.opening #=> "Giuoco Piano" # # @faker.version next def opening fetch('chess.openings') end ## # Produces a chess title. # # @return [String] # # @example # Faker::Sports::Chess.title #=> "GM" # # @faker.version next def title fetch('chess.titles') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/sports/basketball.rb
lib/faker/sports/basketball.rb
# frozen_string_literal: true module Faker class Sports class Basketball < Base class << self ## # Produces the name of a basketball team. # # @return [String] # # @example # Faker::Sports::Basketball.team #=> "Golden State Warriors" # # @faker.version 1.9.4 def team fetch('basketball.teams') end ## # Produces the name of a basketball player. # # @return [String] # # @example # Faker::Sports::Basketball.player #=> "LeBron James" # # @faker.version 1.9.4 def player fetch('basketball.players') end ## # Produces the name of a basketball coach. # # @return [String] # # @example # Faker::Sports::Basketball.coach #=> "Gregg Popovich" # # @faker.version 1.9.4 def coach fetch('basketball.coaches') end ## # Produces a position in basketball. # # @return [String] # # @example # Faker::Sports::Basketball.position #=> "Point Guard" # # @faker.version 1.9.4 def position fetch('basketball.positions') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/sports/football.rb
lib/faker/sports/football.rb
# frozen_string_literal: true module Faker class Sports class Football < Base class << self ## # Produces the name of a football team. # # @return [String] # # @example # Faker::Sports::Football.team #=> "Manchester United" # # @faker.version 1.9.0 def team fetch('football.teams') end ## # Produces the name of a football player. # # @return [String] # # @example # Faker::Sports::Football.player #=> "Lionel Messi" # # @faker.version 1.9.0 def player fetch('football.players') end ## # Produces the name of a football coach. # # @return [String] # # @example # Faker::Sports::Football.coach #=> "Jose Mourinho" # # @faker.version 1.9.0 def coach fetch('football.coaches') end ## # Produces a football competition. # # @return [String] # # @example # Faker::Sports::Football.competition #=> "FIFA World Cup" # # @faker.version 1.9.0 def competition fetch('football.competitions') end ## # Produces a position in football. # # @return [String] # # @example # Faker::Sports::Football.position #=> "Defensive Midfielder" # # @faker.version 1.9.2 def position fetch('football.positions') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/sports/mountaineering.rb
lib/faker/sports/mountaineering.rb
# frozen_string_literal: true module Faker class Sports class Mountaineering < Base class << self ## # Produces the name of a Mountaineer. # # @return [String] # # @example # Faker::Sports::Mountaineering.mountaineer #=> "Junko Tabei" # # @faker.version next def mountaineer fetch('mountaineering.mountaineer') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/sports/sport.rb
lib/faker/sports/sport.rb
# frozen_string_literal: true module Faker class Sport < Base class << self ## # Produces a sport from the modern olympics or paralympics, summer or winter. # # @param include_ancient [Boolean] If true, may produce a sport from the ancient olympics # @param include_unusual [Boolean] If true, may produce an unusual (definitely not olympic) sport # # @return [String] # # @example # Faker::Sport.sport #=> "Football" # @example # Faker::Sport.sport(include_ancient: true) #=> "Chariot racing" # @example # Faker::Sport.sport(include_unsual: true) #=> "Flugtag/Birdman" # @example # Faker::Sport.sport(include_ancient:true, include_unusual: true) #=> "Water polo" # # @faker.version next def sport(include_ancient: false, include_unusual: false) sports = [] sports.concat( fetch_all('sport.summer_olympics'), fetch_all('sport.summer_paralympics'), fetch_all('sport.winter_olympics'), fetch_all('sport.winter_paralympics') ) sports.concat(fetch_all('sport.ancient_olympics')) if include_ancient sports.concat(fetch_all('sport.unusual')) if include_unusual sample(sports) end ## # Produces a sport from the summer olympics. # # @return [String] # # @example # Faker::Sport.summer_olympics_sport #=> "Archery" # # @faker.version next def summer_olympics_sport fetch('sport.summer_olympics') end ## # Produces a sport from the winter olympics. # # @return [String] # # @example # Faker::Sport.winter_olympics_sport #=> "Bobsleigh" # # @faker.version next def winter_olympics_sport fetch('sport.winter_olympics') end ## # Produces a sport from the summer paralympics. # # @return [String] # # @example # Faker::Sport.summer_paralympics_sport #=> "Wheelchair Basketball" # # @faker.version next def summer_paralympics_sport fetch('sport.summer_paralympics') end ## # Produces a sport from the winter paralympics. # # @return [String] # # @example # Faker::Sport.winter_paralympics_sport #=> "Para Ice Hockey" # # @faker.version next def winter_paralympics_sport fetch('sport.winter_paralympics') end ## # Produces an unusual sport. # # @return [String] # # @example # Faker::Sport.unusual_sport #=> "Camel Jumping" # # @faker.version next def unusual_sport fetch('sport.unusual') end ## # Produces a sport from the ancient olympics. # # @return [String] # # @example # Faker::Sport.ancient_olympics_sport #=> "Pankration" # # @faker.version next def ancient_olympics_sport fetch('sport.ancient_olympics') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/quotes/rajnikanth.rb
lib/faker/quotes/rajnikanth.rb
# frozen_string_literal: true module Faker class Quotes class Rajnikanth < Base flexible :rajnikanth class << self ## # Produces a Rajnikanth. # Original list of jokes: # http://www.rajinikanthjokes.com/ # # @return [String] # # @example # Faker::Rajnikanth.joke # #=> "Rajinikanth is so fast that he always comes yesterday." # # @faker.version 2.11.0 def joke fetch('rajnikanth.joke') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/quotes/quote.rb
lib/faker/quotes/quote.rb
# frozen_string_literal: true module Faker class Quote < Base class << self ## # Produces a famous last words quote. # # @return [String] # # @example # Faker::Quote.famous_last_words #=> "My vocabulary did this to me. Your love will let you go on..." # # @faker.version 1.9.0 def famous_last_words fetch('quote.famous_last_words') end ## # Produces a quote from Deep Thoughts by Jack Handey. # # @return [String] # # @example # Faker::Quote.jack_handey # => "I hope life isn't a big joke, because I don't get it." # # @faker.version next def jack_handey fetch('quote.jack_handey') end ## # Produces a quote from Matz. # # @return [String] # # @example # Faker::Quote.matz #=> "You want to enjoy life, don't you? If you get your job done quickly and your job is fun, that's good isn't it? That's the purpose of life, partly. Your life is better." # # @faker.version 1.9.0 def matz fetch('quote.matz') end ## # Produces a quote about the most interesting man in the world. # # @return [String] # # @example # Faker::Quote.most_interesting_man_in_the_world #=> "He can speak Russian... in French" # # @faker.version 1.9.0 def most_interesting_man_in_the_world fetch('quote.most_interesting_man_in_the_world') end ## # Produces a Robin quote. # # @return [String] # # @example # Faker::Quote.robin #=> "Holy Razors Edge" # # @faker.version 1.9.0 def robin fetch('quote.robin') end ## # Produces a singular siegler quote. # # @return [String] # # @example # Faker::Quote.singular_siegler #=> "Texas!" # # @faker.version 1.9.0 def singular_siegler fetch('quote.singular_siegler') end ## # Produces a quote from Yoda. # # @return [String] # # @example # Faker::Quote.yoda #=> "Use your feelings, Obi-Wan, and find him you will." # # @faker.version 1.9.0 def yoda fetch('quote.yoda') end ## # Produces a quote from a fortune cookie. # # @return [String] # # @example # Faker::Quote.fortune_cookie #=> "This cookie senses that you are superstitious; it is an inclination that is bad for your mental health." # # @faker.version next def fortune_cookie fetch('quote.fortune_cookie') end ## # Produces a quote from comedian Mitch Hedberg. # # @return [String] # # @example # Faker::Quote.mitch_hedberg # => "I like Kit-Kats, unless I'm with four or more people." # # @faker.version next def mitch_hedberg fetch('quote.mitch_hedberg') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/quotes/shakespeare.rb
lib/faker/quotes/shakespeare.rb
# frozen_string_literal: true module Faker class Quotes class Shakespeare < Base class << self ## # Produces a Shakespeare quote from Hamlet. # # @return [String] # # @example # Faker::Quotes::Shakespeare.hamlet_quote # => "To be, or not to be: that is the question." # # @faker.version 1.9.2 def hamlet_quote sample(hamlet) end ## # Produces a Shakespeare quote from As You Like It. # # @return [String] # # @example # Faker::Quotes::Shakespeare.as_you_like_it_quote # => "Can one desire too much of a good thing?." # # @faker.version 1.9.2 def as_you_like_it_quote sample(as_you_like_it) end ## # Produces a Shakespeare quote from King Richard III. # # @return [String] # # @example # Faker::Quotes::Shakespeare.king_richard_iii_quote # => "Now is the winter of our discontent." # # @faker.version 1.9.2 def king_richard_iii_quote sample(king_richard_iii) end ## # Produces a Shakespeare quote from Romeo And Juliet. # # @return [String] # # @example # Faker::Quotes::Shakespeare.romeo_and_juliet_quote # => "O Romeo, Romeo! wherefore art thou Romeo?." # # @faker.version 1.9.2 def romeo_and_juliet_quote sample(romeo_and_juliet) end ## # Generates quote from Hamlet # # @return [String] # # @example # Faker::Quotes::Shakespeare.hamlet #=> "A little more than kin, and less than kind." # # @faker.version 1.9.2 def hamlet fetch('shakespeare.hamlet') end ## # Generates quote from 'As you like it!' # # @return [String] # # @example # Faker::Quotes::Shakespeare.as_you_like_it #=> "How bitter a thing it is to look into happiness through another man's eyes!" # # @faker.version 1.9.2 def as_you_like_it fetch('shakespeare.as_you_like_it') end ## # Returns quote from 'King Rechard III' # # @return [String] # # @example # Faker::Quotes::Shakespeare #=> "The king's name is a tower of strength." def king_richard_iii fetch('shakespeare.king_richard_iii') end ## # Quote from 'Romeo and Juliet' # # @return [String] # # @example # Faker::Quotes::Shakespeare.romeo_and_juliet #=> "Wisely and slow; they stumble that run fast." # # @faker.version 1.9.2 def romeo_and_juliet fetch('shakespeare.romeo_and_juliet') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/quotes/chiquito.rb
lib/faker/quotes/chiquito.rb
# frozen_string_literal: true module Faker class Quotes class Chiquito < Base class << self ## # Produces an Expression from Chiquito # # @return [String] # # @example # Faker::Quotes::Chiquito.expression # => "Ereh un torpedo!" # # @faker.version 2.11.0 def expression sample(expressions) end ## # Produces a concept from Chiquito # # @return [String] # # @example # Faker::Quotes::Chiquito.term # => "Fistro" # # @faker.version 2.11.0 def term sample(terms) end ## # Produces a joke from Chiquito # # @return [String] # # @example # Faker::Quotes::Chiquito.joke # => "- Papar papar llevame al circo! # - Noorl! El que quiera verte que venga a la casa" # # @faker.version 2.11.0 def joke sample(jokes) end ## # Produces a sentence from Chiquito # # @return [String] # # @example # Faker::Quotes::Chiquito.sentence # => "Te llamo trigo por no llamarte Rodrigo" # # @faker.version 2.11.0 def sentence sample(sentences) end private def expressions fetch('chiquito.expressions') end def terms fetch('chiquito.terms') end def jokes fetch('chiquito.jokes') end def sentences fetch('chiquito.sentences') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/super_smash_bros.rb
lib/faker/games/super_smash_bros.rb
# frozen_string_literal: true module Faker class Games class SuperSmashBros < Base class << self ## # Produces the name of a fighter from the Smash Bros games. # # @return [String] # # @example # Faker::Games::SuperSmashBros.fighter #=> "Mario" # # @faker.version 1.9.2 def fighter fetch('games.super_smash_bros.fighter') end ## # Produces the name of a stage from the Smash Bros games. # # @return [String] # # @example # Faker::Games::SuperSmashBros.stage #=> "Final Destination" # # @faker.version 1.9.2 def stage fetch('games.super_smash_bros.stage') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/world_of_warcraft.rb
lib/faker/games/world_of_warcraft.rb
# frozen_string_literal: true module Faker class Games class WorldOfWarcraft < Base class << self ## # Produces the name of a hero from World of Warcraft. # # @return [String] # # @example # Faker::Games::WorldOfWarcraft.hero #=> "Uther the Lightbringer" # # @faker.version 1.9.2 def hero fetch('games.world_of_warcraft.heros') end ## # Produces a class name from World of Warcraft. # # @return [String] # # @example # Faker::Games::WorldOfWarcraft.class_name #=> "Druid" # # @faker.version next def class_name fetch('games.world_of_warcraft.class_names') end # Produces the name of a race from World of Warcraft. # # @return [String] # # @example # Faker::Games::WorldOfWarcraft.race #=> "Druid" # # @faker.version next def race fetch('games.world_of_warcraft.races') end ## # Produces a quote from World of Warcraft. # # @return [String] # # @example # Faker::Games::WorldOfWarcraft.quote #=> "These are dark times indeed." # # @faker.version 1.9.2 def quote fetch('games.world_of_warcraft.quotes') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/minecraft.rb
lib/faker/games/minecraft.rb
# frozen_string_literal: true module Faker class Games class Minecraft < Base class << self ## # Produces the name of an achievement from Minecraft. # # @return [String] # # @example # Faker::Games::Minecraft.achievement #=> "Time to Mine!" # # @faker.version next def achievement fetch('games.minecraft.achievement') end ## # Produces the name of a biome from Minecraft. # # @return [String] # # @example # Faker::Games::Minecraft.biome #=> "Jungle" # # @faker.version next def biome fetch('games.minecraft.biome') end ## # Produces the name of a block from Minecraft. # # @return [String] # # @example # Faker::Games::Minecraft.block #=> "Stone" # # @faker.version 2.13.0 def block fetch('games.minecraft.blocks') end ## # Produces the name of a enchantment from Minecraft. # # @return [String] # # @example # Faker::Games::Minecraft.enchantment #=> "Fire Protection" # # @faker.version next def enchantment fetch('games.minecraft.enchantment') end ## # Produces the name of a game mode from Minecraft. # # @return [String] # # @example # Faker::Games::Minecraft.game_mode #=> "Survival" # # @faker.version next def game_mode fetch('games.minecraft.game_mode') end ## # Produces the name of an item from Minecraft. # # @return [String] # # @example # Faker::Games::Minecraft.item #=> "Iron Shovel" # # @faker.version 2.13.0 def item fetch('games.minecraft.items') end ## # Produces the name of a mob from Minecraft. # # @return [String] # # @example # Faker::Games::Minecraft.mob #=> "Sheep" # # @faker.version 2.13.0 def mob fetch('games.minecraft.mobs') end ## # Produces the name of a status effect from Minecraft. # # @return [String] # # @example # Faker::Games::Minecraft.status_effect #=> "Weakness" # # @faker.version next def status_effect fetch('games.minecraft.status_effect') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/elder_scrolls.rb
lib/faker/games/elder_scrolls.rb
# frozen_string_literal: true module Faker class Games class ElderScrolls < Base class << self ## # Produces the name of a race from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.race #=> "Argonian" # # @faker.version 1.9.2 def race fetch('games.elder_scrolls.race') end ## # Produces the name of a city from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.city #=> "Whiterun" # # @faker.version 1.9.2 def city fetch('games.elder_scrolls.city') end ## # Produces the name of a creature from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.creature #=> "Frost Troll" # # @faker.version 1.9.2 def creature fetch('games.elder_scrolls.creature') end ## # Produces the name of a region from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.region #=> "Cyrodiil" # # @faker.version 1.9.2 def region fetch('games.elder_scrolls.region') end ## # Produces the name of a dragon from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.dragon #=> "Blood Dragon" # # @faker.version 1.9.2 def dragon fetch('games.elder_scrolls.dragon') end ## # Produces a randomly generated name from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.name #=> "Balgruuf The Old" # # @faker.version 1.9.2 def name "#{fetch('games.elder_scrolls.first_name')} #{fetch('games.elder_scrolls.last_name')}" end ## # Produces a first name from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.first_name #=> "Balgruuf" # # @faker.version 1.9.2 def first_name fetch('games.elder_scrolls.first_name') end ## # Produces a last name from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.last_name #=> "The Old" # # @faker.version 1.9.2 def last_name fetch('games.elder_scrolls.last_name') end ## # Produces a weapon from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.weapon #=> "Elven Bow" # # @faker.version next def weapon fetch('games.elder_scrolls.weapon') end ## # Produces a weapon from the Elder Scrolls universe. # # @return [String] # # @example # Faker::Games::ElderScrolls.jewelry #=> "Silver Ruby Ring" # # @faker.version next def jewelry fetch('games.elder_scrolls.jewelry') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/game.rb
lib/faker/games/game.rb
# frozen_string_literal: true module Faker class Game < Base flexible :game class << self ## # Produces the name of a video game. # # @return [String] # # @example # Faker::Game.title #=> "Half-Life 2" # # @faker.version 1.9.4 def title fetch('game.title') end ## # Produces the name of a video game genre. # # @return [String] # # @example # Faker::Game.genre #=> "Real-time strategy" # # @faker.version 1.9.4 def genre fetch('game.genre') end ## # Produces the name of a video game console or platform. # # @return [String] # # @example # Faker::Game.platform #=> "Nintendo Switch" # # @faker.version 1.9.4 def platform fetch('game.platform') end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/zelda.rb
lib/faker/games/zelda.rb
# frozen_string_literal: true module Faker class Games class Zelda < Base flexible :zelda class << self ## # Produces the name of a Legend of Zelda game. # # @return [String] # # @example # Faker::Games::Zelda.game #=> "Breath of the Wild" # # @faker.version 1.7.3 def game fetch('games.zelda.games') end ## # Produces the name of a character from the Legend of Zelda games. # # @return [String] # # @example # Faker::Games::Zelda.character #=> "Link" # # @faker.version 1.7.3 def character fetch('games.zelda.characters') end ## # Produces the name of a character from the Legend of Zelda games. # # @return [String] # # @example # Faker::Games::Zelda.location #=> "Hyrule Castle" # # @faker.version 1.7.3 def location fetch('games.zelda.locations') end ## # Produces the name of an item from the Legend of Zelda games. # # @return [String] # # @example # Faker::Games::Zelda.item #=> "Boomerang" # # @faker.version 1.7.3 def item fetch('games.zelda.items') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/tarkov.rb
lib/faker/games/tarkov.rb
# frozen_string_literal: true module Faker class Games class Tarkov < Base class << self ## # Produces a random location from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.location #=> "Customs" # # @faker.version next def location fetch('tarkov.locations') end ## # Produces a random trader from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.trader #=> "Prapor" # # @faker.version next def trader fetch('tarkov.traders') end ## # Produces a random item from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.item #=> "Diary" # # @faker.version next def item fetch('tarkov.items') end ## # Produces a random weapon from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.weapon #=> "AK-74N" # # @faker.version next def weapon fetch('tarkov.weapons') end ## # Produces a random boss from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.boss #=> "Tagilla" # # @faker.version next def boss fetch('tarkov.bosses') end ## # Produces a random faction from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.faction #=> "USEC" # # @faker.version next def faction fetch('tarkov.factions') end ## # Produces a random quest from a random trader from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.quest #=> "The Key to Success" # # @faker.version next def quest @traders = %w[prapor therapist skier peacekeeper mechanic ragman jaeger fence] fetch("tarkov.quests.#{@traders.sample}") end ## # Produces a random quest from Prapor from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.prapor_quest #=> "Easy Job - Part 2 # # @faker.version next def prapor_quest fetch('tarkov.quests.prapor') end ## # Produces a random quest from Therapist from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.therapist_quest #=> "Supply Plans" # # @faker.version next def therapist_quest fetch('tarkov.quests.therapist') end ## # Produces a random quest from Skier from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.skier_quest #=> "Safe Corridor" # # @faker.version next def skier_quest fetch('tarkov.quests.skier') end ## # Produces a random quest from Peacekeeper from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.peacekeeper_quest #=> "Overpopulation" # # @faker.version next def peacekeeper_quest fetch('tarkov.quests.peacekeeper') end ## # Produces a random quest from Mechanic from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.mechanic_quest #=> "Signal - Part 4" # # @faker.version next def mechanic_quest fetch('tarkov.quests.mechanic') end ## # Produces a random quest from Ragman from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.ragman_quest #=> "Hot Delivery" # # @faker.version next def ragman_quest fetch('tarkov.quests.ragman') end ## # Produces a random quest from Jaeger from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.jaeger_quest #=> "The Tarkov Shooter - Part 1" # # @faker.version next def jaeger_quest fetch('tarkov.quests.jaeger') end ## # Produces a random quest from Fence from Escape from Tarkov. # # @return [String] # # @example # Faker::Games::Tarkov.fence_quest #=> "Compensation for Damage - Wager" # # @faker.version next def fence_quest fetch('tarkov.quests.fence') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/league_of_legends.rb
lib/faker/games/league_of_legends.rb
# frozen_string_literal: true module Faker class Games class LeagueOfLegends < Base class << self ## # Produces the name of a champion from League of Legends. # # @return [String] # # @example # Faker::Games::LeagueOfLegends.champion #=> "Jarvan IV" # # @faker.version 1.8.0 def champion fetch('games.league_of_legends.champion') end ## # Produces a location from League of Legends. # # @return [String] # # @example # Faker::Games::LeagueOfLegends.location #=> "Demacia" # # @faker.version 1.8.0 def location fetch('games.league_of_legends.location') end ## # Produces a quote from League of Legends. # # @return [String] # # @example # Faker::Games::LeagueOfLegends.quote #=> "Purge the unjust." # # @faker.version 1.8.0 def quote fetch('games.league_of_legends.quote') end ## # Produces a summoner spell from League of Legends. # # @return [String] # # @example # Faker::Games::LeagueOfLegends.summoner_spell #=> "Flash" # # @faker.version 1.8.0 def summoner_spell fetch('games.league_of_legends.summoner_spell') end ## # Produces a mastery from League of Legends. # # @return [String] # # @example # Faker::Games::LeagueOfLegends.masteries #=> "Double Edged Sword" # # @faker.version 1.8.0 def masteries fetch('games.league_of_legends.masteries') end ## # Produces a rank from League of Legends. # # @return [String] # # @example # Faker::Games::LeagueOfLegends.rank #=> "Bronze V" # # @faker.version 1.8.0 def rank fetch('games.league_of_legends.rank') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/sonic_the_hedgehog.rb
lib/faker/games/sonic_the_hedgehog.rb
# frozen_string_literal: true module Faker class Games class SonicTheHedgehog < Base class << self ## # Produces the name of a character from Sonic the Hedgehog. # # @return [String] # # @example # Faker::Games::SonicTheHedgehog.character #=> "Sonic the Hedgehog" # # @faker.version 1.9.2 def character fetch('games.sonic_the_hedgehog.character') end ## # Produces the name of a zone from Sonic the Hedgehog. # # @return [String] # # @example # Faker::Games::SonicTheHedgehog.zone #=> "Green Hill Zone" # # @faker.version 1.9.2 def zone fetch('games.sonic_the_hedgehog.zone') end ## # Produces the name of a game from the Sonic the Hedgehog series. # # @return [String] # # @example # Faker::Games::SonicTheHedgehog.game #=> "Waku Waku Sonic Patrol Car" # # @faker.version 1.9.2 def game fetch('games.sonic_the_hedgehog.game') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/myst.rb
lib/faker/games/myst.rb
# frozen_string_literal: true module Faker class Games class Myst < Base class << self ## # Produces the name of a game from the Myst series. # # @return [String] # # @example # Faker::Games::Myst.game #=> "Myst III: Exile" # # @faker.version 1.9.0 def game fetch('games.myst.games') end ## # Produces the name of a creature from Myst. # # @return [String] # # @example # Faker::Games::Myst.creature #=> "squee" # # @faker.version 1.9.0 def creature fetch('games.myst.creatures') end ## # Produces the name of an age from Myst. # # @return [String] # # @example # Faker::Games::Myst.age #=> "Relto" # # @faker.version 1.9.0 def age fetch('games.myst.ages') end ## # Produces the name of a character from Myst. # # @return [String] # # @example # Faker::Games::Myst.character #=> "Gehn" # # @faker.version 1.9.0 def character fetch('games.myst.characters') end ## # Produces a quote from Myst. # # @return [String] # # @example # Faker::Games::Myst.quote #=> "I realized, the moment I fell into the fissure, that the Book would not be destroyed as I had planned." # # @faker.version 1.9.0 def quote fetch('games.myst.quotes') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/dota.rb
lib/faker/games/dota.rb
# frozen_string_literal: true module Faker class Games class Dota < Base class << self ## # Produces the name of a building from Dota. # # @return [String] # # @example # Faker::Games::Dota.building #=> "Tower" # # @faker.version 1.9.0 def building fetch('games.dota.building') end ## # Produces the name of a hero from Dota. # # @return [String] # # @example # Faker::Games::Dota.hero #=> "Abaddon" # # @faker.version 1.9.0 def hero fetch('games.dota.hero') end ## # Produces the name of an item from Dota. # # @return [String] # # @example # Faker::Games::Dota.item #=> "Armlet of Mordiggian" # # @faker.version 1.9.0 def item fetch('games.dota.item') end ## # Produces the name of a professional Dota team. # # @return [String] # # @example # Faker::Games::Dota.team #=> "Evil Geniuses" # # @faker.version 1.9.0 def team fetch('games.dota.team') end ## # Produces the name of a professional Dota player. # # @return [String] # # @example # Faker::Games::Dota.player #=> "Dendi" # # @faker.version 1.9.0 def player fetch('games.dota.player') end ## # Produces the name of a hero from Dota. # # @param hero [String] The name of a Dota hero. # @return [String] # # @example # Faker::Games::Dota.quote #=> "You have called death upon yourself." # Faker::Games::Dota.quote(hero: 'alchemist') #=> "Better living through alchemy!" # # @faker.version 1.9.0 def quote(hero: 'abaddon') fetch("games.dota.#{hero}.quote") end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/heroes_of_the_storm.rb
lib/faker/games/heroes_of_the_storm.rb
# frozen_string_literal: true module Faker class Games class HeroesOfTheStorm < Base class << self ## # Produces a battleground from Heroes of the Storm. # # @return [String] # # @example # Faker::Games::HeroesOfTheStorm.battleground #=> "Towers of Doom" # # @faker.version 1.9.2 def battleground fetch('heroes_of_the_storm.battlegrounds') end ## # Produces a class name from Heroes of the Storm. # # @return [String] # # @example # Faker::Games::HeroesOfTheStorm.class_name #=> "Support" # # @faker.version 2.13.0 def class_name fetch('heroes_of_the_storm.class_names') end ## # Produces a hero from Heroes of the Storm. # # @return [String] # # @example # Faker::Games::HeroesOfTheStorm.hero #=> "Illidan" # # @faker.version 1.9.2 def hero fetch('heroes_of_the_storm.heroes') end ## # Produces a quote from Heroes of the Storm. # # @return [String] # # @example # Faker::Games::HeroesOfTheStorm.quote #=> "MEAT!!!" # # @faker.version 1.9.2 def quote fetch('heroes_of_the_storm.quotes') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/witcher.rb
lib/faker/games/witcher.rb
# frozen_string_literal: true module Faker class Games class Witcher < Base class << self ## # Produces the name of a character from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.character #=> "Triss Merigold" # # @faker.version 1.8.3 def character fetch('games.witcher.characters') end ## # Produces the name of a witcher from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.witcher #=> "Geralt of Rivia" # # @faker.version 1.8.3 def witcher fetch('games.witcher.witchers') end ## # Produces the name of a school from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.school #=> "Wolf" # # @faker.version 1.8.3 def school fetch('games.witcher.schools') end ## # Produces the name of a location from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.location #=> "Novigrad" # # @faker.version 1.8.3 def location fetch('games.witcher.locations') end ## # Produces a quote from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.quote #=> "No Lollygagin'!" # # @faker.version 1.8.3 def quote fetch('games.witcher.quotes') end ## # Produces the name of a monster from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.monster #=> "Katakan" # # @faker.version 1.8.3 def monster fetch('games.witcher.monsters') end ## # Produces the name of a sign from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.sign #=> "Igni" # # @faker.version 2.18.0 def sign fetch('games.witcher.signs') end ## # Produces the name of a potion from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.potion #=> "Gadwall" # # @faker.version 2.18.0 def potion fetch('games.witcher.potions') end ## # Produces the name of a book from The Witcher. # # @return [String] # # @example # Faker::Games::Witcher.book #=> "Sword of Destiny" # # @faker.version 2.18.0 def book fetch('games.witcher.books') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/half_life.rb
lib/faker/games/half_life.rb
# frozen_string_literal: true module Faker class Games class HalfLife < Base class << self ## # Produces the name of a character from the Half-Life games. # # @return [String] # # @example # Faker::Games::HalfLife.character #=> "Gordon Freeman" # # @faker.version 1.9.2 def character fetch('games.half_life.character') end ## # Produces the name of an enemy from the Half-Life games. # # @return [String] # # @example # Faker::Games::HalfLife.enemy #=> "Headcrab" # # @faker.version 1.9.2 def enemy fetch('games.half_life.enemy') end ## # Produces the name of a location from the Half-Life games. # # @return [String] # # @example # Faker::Games::HalfLife.location #=> "Black Mesa Research Facility" # # @faker.version 1.9.2 def location fetch('games.half_life.location') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/heroes.rb
lib/faker/games/heroes.rb
# frozen_string_literal: true module Faker class Games class Heroes < Base class << self ## # Produces the name of a hero from Heroes 3. # # @return [String] # # @example # Faker::Games::Heroes.name #=> "Christian" # # @faker.version 1.9.2 def name fetch('heroes.names') end ## # Produces the name of a specialty from Heroes 3. # # @return [String] # # @example # Faker::Games::Heroes.specialty #=> "Ballista" # # @faker.version 1.9.2 def specialty fetch('heroes.specialties') end ## # Produces the name of a class from Heroes 3. # # @return [String] # # @example # Faker::Games::Heroes.klass #=> "Knight" # # @faker.version 1.9.2 def klass fetch('heroes.klasses') end ## # Produces the name of an artifact from Heroes 3. # # @return [String] # # @example # Faker::Games::Heroes.artifact #=> "Armageddon's Blade" # # @faker.version next def artifact fetch('heroes.artifacts') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/clash_of_clans.rb
lib/faker/games/clash_of_clans.rb
# frozen_string_literal: true module Faker class Games class ClashOfClans < Base class << self ## # Produces the name of a troop from Clash of Clans. # # @return [String] # # @example # Faker::Games::ClashOfClans.troop #=> "Barbarian" # # @faker.version next def troop fetch('games.clash_of_clans.troops') end ## # Produces the name of a rank from Clash Of Clans. # # @return [String] # # @example # Faker::Games::ClashOfClans.rank #=> "Legend" # # @faker.version next def rank fetch('games.clash_of_clans.ranks') end ## # Produces the name of a defensive building from Clash Of Clans. # # @return [String] # # @example # Faker::Games::ClashOfClans.defensive_building #=> "Cannon" # # @faker.version next def defensive_building fetch('games.clash_of_clans.defensive_buildings') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/control.rb
lib/faker/games/control.rb
# frozen_string_literal: true module Faker class Games class Control < Base class << self ## # Produces the name of a character from Control. # # @return [String] # # @example # Faker::Games::Control.character #=> "Jesse Faden" # # @faker.version 2.13.0 def character fetch('games.control.character') end ## # Produces the name of a location from Control. # # @return [String] # # @example # Faker::Games::Control.location #=> "Dimensional Research" # # @faker.version 2.13.0 def location fetch('games.control.location') end ## # Produces the name of an Object of Power (OoP) # # @return [String] # # @example # Faker::Games::Control.object_of_power #=> "Hotline" # # @faker.version 2.13.0 def object_of_power fetch('games.control.object_of_power') end ## # Produces the name of an Altered Item # # @return [String] # # @example # Faker::Games::Control.altered_item #=> "Rubber Duck" # # @faker.version 2.13.0 def altered_item fetch('games.control.altered_item') end ## # Produces the location of an Altered World Event (AWE) # # @return [String] # # @example # Faker::Games::Control.altered_world_event #=> "Ordinary, Wisconsin" # # @faker.version 2.13.0 def altered_world_event fetch('games.control.altered_world_event') end ## # Produces a line from the Hiss incantation # # @return [String] # # @example # Faker::Games::Control.hiss #=> "Push the fingers through the surface into the wet." # # @faker.version 2.13.0 def hiss fetch('games.control.hiss') end ## # < Produces a line/quote/message from The Board > # # @return [String] # # @example # Faker::Games::Control.the_board #=> "< You/We wield the Gun/You. The Board appoints you. Congratulations, Director. >" # # @faker.version 2.13.0 def the_board fetch('games.control.the_board') end ## # Produces a quote from Control # # @return [String] # # @example # Faker::Games::Control.quote #=> "He never liked fridge duty" # # @faker.version 2.13.0 def quote fetch('games.control.quote') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/final_fantasy_xiv.rb
lib/faker/games/final_fantasy_xiv.rb
# frozen_string_literal: true module Faker class Games class FinalFantasyXIV < Base class << self ## # Produces the name of a character from FFXIV. # # @return [String] # # @example # Faker::Games::FinalFantasyXIV.character #=> "Y'shtola Rhul" # # @faker.version next def character fetch('games.final_fantasy_xiv.characters') end ## # Produces a job name from Final Fantasy XIV. Either a battle or non-battle playable job. # # @return [String] # # @example # Faker::Games::FinalFantasyXIV.job #=> "Paladin" # # @faker.version next def job fetch('games.final_fantasy_xiv.jobs') end # Produces the name of a playable race from Final Fantasy XIV. # # @return [String] # # @example # Faker::Games::FinalFantasyXIV.race #=> "Miqo'te" # # @faker.version next def race fetch('games.final_fantasy_xiv.races') end ## # Produces a data center from Final Fantasy XIV. # # @return [String] # # @example # Faker::Games::FinalFantasyXIV.data_center #=> "Aether" # # @faker.version next def data_center fetch('games.final_fantasy_xiv.data_centers') end ## # Produces a geographical zone from Final Fantasy XIV. # # @return [String] # # @example # Faker::Games::FinalFantasyXIV.zone #=> "Eastern La Noscea" # # @faker.version next def zone fetch('games.final_fantasy_xiv.zones') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/super_mario.rb
lib/faker/games/super_mario.rb
# frozen_string_literal: true module Faker class Games class SuperMario < Base class << self ## # Produces the name of a Super Mario character. # # @return [String] # # @example # Faker::Games::SuperMario.character #=> "Luigi" # # @faker.version next def character fetch('games.super_mario.characters') end ## # Produces the name of a Super Mario game. # # @return [String] # # @example # Faker::Games::SuperMario.game #=> "Super Mario Odyssey" # # @faker.version next def game fetch('games.super_mario.games') end ## # Produces the name of a Super Mario location. # # @return [String] # # @example # Faker::Games::SuperMario.location #=> "Kong City" # # @faker.version next def location fetch('games.super_mario.locations') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/warhammer_fantasy.rb
lib/faker/games/warhammer_fantasy.rb
# frozen_string_literal: true module Faker class Games class WarhammerFantasy < Base class << self ## # Produces the name of a hero from the Warhammer Fantasy setting. # # @return [String] # # @example # Faker::Games::WarhammerFantasy.hero #=> "Sigmar Heldenhammer" # # @faker.version 2.13.0 def hero fetch('games.warhammer_fantasy.heros') end ## # Produces a quote from the Warhammer Fantasy setting. # # @return [String] # # @example # Faker::Games::WarhammerFantasy.quote #=> "The softest part of a castle is the belly of the man inside." # # @faker.version 2.13.0 def quote fetch('games.warhammer_fantasy.quotes') end ## # Produces a location from the Warhammer Fantasy setting. # # @return [String] # # @example # Faker::Games::WarhammerFantasy.location #=> "Lustria" # # @faker.version 2.13.0 def location fetch('games.warhammer_fantasy.locations') end ## # Produces a faction from the Warhammer Fantasy setting. # # @return [String] # # @example # Faker::Games::WarhammerFantasy.faction #=> "Bretonnia" # # @faker.version 2.13.0 def faction fetch('games.warhammer_fantasy.factions') end ## # Produces a creature from the Warhammer Fantasy setting. # # @return [String] # # @example # Faker::Games::WarhammerFantasy.creature #=> "Hydra" # # @faker.version 2.13.0 def creature fetch('games.warhammer_fantasy.creatures') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/street_fighter.rb
lib/faker/games/street_fighter.rb
# frozen_string_literal: true module Faker class Games class StreetFighter < Base class << self ## # Produces the name of a playable character from Street Fighter. # # @return [String] # # @example # Faker::Games::StreetFighter.character #=> "Ryu" # # @faker.version 2.14.0 def character fetch('games.street_fighter.characters') end ## # Produces the name of a stage from Street Fighter. # # @return [String] # # @example # Faker::Games::StreetFighter.stage #=> "Volcanic Rim" # # @faker.version 2.14.0 def stage fetch('games.street_fighter.stages') end ## # Produces a quote from Street Fighter. # # @return [String] # # @example # Faker::Games::StreetFighter.quote #=> "Go home and be a family man." # # @faker.version 2.14.0 def quote fetch('games.street_fighter.quotes') end ## # Produces the name of a move from Street Fighter. # # @return [String] # # @example # Faker::Games::StreetFighter.move #=> "Shoryuken" # # @faker.version 2.14.0 def move fetch('games.street_fighter.moves') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/fallout.rb
lib/faker/games/fallout.rb
# frozen_string_literal: true module Faker class Games class Fallout < Base class << self ## # Produces the name of a character from the Fallout games. # # @return [String] # # @example # Faker::Games::Fallout.character #=> "Liberty Prime" # # @faker.version 1.9.2 def character fetch('games.fallout.characters') end ## # Produces the name of a faction from the Fallout games. # # @return [String] # # @example # Faker::Games::Fallout.faction #=> "Brotherhood of Steel" # # @faker.version 1.9.2 def faction fetch('games.fallout.factions') end ## # Produces the name of a location from the Fallout games. # # @return [String] # # @example # Faker::Games::Fallout.location #=> "New Vegas" # # @faker.version 1.9.2 def location fetch('games.fallout.locations') end ## # Produces a quote from the Fallout games. # # @return [String] # # @example # Faker::Games::Fallout.quote # #=> "Democracy is non-negotiable" # # @faker.version 1.9.2 def quote fetch('games.fallout.quotes') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/pokemon.rb
lib/faker/games/pokemon.rb
# frozen_string_literal: true module Faker class Games class Pokemon < Base class << self ## # Produces the name of a Pokemon. # # @return [String] # # @example # Faker::Games::Pokemon.name #=> "Pikachu" # # @faker.version 1.7.0 def name fetch('games.pokemon.names') end ## # Produces a location from Pokemon. # # @return [String] # # @example # Faker::Games::Pokemon.location #=> "Pallet Town" # # @faker.version 1.7.0 def location fetch('games.pokemon.locations') end ## # Produces a move from Pokemon. # # @return [String] # # @example # Faker::Games::Pokemon.move #=> "Thunder Shock" # # @faker.version 1.7.0 def move fetch('games.pokemon.moves') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/dnd.rb
lib/faker/games/dnd.rb
# frozen_string_literal: true module Faker class Games class DnD < Base class << self ## # Produces the name of an alignment from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.alignment #=> "Lawful Neutral" # # @faker.version 2.13.0 def alignment fetch('dnd.alignments') end ## # Produces the name of a background from Dungeons and Dragons (PHB). # # @return [String] # # @example # Faker::Games::DnD.background #=> "Urchin" # # @faker.version 2.13.0 def background fetch('dnd.backgrounds') end ## # Produces the name of a city from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.city #=> "Earthfast" # # @faker.version 2.14.0 def city fetch('dnd.cities') end ## # Produces the first name of a character or monster from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.name #=> "Eilonwy" # # @faker.version next def first_name fetch('dnd.name.first_name') end ## # Produces the name of a class from Dungeons and Dragons (PHB). # # @return [String] # # @example # Faker::Games::DnD.klass #=> "Warlock" # # @faker.version 2.13.0 def klass fetch('dnd.klasses') end ## # Produces the name of a language from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.language #=> "Gnomish" # # @faker.version 2.14.0 def language fetch('dnd.languages') end ## # Produces a last name from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.last_name #=> "Leafwhisper" # # @faker.version next def last_name fetch('dnd.name.last_name') end ## # Produces the name of a melee weapon from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.melee_weapon #=> "Handaxe" # # @faker.version 2.14.0 def melee_weapon fetch('dnd.melee_weapons') end ## # Produces the name of a monster from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.monster #=> "Manticore" # # @faker.version 2.14.0 def monster fetch('dnd.monsters') end ## # Produces a full name from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.name #=> "Drakon Blackthorn" # # @faker.version next def name "#{fetch('dnd.name.first_name')} #{fetch('dnd.name.last_name')}" end ## # Produces the name of a race from Dungeons and Dragons (PHB). # # @return [String] # # @example # Faker::Games::DnD.races #=> "Dwarf" # # @faker.version 2.14.0 def race fetch('dnd.races') end ## # Produces the name of a ranged weapon from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.ranged_weapon #=> "Shortbow" # # @faker.version 2.14.0 def ranged_weapon fetch('dnd.ranged_weapons') end ## # Produces a last name from Dungeons and Dragons. # # @return [String] # # @example # Faker::Games::DnD.title_name #=> "Corvus the Cunning" # # @faker.version next def title_name "#{fetch('dnd.name.first_name')} #{fetch('dnd.name.title')}" end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/overwatch.rb
lib/faker/games/overwatch.rb
# frozen_string_literal: true module Faker class Games class Overwatch < Base class << self ## # Produces the name of a hero from Overwatch. # # @return [String] # # @example # Faker::Games::Overwatch.hero #=> "Tracer" # # @faker.version 1.8.0 def hero fetch('games.overwatch.heroes') end ## # Produces the name of a location from Overwatch. # # @return [String] # # @example # Faker::Games::Overwatch.location #=> "Numbani" # # @faker.version 1.8.0 def location fetch('games.overwatch.locations') end ## # Produces a quote from Overwatch. # # @return [String] # # @example # Faker::Games::Overwatch.quote #=> "It's high noon" # # @faker.version 1.8.0 def quote fetch('games.overwatch.quotes') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/games/touhou.rb
lib/faker/games/touhou.rb
# frozen_string_literal: true module Faker class Games class Touhou < Base flexible :touhou class << self ## # Produces the name of a Touhou game. # # @return [String] # # @example # Faker::Games::Touhou.game #=> "Mountain of Faith" # # @faker.version next def game fetch('games.touhou.games') end ## # Produces the name of a character from the Touhou games. # # @return [String] # # @example # Faker::Games::Touhou.character #=> "Sanae Kochiya" # # @faker.version next def character fetch('games.touhou.characters') end ## # Produces the name of a location from the Touhou games. # # @return [String] # # @example # Faker::Games::Touhou.location #=> "Moriya Shrine" # # @faker.version next def location fetch('games.touhou.locations') end ## # Produces the name of a spell card from the Touhou games. # # @return [String] # # @example # Faker::Games::Touhou.spell_card #=> 'Esoterica "Gray Thaumaturgy"' # # @faker.version next def spell_card fetch('games.touhou.spell_cards') end ## # Produces the name of a song from the Touhou games. # # @return [String] # # @example # Faker::Games::Touhou.song #=> "Faith Is for the Transient People" # # @faker.version next def song fetch('games.touhou.songs') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/travel/airport.rb
lib/faker/travel/airport.rb
# frozen_string_literal: true module Faker class Travel class Airport < Base class << self ## # Produces random Airport by name and takes arguments for size and region # # @param size [String] airport size, united_states has large, or medium, or small, european_union has large, or medium # # @param region [String] airport region, currently available -> united_states or european_union # # @return [String] # # @example # Faker::Travel::Airport.name(size: 'large', region: 'united_states') => "Los Angeles International Airport" # # @faker.version next def name(size:, region:) fetch("airport.#{region}.#{size}") end ## # Produces random Airport by IATA code and takes arguments for size and region # # @param size [String] airport size, united_states has large, or medium, or small, european_union has large, or medium # # @param region [String] airport region, currently available -> united_states or european_union # # @return [String] # # @example # Faker::Travel::Airport.iata(size: 'large', region: 'united_states') => "LAX" # # @faker.version next def iata(size:, region:) fetch("airport.#{region}.iata_code.#{size}") end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/travel/train_station.rb
lib/faker/travel/train_station.rb
# frozen_string_literal: true module Faker class Travel class TrainStation < Base class << self ## # Produces random Train Station by name and takes optional arguments for region and type # # @param region [String] Train station region: germany, spain, united_kingdom, united_states # # @param type [String] Train station type: metro, railway # # @return [String] # # @examples # Faker::Travel::TrainStation.name(region: 'united_kingdom', type: 'metro') => "Brockley" # Faker::Travel::TrainStation.name(type: 'railway') => "Düsseldorf Hauptbahnhof" # Faker::Travel::TrainStation.name(region: 'spain') => "Santa Eulàlia" # # @faker.version next def name(region: nil, type: nil) region, type = fill_missing_inputs_with_samples(region, type) fetch("train_station.#{region}.#{type}") end private def fill_missing_inputs_with_samples(region, type) regions = %w[germany spain united_kingdom united_states] types = %w[metro railway] if region.nil? && type.nil? region = sample(regions) type = sample(types) elsif region.nil? validate_arguments(type, types, 'type') region = sample(regions) elsif type.nil? validate_arguments(region, regions, 'region') type = sample(types) end [region, type] end def validate_arguments(argument, correct_values, argument_name) return if correct_values.include?(argument) raise ArgumentError, "'#{argument}' not found, #{argument_name} can be blank, or one of the following, as strings: #{correct_values.join(', ')}" end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/creature/bird.rb
lib/faker/creature/bird.rb
# frozen_string_literal: true module Faker class Creature class Bird < Base flexible :bird class << self ## # Produces a random common family name of a bird. # # @return [String] # # @example # Faker::Creature::Bird.common_family_name #=> "Owls" # # @faker.version next def common_family_name fetch('creature.bird.common_family_name') end ## # Produces a random common taxonomic order from the class Aves # # @return [String] # # @example # Faker::Creature::Bird.order #=> "Passeriformes" # # @faker.version next def order orders = I18n.translate('faker.creature.bird.order_common_map').keys sample(orders).to_s end ## # Produces a random bird anatomy word # # @return [String] # # @example # Faker::Creature::Bird.anatomy #=> "rump" # # @faker.version next def anatomy fetch('creature.bird.anatomy') end ## # Produces a random, past tensed bird anatomy word # # @return [String] # # @example # Faker::Creature::Bird.anatomy #=> "breasted" # # @faker.version next def anatomy_past_tense fetch('creature.bird.anatomy_past_tense') end ## # Produces a random geographical word used in describing birds # # @return [String] # # @example # Faker::Creature::Bird.geo #=> "Eurasian" # # @faker.version next def geo fetch('creature.bird.geo') end ## # Produces a random color word used in describing birds # # @return [String] # # @example # Faker::Creature::Bird.color #=> "ferruginous" # # @faker.version next def color fetch('creature.bird.colors') end ## # Produces a random adjective used to described birds # # @return [String] # # @example # Faker::Creature::Bird.adjective #=> 'common' # # @faker.version next def adjective fetch('creature.bird.adjectives') end ## # Produces a random emotional adjective NOT used to described birds # ...but could be # # @return [String] # # @example # Faker::Creature::Bird.emotional_adjective #=> 'cantankerous' # # @faker.version next def emotional_adjective fetch('creature.bird.emotional_adjectives') end ## # Produces a random adjective NOT used to described birds # ...but probably shouldn't # # @return [String] # # @example # Faker::Creature::Bird.silly_adjective #=> 'drunk' # # @faker.version next def silly_adjective fetch('creature.bird.silly_adjectives') end ## # Produces a random common name for a bird # # @param [String | Symbol | nil] tax_order Tax # @return [String] # @raises TypeError If `tax_order` cannot be converted into a Symbol # @raises ArgumentError If `tax_order` is not a valid taxonomic order # # @example # Faker::Creature::Bird.common_name #=> 'wren' # # @faker.version next def common_name(tax_order = nil) map = translate('faker.creature.bird.order_common_map') if tax_order.nil? sample(map.values.flatten).downcase else raise TypeError, 'tax_order parameter must be symbolizable' \ unless tax_order.respond_to?(:to_sym) raise ArgumentError, "#{tax_order} is not a valid taxonomic order" \ unless map.keys.include?(tax_order.to_sym) the_order = translate('faker.creature.bird.order_common_map')[tax_order.to_sym] sample(the_order).downcase end end ## # Produces a random and plausible common name for a bird # # @return [String] # # @example # Faker::Creature::Bird.plausible_common_name #=> 'Hellinger's Wren' # # @faker.version next def plausible_common_name parse('creature.bird.plausible_common_names').capitalize end ## # Produces a random and IMplausible common name for a bird # # @return [String] # # @example # Faker::Creature::Bird.implausible_common_name #=> 'Hellinger's Cantankerous Chickadee' # # @faker.version next def implausible_common_name parse('creature.bird.implausible_common_names').capitalize end ## # Produces a hash entry with a random order and a random common name # that is of that order # # @return [Hash<order,common_name>] # # @example # Faker::Creature::Bird.order_with_common_name #=> { # order: ''Accipitriformes', # common_name: 'Osprey' # } # # @faker.version next def order_with_common_name(tax_order = nil) map = I18n.translate('faker.creature.bird.order_common_map') o = tax_order.nil? ? order : tax_order { order: o, common_name: sample(map[o.to_sym]) } end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/creature/animal.rb
lib/faker/creature/animal.rb
# frozen_string_literal: true module Faker class Creature class Animal < Base class << self ## # Produces a random animal name # # @return [String] # # @example # Faker::Creature::Animal.name #=> "fly" # # @faker.version 1.9.2 def name fetch('creature.animal.name') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/creature/horse.rb
lib/faker/creature/horse.rb
# frozen_string_literal: true module Faker class Creature class Horse < Base flexible :horse class << self ## # Produces a random name for a horse # # @return [String] # # @example # Faker::Creature::Horse.name #=> "Noir" # # @faker.version 1.9.2 def name fetch('creature.horse.name') end ## # Produces a random horse breed # # @return [String] # # @example # Faker::Creature::Horse.breed #=> "Spanish Barb see Barb Horse" # # @faker.version 1.9.2 def breed fetch('creature.horse.breed') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/creature/dog.rb
lib/faker/creature/dog.rb
# frozen_string_literal: true module Faker class Creature class Dog < Base flexible :dog class << self ## # Produces a random name for a dog # # @return [String] # # @example # Faker::Creature::Dog.name #=> "Spike" # # @faker.version 1.9.2 def name fetch('creature.dog.name') end ## # Produces a random dog breed # # @return [String] # # @example # Faker::Creature::Dog.breed #=> "Yorkshire Terrier" # # @faker.version 1.9.2 def breed fetch('creature.dog.breed') end ## # Produces a random sound made by a dog # # @return [String] # # @example # Faker::Creature::Dog.sound #=> "woof woof" # # @faker.version 1.9.2 def sound fetch('creature.dog.sound') end ## # Produces a random dog meme phrase # # @return [String] # # @example # Faker::Creature::Dog.meme_phrase #=> "smol pupperino" # # @faker.version 1.9.2 def meme_phrase fetch('creature.dog.meme_phrase') end ## # Produces a random dog age # # @return [String] # # @example # Faker::Creature::Dog.age #=> "puppy" # # @faker.version 1.9.2 def age fetch('creature.dog.age') end ## # Produces a random gender # # @return [String] # # @example # Faker::Creature::Dog.gender #=> "Female" # # @faker.version 1.9.2 def gender Faker::Gender.binary_type end ## # Produces a random coat length # # @return [String] # # @example # Faker::Creature::Dog.coat_length #=> "short" # # @faker.version 1.9.2 def coat_length fetch('creature.dog.coat_length') end ## # Produces a random size of a dog # # @return [String] # # @example # Faker::Creature::Dog.size #=> "small" # # @faker.version 1.9.2 def size fetch('creature.dog.size') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/creature/cat.rb
lib/faker/creature/cat.rb
# frozen_string_literal: true module Faker class Creature class Cat < Base flexible :cat class << self ## # Produces a random name for a cat # # @return [String] # # @example # Faker::Creature::Cat.name #=> "Felix" # # @faker.version 1.9.2 def name fetch('creature.cat.name') end ## # Produces a random cat breed # # @return [String] # # @example # Faker::Creature::Cat.breed #=> "Scottish Fold" # # @faker.version 1.9.2 def breed fetch('creature.cat.breed') end ## # Produces a random cat breed registry # # @return [String] # # @example # Faker::Creature::Cat.registry #=> "Fancy Southern Africa Cat Council" # # @faker.version 1.9.2 def registry fetch('creature.cat.registry') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/locations/australia.rb
lib/faker/locations/australia.rb
# frozen_string_literal: true module Faker class Locations class Australia < Base class << self ## # Produces a location in Australia # # @return [String] # # @example # Faker::Locations::Australia.location # #=> "Sydney" # # @faker.version next def location fetch('locations.australia.locations') end # Produces an Australian animal # # @return [String] # # @example # Faker::Locations::Australia.animal # #=> "Dingo" # # @faker.version next def animal fetch('locations.australia.animals') end # Produces an Australian State or Territory # # @return [String] # # @example # Faker::Locations::Australia.state # #=> "New South Wales" # # @faker.version next def state fetch('locations.australia.states') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/tv_shows/archer.rb
lib/faker/tv_shows/archer.rb
# frozen_string_literal: true module Faker class TvShows class Archer < Base flexible :archer class << self ## # Produces a character from Archer. # # @return [String] # # @example # Faker::TvShows::Archer.character #=> "Sterling Archer" # # @faker.version next def character fetch('archer.characters') end ## # Produces a location from Archer. # # @return [String] # # @example # Faker::TvShows::Archer.location #=> "The Tuntmore Towers" # # @faker.version next def location fetch('archer.locations') end ## # Produces a quote from Archer. # # @return [String] # # @example # Faker::TvShows::Archer.quote # #=> "You're not my supervisor!" # # @faker.version next def quote fetch('archer.quotes') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false
faker-ruby/faker
https://github.com/faker-ruby/faker/blob/a4d5e503edda970fc085e942018ee235622bfb11/lib/faker/tv_shows/michael_scott.rb
lib/faker/tv_shows/michael_scott.rb
# frozen_string_literal: true module Faker class TvShows class MichaelScott < Base class << self ## # Produces a quote from Michael Scott. # # @return [String] # # @example # Faker::TvShows::MichaelScott.quote # #=> "I am Beyoncé, always." # # @faker.version 1.9.0 def quote fetch('michael_scott.quotes') end end end end end
ruby
MIT
a4d5e503edda970fc085e942018ee235622bfb11
2026-01-04T15:37:50.353881Z
false