faker 1.8.7 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +146 -6
  3. data/README.md +44 -4
  4. data/lib/extensions/array.rb +10 -10
  5. data/lib/extensions/symbol.rb +0 -1
  6. data/lib/faker.rb +42 -35
  7. data/lib/faker/address.rb +39 -13
  8. data/lib/faker/app.rb +1 -3
  9. data/lib/faker/appliance.rb +13 -0
  10. data/lib/faker/avatar.rb +2 -2
  11. data/lib/faker/bank.rb +72 -15
  12. data/lib/faker/beer.rb +0 -1
  13. data/lib/faker/bitcoin.rb +4 -5
  14. data/lib/faker/bojack_horseman.rb +17 -0
  15. data/lib/faker/breaking_bad.rb +0 -3
  16. data/lib/faker/business.rb +1 -2
  17. data/lib/faker/cannabis.rb +42 -0
  18. data/lib/faker/chuck_norris.rb +3 -2
  19. data/lib/faker/code.rb +59 -20
  20. data/lib/faker/coffee.rb +4 -0
  21. data/lib/faker/color.rb +2 -2
  22. data/lib/faker/commerce.rb +3 -4
  23. data/lib/faker/community.rb +13 -0
  24. data/lib/faker/company.rb +80 -24
  25. data/lib/faker/currency.rb +17 -0
  26. data/lib/faker/date.rb +13 -27
  27. data/lib/faker/demographic.rb +2 -2
  28. data/lib/faker/device.rb +29 -0
  29. data/lib/faker/dota.rb +25 -0
  30. data/lib/faker/dr_who.rb +7 -8
  31. data/lib/faker/dumb_and_dumber.rb +1 -1
  32. data/lib/faker/dune.rb +4 -4
  33. data/lib/faker/elder_scrolls.rb +16 -0
  34. data/lib/faker/electrical_components.rb +19 -0
  35. data/lib/faker/ethereum.rb +12 -0
  36. data/lib/faker/famous_last_words.rb +11 -0
  37. data/lib/faker/file.rb +2 -5
  38. data/lib/faker/fillmurray.rb +3 -4
  39. data/lib/faker/finance.rb +3 -4
  40. data/lib/faker/food.rb +21 -1
  41. data/lib/faker/football.rb +21 -0
  42. data/lib/faker/gender.rb +13 -0
  43. data/lib/faker/greek_philosophers.rb +13 -0
  44. data/lib/faker/hacker.rb +9 -11
  45. data/lib/faker/harry_potter.rb +4 -0
  46. data/lib/faker/hipster.rb +12 -4
  47. data/lib/faker/id_number.rb +24 -9
  48. data/lib/faker/internet.rb +69 -57
  49. data/lib/faker/invoice.rb +94 -0
  50. data/lib/faker/job.rb +10 -3
  51. data/lib/faker/lebowski.rb +2 -2
  52. data/lib/faker/lord_of_the_rings.rb +5 -1
  53. data/lib/faker/lorem.rb +32 -8
  54. data/lib/faker/lorem_flickr.rb +43 -0
  55. data/lib/faker/lorem_pixel.rb +20 -5
  56. data/lib/faker/lovecraft.rb +12 -5
  57. data/lib/faker/markdown.rb +12 -4
  58. data/lib/faker/measurement.rb +35 -80
  59. data/lib/faker/michael_scott.rb +9 -0
  60. data/lib/faker/military.rb +25 -0
  61. data/lib/faker/music.rb +13 -1
  62. data/lib/faker/myst.rb +25 -0
  63. data/lib/faker/name.rb +22 -8
  64. data/lib/faker/nation.rb +24 -0
  65. data/lib/faker/nato_phonetic_alphabet.rb +9 -0
  66. data/lib/faker/new_girl.rb +13 -0
  67. data/lib/faker/number.rb +12 -12
  68. data/lib/faker/omniauth.rb +110 -122
  69. data/lib/faker/parks_and_rec.rb +13 -0
  70. data/lib/faker/phone_number.rb +11 -19
  71. data/lib/faker/placeholdit.rb +11 -2
  72. data/lib/faker/princess_bride.rb +13 -0
  73. data/lib/faker/rick_and_morty.rb +1 -1
  74. data/lib/faker/science.rb +4 -2
  75. data/lib/faker/seinfeld.rb +1 -1
  76. data/lib/faker/shakespeare.rb +0 -3
  77. data/lib/faker/silicon_valley.rb +4 -0
  78. data/lib/faker/simpsons.rb +3 -8
  79. data/lib/faker/singular_siegler.rb +9 -0
  80. data/lib/faker/slack_emoji.rb +0 -2
  81. data/lib/faker/source.rb +18 -0
  82. data/lib/faker/space.rb +4 -0
  83. data/lib/faker/star_trek.rb +2 -2
  84. data/lib/faker/star_wars.rb +5 -6
  85. data/lib/faker/stranger_thing.rb +13 -0
  86. data/lib/faker/string.rb +45 -0
  87. data/lib/faker/stripe.rb +63 -0
  88. data/lib/faker/sword_art_online.rb +21 -0
  89. data/lib/faker/team.rb +4 -1
  90. data/lib/faker/the_it_crowd.rb +21 -0
  91. data/lib/faker/time.rb +10 -10
  92. data/lib/faker/twin_peaks.rb +2 -2
  93. data/lib/faker/twitter.rb +1 -1
  94. data/lib/faker/types.rb +36 -40
  95. data/lib/faker/university.rb +3 -3
  96. data/lib/faker/vehicle.rb +72 -10
  97. data/lib/faker/verb.rb +25 -0
  98. data/lib/faker/version.rb +1 -1
  99. data/lib/faker/world_cup.rb +25 -0
  100. data/lib/helpers/char.rb +19 -20
  101. data/lib/helpers/unique_generator.rb +7 -1
  102. data/lib/locales/ca-CAT.yml +1 -1
  103. data/lib/locales/da-DK.yml +1 -0
  104. data/lib/locales/de-AT.yml +3 -2
  105. data/lib/locales/de.yml +6 -5
  106. data/lib/locales/ee.yml +59 -0
  107. data/lib/locales/en-CA.yml +23 -1
  108. data/lib/locales/en-GB.yml +1 -0
  109. data/lib/locales/en-NZ.yml +4 -3
  110. data/lib/locales/en-US.yml +2 -0
  111. data/lib/locales/en.yml +2 -2
  112. data/lib/locales/en/appliance.yml +5 -0
  113. data/lib/locales/en/bank.yml +274 -59
  114. data/lib/locales/en/bojack_horseman.yml +6 -0
  115. data/lib/locales/en/cannabis.yml +12 -0
  116. data/lib/locales/en/community.yml +33 -0
  117. data/lib/locales/en/currency.yml +6 -0
  118. data/lib/locales/en/dessert.yml +3 -3
  119. data/lib/locales/en/device.yml +7 -0
  120. data/lib/locales/en/dota.yml +102 -0
  121. data/lib/locales/en/dr_who.yml +5 -1
  122. data/lib/locales/en/dumb_and_dumber.yml +1 -1
  123. data/lib/locales/en/elder_scrolls.yml +8 -5
  124. data/lib/locales/en/electrical_components.yml +6 -0
  125. data/lib/locales/en/famous_last_words.yml +4 -0
  126. data/lib/locales/en/food.yml +6 -3
  127. data/lib/locales/en/football.yml +7 -0
  128. data/lib/locales/en/gender.yml +5 -0
  129. data/lib/locales/en/greek_philosophers.yml +26 -0
  130. data/lib/locales/en/harry_potter.yml +2 -1
  131. data/lib/locales/en/invoice.yml +6 -0
  132. data/lib/locales/en/job.yml +2 -2
  133. data/lib/locales/en/lord_of_the_rings.yml +1 -0
  134. data/lib/locales/en/lorem.yml +4 -0
  135. data/lib/locales/en/michael_scott.yml +45 -0
  136. data/lib/locales/en/military.yml +8 -0
  137. data/lib/locales/en/music.yml +29 -1
  138. data/lib/locales/en/myst.yml +47 -0
  139. data/lib/locales/en/name.yml +13 -12
  140. data/lib/locales/en/nation.yml +8 -0
  141. data/lib/locales/en/nato_phonetic_alphabet.yml +4 -0
  142. data/lib/locales/en/new_girl.yml +40 -0
  143. data/lib/locales/en/overwatch.yml +3 -2
  144. data/lib/locales/en/parks_and_rec.yml +7 -0
  145. data/lib/locales/en/princess_bride.yml +5 -0
  146. data/lib/locales/en/programming_language.yml +2 -1
  147. data/lib/locales/en/science.yml +1 -0
  148. data/lib/locales/en/silicon_valley.yml +1 -0
  149. data/lib/locales/en/singular_siegler.yml +37 -0
  150. data/lib/locales/en/source.yml +16 -0
  151. data/lib/locales/en/space.yml +2 -1
  152. data/lib/locales/en/star_wars.yml +10 -0
  153. data/lib/locales/en/stranger_thing.yml +36 -0
  154. data/lib/locales/en/stripe.yml +42 -0
  155. data/lib/locales/en/sword_art_online.yml +334 -0
  156. data/lib/locales/en/team.yml +1 -1
  157. data/lib/locales/en/the_it_crowd.yml +155 -0
  158. data/lib/locales/en/vehicle.yml +24 -0
  159. data/lib/locales/en/verbs.yml +8 -0
  160. data/lib/locales/en/world_cup.yml +271 -0
  161. data/lib/locales/es.yml +6 -1
  162. data/lib/locales/fi-FI.yml +9 -4
  163. data/lib/locales/fr-CA.yml +90 -0
  164. data/lib/locales/fr-CH.yml +73 -0
  165. data/lib/locales/fr.yml +4 -2
  166. data/lib/locales/it.yml +1 -1
  167. data/lib/locales/ja.yml +11 -0
  168. data/lib/locales/lv.yml +53 -0
  169. data/lib/locales/nl.yml +1 -1
  170. data/lib/locales/no.yml +7 -0
  171. data/lib/locales/pl.yml +1 -0
  172. data/lib/locales/pt-BR.yml +21 -13
  173. data/lib/locales/pt.yml +1 -0
  174. data/lib/locales/sv.yml +4 -4
  175. data/lib/locales/tr.yml +8 -0
  176. data/lib/locales/uk.yml +9 -0
  177. metadata +167 -3
