faker 1.7.3 → 1.8.0

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +90 -3
  3. data/README.md +45 -0
  4. data/lib/faker.rb +37 -75
  5. data/lib/faker/address.rb +12 -7
  6. data/lib/faker/app.rb +1 -5
  7. data/lib/faker/bank.rb +1 -0
  8. data/lib/faker/bitcoin.rb +1 -1
  9. data/lib/faker/code.rb +1 -1
  10. data/lib/faker/coffee.rb +29 -0
  11. data/lib/faker/color.rb +2 -2
  12. data/lib/faker/commerce.rb +1 -2
  13. data/lib/faker/company.rb +38 -6
  14. data/lib/faker/compass.rb +65 -0
  15. data/lib/faker/dessert.rb +19 -0
  16. data/lib/faker/dr_who.rb +34 -0
  17. data/lib/faker/dragon_ball.rb +9 -0
  18. data/lib/faker/family_guy.rb +17 -0
  19. data/lib/faker/fillmurray.rb +2 -2
  20. data/lib/faker/finance.rb +1 -1
  21. data/lib/faker/food.rb +4 -0
  22. data/lib/faker/funny_name.rb +43 -0
  23. data/lib/faker/hacker.rb +1 -1
  24. data/lib/faker/hey_arnold.rb +17 -0
  25. data/lib/faker/hipster.rb +3 -3
  26. data/lib/faker/hitchhikers_guide_to_the_galaxy.rb +33 -0
  27. data/lib/faker/hobbit.rb +21 -0
  28. data/lib/faker/how_i_met_your_mother.rb +21 -0
  29. data/lib/faker/id_number.rb +3 -7
  30. data/lib/faker/internet.rb +20 -14
  31. data/lib/faker/league_of_legends.rb +29 -0
  32. data/lib/faker/lorem.rb +5 -5
  33. data/lib/faker/lovecraft.rb +73 -0
  34. data/lib/faker/markdown.rb +66 -0
  35. data/lib/faker/matz.rb +9 -0
  36. data/lib/faker/music.rb +2 -2
  37. data/lib/faker/number.rb +6 -6
  38. data/lib/faker/omniauth.rb +77 -29
  39. data/lib/faker/overwatch.rb +17 -0
  40. data/lib/faker/phone_number.rb +2 -10
  41. data/lib/faker/pokemon.rb +5 -1
  42. data/lib/faker/rick_and_morty.rb +17 -0
  43. data/lib/faker/robin.rb +9 -0
  44. data/lib/faker/rupaul.rb +11 -0
  45. data/lib/faker/shakespeare.rb +4 -4
  46. data/lib/faker/simpsons.rb +22 -0
  47. data/lib/faker/star_trek.rb +21 -0
  48. data/lib/faker/star_wars.rb +9 -9
  49. data/lib/faker/time.rb +2 -2
  50. data/lib/faker/twitter.rb +114 -43
  51. data/lib/faker/vehicle.rb +3 -3
  52. data/lib/faker/version.rb +1 -1
  53. data/lib/faker/zelda.rb +4 -0
  54. data/lib/locales/bg.yml +41 -0
  55. data/lib/locales/de.yml +45 -1
  56. data/lib/locales/en-IND.yml +2 -2
  57. data/lib/locales/en-MS.yml +39 -0
  58. data/lib/locales/en.yml +301 -38
  59. data/lib/locales/en/README.md +13 -0
  60. data/lib/locales/en/address.yml +37 -0
  61. data/lib/locales/en/dr_who.yml +74 -0
  62. data/lib/locales/en/family_guy.yml +7 -0
  63. data/lib/locales/en/internet.yml +21 -0
  64. data/lib/locales/en/lovecraft.yml +9 -0
  65. data/lib/locales/en/rick_and_morty.yml +6 -0
  66. data/lib/locales/fr.yml +5 -1
  67. data/lib/locales/nl.yml +26 -26
  68. data/lib/locales/pt-BR.yml +1 -1
  69. metadata +33 -3
