faker 2.14.0 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +218 -19
  3. data/History.md +4 -4
  4. data/README.md +18 -1
  5. data/lib/faker.rb +12 -13
  6. data/lib/faker/blockchain/aeternity.rb +4 -4
  7. data/lib/faker/blockchain/bitcoin.rb +2 -2
  8. data/lib/faker/blockchain/tezos.rb +30 -2
  9. data/lib/faker/books/dune.rb +15 -2
  10. data/lib/faker/books/lovecraft.rb +8 -4
  11. data/lib/faker/creature/bird.rb +203 -0
  12. data/lib/faker/default/address.rb +4 -4
  13. data/lib/faker/default/app.rb +1 -1
  14. data/lib/faker/default/avatar.rb +1 -1
  15. data/lib/faker/default/bank.rb +20 -6
  16. data/lib/faker/default/barcode.rb +44 -33
  17. data/lib/faker/default/beer.rb +3 -3
  18. data/lib/faker/default/camera.rb +46 -0
  19. data/lib/faker/default/cannabis.rb +10 -0
  20. data/lib/faker/default/chile_rut.rb +3 -2
  21. data/lib/faker/default/chuck_norris.rb +1 -0
  22. data/lib/faker/default/code.rb +5 -5
  23. data/lib/faker/default/commerce.rb +1 -1
  24. data/lib/faker/default/company.rb +58 -10
  25. data/lib/faker/default/crypto.rb +17 -4
  26. data/lib/faker/default/driving_licence.rb +4 -3
  27. data/lib/faker/default/drone.rb +25 -25
  28. data/lib/faker/default/educator.rb +13 -0
  29. data/lib/faker/default/faker_adjective.rb +35 -0
  30. data/lib/faker/default/file.rb +6 -4
  31. data/lib/faker/default/finance.rb +21 -0
  32. data/lib/faker/default/food.rb +1 -1
  33. data/lib/faker/default/hipster.rb +14 -11
  34. data/lib/faker/default/id_number.rb +36 -2
  35. data/lib/faker/default/internet.rb +232 -6
  36. data/lib/faker/default/invoice.rb +1 -1
  37. data/lib/faker/default/json.rb +7 -6
  38. data/lib/faker/default/lorem.rb +160 -5
  39. data/lib/faker/default/lorem_flickr.rb +3 -8
  40. data/lib/faker/default/lorem_pixel.rb +2 -1
  41. data/lib/faker/default/markdown.rb +4 -2
  42. data/lib/faker/default/measurement.rb +3 -2
  43. data/lib/faker/default/military.rb +26 -0
  44. data/lib/faker/default/mountain.rb +33 -0
  45. data/lib/faker/default/number.rb +23 -6
  46. data/lib/faker/default/omniauth.rb +5 -10
  47. data/lib/faker/default/placeholdit.rb +3 -2
  48. data/lib/faker/default/relationship.rb +1 -1
  49. data/lib/faker/default/science.rb +26 -0
  50. data/lib/faker/default/space.rb +1 -1
  51. data/lib/faker/default/string.rb +3 -2
  52. data/lib/faker/default/stripe.rb +3 -3
  53. data/lib/faker/default/tea.rb +41 -0
  54. data/lib/faker/default/types.rb +4 -3
  55. data/lib/faker/default/vehicle.rb +1 -1
  56. data/lib/faker/fantasy/tolkien.rb +67 -0
  57. data/lib/faker/games/clash_of_clans.rb +48 -0
  58. data/lib/faker/games/control.rb +1 -1
  59. data/lib/faker/games/dnd.rb +6 -6
  60. data/lib/faker/games/elder_scrolls.rb +26 -0
  61. data/lib/faker/games/heroes.rb +13 -0
  62. data/lib/faker/games/minecraft.rb +65 -0
  63. data/lib/faker/games/street_fighter.rb +4 -4
  64. data/lib/faker/games/super_mario.rb +48 -0
  65. data/lib/faker/games/touhou.rb +75 -0
  66. data/lib/faker/games/witcher.rb +39 -0
  67. data/lib/faker/games/world_of_warcraft.rb +26 -1
  68. data/lib/faker/japanese_media/conan.rb +48 -0
  69. data/lib/faker/japanese_media/doraemon.rb +48 -0
  70. data/lib/faker/japanese_media/dragon_ball.rb +26 -0
  71. data/lib/faker/japanese_media/naruto.rb +61 -0
  72. data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
  73. data/lib/faker/movies/hobbit.rb +4 -4
  74. data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
  75. data/lib/faker/movies/lord_of_the_rings.rb +3 -3
  76. data/lib/faker/movies/room.rb +63 -0
  77. data/lib/faker/movies/star_wars.rb +74 -2
  78. data/lib/faker/music/hiphop.rb +48 -0
  79. data/lib/faker/music/music.rb +12 -0
  80. data/lib/faker/music/opera.rb +237 -1
  81. data/lib/faker/music/rock_band.rb +12 -0
  82. data/lib/faker/quotes/quote.rb +26 -0
  83. data/lib/faker/quotes/rajnikanth.rb +1 -0
  84. data/lib/faker/quotes/shakespeare.rb +34 -0
  85. data/lib/faker/sports/volleyball.rb +74 -0
  86. data/lib/faker/tv_shows/big_bang_theory.rb +1 -1
  87. data/lib/faker/tv_shows/buffy.rb +17 -4
  88. data/lib/faker/tv_shows/final_space.rb +51 -0
  89. data/lib/faker/tv_shows/suits.rb +1 -1
  90. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
  91. data/lib/faker/version.rb +1 -1
  92. data/lib/locales/en-US.yml +1 -1
  93. data/lib/locales/en/adjective.yml +179 -0
  94. data/lib/locales/en/bird.yml +1281 -0
  95. data/lib/locales/en/book.yml +487 -3
  96. data/lib/locales/en/buffy.yml +1 -1
  97. data/lib/locales/en/camera.yml +611 -0
  98. data/lib/locales/en/clash_of_clan.yml +101 -0
  99. data/lib/locales/en/company.yml +2 -2
  100. data/lib/locales/en/conan.yml +171 -0
  101. data/lib/locales/en/demographic.yml +218 -5
  102. data/lib/locales/en/device.yml +112 -4
  103. data/lib/locales/en/doraemon.yml +286 -0
  104. data/lib/locales/en/dota.yml +531 -63
  105. data/lib/locales/en/dragon_ball.yml +243 -1
  106. data/lib/locales/en/driving_license.yml +3 -0
  107. data/lib/locales/en/dune.yml +270 -131
  108. data/lib/locales/en/educator.yml +6 -0
  109. data/lib/locales/en/elder_scrolls.yml +583 -9
  110. data/lib/locales/en/fallout.yml +311 -133
  111. data/lib/locales/en/final_space.yml +37 -0
  112. data/lib/locales/en/finance.yml +53 -0
  113. data/lib/locales/en/football.yml +3 -3
  114. data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
  115. data/lib/locales/en/half_life.yml +84 -3
  116. data/lib/locales/en/heroes.yml +408 -3
  117. data/lib/locales/en/heroes_of_the_storm.yml +131 -4
  118. data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
  119. data/lib/locales/en/jack_handey.yml +54 -0
  120. data/lib/locales/en/league_of_legends.yml +285 -6
  121. data/lib/locales/en/lebowski.yml +1 -1
  122. data/lib/locales/en/lovecraft.yml +76 -6
  123. data/lib/locales/en/military.yml +179 -5
  124. data/lib/locales/en/minecraft.yml +273 -0
  125. data/lib/locales/en/mountain.yml +158 -0
  126. data/lib/locales/en/music.yml +461 -29
  127. data/lib/locales/en/myst.yml +87 -31
  128. data/lib/locales/en/naruto.yml +231 -0
  129. data/lib/locales/en/opera.yml +168 -0
  130. data/lib/locales/en/overwatch.yml +2650 -2622
  131. data/lib/locales/en/pokemon.yml +417 -4
  132. data/lib/locales/en/quote.yml +692 -163
  133. data/lib/locales/en/rock_band.yml +1 -0
  134. data/lib/locales/en/room.yml +68 -0
  135. data/lib/locales/en/science.yml +355 -3
  136. data/lib/locales/en/shakespeare.yml +21 -24
  137. data/lib/locales/en/source.yml +30 -0
  138. data/lib/locales/en/space.yml +1 -1
  139. data/lib/locales/en/star_trek.yml +1 -1
  140. data/lib/locales/en/street_fighter.yml +4 -4
  141. data/lib/locales/en/studio_ghibli.yml +107 -0
  142. data/lib/locales/en/super_mario.yml +58 -0
  143. data/lib/locales/en/super_smash_bros.yml +18 -4
  144. data/lib/locales/en/tea.yml +172 -0
  145. data/lib/locales/en/tolkien.yml +2453 -0
  146. data/lib/locales/en/touhou.yml +839 -0
  147. data/lib/locales/en/volleyball.yml +501 -0
  148. data/lib/locales/en/witcher.yml +426 -7
  149. data/lib/locales/en/world_of_warcraft.yml +122 -4
  150. data/lib/locales/en/zelda.yml +962 -4
  151. data/lib/locales/es-AR.yml +4603 -0
  152. data/lib/locales/es.yml +56 -0
  153. data/lib/locales/fr.yml +0 -118
  154. data/lib/locales/fr/address.yml +21 -0
  155. data/lib/locales/fr/book.yml +7 -0
  156. data/lib/locales/fr/color.yml +4 -0
  157. data/lib/locales/fr/company.yml +17 -0
  158. data/lib/locales/fr/compass.yml +23 -0
  159. data/lib/locales/fr/demographic.yml +4 -0
  160. data/lib/locales/fr/gender.yml +6 -0
  161. data/lib/locales/fr/internet.yml +5 -0
  162. data/lib/locales/fr/lorem.yml +5 -0
  163. data/lib/locales/fr/measurement.yml +7 -0
  164. data/lib/locales/fr/name.yml +21 -0
  165. data/lib/locales/fr/phone_number.yml +7 -0
  166. data/lib/locales/fr/pokemon.yml +9 -0
  167. data/lib/locales/id.yml +1 -0
  168. data/lib/locales/ja/README.md +13 -0
  169. data/lib/locales/ja/address.yml +17 -0
  170. data/lib/locales/ja/ancient.yml +4 -0
  171. data/lib/locales/ja/bank.yml +4 -0
  172. data/lib/locales/ja/book.yml +7 -0
  173. data/lib/locales/ja/coffee.yml +4 -0
  174. data/lib/locales/ja/color.yml +4 -0
  175. data/lib/locales/ja/commerce.yml +11 -0
  176. data/lib/locales/ja/company.yml +8 -0
  177. data/lib/locales/ja/creature.yml +9 -0
  178. data/lib/locales/ja/food.yml +4 -0
  179. data/lib/locales/ja/games.yml +18 -0
  180. data/lib/locales/ja/gender.yml +4 -0
  181. data/lib/locales/ja/lorem.yml +9 -0
  182. data/lib/locales/ja/name.yml +13 -0
  183. data/lib/locales/ja/phone_number.yml +7 -0
  184. data/lib/locales/ja/restaurant.yml +11 -0
  185. data/lib/locales/ja/space.yml +5 -0
  186. data/lib/locales/ja/subscription.yml +8 -0
  187. data/lib/locales/ja/university.yml +9 -0
  188. data/lib/locales/pt-BR.yml +2 -1
  189. data/lib/locales/ru.yml +39 -0
  190. data/lib/locales/uk.yml +2 -0
  191. metadata +92 -19
  192. data/lib/locales/en/hobbit.yml +0 -19
  193. data/lib/locales/en/lord_of_the_rings.yml +0 -6
  194. data/lib/locales/ja.yml +0 -101