@@ -0,0 +1,9 @@
1
+ module Faker
2
+ class MichaelScott < Base
3
+ class << self
4
+ def quote
5
+ fetch('michael_scott.quotes')
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ module Faker
2
+ class Military < Base
3
+ class << self
4
+ def army_rank
5
+ fetch('military.army_rank')
6
+ end
7
+
8
+ def marines_rank
9
+ fetch('military.marines_rank')
10
+ end
11
+
12
+ def navy_rank
13
+ fetch('military.navy_rank')
14
+ end
15
+
16
+ def air_force_rank
17
+ fetch('military.air_force_rank')
18
+ end
19
+
20
+ def dod_paygrade
21
+ fetch('military.dod_paygrade')
22
+ end
23
+ end
24
+ end
25
+ end
@@ -14,7 +14,7 @@ module Faker
14
14
  end
15
15
 
16
16
  def keys
17
- ['C', 'D', 'E', 'F', 'G', 'A', 'B']
17
+ %w[C D E F G A B]
18
18
  end
19
19
 
20
20
  def key_variants
@@ -28,6 +28,18 @@ module Faker
28
28
  def chord_types
29
29
  ['', 'maj', '6', 'maj7', 'm', 'm7', '-7', '7', 'dom7', 'dim', 'dim7', 'm7b5']
