diff --git a/lib/faker/default/app.rb b/lib/faker/default/app.rb index be131cf82f..d9b78a28da 100644 --- a/lib/faker/default/app.rb +++ b/lib/faker/default/app.rb @@ -63,7 +63,6 @@ def author # # @faker.version 1.4.3 def semantic_version(legacy_major = NOT_GIVEN, legacy_minor = NOT_GIVEN, legacy_patch = NOT_GIVEN, major: 0..9, minor: 0..9, patch: 1..9) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :major if legacy_major != NOT_GIVEN keywords << :minor if legacy_minor != NOT_GIVEN @@ -72,6 +71,7 @@ def semantic_version(legacy_major = NOT_GIVEN, legacy_minor = NOT_GIVEN, legacy_ [major, minor, patch].map { |chunk| sample(Array(chunk)) }.join('.') end + # rubocop:enable Metrics/ParameterLists end end end diff --git a/lib/faker/default/avatar.rb b/lib/faker/default/avatar.rb index c191e7bd02..feb80e0a61 100644 --- a/lib/faker/default/avatar.rb +++ b/lib/faker/default/avatar.rb @@ -39,7 +39,6 @@ class << self # # @faker.version 1.4.3 def image(legacy_slug = NOT_GIVEN, legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_set = NOT_GIVEN, legacy_bgset = NOT_GIVEN, slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :slug if legacy_slug != NOT_GIVEN keywords << :size if legacy_size != NOT_GIVEN @@ -55,6 +54,7 @@ def image(legacy_slug = NOT_GIVEN, legacy_size = NOT_GIVEN, legacy_format = NOT_ bgset_query = "&bgset=#{bgset}" if bgset "https://robohash.org/#{slug}.#{format}?size=#{size}&set=#{set}#{bgset_query}" end + # rubocop:enable Metrics/ParameterLists end end end diff --git a/lib/faker/default/barcode.rb b/lib/faker/default/barcode.rb index c5c15b634a..86ff692dec 100644 --- a/lib/faker/default/barcode.rb +++ b/lib/faker/default/barcode.rb @@ -3,7 +3,8 @@ module Faker class Barcode < Base class << self - ## Returns a EAN 8 or 13 digit format barcode number with check digit + ## + # Returns a EAN 8 or 13 digit format barcode number with check digit # @return [String] # # @example @@ -16,7 +17,8 @@ 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 + ## + # Returns a EAN 8 or 13 digit format barcode number with composite string attached with check digit # @return [String] # # @example @@ -29,7 +31,8 @@ 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 + ## + # Returns a UPC_A format barcode number with check digit # @return [String] # # @example @@ -40,7 +43,8 @@ def upc_a generate_barcode('barcode.upc_a') end - ## Returns a UPC_E format barcode number with check digit + ## + # Returns a UPC_E format barcode number with check digit # @return [String] # # @example @@ -51,7 +55,8 @@ def upc_e generate_barcode('barcode.upc_e') end - ## Returns a UPC_A format barcode number with composite string attached with check digit + ## + # Returns a UPC_A format barcode number with composite string attached with check digit # @return [String] # # @example @@ -62,7 +67,8 @@ 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 + ## + # Returns a UPC_E format barcode number with composite string attached with check digit # @return [String] # # @example @@ -73,7 +79,8 @@ def upc_e_with_composite_symbology "#{upc_e}|#{bothify(parse('barcode.composite_symbol'))}" end - ## Returns a ISBN format barcode number with check digit + ## + # Returns a ISBN format barcode number with check digit # @return [String] # # @example @@ -84,7 +91,8 @@ def isbn generate_barcode('barcode.isbn') end - ## Returns a ISMN format barcode number with check digit + ## + # Returns a ISMN format barcode number with check digit # @return [String] # # @example @@ -95,7 +103,8 @@ def ismn generate_barcode('barcode.ismn') end - ## Returns a ISSN format barcode number with check digit + ## + # Returns a ISSN format barcode number with check digit # @return [String] # # @example @@ -114,7 +123,8 @@ def generate_barcode(key) "#{barcode}#{check_digit}" end - ## Returns the sum of even and odd numbers from value passed + ## + # Returns the sum of even and odd numbers from value passed # # @return [Array] # @@ -137,7 +147,8 @@ def sum_even_odd(fake_num) [sum_odd, sum_even] end - ## Generates the check digits from sum passed + ## + # Generates the check digits from sum passed # # @return [Integer] # diff --git a/lib/faker/default/cannabis.rb b/lib/faker/default/cannabis.rb index 9755e2a148..88a281ffa9 100644 --- a/lib/faker/default/cannabis.rb +++ b/lib/faker/default/cannabis.rb @@ -2,6 +2,7 @@ module Faker class Cannabis < Base + ## # Produces a random strain. # # @return [String] @@ -14,6 +15,7 @@ def self.strain fetch('cannabis.strains') end + ## # Produces a random abbreviation. # # @return [String] @@ -26,6 +28,7 @@ def self.cannabinoid_abbreviation fetch('cannabis.cannabinoid_abbreviations') end + ## # Produces a random cannabinoid type. # # @return [String] @@ -38,6 +41,7 @@ def self.cannabinoid fetch('cannabis.cannabinoids') end + ## # Produces a random terpene type. # # @return [String] @@ -50,6 +54,7 @@ def self.terpene fetch('cannabis.terpenes') end + ## # Produces a random kind of medical use. # # @return [String] @@ -62,6 +67,7 @@ def self.medical_use fetch('cannabis.medical_uses') end + ## # Produces a random health benefit. # # @return [String] @@ -74,6 +80,7 @@ def self.health_benefit fetch('cannabis.health_benefits') end + ## # Produces a random category. # # @return [String] @@ -86,6 +93,7 @@ def self.category fetch('cannabis.categories') end + ## # Produces a random type. # # @return [String] @@ -98,6 +106,7 @@ def self.type fetch('cannabis.types') end + ## # Produces a random buzzword. # # @return [String] @@ -110,6 +119,7 @@ def self.buzzword fetch('cannabis.buzzwords') end + ## # Produces a random brand. # # @return [String] diff --git a/lib/faker/default/chuck_norris.rb b/lib/faker/default/chuck_norris.rb index 34b2b700cc..419b86fe24 100644 --- a/lib/faker/default/chuck_norris.rb +++ b/lib/faker/default/chuck_norris.rb @@ -5,6 +5,7 @@ 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 diff --git a/lib/faker/default/code.rb b/lib/faker/default/code.rb index 8f34b2ef78..ce5939636a 100644 --- a/lib/faker/default/code.rb +++ b/lib/faker/default/code.rb @@ -80,11 +80,11 @@ def rut value << "-#{vd}" end + ## + # Produces a random NRIC (National Registry Identity Card) code. # By default generates a Singaporean NRIC ID for someone # who is born between the age of 18 and 65. # - # Produces a random NRIC (National Registry Identity Card) code. - # # @param min_age [Integer] the min age of the person in years # @param max_age [Integer] the max age of the person in years # @return [String] diff --git a/lib/faker/default/company.rb b/lib/faker/default/company.rb index c44bc52738..e80c79afd1 100644 --- a/lib/faker/default/company.rb +++ b/lib/faker/default/company.rb @@ -404,7 +404,18 @@ def brazilian_company_number(legacy_formatted = NOT_GIVEN, formatted: false) 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 @@ -507,7 +518,14 @@ def weight_sum(array, weights) # # 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) # rubocop:enable Style/AsciiComments def inn_number(region, type) n10 = [2, 4, 10, 3, 5, 9, 4, 6, 8] diff --git a/lib/faker/default/driving_licence.rb b/lib/faker/default/driving_licence.rb index e11134cbfc..6210cb1422 100644 --- a/lib/faker/default/driving_licence.rb +++ b/lib/faker/default/driving_licence.rb @@ -6,6 +6,8 @@ class DrivingLicence < Base NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population class << self + # rubocop:disable Metrics/ParameterLists + ## # Produces a random British driving licence number. # @@ -23,9 +25,7 @@ class << self # date_of_birth: Date.parse("1986-10-24")) #=> "OCARR815246J91HT" # # @faker.version 1.9.2 - # rubocop:disable Metrics/ParameterLists def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_GIVEN, legacy_gender = NOT_GIVEN, legacy_date_of_birth = NOT_GIVEN, 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)) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :last_name if legacy_last_name != NOT_GIVEN keywords << :initials if legacy_initials != NOT_GIVEN @@ -40,6 +40,7 @@ def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_ gb_licence_checksum ].join end + # rubocop:enable Metrics/ParameterLists ## # Produces a random Northern Irish licence number. diff --git a/lib/faker/default/file.rb b/lib/faker/default/file.rb index dd93006ba5..abec3fcf4a 100644 --- a/lib/faker/default/file.rb +++ b/lib/faker/default/file.rb @@ -3,6 +3,8 @@ module Faker class File < Base class << self + # rubocop:disable Metrics/ParameterLists + ## # Produces a random directory name. # @@ -18,9 +20,7 @@ class << self # Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "aut-ullam\\quia_quisquam\\ut-eos" # # @faker.version 1.6.4 - # rubocop:disable Metrics/ParameterLists def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: ::File::Separator) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :segment_count if legacy_segment_count != NOT_GIVEN keywords << :root if legacy_root != NOT_GIVEN @@ -34,6 +34,7 @@ def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_direct .join(directory_separator) .squeeze(directory_separator) end + # rubocop:enable Metrics/ParameterLists ## # Produces a random file extension. @@ -61,6 +62,8 @@ def mime_type fetch('file.mime_type') end + # rubocop:disable Metrics/ParameterLists + ## # Produces a random file name. # @@ -77,9 +80,7 @@ def mime_type # Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo/bar\\baz.mp3" # # @faker.version 1.6.4 - # rubocop:disable Metrics/ParameterLists def file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :dir if legacy_dir != NOT_GIVEN keywords << :name if legacy_name != NOT_GIVEN @@ -93,6 +94,7 @@ def file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_ [dir, name].join(directory_separator) + ".#{ext}" end + # rubocop:enable Metrics/ParameterLists end end end diff --git a/lib/faker/default/hipster.rb b/lib/faker/default/hipster.rb index 4d5644b86a..7083097039 100644 --- a/lib/faker/default/hipster.rb +++ b/lib/faker/default/hipster.rb @@ -17,6 +17,8 @@ def word random_word =~ /\s/ ? word : random_word end + # rubocop:disable Metrics/ParameterLists + ## # Produces a random hipster word. # @@ -32,9 +34,7 @@ def word # Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"] # # @faker.version 1.6.0 - # rubocop:disable Metrics/ParameterLists def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN keywords << :supplemental if legacy_supplemental != NOT_GIVEN @@ -73,9 +73,7 @@ def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spa # 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 - # rubocop:disable Metrics/ParameterLists def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :word_count if legacy_word_count != NOT_GIVEN keywords << :supplemental if legacy_supplemental != NOT_GIVEN @@ -84,6 +82,7 @@ def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, leg "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}." end + # rubocop:enable Metrics/ParameterLists ## # Produces random hipster sentences. @@ -111,6 +110,8 @@ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number end end + # rubocop:disable Metrics/ParameterLists + ## # Produces a random hipster paragraph. # @@ -127,9 +128,7 @@ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number # 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 - # rubocop:disable Metrics/ParameterLists def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 3) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN keywords << :supplemental if legacy_supplemental != NOT_GIVEN @@ -138,6 +137,7 @@ def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ') end + # rubocop:enable Metrics/ParameterLists ## # Produces random hipster paragraphs. diff --git a/lib/faker/default/internet.rb b/lib/faker/default/internet.rb index 60c53e557c..cc89d3ecb5 100644 --- a/lib/faker/default/internet.rb +++ b/lib/faker/default/internet.rb @@ -3,6 +3,20 @@ module Faker class Internet < Base class << self + ## + # Returns the email address + # + # @return [String] + # + # @param name [String] + # @param separators [Array] + # @param domain [String] + # + # @example + # Faker::Internet.email #=> "samsmith@faker.com" + # Faker::Internet.email(name: 'smith') #=> "smith@faker.com" + # Faker::Internet.email(name: 'sam smith', separators: ['-']) #=> "sam-smith@faker.com" + # Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'gmail') #=> "sam-smith@gmail.com" def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, separators: nil, domain: nil) warn_for_deprecated_arguments do |keywords| keywords << :name if legacy_name != NOT_GIVEN @@ -19,6 +33,16 @@ def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, sep construct_email(sanitized_local_part, domain_name(domain: domain)) end + ## + # Returns the email address with doamin either gmail.com, yahoo.com or hotmail.com + # + # @return [String] + # + # @param name [String] + # + # @example + # Faker::Internet.free_email #=> "samsmith@gmail.com" + # Faker::Internet.free_email(name: 'smith') #=> "smith@yahoo.com" def free_email(legacy_name = NOT_GIVEN, name: nil) warn_for_deprecated_arguments do |keywords| keywords << :name if legacy_name != NOT_GIVEN @@ -30,6 +54,16 @@ def free_email(legacy_name = NOT_GIVEN, name: nil) ) end + ## + # Returns the email address with fixed domain name as 'example' + # + # @return [String] + # + # @param name [String] + # + # @example + # Faker::Internet.safe_email #=> "samsmith@example.com" + # Faker::Internet.safe_email(name: 'smith') #=> "smith@example.net" def safe_email(legacy_name = NOT_GIVEN, name: nil) warn_for_deprecated_arguments do |keywords| keywords << :name if legacy_name != NOT_GIVEN @@ -41,6 +75,19 @@ def safe_email(legacy_name = NOT_GIVEN, name: nil) ) end + ## + # Returns the username + # + # @return [String] + # + # @param specifier [Integer, Range] When int value passed it returns the username longer than specifier. Max value can be 10^6 + # @param separator [Array] + # + # @wxample + # 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(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _]) warn_for_deprecated_arguments do |keywords| keywords << :specifier if legacy_specifier != NOT_GIVEN @@ -108,7 +155,6 @@ def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specif # # @faker.version 2.1.3 def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legacy_mix_case = NOT_GIVEN, legacy_special_characters = NOT_GIVEN, min_length: 8, max_length: 16, mix_case: true, special_characters: false) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :min_length if legacy_min_length != NOT_GIVEN keywords << :max_length if legacy_max_length != NOT_GIVEN @@ -144,7 +190,21 @@ def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legac temp end + # rubocop:enable Metrics/ParameterLists + ## + # 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 #=> "test.net" + # Faker::Internet.domain_name(subdomain: true) #=> "test.faker.io" + # Faker::Internet.domain_name(subdomain: true, domain: 'example') #=> "faker.example.com" + # Faker::Internet.domain_name(domain: 'faker') #=> "faker.org" def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false, domain: nil) warn_for_deprecated_arguments do |keywords| keywords << :subdomain if legacy_subdomain != NOT_GIVEN @@ -167,6 +227,19 @@ def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false, domain: nil) end end + # rubocop:disable Style/AsciiComments + + ## + # 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(legacy_string = NOT_GIVEN, string: '') warn_for_deprecated_arguments do |keywords| keywords << :string if legacy_string != NOT_GIVEN @@ -174,15 +247,40 @@ def fix_umlauts(legacy_string = NOT_GIVEN, string: '') Char.fix_umlauts(string) end + # rubocop:enable Style/AsciiComments + ## + # 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] + # + # @wxample + # Faker::Internet.domain_suffix #=> "com" + # Faker::Internet.domain_suffix #=> "biz" def domain_suffix fetch('internet.domain_suffix') 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(legacy_prefix = NOT_GIVEN, prefix: '') warn_for_deprecated_arguments do |keywords| keywords << :prefix if legacy_prefix != NOT_GIVEN @@ -193,11 +291,25 @@ def mac_address(legacy_prefix = NOT_GIVEN, prefix: '') (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 addr = nil loop do @@ -207,6 +319,13 @@ def private_ip_v4_address addr 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 @@ -216,6 +335,13 @@ def public_ip_v4_address 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 @@ -229,10 +355,25 @@ def private_nets_regex ] 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 @@ -245,25 +386,69 @@ def reserved_nets_regex ] end + ## + # Returns lambda function to check address passed is reserverd 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 # rubocop:disable Metrics/ParameterLists + + ## + # Returns URL + # + # @return [String] + # + # @param host [String] + # @param path [String] + # @param scheme [String] + # + # @example + # Faker::Internet.url #=> "http://sipes-okon.com/hung.macejkovic" + # Faker::Internet.url(host: 'faker') #=> "http://faker/shad" + # Faker::Internet.url(host: 'faker', path: '/fake_test_path') #=> "http://faker/fake_test_path" + # Faker::Internet.url(host: 'faker', path: '/fake_test_path', scheme: 'https') #=> "https://faker/fake_test_path" def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http') - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :host if legacy_host != NOT_GIVEN keywords << :path if legacy_path != NOT_GIVEN @@ -272,7 +457,21 @@ def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GI "#{scheme}://#{host}#{path}" end + # rubocop:enable Metrics/ParameterLists + ## + # 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(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil) warn_for_deprecated_arguments do |keywords| keywords << :words if legacy_words != NOT_GIVEN @@ -283,10 +482,29 @@ def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: ni (words || Faker::Lorem.words(number: 2).join(' ')).delete(',.').gsub(' ', glue).downcase 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(legacy_vendor = NOT_GIVEN, vendor: nil) warn_for_deprecated_arguments do |keywords| keywords << :vendor if legacy_vendor != NOT_GIVEN @@ -297,6 +515,13 @@ def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil) 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') diff --git a/lib/faker/default/json.rb b/lib/faker/default/json.rb index 4d091276b6..04dfe4140b 100644 --- a/lib/faker/default/json.rb +++ b/lib/faker/default/json.rb @@ -33,6 +33,8 @@ def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, JSON.generate(hash) end + # rubocop:disable Metrics/ParameterLists + ## # Produces a random nested JSON formatted string that can take JSON as an additional argument. # @@ -71,9 +73,7 @@ def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, # {"Rick":"Wiza","Bonita":"Bayer","Gardner":"Auer","Felicity":"Abbott"}}} # # @faker.version 1.9.2 - # rubocop:disable Metrics/ParameterLists def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :json if legacy_json != NOT_GIVEN end @@ -93,6 +93,7 @@ def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_ end JSON.generate(hash) end + # rubocop:enable Metrics/ParameterLists private diff --git a/lib/faker/default/lorem.rb b/lib/faker/default/lorem.rb index eb582f632c..429f9296de 100644 --- a/lib/faker/default/lorem.rb +++ b/lib/faker/default/lorem.rb @@ -4,10 +4,32 @@ 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.version 2.1.3 def word sample(translate('faker.lorem.words')) 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.version 2.1.3 def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN @@ -23,6 +45,15 @@ def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, shuffle(word_list)[0, resolved_num] end + ## + # Generates single character + # + # @return [String] + # + # @example + # Faker::Lorem.character #=> "e" + # + # @faker.version 2.1.3 def character sample(Types::CHARACTERS) end @@ -51,13 +82,42 @@ def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric) end + # rubocop:disable Style/AsciiComments + + ## + # 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 + # rubocop:enable Style/AsciiComments # rubocop:disable Metrics/ParameterLists + + ## + # 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(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :word_count if legacy_word_count != NOT_GIVEN keywords << :supplemental if legacy_supplemental != NOT_GIVEN @@ -66,7 +126,22 @@ def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, leg words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period end + # rubocop:enable Metrics/ParameterLists + ## + # 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(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN @@ -77,8 +152,28 @@ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number end # rubocop:disable Metrics/ParameterLists + + ## + # 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(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 0) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN keywords << :supplemental if legacy_supplemental != NOT_GIVEN @@ -87,7 +182,22 @@ def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space) end + # rubocop:enable Metrics/ParameterLists + ## + # 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(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN @@ -99,6 +209,20 @@ def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, numbe 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) } 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(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 256, supplemental: false) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN @@ -113,8 +237,24 @@ def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVE end # rubocop:disable Metrics/ParameterLists + + ## + # 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(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :word_count if legacy_word_count != NOT_GIVEN keywords << :supplemental if legacy_supplemental != NOT_GIVEN @@ -123,7 +263,22 @@ def question(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, leg words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark end + # rubocop:enable Metrics/ParameterLists + ## + # 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(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false) warn_for_deprecated_arguments do |keywords| keywords << :number if legacy_number != NOT_GIVEN diff --git a/lib/faker/default/lorem_flickr.rb b/lib/faker/default/lorem_flickr.rb index e817427c9a..0c6bbe52f6 100644 --- a/lib/faker/default/lorem_flickr.rb +++ b/lib/faker/default/lorem_flickr.rb @@ -5,6 +5,8 @@ class LoremFlickr < Base class << self SUPPORTED_COLORIZATIONS = %w[red green blue].freeze + # rubocop:disable Metrics/ParameterLists + ## # Produces a random image URL from loremflickr.com. # @@ -21,9 +23,7 @@ class << self # Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/50/60/sports,fitness/all" # # @faker.version 1.9.0 - # rubocop:disable Metrics/ParameterLists def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :size if legacy_size != NOT_GIVEN keywords << :search_terms if legacy_search_terms != NOT_GIVEN @@ -49,9 +49,7 @@ def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match # Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/g/50/60/sports,fitness/all" # # @faker.version 1.9.0 - # rubocop:disable Metrics/ParameterLists def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :size if legacy_size != NOT_GIVEN keywords << :search_terms if legacy_search_terms != NOT_GIVEN @@ -79,9 +77,7 @@ def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, le # Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/p/50/60/sports,fitness/all" # # @faker.version 1.9.0 - # rubocop:disable Metrics/ParameterLists def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :size if legacy_size != NOT_GIVEN keywords << :search_terms if legacy_search_terms != NOT_GIVEN @@ -110,9 +106,7 @@ def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, le # Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/blue/50/60/sports,fitness/all" # # @faker.version 1.9.0 - # rubocop:disable Metrics/ParameterLists def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :size if legacy_size != NOT_GIVEN keywords << :color if legacy_color != NOT_GIVEN @@ -125,6 +119,7 @@ def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_se build_url(size, color, search_terms, match_all) end + # rubocop:enable Metrics/ParameterLists private diff --git a/lib/faker/default/lorem_pixel.rb b/lib/faker/default/lorem_pixel.rb index ab62443744..7b22344894 100644 --- a/lib/faker/default/lorem_pixel.rb +++ b/lib/faker/default/lorem_pixel.rb @@ -17,6 +17,8 @@ class << self technics transport].freeze + # rubocop:disable Metrics/ParameterLists + ## # Produces a random image URL from lorempixel.com. # @@ -39,7 +41,6 @@ class << self # Faker::LoremPixel.image(secure: false) #=> "http://lorempixel.com/300/300" # # @faker.version 1.7.0 - # rubocop:disable Metrics/ParameterLists def image(legacy_size = NOT_GIVEN, legacy_is_gray = NOT_GIVEN, legacy_category = NOT_GIVEN, legacy_number = NOT_GIVEN, legacy_text = NOT_GIVEN, legacy_secure = NOT_GIVEN, size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true) warn_for_deprecated_arguments do |keywords| keywords << :size if legacy_size != NOT_GIVEN diff --git a/lib/faker/default/omniauth.rb b/lib/faker/default/omniauth.rb index dfabc8d204..0cf566e3df 100644 --- a/lib/faker/default/omniauth.rb +++ b/lib/faker/default/omniauth.rb @@ -17,6 +17,8 @@ def initialize(name: nil, email: nil) end class << self + # rubocop:disable Metrics/ParameterLists + ## # Generate a mock Omniauth response from Google. # @@ -27,9 +29,7 @@ class << self # @return [Hash] An auth hash in the format provided by omniauth-google. # # @faker.version 1.8.0 - # rubocop:disable Metrics/ParameterLists def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 9).to_s) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :name if legacy_name != NOT_GIVEN keywords << :email if legacy_email != NOT_GIVEN @@ -95,9 +95,7 @@ def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_G # @return [Hash] An auth hash in the format provided by omniauth-facebook. # # @faker.version 1.8.0 - # rubocop:disable Metrics/ParameterLists def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :name if legacy_name != NOT_GIVEN keywords << :email if legacy_email != NOT_GIVEN @@ -156,9 +154,7 @@ def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username # @return [Hash] An auth hash in the format provided by omniauth-twitter. # # @faker.version 1.8.0 - # rubocop:disable Metrics/ParameterLists def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, nickname: nil, uid: Number.number(digits: 6).to_s) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :name if legacy_name != NOT_GIVEN keywords << :nickname if legacy_nickname != NOT_GIVEN @@ -247,9 +243,7 @@ def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = N # @return [Hash] An auth hash in the format provided by omniauth-linkedin. # # @faker.version 1.8.0 - # rubocop:disable Metrics/ParameterLists def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 6).to_s) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :name if legacy_name != NOT_GIVEN keywords << :email if legacy_email != NOT_GIVEN @@ -328,9 +322,7 @@ def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT # @return [Hash] An auth hash in the format provided by omniauth-github. # # @faker.version 1.8.0 - # rubocop:disable Metrics/ParameterLists def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 8).to_s) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :name if legacy_name != NOT_GIVEN keywords << :email if legacy_email != NOT_GIVEN @@ -393,6 +385,7 @@ def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_G } } end + # rubocop:enable Metrics/ParameterLists ## # Generate a mock Omniauth response from Apple. diff --git a/lib/faker/default/placeholdit.rb b/lib/faker/default/placeholdit.rb index 9131b53bec..ac8f40a29c 100644 --- a/lib/faker/default/placeholdit.rb +++ b/lib/faker/default/placeholdit.rb @@ -5,6 +5,8 @@ class Placeholdit < Base class << self SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze + # rubocop:disable Metrics/ParameterLists + ## # Produces a random placeholder image from https://placehold.it. # @@ -26,9 +28,7 @@ class << self # Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://placehold.it/50x50.jpg/ffffff/000?text=Some Custom Text" # # @faker.version 1.6.0 - # rubocop:disable Metrics/ParameterLists def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_color = NOT_GIVEN, legacy_text_color = NOT_GIVEN, legacy_text = NOT_GIVEN, size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil) - # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :size if legacy_size != NOT_GIVEN keywords << :format if legacy_format != NOT_GIVEN @@ -51,6 +51,7 @@ def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_ image_url += "?text=#{text}" if text image_url end + # rubocop:enable Metrics/ParameterLists private diff --git a/lib/faker/default/string.rb b/lib/faker/default/string.rb index bfcece20a3..774878829d 100644 --- a/lib/faker/default/string.rb +++ b/lib/faker/default/string.rb @@ -3,6 +3,8 @@ module Faker class String < Base class << self + # rubocop:disable Style/AsciiComments + ## # Produces a random UTF-8 string with optional nested length selectors. # @@ -10,13 +12,11 @@ class << self # @return [String] # # @example - # rubocop:disable Style/AsciiComments # 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#ћ" - # rubocop:enable Style/AsciiComments # # @faker.version 1.9.0 def random(legacy_length = NOT_GIVEN, length: 32) @@ -26,6 +26,7 @@ def random(legacy_length = NOT_GIVEN, length: 32) utf8string select_a length end + # rubocop:enable Style/AsciiComments private diff --git a/lib/faker/movies/star_wars.rb b/lib/faker/movies/star_wars.rb index a212f055fc..9fd5c7336b 100644 --- a/lib/faker/movies/star_wars.rb +++ b/lib/faker/movies/star_wars.rb @@ -161,34 +161,106 @@ def quote(legacy_character = NOT_GIVEN, character: nil) fetch("star_wars.quotes.#{character}") end + ## + # Generates numbers array + # + # @return [Array] + # + # @example + # Faker::Movies::StarWars.call_numbers #=> ["Leader", "#"] + # + # @faker.version 1.6.2 def call_numbers fetch_all('star_wars.call_numbers') end + ## + # Returns squadrons array + # + # @return [Array] + # + # @example + # Faker::Movies::StarWars.call_squadrons #=> ["Rogue", "Red", "Gray", "Green", "Blue", "Gold", "Black", "Yellow", "Phoenix"] + # + # @faker.version 1.6.2 def call_squadrons fetch_all('star_wars.call_squadrons') end + ## + # Returns all character names in movie + # + # @return [Array] + # + # @example + # Faker::Movies::StarWars.characters + # + # @faker.version 1.6.2 def characters fetch_all('star_wars.characters') end + ## + # Returns droid list + # + # @return [Array] + # + # @example + # Faker::Movies::StarWars.droids + # + # @faker.versionn 1.6.2 def droids fetch_all('star_wars.droids') end + ## + # Lists out all planet names + # + # @return [Array] + # + # @example + # Faker::Movies::StarWars.planets + # + # @faker.version 1.6.2 def planets fetch_all('star_wars.planets') end + ## + # Returns name of all species + # + # @return [Array] + # + # @example + # Faker::Movies::StarWars.species + # + # @faker.version 1.6.2 def species fetch_all('star_wars.species') end + ## + # Lists out all vehicles + # + # @return [Array] + # + # @example + # Faker::Movies::StarWars.vehicles + # + # @faker.version 1.6.2 def vehicles fetch_all('star_wars.vehicles') end + ## + # All wookiee words + # + # @return [Array] + # + # @example + # Faker::Movies::StarWars.wookiee_words + # + # @faker.version 1.6.2 def wookiee_words fetch_all('star_wars.wookiee_words') end diff --git a/lib/faker/quotes/rajnikanth.rb b/lib/faker/quotes/rajnikanth.rb index e637353462..b14006b9c1 100644 --- a/lib/faker/quotes/rajnikanth.rb +++ b/lib/faker/quotes/rajnikanth.rb @@ -6,6 +6,7 @@ class Rajnikanth < Base flexible :rajnikanth class << self + ## # Produces a Rajnikanth. # Original list of jokes: # http://www.rajinikanthjokes.com/ diff --git a/lib/faker/quotes/shakespeare.rb b/lib/faker/quotes/shakespeare.rb index 13f53db892..75de12a6ba 100644 --- a/lib/faker/quotes/shakespeare.rb +++ b/lib/faker/quotes/shakespeare.rb @@ -56,18 +56,52 @@ 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