data/lib/faker.rb CHANGED
@@ -12,13 +12,12 @@ I18n.load_path += Dir[File.join(mydir, 'locales', '**/*.yml')]
12
12
  I18n.reload! if I18n.backend.initialized?
13
13
 
14
14
  module Faker
15
- class Config
15
+ module Config
16
16
  @locale = nil
17
17
  @random = nil
18
18
 
19
19
  class << self
20
- attr_writer :locale
21
- attr_writer :random
20
+ attr_writer :locale, :random
22
21
 
23
22
  def locale
24
23
  # Because I18n.locale defaults to :en, if we don't have :en in our available_locales, errors will happen
@@ -30,7 +29,7 @@ module Faker
30
29
  end
31
30
 
32
31
  def random
33
- @random || Random::DEFAULT
32
+ @random || Random.new
34
33
  end
35
34
  end
36
35
  end
@@ -81,13 +80,13 @@ module Faker
81
80
  def regexify(reg)
82
81
  reg = reg.source if reg.respond_to?(:source) # Handle either a Regexp or a String that looks like a Regexp
83
82
  reg
84
- .gsub(%r{^\/?\^?}, '').gsub(%r{\$?\/?$}, '') # Ditch the anchors
83
+ .gsub(%r{^/?\^?}, '').gsub(%r{\$?/?$}, '') # Ditch the anchors
85
84
  .gsub(/\{(\d+)\}/, '{\1,\1}').gsub(/\?/, '{0,1}') # All {2} become {2,2} and ? become {0,1}