@@ -0,0 +1,17 @@
1
+ module Faker
2
+ class Overwatch < Base
3
+ class << self
4
+ def hero
5
+ fetch('overwatch.heroes')
6
+ end
7
+
8
+ def location
9
+ fetch('overwatch.locations')
10
+ end
11
+
12
+ def quote
13
+ fetch('overwatch.quotes')
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,19 +2,11 @@ module Faker
2
2
  class PhoneNumber < Base
3
3
  class << self
4
4
  def phone_number
5
- if parse('phone_number.formats') == ""
6
- numerify(fetch('phone_number.formats'))
7
- else
8
- parse('phone_number.formats')
9
- end
5
+ parse('phone_number.formats')
10
6
  end
11
7
 
12
8
  def cell_phone
13
- if parse('cell_phone.formats') == ""
14
- numerify(fetch('cell_phone.formats'))
15
- else
16
- parse('cell_phone.formats')
17
- end
9
+ parse('cell_phone.formats')
18
10
  end
19
11
 
20
12
  # US only
@@ -8,6 +8,10 @@ module Faker
8
8
  def location
9
9
  fetch('pokemon.locations')
10
10
  end
11
+
12
+ def move
13
+ fetch('pokemon.moves')
14
+ end
11
15
  end
12
16
  end
13
- end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Faker
2
+ class RickAndMorty < Base
3
+ class << self
4
+ def character
5
+ fetch('rick_and_morty.characters')
6
+ end
7
+
8
+ def location
9
+ fetch('rick_and_morty.locations')
10
+ end
11
+
12
+ def quote
13
+ fetch('rick_and_morty.quotes')
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Faker
2
+ class Robin < Base
3
+ class << self
4
+ def quote
5
+ fetch('robin.quotes')
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Faker
2
+ class RuPaul < Base
3
+ flexible :rupaul
4
+
5
+ class << self
6
+ def quote
7
+ fetch('rupaul.quotes')
8
+ end
9
+ end
10
+ end
11
+ end
@@ -3,19 +3,19 @@ module Faker
3
3
  class << self
4
4
 
5
5
  def hamlet_quote
6
- hamlet.sample
6
+ sample(hamlet)
7
7
  end
8
8
 
9
9
  def as_you_like_it_quote
10
- as_you_like_it.sample
10
+ sample(as_you_like_it)
11
11
  end
12
12
 
13
13
  def king_richard_iii_quote
14
- king_richard_iii.sample
14
+ sample(king_richard_iii)
15
15
  end
16
16
 
17
17
  def romeo_and_juliet_quote
18
- romeo_and_juliet.sample
18
+ sample(romeo_and_juliet)
19
19
  end
20
20
 
21
21
  def hamlet
@@ -0,0 +1,22 @@
1
+ #encoding: utf-8
2
+ #frozen_string_literal: true
3
+
4
+ module Faker
5
+
6
+ class Simpsons < Base
7
+
8
+ def self.character
9
+ fetch('simpsons.characters')
10
+ end
11
+
12
+ def self.location
13
+ fetch('simpsons.locations')
14
+ end
15
+
16
+ def self.quote
17
+ fetch('simpsons.quotes')
18
+ end
19
+
20
+ end #class Simpsons
21
+
22
+ end #module Faker
@@ -0,0 +1,21 @@
1
+ module Faker
2
+ class StarTrek < Base
3
+ class << self
4
+ def character
5
+ fetch('star_trek.character')
6
+ end
7
+
8
+ def location
9
+ fetch('star_trek.location')
10
+ end
11
+
12
+ def specie
13
+ fetch('star_trek.specie')
14
+ end
15
+
16
+ def villain
17
+ fetch('star_trek.villain')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,35 +2,35 @@ module Faker
2
2
  class StarWars < Base
3
3
  class << self