30
30
  end
31
+
32
+ def band
33
+ fetch('music.bands')
34
+ end
35
+
36
+ def album
37
+ fetch('music.albums')
38
+ end
39
+
40
+ def genre
41
+ fetch('music.genres')
42
+ end
31
43
  end
32
44
  end
33
45
  end
@@ -0,0 +1,25 @@
1
+ module Faker
2
+ class Myst < Base
3
+ class << self
4
+ def game
5
+ fetch('myst.games')
6
+ end
7
+
8
+ def creature
9
+ fetch('myst.creatures')
10
+ end
11
+
12
+ def age
13
+ fetch('myst.ages')
14
+ end
15
+
16
+ def character
17
+ fetch('myst.characters')
18
+ end
19
+
20
+ def quote
21
+ fetch('myst.quotes')
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,6 +3,7 @@ module Faker
3
3
  flexible :name
4
4
 
5
5
  class << self
6
+ extend Gem::Deprecate
6
7
 
7
8
  def name
8
9
  parse('name.name')
@@ -13,11 +14,23 @@ module Faker
13
14
  end
14
15
 
15
16
  def first_name
16
- fetch('name.first_name')
17
+ if parse('name.first_name').empty?
18
+ fetch('name.first_name')
19
+ else
20
+ parse('name.first_name')
21
+ end
22
+ end
23
+
24
+ def male_first_name
25
+ fetch('name.male_first_name')
26
+ end
27
+
28
+ def female_first_name
29
+ fetch('name.female_first_name')
17
30
  end