86
85
  .gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # [12]{1,2} becomes [12] or [12][12]
87
- .gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
86
+ .gsub(/(\([^)]+\))\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
88
87
  .gsub(/(\\?.)\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # A{1,2} becomes A or AA or \d{3} becomes \d\d\d
89
- .gsub(/\((.*?)\)/) { |match| sample(match.gsub(/[\(\)]/, '').split('|')) } # (this|that) becomes 'this' or 'that'
90
- .gsub(/\[([^\]]+)\]/) { |match| match.gsub(/(\w\-\w)/) { |range| sample(Array(Range.new(*range.split('-')))) } } # All A-Z inside of [] become C (or X, or whatever)
88
+ .gsub(/\((.*?)\)/) { |match| sample(match.gsub(/[()]/, '').split('|')) } # (this|that) becomes 'this' or 'that'
89
+ .gsub(/\[([^\]]+)\]/) { |match| match.gsub(/(\w-\w)/) { |range| sample(Array(Range.new(*range.split('-')))) } } # All A-Z inside of [] become C (or X, or whatever)
91
90
  .gsub(/\[([^\]]+)\]/) { |_match| sample(Regexp.last_match(1).split('')) } # All [ABC] become B (or A or C)
92
91
  .gsub('\d') { |_match| sample(Numbers) }