4
4
  def character
5
- characters.sample
5
+ sample(characters)
6
6
  end
7
7
 
8
8
  def droid
9
- droids.sample
9
+ sample(droids)
10
10
  end
11
11
 
12
12
  def planet
13
- planets.sample
13
+ sample(planets)
14
14
  end
15
15
 
16
16
  def quote
17
- quotes.sample
17
+ sample(quotes)
18
18
  end
19
19
 
20
20
  def specie
21
- species.sample
21
+ sample(species)
22
22
  end
23
23
 
24
24
  def vehicle
25
- vehicles.sample
25
+ sample(vehicles)
26
26
  end
27
27
 
28
28
  def wookie_sentence
29
- sentence = wookie_words.sample.capitalize
29
+ sentence = sample(wookie_words).capitalize
30
30
 
31
- rand(0..10).times { sentence += " " + wookie_words.sample}
31
+ rand(0..10).times { sentence += " " + sample(wookie_words)}
32
32
 
33
- sentence + ['.','?','!'].sample
33
+ sentence + sample(['.','?','!'])
34
34
  end
35
35
 
36
36
  def characters
@@ -36,7 +36,7 @@ module Faker
36
36
 
37
37
  def hours(period)
38
38
  raise ArgumentError, 'invalid period' unless TIME_RANGES.has_key? period
39
- TIME_RANGES[period].to_a.sample
39
+ sample(TIME_RANGES[period].to_a)
40
40
  end
41
41
 
42
42
  def minutes
@@ -44,7 +44,7 @@ module Faker
44
44
  end
45
45
 
46
46
  def seconds
47
- (0..59).to_a.sample
47
+ sample((0..59).to_a)
48
48
  end
49
49
  end
50
50
  end
@@ -1,88 +1,94 @@
1
1
  module Faker
2
2
  class Twitter < Base
3
3
  class << self
4
- def user(include_status: true)
4
+ def user(include_status: true, include_email: false)
5
5
  user_id = id
6
6
  background_image_url = Faker::LoremPixel.image('600x400') # TODO: Make the dimensions change
7
7
  profile_image_url = Faker::Avatar.image(user_id, '48x48')