18
31
 
19
32
  def last_name
20
- fetch('name.last_name')
33
+ parse('name.last_name')
21
34
  end
22
35
 
23
36
  def prefix
@@ -28,19 +41,20 @@ module Faker
28
41
  fetch('name.suffix')
29
42
  end
30
43
 
31
- # Generate a buzzword-laden job title
32
- # Wordlist from http://www.bullshitjob.com/title/
33
44
  def title
34
- "#{fetch('name.title.descriptor')} #{fetch('name.title.level')} #{fetch('name.title.job')}"
45
+ Faker::Job.title
35
46
  end
36
47
 
37
- def initials(character_count=3)
38
- (0...character_count).map { (65 + rand(26)).chr }.join
48
+ def initials(character_count = 3)
49
+ (0...character_count).map { rand(65..90).chr }.join
39
50
  end
40
51
 
41
52
  def job_titles
42
- fetch_all('name.title.job')
53
+ fetch_all('job.position')
43
54
  end
55
+
56
+ deprecate :title, 'Faker::Job.title', 2018, 9
57
+ deprecate :job_titles, :none, 2018, 9
44
58
  end
45
59
  end
46
60
  end
@@ -0,0 +1,24 @@
1
+ module Faker
2
+ class Nation < Base
3
+ flexible :nation
4
+ class << self
5
+ def nationality
6
+ fetch('nation.nationality')
7
+ end
8
+
9
+ def language
10
+ fetch('nation.language')
11
+ end
12
+
13
+ # Fetch random capital city
14
+ def capital_city
15
+ fetch('nation.capital_city')
16
+ end
17
+
18
+ # Fetch random natinal sport
19
+ def national_sport
20
+ fetch('team.sport')
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ module Faker
2
+ class NatoPhoneticAlphabet < Base
3
+ class << self
4
+ def code_word
5
+ fetch('nato_phonetic_alphabet.code_word')
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module Faker
2
+ class NewGirl < Base
3
+ class << self
4
+ def character
5
+ fetch('new_girl.characters')
6
+ end
7
+
8
+ def quote
9
+ fetch('new_girl.quotes')
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,7 +1,7 @@
1
1
  module Faker
2
2
  class Number < Base
3
3
  class << self
4
- def number(digits=10)
4
+ def number(digits = 10)
5
5
  num = ''
6
6
  if digits > 1
7
7
  num = non_zero_digit
@@ -10,11 +10,11 @@ module Faker
10
10
  num + leading_zero_number(digits)
11
11
  end
12
12
 
13
- def leading_zero_number(digits=10)
14
- (1..digits).collect {digit}.join
13
+ def leading_zero_number(digits = 10)
14
+ (1..digits).collect { digit }.join
15
15
  end
16
16
 
