/usr/share/rubygems-integration/all/gems/faker-1.6.6/lib/faker/company.rb is in ruby-faker 1.6.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | module Faker
class Company < Base
flexible :company
class << self
def name
parse('company.name')
end
def suffix
fetch('company.suffix')
end
def industry
fetch('company.industry')
end
# Generate a buzzword-laden catch phrase.
def catch_phrase
translate('faker.company.buzzwords').collect {|list| list.sample }.join(' ')
end
def buzzword
translate('faker.company.buzzwords').flatten.sample
end
# When a straight answer won't do, BS to the rescue!
def bs
translate('faker.company.bs').collect {|list| list.sample }.join(' ')
end
def ein
('%09d' % rand(10 ** 9)).gsub(/(\d\d)(\d\d\d\d\d\d\d)/, '\\1-\\2')
end
def duns_number
('%09d' % rand(10 ** 9)).gsub(/(\d\d)(\d\d\d)(\d\d\d\d)/, '\\1-\\2-\\3')
end
# Get a random company logo url in PNG format.
def logo
rand_num = Random.rand(13) + 1
"https://pigment.github.io/fake-logos/logos/medium/color/#{rand_num}.png"
end
def swedish_organisation_number
base = ('%09d' % rand(10 ** 9))
base + luhn_algorithm(base).to_s
end
def australian_business_number
base = ('%09d' % rand(10 ** 9))
abn = '00' + base
(99 - (abn_checksum(abn) % 89)).to_s + base
end
def profession
fetch('company.profession')
end
private
def luhn_algorithm(number)
multiplications = []
number.split(//).each_with_index do |digit, i|
if i % 2 == 0
multiplications << digit.to_i * 2
else
multiplications << 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 == 0
control_digit = 0
else
control_digit = (sum / 10 + 1) * 10 - sum
end
control_digit
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
end
end
end
|