93
92
  .gsub('\w') { |_match| sample(Letters) }
@@ -97,7 +96,7 @@ module Faker
97
96
  # with an array of values and selecting one of them.
98
97
  def fetch(key)
99
98
  fetched = sample(translate("faker.#{key}"))
100
- if fetched&.match(%r{^\/}) && fetched&.match(%r{\/$}) # A regex
99
+ if fetched&.match(%r{^/}) && fetched&.match(%r{/$}) # A regex
101
100
  regexify(fetched)
102
101
  else
103
102
  fetched
@@ -109,7 +108,7 @@ module Faker
109
108
  def fetch_all(key)
110
109
  fetched = translate("faker.#{key}")
111
110
  fetched = fetched.last if fetched.size <= 1
112
- if !fetched.respond_to?(:sample) && fetched.match(%r{^\/}) && fetched.match(%r{\/$}) # A regex
111
+ if !fetched.respond_to?(:sample) && fetched.match(%r{^/}) && fetched.match(%r{/$}) # A regex
113
112
  regexify(fetched)
114
113
  else
115
114
  fetched
@@ -121,7 +120,7 @@ module Faker
121
120
  # formatted translation: e.g., "#{first_name} #{last_name}".
122
121
  def parse(key)
123
122
  fetched = fetch(key)