17
- def decimal_part(digits=10)
17
+ def decimal_part(digits = 10)
18
18
  num = ''
19
19
  if digits > 1
20
20
  num = non_zero_digit
@@ -23,27 +23,27 @@ module Faker
23
23
  leading_zero_number(digits) + num
24
24
  end
25
25
 
26
- def decimal(l_digits=5, r_digits=2)
27
- l_d = self.number(l_digits)
28
- r_d = self.decimal_part(r_digits)
26
+ def decimal(l_digits = 5, r_digits = 2)
27
+ l_d = number(l_digits)
28
+ r_d = decimal_part(r_digits)
29
29
  "#{l_d}.#{r_d}"
30
30
  end
31
31
 
32
32
  def non_zero_digit
33
- (rand(9) + 1).to_s
33
+ rand(1..9).to_s
34
34
  end
35
35
 
36
36
  def digit
37
37
  rand(10).to_s
38
38
  end
39
39
 
40
- def hexadecimal(digits=6)
41
- hex = ""
40
+ def hexadecimal(digits = 6)
41
+ hex = ''
42
42
  digits.times { hex += rand(15).to_s(16) }
43
43
  hex
44
44
  end
45
45
 
46
- def normal(mean=1, standard_deviation=1)
46
+ def normal(mean = 1, standard_deviation = 1)
47
47
  theta = 2 * Math::PI * rand
48
48
  rho = Math.sqrt(-2 * Math.log(1 - rand))
49
49
  scale = standard_deviation * rho
@@ -51,7 +51,7 @@ module Faker
51
51
  end
52
52
 
53
53
  def between(from = 1.00, to = 5000.00)
54
- Faker::Base::rand_in_range(from, to)
54
+ Faker::Base.rand_in_range(from, to)
55
55
  end
56
56
 
57
57
  def positive(from = 1.00, to = 5000.00)
@@ -3,27 +3,26 @@ module Faker
3
3
  require 'time'
4
4
  attr_reader :name,
5
5
  :first_name,
6
- :last_name
6
+ :last_name,
7
+ :email
7
8
 
8
- def initialize
9
- @name = "#{Name.first_name} #{Name.last_name}"
10
- @first_name = name.split(' ').first
11
- @last_name = name.split(' ').last
9
+ def initialize(name: nil, email: nil)
10
+ @name = name || "#{Name.first_name} #{Name.last_name}"
11
+ @email = email || Internet.safe_email(self.name)
12
+ @first_name, @last_name = self.name.split
12
13
  end
13
14
 
14
15
  class << self