8
8
  user = {
9
9
  id: user_id,
10
10
  id_str: user_id.to_s,
11
- name: Faker::Name.name,
12
- screen_name: Faker::Internet.user_name,
13
- location: "#{Faker::Address.city}, #{Faker::Address.state_abbr}, #{Faker::Address.country_code}",
11
+ contributors_enabled: Faker::Boolean.boolean(0.1),
12
+ created_at: created_at,
13
+ default_profile_image: Faker::Boolean.boolean(0.1),
14
+ default_profile: Faker::Boolean.boolean(0.1),
14
15
  description: Faker::Lorem.sentence,
15
- url: Faker::Internet.url('example.com'),
16
- entities: nil, # TODO
17
- protected: Faker::Boolean.boolean(0.1),
16
+ entities: user_entities,
17
+ favourites_count: Faker::Number.between(1, 100_000),
18
+ follow_request_sent: false,
18
19
  followers_count: Faker::Number.between(1, 10_000_000),
20
+ following: false,
19
21
  friends_count: Faker::Number.between(1, 100_000),
20
- listed_count: Faker::Number.between(1, 1000),
21
- created_at: created_at,
22
- favourites_count: Faker::Number.between(1, 100_000),
23
- utc_offset: utc_offset,
24
- time_zone: Faker::Address.time_zone,
25
22
  geo_enabled: Faker::Boolean.boolean(0.1),
26
- verified: Faker::Boolean.boolean(0.1),
27
- statuses_count: Faker::Number.between(1, 100_000),
28
- lang: Faker::Address.country_code,
29
- contributors_enabled: Faker::Boolean.boolean(0.1),
30
- is_translator: Faker::Boolean.boolean(0.1),
31
23
  is_translation_enabled: Faker::Boolean.boolean(0.1),
24
+ is_translator: Faker::Boolean.boolean(0.1),
25
+ lang: Faker::Address.country_code,
26
+ listed_count: Faker::Number.between(1, 1000),
27
+ location: "#{Faker::Address.city}, #{Faker::Address.state_abbr}, #{Faker::Address.country_code}",
28
+ name: Faker::Name.name,
29
+ notifications: false,
32
30
  profile_background_color: Faker::Color.hex_color,
33
- profile_background_image_url: background_image_url.sub('https://', 'http://'),
34
31
  profile_background_image_url_https: background_image_url,
32
+ profile_background_image_url: background_image_url.sub('https://', 'http://'),
35
33
  profile_background_tile: Faker::Boolean.boolean(0.1),
36
- profile_image_url: profile_image_url.sub('https://', 'http://'),
37
- profile_image_url_https: profile_image_url,
38
34
  profile_banner_url: Faker::LoremPixel.image('1500x500'),
35
+ profile_image_url_https: profile_image_url,
36
+ profile_image_url: profile_image_url.sub('https://', 'http://'),
39
37
  profile_link_color: Faker::Color.hex_color,
40
38
  profile_sidebar_border_color: Faker::Color.hex_color,
41
39
  profile_sidebar_fill_color: Faker::Color.hex_color,
42
40
  profile_text_color: Faker::Color.hex_color,
43
41
  profile_use_background_image: Faker::Boolean.boolean(0.4),
44
- default_profile: Faker::Boolean.boolean(0.1),
45
- default_profile_image: Faker::Boolean.boolean(0.1),
46
- following: false,
47
- follow_request_sent: false,
48
- notifications: false
42
+ protected: Faker::Boolean.boolean(0.1),
43
+ screen_name: screen_name,
44
+ statuses_count: Faker::Number.between(1, 100_000),
45
+ time_zone: Faker::Address.time_zone,
46
+ url: Faker::Internet.url('example.com'),
47
+ utc_offset: utc_offset,
48
+ verified: Faker::Boolean.boolean(0.1)
49
49
  }
50
50
  user[:status] = Faker::Twitter.status(include_user: false) if include_status
51
+ user[:email] = Faker::Internet.safe_email if include_email
51
52
  user
52
53
  end
53
54
 
54
- def status(include_user: true)
55
+ def status(include_user: true, include_photo: false)
55
56
  status_id = id
56
57
  status = {
57
- created_at: created_at,
58
58
  id: status_id,
59
59
  id_str: status_id.to_s,
60
- text: Faker::Lorem.sentence,
61
- truncated: false,
62
- entities: nil, # TODO
63
- source: "<a href=\"#{Faker::Internet.url('example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
60
+ contributors: nil,
61
+ coordinates: nil,
62
+ created_at: created_at,
63
+ entities: status_entities(include_photo: include_photo),
64
+ favorite_count: Faker::Number.between(1, 10_000),
65
+ favorited: false,
66
+ geo: nil,
67
+ in_reply_to_screen_name: nil,
64
68
  in_reply_to_status_id: nil,
65
- nil: nil,
66
- in_reply_to_user_id: nil,
67
69
  in_reply_to_user_id_str: nil,
68
- in_reply_to_screen_name: nil,
69
- geo: nil,
70
- coordinates: nil,
71
- place: nil,
72
- contributors: nil,
73
- retweeted_status: nil,
70
+ in_reply_to_user_id: nil,
74
71
  is_quote_status: false,
72
+ lang: Faker::Address.country_code,
73
+ nil: nil,
74
+ place: nil,
75
+ possibly_sensitive: Faker::Boolean.boolean(0.1),
75
76
  retweet_count: Faker::Number.between(1, 10_000),
76
- favorite_count: Faker::Number.between(1, 10_000),
77
- favorited: false,
77
+ retweeted_status: nil,
78
78
  retweeted: false,
79
- possibly_sensitive: Faker::Boolean.boolean(0.1),
80
- lang: Faker::Address.country_code
79
+ source: "<a href=\"#{Faker::Internet.url('example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
80
+ text: Faker::Lorem.sentence,
81
+ truncated: false
81
82
  }