124
- parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^\}]+)\}([^#]+)?/).map do |prefix, kls, meth, etc|
123
+ parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^}]+)\}([^#]+)?/).map do |prefix, kls, meth, etc|
125
124
  # If the token had a class Prefix (e.g., Name.first_name)
126
125
  # grab the constant, otherwise use self
127
126
  cls = kls ? Faker.const_get(kls.chop) : self
@@ -165,12 +164,12 @@ module Faker
165
164
  end
166
165
 
167
166
  # Executes block with given locale set.
168
- def with_locale(tmp_locale = nil)
167
+ def with_locale(tmp_locale = nil, &block)
169
168
  current_locale = Faker::Config.own_locale
170
169
  Faker::Config.locale = tmp_locale
171
170
 
172
171
  disable_enforce_available_locales do
173
- I18n.with_locale(tmp_locale) { yield }
172
+ I18n.with_locale(tmp_locale, &block)
174
173
  end
175
174
  ensure
176
175
  Faker::Config.locale = current_locale
@@ -14,7 +14,7 @@ module Faker
14
14
  # #=> "ak_zvU8YQLagjcfng7Tg8yCdiZ1rpiWNp1PBn3vtUs44utSvbJVR"
15
15
  #
16
16
  def address
17
- 'ak_' + rand_strings
17
+ "ak_#{rand_strings}"
18
18
  end
19
19
 
20
20
  ##
@@ -27,7 +27,7 @@ module Faker
27
27
  # #=> "th_147nDP22h3pHrLt2qykTH4txUwQh1ccaXp"
28
28
  #
29
29
  def transaction
30
- 'th_' + rand_strings(51)
30
+ "th_#{rand_strings(51)}"
31
31
  end
32
32
 
33
33
  ##
@@ -40,7 +40,7 @@ module Faker
40
40
  # #=> "ct_Hk2JsNeWGEYQEHHQCfcBeGrwbhtYSwFTPdDhW2SvjFYVojyhW"
41
41
  #
42
42
  def contract
43
- 'ct_' + rand_strings
43
+ "ct_#{rand_strings}"
44
44
  end
45
45
 
46
46
  ##
@@ -53,7 +53,7 @@ module Faker
53
53
  # #=> "ok_28QDg7fkF5qiKueSdUvUBtCYPJdmMEoS73CztzXCRAwMGKHKZh"
54
54
  #
55
55
  def oracle
56
- 'ok_' + rand_strings(51)
56
+ "ok_#{rand_strings(51)}"
57
57
  end
58
58
 
59
59
  protected
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'digest'
3
+ require 'openssl'
4
4
  require 'securerandom'
5
5
 
6
6
  module Faker
@@ -51,7 +51,7 @@ module Faker
51
51
  def address_for(network)
52
52
  version = PROTOCOL_VERSIONS.fetch(network)
53
53
  packed = version.chr + Faker::Config.random.bytes(20)
54
- checksum = Digest::SHA2.digest(Digest::SHA2.digest(packed))[0..3]
54
+ checksum = OpenSSL::Digest::SHA256.digest(OpenSSL::Digest::SHA256.digest(packed))[0..3]
55
55
  Faker::Base58.encode(packed + checksum)
56
56
  end
57
57
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'digest'
3
+ require 'openssl'
4
4
  require 'securerandom'
5
5
 
6
6
  module Faker
@@ -88,6 +88,34 @@ module Faker
88
88
  encode_tz(:edsig, 64)
89
89
  end
90
90
 
91
+ ##
92
+ # Produces a random Tezos public key
93
+ #
94
+ # @return [String]
95
+ #
96
+ # @example
97
+ # Faker::Blockchain::Tezos.public_key
98
+ # #=> "edpkuib9x8QXRc5nWwHUg7U1dXsVmaUrUNU5sX9pVEEvwbMVdfMCeq"
99
+ #
100
+ # @faker.version 2.15.2
101
+ def public_key
102
+ encode_tz(:edpk, 32)
103
+ end
104
+
105
+ ##
106
+ # Produces a random Tezos public key
107
+ #
108
+ # @return [String]
109
+ #
110
+ # @example
111
+ # Faker::Blockchain::Tezos.secret_key
112
+ # #=> "edsk3HZCAGEGpzQPnQUwQeFY4ESanFhQCgLpKriQw8GHyhKCrjHawv"
113
+ #
114
+ # @faker.version 2.15.2
115
+ def secret_key
116
+ encode_tz(:edsk, 32)
117
+ end
118
+
91
119
  protected
92
120
 
93
121
  ##
@@ -98,7 +126,7 @@ module Faker
98
126
  def encode_tz(prefix, payload_size)
99
127
  prefix = PREFIXES.fetch(prefix)
100
128
  packed = prefix.map(&:chr).join('') + Faker::Config.random.bytes(payload_size)
101
- checksum = Digest::SHA2.digest(Digest::SHA2.digest(packed))[0..3]
129
+ checksum = OpenSSL::Digest::SHA256.digest(OpenSSL::Digest::SHA256.digest(packed))[0..3]
102
130
  Faker::Base58.encode(packed + checksum)
103
131
  end
104
132
  end
@@ -30,6 +30,19 @@ module Faker
30
30
  fetch('dune.titles')
31
31
  end
32
32
 
33
+ ##
34
+ # Produces the name of a city from Dune
35
+ #
36
+ # @return [String]
37
+ #
38
+ # @example
39
+ # Faker::Books::Dune.city #=> "Arrakeen"
40
+ #
41
+ # @faker.version next
42
+ def city
43
+ fetch('dune.cities')
44
+ end
45
+
33
46
  ##
34
47
  # Produces the name of a planet from Dune
35
48
  #
@@ -76,7 +89,7 @@ module Faker
76
89
  end
77
90
  end
78
91
 
79
- fetch('dune.quotes.' + character)
92
+ fetch("dune.quotes.#{character}")
80
93
  end
81
94
 
82
95
  ##
@@ -111,7 +124,7 @@ module Faker
111
124
  end
112
125
  end
113
126
 
114
- fetch('dune.sayings.' + source)
127
+ fetch("dune.sayings.#{source}")
115
128
  end
116
129
  end
117
130
  end
@@ -68,6 +68,7 @@ module Faker
68
68
  #
69
69
  # @param word_count [Integer] The number of words to have in the sentence
70
70
  # @param random_words_to_add [Integer]
71
+ # @param open_compounds_allowed [Boolean] If true, generated sentence can contain words having additional spaces
71
72
  #
72
73
  # @return [String]
73
74
  #
@@ -80,15 +81,18 @@ module Faker
80
81
  # @example
81
82
  # Faker::Books::Lovecraft.sentence(word_count: 3, random_words_to_add: 1)
82
83
  # #=> "Amorphous indescribable tenebrous."
84
+ # @example
85
+ # Faker::Books::Lovecraft.sentence(word_count: 3, random_words_to_add: 0, open_compounds_allowed: true)
86
+ # #=> "Effulgence unmentionable gambrel."
83
87
  #
84
88
  # @faker.version 1.9.3
85
- def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6)
89
+ def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6, open_compounds_allowed: true)
86
90
  warn_for_deprecated_arguments do |keywords|
