Skip to content

Commit

Permalink
2243 yard doc (#2247)
Browse files Browse the repository at this point in the history
* Added yard doc for internet

* Fixed yard doc

* Added yard doc for lorem

* Added missing yard doc
  • Loading branch information
sudeeptarlekar committed Feb 7, 2021
1 parent 664cbaf commit 88c3804
Show file tree
Hide file tree
Showing 21 changed files with 579 additions and 57 deletions.
2 changes: 1 addition & 1 deletion lib/faker/default/app.rb
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/faker/default/avatar.rb
Expand Up @@ -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
Expand All @@ -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
33 changes: 22 additions & 11 deletions lib/faker/default/barcode.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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]
#
Expand All @@ -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]
#
Expand Down
10 changes: 10 additions & 0 deletions lib/faker/default/cannabis.rb
Expand Up @@ -2,6 +2,7 @@

module Faker
class Cannabis < Base
##
# Produces a random strain.
#
# @return [String]
Expand All @@ -14,6 +15,7 @@ def self.strain
fetch('cannabis.strains')
end

##
# Produces a random abbreviation.
#
# @return [String]
Expand All @@ -26,6 +28,7 @@ def self.cannabinoid_abbreviation
fetch('cannabis.cannabinoid_abbreviations')
end

##
# Produces a random cannabinoid type.
#
# @return [String]
Expand All @@ -38,6 +41,7 @@ def self.cannabinoid
fetch('cannabis.cannabinoids')
end

##
# Produces a random terpene type.
#
# @return [String]
Expand All @@ -50,6 +54,7 @@ def self.terpene
fetch('cannabis.terpenes')
end

##
# Produces a random kind of medical use.
#
# @return [String]
Expand All @@ -62,6 +67,7 @@ def self.medical_use
fetch('cannabis.medical_uses')
end

##
# Produces a random health benefit.
#
# @return [String]
Expand All @@ -74,6 +80,7 @@ def self.health_benefit
fetch('cannabis.health_benefits')
end

##
# Produces a random category.
#
# @return [String]
Expand All @@ -86,6 +93,7 @@ def self.category
fetch('cannabis.categories')
end

##
# Produces a random type.
#
# @return [String]
Expand All @@ -98,6 +106,7 @@ def self.type
fetch('cannabis.types')
end

##
# Produces a random buzzword.
#
# @return [String]
Expand All @@ -110,6 +119,7 @@ def self.buzzword
fetch('cannabis.buzzwords')
end

##
# Produces a random brand.
#
# @return [String]
Expand Down
1 change: 1 addition & 0 deletions lib/faker/default/chuck_norris.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/faker/default/code.rb
Expand Up @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions lib/faker/default/company.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
5 changes: 3 additions & 2 deletions lib/faker/default/driving_licence.rb
Expand Up @@ -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.
#
Expand All @@ -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
Expand All @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions lib/faker/default/file.rb
Expand Up @@ -3,6 +3,8 @@
module Faker
class File < Base
class << self
# rubocop:disable Metrics/ParameterLists

##
# Produces a random directory name.
#
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -61,6 +62,8 @@ def mime_type
fetch('file.mime_type')
end

# rubocop:disable Metrics/ParameterLists

##
# Produces a random file name.
#
Expand All @@ -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
Expand All @@ -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

0 comments on commit 88c3804

Please sign in to comment.