82
83
  status[:user] = Faker::Twitter.user(include_status: false) if include_user
84
+ status[:text] = "#{status[:text]} #{status[:entities][:media].first[:url]}" if include_photo
83
85
  status
84
86
  end
85
87
 
88
+ def screen_name
89
+ Faker::Internet.user_name(nil, ['_'])[0...20]
90
+ end
91
+
86
92
  private
87
93
 
88
94
  def id
@@ -96,6 +102,71 @@ module Faker
96
102
  def utc_offset
97
103
  Faker::Number.between(-43_200, 50_400)
98
104
  end
105
+
106
+ def user_entities
107
+ {
108
+ url: {
109
+ urls: []
110
+ },
111
+ description: {
112
+ urls: []
113
+ }
114
+ }
115
+ end
116
+
117
+ def status_entities(include_photo: false)
118
+ entities = {
119
+ hashtags: [],
120
+ symbols: [],
121
+ user_mentions: [],
122
+ urls: []
123
+ }
124
+ entities[:media] = [photo_entity] if include_photo
125
+ entities
126
+ end
127
+
128
+ def photo_entity
129
+ # TODO: Dynamic image sizes
130
+ # TODO: Return accurate indices
131
+ media_url = Faker::LoremPixel.image('1064x600')
132
+ media_id = id
133
+ {
134
+ id: media_id,
135
+ id_str: media_id.to_s,
136
+ indices: [
137
+ 103,
138
+ 126
139
+ ],
140
+ media_url: media_url.sub('https://', 'http://'),
141
+ media_url_https: media_url,
142
+ url: Faker::Internet.url('example.com'),
143
+ display_url: 'example.com',
144
+ expanded_url: Faker::Internet.url('example.com'),
145
+ type: 'photo',
146
+ sizes: {
147
+ medium: {
148
+ w: 1064,
149
+ h: 600,
150
+ resize: 'fit'
151
+ },
152
+ large: {
153
+ w: 1064,
154
+ h: 600,
155
+ resize: 'fit'
156
+ },
157
+ small: {
158
+ w: 680,
159
+ h: 383,
160
+ resize: 'fit'
161
+ },
162
+ thumb: {
163
+ w: 150,
164
+ h: 150,
165
+ resize: 'crop'
166
+ }
167
+ }
168
+ }
169
+ end
99
170
  end
100
171
  end
101
172
  end
@@ -7,10 +7,10 @@ module Faker
7
7
  class << self
8
8
  #ISO 3779
9
9
  def vin
10
- _, wmi, wmi_ext = fetch_all('vehicle.manufacture').sample
10
+ _, wmi, wmi_ext = sample(fetch_all('vehicle.manufacture'))
11
11
 
12
12
  c = VIN_CHARS.split('').reject{ |n| n == '.'}
13
- vehicle_identification_number = wmi.split('').concat( Array.new(14) { c.sample } )
13
+ vehicle_identification_number = wmi.split('').concat( Array.new(14) { sample(c) } )
14
14
  (12..14).to_a.each_with_index { |n, i| vehicle_identification_number[n] = wmi_ext[i] } unless wmi_ext.nil?
15
15
  vehicle_identification_number[10] = fetch('vehicle.year')
16
16
  vehicle_identification_number[8] = vin_checksum(vehicle_identification_number)
@@ -19,7 +19,7 @@ module Faker
19
19
  end
20
20
 
21
21
  def manufacture
22
- fetch_all('vehicle.manufacture').sample.first
22
+ sample(fetch_all('vehicle.manufacture')).first
23
23
  end
24
24
 
25
25
  private