87
91
  keywords << :word_count if legacy_word_count != NOT_GIVEN
88
92
  keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
89
93
  end
90
94
 
91
- words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: true).join(' ').capitalize + '.'
95
+ "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
92
96
  end
93
97
 
94
98
  ##
@@ -266,9 +270,9 @@ module Faker
266
270
 
267
271
  paragraph = paragraph(sentence_count: 3)
268
272
 
269
- paragraph += ' ' + paragraph(sentence_count: 3) while paragraph.length < characters
273
+ paragraph += " #{paragraph(sentence_count: 3)}" while paragraph.length < characters
270
274
 
271
- paragraph[0...characters - 1] + '.'
275
+ "#{paragraph[0...characters - 1]}."
272
276
  end
273
277
  end
274
278
  end
@@ -0,0 +1,203 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Creature
5
+ class Bird < Base
6
+ flexible :bird
7
+
8
+ class << self
9
+ ##
10
+ # Produces a random common family name of a bird.
11
+ #
12
+ # @return [String]
13
+ #
14
+ # @example
15
+ # Faker::Creature::Bird.common_family_name #=> "Owls"
16
+ #
17
+ # @faker.version next
18
+ def common_family_name
19
+ fetch('creature.bird.common_family_name')
20
+ end
21
+
22
+ ##
23
+ # Produces a random common taxonomic order from the class Aves
24
+ #
25
+ # @return [String]
26
+ #
27
+ # @example
28
+ # Faker::Creature::Bird.order #=> "Passeriformes"
29
+ #
30
+ # @faker.version next
31
+ def order
32
+ orders = I18n.translate('faker.creature.bird.order_common_map').keys
33
+ sample(orders).to_s
34
+ end
35
+
36
+ ##
37
+ # Produces a random bird anatomy word
38
+ #
39
+ # @return [String]
40
+ #
41
+ # @example
42
+ # Faker::Creature::Bird.anatomy #=> "rump"
43
+ #
44
+ # @faker.version next
45
+ def anatomy
46
+ fetch('creature.bird.anatomy')
47
+ end
48
+
49
+ ##
50
+ # Produces a random, past tensed bird anatomy word
51
+ #
52
+ # @return [String]
53
+ #
54
+ # @example
55
+ # Faker::Creature::Bird.anatomy #=> "breasted"
56
+ #
57
+ # @faker.version next
58
+ def anatomy_past_tense
59
+ fetch('creature.bird.anatomy_past_tense')
60
+ end
61
+
62
+ ##
63
+ # Produces a random geographical word used in describing birds
64
+ #
65
+ # @return [String]
66
+ #
67
+ # @example
68
+ # Faker::Creature::Bird.geo #=> "Eurasian"
69
+ #
70
+ # @faker.version next
71
+ def geo
72
+ fetch('creature.bird.geo')
73
+ end
74
+
75
+ ##
76
+ # Produces a random color word used in describing birds
77
+ #
78
+ # @return [String]
79
+ #
80
+ # @example
81
+ # Faker::Creature::Bird.color #=> "ferruginous"
82
+ #
83
+ # @faker.version next
84
+ def color
85
+ fetch('creature.bird.colors')
86
+ end
87
+
88
+ ##
89
+ # Produces a random adjective used to described birds
90
+ #
91
+ # @return [String]
92
+ #
93
+ # @example
94
+ # Faker::Creature::Bird.adjective #=> 'common'
95
+ #
96
+ # @faker.version next
97
+ def adjective
98
+ fetch('creature.bird.adjectives')
99
+ end
100
+
101
+ ##
102
+ # Produces a random emotional adjective NOT used to described birds
103
+ # ...but could be
104
+ #
105
+ # @return [String]
106
+ #
107
+ # @example
108
+ # Faker::Creature::Bird.emotional_adjective #=> 'cantankerous'
109
+ #
110
+ # @faker.version next
111
+ def emotional_adjective
112
+ fetch('creature.bird.emotional_adjectives')
113
+ end
114
+
115
+ ##
116
+ # Produces a random adjective NOT used to described birds
117
+ # ...but probably shouldn't
118
+ #
119
+ # @return [String]
120
+ #
121
+ # @example
122
+ # Faker::Creature::Bird.silly_adjective #=> 'drunk'
123
+ #
124
+ # @faker.version next
125
+ def silly_adjective
126
+ fetch('creature.bird.silly_adjectives')
127
+ end
128
+
129
+ ##
130
+ # Produces a random common name for a bird
131
+ #
132
+ # @param [String | Symbol | nil] tax_order Tax
133
+ # @return [String]
134
+ # @raises TypeError If `tax_order` cannot be converted into a Symbol
135
+ # @raises ArgumentError If `tax_order` is not a valid taxonomic order
136
+ #
137
+ # @example
138
+ # Faker::Creature::Bird.common_name #=> 'wren'
139
+ #
140
+ # @faker.version next
141
+ def common_name(tax_order = nil)
142
+ map = translate('faker.creature.bird.order_common_map')
143
+ if tax_order.nil?
144
+ sample(map.values.flatten).downcase
145
+ else
146
+ raise TypeError, 'tax_order parameter must be symbolizable' \
147
+ unless tax_order.respond_to?(:to_sym)
148
+ raise ArgumentError, "#{tax_order} is not a valid taxonomic order" \
149
+ unless map.keys.include?(tax_order.to_sym)
150
+
151
+ the_order = translate('faker.creature.bird.order_common_map')[tax_order.to_sym]
152
+ sample(the_order).downcase
153
+ end
154
+ end
155
+
156
+ ##
157
+ # Produces a random and plausible common name for a bird
158
+ #
159
+ # @return [String]
160
+ #
161
+ # @example
162
+ # Faker::Creature::Bird.plausible_common_name #=> 'Hellinger's Wren'
163
+ #
164
+ # @faker.version next
165
+ def plausible_common_name
166
+ parse('creature.bird.plausible_common_names').capitalize
167
+ end
168
+
169
+ ##
170
+ # Produces a random and IMplausible common name for a bird
171
+ #
172
+ # @return [String]
173
+ #
174
+ # @example
175
+ # Faker::Creature::Bird.implausible_common_name #=> 'Hellinger's Cantankerous Chickadee'
176
+ #
177
+ # @faker.version next
178
+ def implausible_common_name
179
+ parse('creature.bird.implausible_common_names').capitalize
180
+ end
181
+
182
+ ##
183
+ # Produces a hash entry with a random order and a random common name
184
+ # that is of that order
185
+ #
186
+ # @return [Hash<order,common_name>]
187
+ #
188
+ # @example
189
+ # Faker::Creature::Bird.order_with_common_name #=> {
190
+ # order: ''Accipitriformes',
191
+ # common_name: 'Osprey'
192
+ # }
193
+ #
194
+ # @faker.version next
195
+ def order_with_common_name(tax_order = nil)
196
+ map = I18n.translate('faker.creature.bird.order_common_map')
197
+ o = tax_order.nil? ? order : tax_order
198
+ { order: o, common_name: sample(map[o.to_sym]) }
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end