15
- def google
16
- uid = Number.number(9)
17
- auth = Omniauth.new()
18
- email = "#{auth.first_name.downcase}@example.com"
16
+ def google(name: nil, email: nil, uid: Number.number(9))
17
+ auth = Omniauth.new(name: name, email: email)
19
18
  {
20
- provider: "google_oauth2",
19
+ provider: 'google_oauth2',
21
20
  uid: uid,
22
21
  info: {
23
22
  name: auth.name,
24
23
  first_name: auth.first_name,
25
24
  last_name: auth.last_name,
26
- email: email,
25
+ email: auth.email,
27
26
  image: image
28
27
  },
29
28
  credentials: {
@@ -35,44 +34,42 @@ module Faker
35
34
  extra: {
36
35
  raw_info: {
37
36
  sub: uid,
38
- email: email,
39
- email_verified: random_boolean,
37
+ email: auth.email,
38
+ email_verified: random_boolean.to_s,
40
39
  name: auth.name,
41
40
  given_name: auth.first_name,
42
41
  family_name: auth.last_name,
43
42
  profile: "https://plus.google.com/#{uid}",
44
43
  picture: image,
45
44
  gender: gender,
46
- birthday: Date.backward(36400).strftime("%Y-%m-%d"),
47
- local: "en",
45
+ birthday: Date.backward(36_400).strftime('%Y-%m-%d'),
46
+ local: 'en',
48
47
  hd: "#{Company.name.downcase}.com"
49
48
  },
50
- },
51
- id_info: {
52
- "iss" => "accounts.google.com",
53
- "at_hash" => Crypto.md5,
54
- "email_verified" => "true",
55
- "sub" => Number.number(28).to_s,
56
- "azp" => "APP_ID",
57
- "email" => email,
58
- "aud" => "APP_ID",
59
- "iat" => Number.number(10),
60
- "exp" => Time.forward.to_i.to_s,
61
- "openid_id" => "https://www.google.com/accounts/o8/id?id=#{uid}"
49
+ id_info: {
50
+ 'iss' => 'accounts.google.com',
51
+ 'at_hash' => Crypto.md5,
52
+ 'email_verified' => true,
53
+ 'sub' => Number.number(28).to_s,
54
+ 'azp' => 'APP_ID',
55
+ 'email' => auth.email,
56
+ 'aud' => 'APP_ID',
57
+ 'iat' => Time.forward.to_i,
58
+ 'exp' => Time.forward.to_i,
59
+ 'openid_id' => "https://www.google.com/accounts/o8/id?id=#{uid}"
60
+ }
62
61
  }
63
62
  }
64
63
  end
65
64
 
66
- def facebook
67
- uid = Number.number(7)
68
- auth = Omniauth.new()
69
- username = "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
70
- email = "#{auth.first_name.downcase}@#{auth.last_name.downcase}.com"
65
+ def facebook(name: nil, email: nil, username: nil, uid: Number.number(7))
66
+ auth = Omniauth.new(name: name, email: email)
67
+ username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
71
68
  {
72
- provider: "facebook",
69
+ provider: 'facebook',
73
70
  uid: uid,
74
71
  info: {
75
- email: email,
72
+ email: auth.email,
76
73
  name: auth.name,
77
74
  first_name: auth.first_name,
78
75
  last_name: auth.last_name,
@@ -97,7 +94,7 @@ module Faker
97
94
  name: city_state
98
95
  },
99
96
  gender: gender,
100
- email: email,
97
+ email: auth.email,
101
98
  timezone: timezone,
102
99
  locale: 'en_US',
103
100
  verified: random_boolean,
@@ -107,23 +104,23 @@ module Faker
107
104
  }
108
105
  end
109
106
 
110
- def twitter
111
- uid = Number.number(6)
112
- auth = Omniauth.new()
107
+ def twitter(name: nil, nickname: nil, uid: Number.number(6))
108
+ auth = Omniauth.new(name: name)
109
+ nickname ||= auth.name.downcase.delete(' ')
113
110
  location = city_state
114
111
  description = Lorem.sentence
115
112
  {
116
- provider: "twitter",
113
+ provider: 'twitter',
117
114
  uid: uid,
118
115
  info: {
119
- nickname: auth.name.downcase.gsub(' ', ''),
116
+ nickname: nickname,
120
117
  name: auth.name,
121
118
  location: location,
122
119
  image: image,
123
120
  description: description,
124
121
  urls: {
125
122
  Website: nil,
126
- Twitter: "https://twitter.com/#{auth.name.downcase.gsub(' ', '')}"
123
+ Twitter: "https://twitter.com/#{nickname}"
127
124
  }
128
125
  },
129
126
  credentials: {
@@ -131,7 +128,7 @@ module Faker
131
128
  secret: Crypto.md5
132
129
  },
133
130
  extra: {
134
- access_token: "",
131
+ access_token: '',
135
132
  raw_info: {
136
133
  name: auth.name,
137
134
  listed_count: random_number_from_range(1..10),
@@ -147,7 +144,7 @@ module Faker
147
144
  id: uid,
148
145
  profile_background_tile: random_boolean,
149
146
  profile_sidebar_fill_color: Color.hex_color,
150
- followers_count: random_number_from_range(1..10000),
147
+ followers_count: random_number_from_range(1..10_000),
151
148
  default_profile_image: random_boolean,
152
149
  screen_name: '',
153
150
  following: random_boolean,
@@ -156,14 +153,14 @@ module Faker
156
153
  favourites_count: random_number_from_range(1..10),
157
154
  profile_background_color: Color.hex_color,
158
155
  is_translator: random_boolean,
159
- friends_count: random_number_from_range(1..10000),
156
+ friends_count: random_number_from_range(1..10_000),
160
157
  notifications: random_boolean,
161
158
  geo_enabled: random_boolean,
162
159
  profile_background_image_url: image,
163
160
  protected: random_boolean,
164
161
  description: description,
165
162
  profile_link_color: Color.hex_color,
166
- created_at: Time.backward.strftime("%a %b %d %H:%M:%S %z %Y"),
163
+ created_at: Time.backward.strftime('%a %b %d %H:%M:%S %z %Y'),
167
164
  id_str: uid,
168
165
  profile_image_url_https: image,
169
166
  default_profile: random_boolean,
@@ -180,12 +177,10 @@ module Faker
180
177
  }
181
178
  end
182
179
 
183
- def linkedin
184
- uid = Number.number(6)
185
- auth = Omniauth.new()
180
+ def linkedin(name: nil, email: nil, uid: Number.number(6))
181
+ auth = Omniauth.new(name: name, email: email)
186
182
  first_name = auth.first_name.downcase
187
183
  last_name = auth.last_name.downcase
188
- email = "#{first_name}@#{last_name}.com"
189
184
  location = city_state
190
185
  description = Lorem.sentence
191
186
  token = Crypto.md5
@@ -193,77 +188,72 @@ module Faker
193
188
  industry = Commerce.department
194
189
  url = "http://www.linkedin.com/in/#{first_name}#{last_name}"
195
190
  {
196
- "provider" => "linkedin",
197
- "uid" => uid,
198
- "info" => {
199
- "name" => auth.name,
200
- "email" => email,
201
- "nickname" => auth.name,
202
- "first_name" => auth.first_name,
203
- "last_name" => auth.last_name,
204
- "location" => location,
205
- "description" => description,
206
- "image" => image,
207
- "phone" => PhoneNumber.phone_number,
208
- "headline" => description,
209
- "industry" => industry,
210
- "urls" => {
211
- "public_profile" => url
191
+ 'provider' => 'linkedin',
192
+ 'uid' => uid,
193
+ 'info' => {
194
+ 'name' => auth.name,
195
+ 'email' => auth.email,
196
+ 'nickname' => auth.name,
197
+ 'first_name' => auth.first_name,
198
+ 'last_name' => auth.last_name,
199
+ 'location' => location,
200
+ 'description' => description,
201
+ 'image' => image,
202
+ 'phone' => PhoneNumber.phone_number,
203
+ 'headline' => description,
204
+ 'industry' => industry,
205
+ 'urls' => {
206
+ 'public_profile' => url
212
207
  }
213
208
  },
214
- "credentials" => {
215
- "token" => token,
216
- "secret" => secret
209
+ 'credentials' => {
210
+ 'token' => token,
211
+ 'secret' => secret
217
212
  },
218
- "extra" => {
219
- "access_token" => {
220
- "token" => token,
221
- "secret" => secret,
222
- "consumer" => nil,
223
- "params" => {
213
+ 'extra' => {
214
+ 'access_token' => {
215
+ 'token' => token,
216
+ 'secret' => secret,
217
+ 'consumer' => nil,
218
+ 'params' => {
224
219
  oauth_token: token,
225
220
  oauth_token_secret: secret,
226
221
  oauth_expires_in: Time.forward.to_i,
227
- oauth_authorization_expires_in: Time.forward.to_i,
222
+ oauth_authorization_expires_in: Time.forward.to_i
228
223
  },
229
- "response" => nil
224
+ 'response' => nil
230
225
  },
231
- "raw_info" => {
232
- "firstName" => auth.first_name,
233
- "headline" => description,
234
- "id" => uid,
235
- "industry" => industry,
236
- "lastName" => auth.last_name,
237
- "location" => {
238
- "country" => { "code" => Address.country_code.downcase },
239
- "name" => city_state.split(', ').first,
226
+ 'raw_info' => {
227
+ 'firstName' => auth.first_name,
228
+ 'headline' => description,
229
+ 'id' => uid,
230
+ 'industry' => industry,
231
+ 'lastName' => auth.last_name,
232
+ 'location' => {
233
+ 'country' => { 'code' => Address.country_code.downcase },
234
+ 'name' => city_state.split(', ').first
240
235
  },
241
- "pictureUrl" => image,
242
- "publicProfileUrl" => url
236
+ 'pictureUrl' => image,
237
+ 'publicProfileUrl' => url
243
238
  }
244
239
  }
245
240
  }
246
241
  end
247
242
 
248
- def github
249
- uid = Number.number(8)
250
- auth = Omniauth.new()
251
- first_name = auth.first_name.downcase
252
- last_name = auth.last_name.downcase
253
- login = "#{first_name}-#{last_name}"
243
+ def github(name: nil, email: nil, uid: Number.number(8))
244
+ auth = Omniauth.new(name: name, email: email)
245
+ login = auth.name.downcase.tr(' ', '-')
254
246
  html_url = "https://github.com/#{login}"
255
247
  api_url = "https://api.github.com/users/#{login}"
256
- email = "#{first_name}@example.com"
257
-
258
248
  {
259
- provider: "github",
249
+ provider: 'github',
260
250
  uid: uid,
261
251
  info: {
262
252
  nickname: login,
263
- email: email,
253
+ email: auth.email,
264
254
  name: auth.name,
265
255
  image: image,
266
- urls:{
256
+ urls: {
267
257
  GitHub: html_url
268
258
  }
269
259
  },
@@ -276,7 +266,7 @@ module Faker
276
266
  login: login,
277
267
  id: uid,
278
268
  avatar_url: image,
279
- gravatar_id: "",
269
+ gravatar_id: '',
280
270
  url: api_url,
281
271
  html_url: html_url,
282
272
  followers_url: "#{api_url}/followers",
@@ -288,53 +278,51 @@ module Faker
288
278
  repos_url: "#{api_url}/repos",
289
279
  events_url: "#{api_url}/events{/privacy}",
290
280
  received_events_url: "#{api_url}/received_events",
291
- type: "User",
281
+ type: 'User',
292
282
  site_admin: random_boolean,
293
283
  name: auth.name,
294
284
  company: nil,
295
285
  blog: nil,
296
286
  location: city_state,
297
- email: email,
287
+ email: auth.email,
298
288
  hireable: nil,
299
289
  bio: nil,
300
290
  public_repos: random_number_from_range(1..1000),
301
291
  public_gists: random_number_from_range(1..1000),
302
292
  followers: random_number_from_range(1..1000),
303
293
  following: random_number_from_range(1..1000),
304
- created_at: Time.backward(36400).iso8601,
294
+ created_at: Time.backward(36_400).iso8601,
305
295
  updated_at: Time.backward(2).iso8601
306
296
  }
307
297
  }
308
298
  }
309
-
310
299
  end
311
300
 
312
301
  private
313
302
 
314
- def gender
315
- shuffle(["male", "female"]).pop
316
- end
317
-
318
- def timezone
319
- shuffle((-12..12).to_a).pop
320
- end
303
+ def gender
304
+ shuffle(%w[male female]).pop
305
+ end
321
306
 
322
- def image
323
- Placeholdit.image
324
- end
307
+ def timezone
308
+ shuffle((-12..12).to_a).pop
309
+ end
325
310
 
326
- def city_state
327
- "#{Address.city}, #{Address.state}"
328
- end
311
+ def image
312
+ Placeholdit.image
313
+ end
329
314
 
330
- def random_number_from_range(range)
331
- shuffle(range.to_a).pop
332
- end
315
+ def city_state
316
+ "#{Address.city}, #{Address.state}"
317
+ end
333
318
 
334
- def random_boolean
335
- shuffle([true, false]).pop
336
- end
319
+ def random_number_from_range(range)
320
+ shuffle(range.to_a).pop
321
+ end
337
322
 
323
+ def random_boolean
324
+ shuffle([true, false]).pop
325
+ end
338
326
  end
339
327
  end
340
328
  end