faker 2.2.1 → 2.6.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 (153) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +130 -0
  3. data/README.md +2 -2
  4. data/lib/faker.rb +34 -0
  5. data/lib/faker/blockchain/aeternity.rb +70 -0
  6. data/lib/faker/blockchain/bitcoin.rb +26 -0
  7. data/lib/faker/blockchain/ethereum.rb +10 -0
  8. data/lib/faker/blockchain/tezos.rb +62 -6
  9. data/lib/faker/books/book.rb +36 -0
  10. data/lib/faker/books/culture_series.rb +49 -0
  11. data/lib/faker/books/dune.rb +60 -9
  12. data/lib/faker/books/lovecraft.rb +189 -33
  13. data/lib/faker/creature/animal.rb +9 -0
  14. data/lib/faker/creature/cat.rb +27 -0
  15. data/lib/faker/creature/dog.rb +72 -0
  16. data/lib/faker/creature/horse.rb +18 -0
  17. data/lib/faker/default/address.rb +10 -15
  18. data/lib/faker/default/alphanumeric.rb +29 -18
  19. data/lib/faker/default/app.rb +50 -11
  20. data/lib/faker/default/appliance.rb +18 -0
  21. data/lib/faker/default/artist.rb +9 -0
  22. data/lib/faker/default/avatar.rb +38 -19
  23. data/lib/faker/default/bank.rb +4 -6
  24. data/lib/faker/default/boolean.rb +14 -4
  25. data/lib/faker/default/chile_rut.rb +6 -14
  26. data/lib/faker/default/chuck_norris.rb +1 -1
  27. data/lib/faker/default/code.rb +7 -13
  28. data/lib/faker/default/commerce.rb +8 -17
  29. data/lib/faker/default/company.rb +4 -6
  30. data/lib/faker/default/crypto_coin.rb +6 -9
  31. data/lib/faker/default/date.rb +100 -30
  32. data/lib/faker/default/demographic.rb +2 -3
  33. data/lib/faker/default/dessert.rb +27 -0
  34. data/lib/faker/default/device.rb +54 -0
  35. data/lib/faker/default/driving_licence.rb +7 -17
  36. data/lib/faker/default/electrical_components.rb +27 -0
  37. data/lib/faker/default/file.rb +9 -26
  38. data/lib/faker/default/fillmurray.rb +4 -11
  39. data/lib/faker/default/finance.rb +2 -3
  40. data/lib/faker/default/gender.rb +18 -0
  41. data/lib/faker/default/greek_philosophers.rb +18 -0
  42. data/lib/faker/default/hacker.rb +59 -1
  43. data/lib/faker/default/hipster.rb +21 -54
  44. data/lib/faker/default/house.rb +18 -0
  45. data/lib/faker/default/id_number.rb +5 -7
  46. data/lib/faker/default/industry_segments.rb +36 -0
  47. data/lib/faker/default/internet.rb +49 -76
  48. data/lib/faker/default/invoice.rb +7 -13
  49. data/lib/faker/default/json.rb +9 -16
  50. data/lib/faker/default/lorem.rb +38 -77
  51. data/lib/faker/default/lorem_flickr.rb +17 -48
  52. data/lib/faker/default/lorem_pixel.rb +7 -23
  53. data/lib/faker/default/markdown.rb +3 -7
  54. data/lib/faker/default/marketing.rb +9 -0
  55. data/lib/faker/default/measurement.rb +16 -24
  56. data/lib/faker/default/military.rb +45 -0
  57. data/lib/faker/default/name.rb +2 -3
  58. data/lib/faker/default/nation.rb +48 -5
  59. data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
  60. data/lib/faker/default/nhs.rb +2 -3
  61. data/lib/faker/default/number.rb +149 -50
  62. data/lib/faker/default/omniauth.rb +67 -63
  63. data/lib/faker/default/phone_number.rb +2 -3
  64. data/lib/faker/default/placeholdit.rb +6 -19
  65. data/lib/faker/default/programming_language.rb +18 -0
  66. data/lib/faker/default/relationship.rb +2 -3
  67. data/lib/faker/default/restaurant.rb +54 -2
  68. data/lib/faker/default/science.rb +27 -0
  69. data/lib/faker/default/source.rb +51 -14
  70. data/lib/faker/default/string.rb +2 -3
  71. data/lib/faker/default/stripe.rb +8 -12
  72. data/lib/faker/default/subscription.rb +45 -0
  73. data/lib/faker/default/superhero.rb +45 -0
  74. data/lib/faker/default/time.rb +102 -56
  75. data/lib/faker/default/twitter.rb +23 -32
  76. data/lib/faker/default/types.rb +12 -23
  77. data/lib/faker/default/vehicle.rb +8 -14
  78. data/lib/faker/default/world_cup.rb +55 -10
  79. data/lib/faker/games/dota.rb +49 -3
  80. data/lib/faker/games/elder_scrolls.rb +72 -0
  81. data/lib/faker/games/fallout.rb +37 -0
  82. data/lib/faker/games/game.rb +27 -0
  83. data/lib/faker/games/half_life.rb +27 -0
  84. data/lib/faker/games/heroes.rb +27 -0
  85. data/lib/faker/games/heroes_of_the_storm.rb +36 -0
  86. data/lib/faker/games/league_of_legends.rb +54 -0
  87. data/lib/faker/games/myst.rb +45 -0
  88. data/lib/faker/games/overwatch.rb +27 -0
  89. data/lib/faker/games/pokemon.rb +27 -0
  90. data/lib/faker/games/sonic_the_hedgehog.rb +27 -0
  91. data/lib/faker/games/super_smash_bros.rb +18 -0
  92. data/lib/faker/games/witcher.rb +54 -0
  93. data/lib/faker/games/world_of_warcraft.rb +18 -0
  94. data/lib/faker/games/zelda.rb +37 -1
  95. data/lib/faker/japanese_media/dragon_ball.rb +9 -0
  96. data/lib/faker/japanese_media/one_piece.rb +54 -0
  97. data/lib/faker/japanese_media/sword_art_online.rb +36 -0
  98. data/lib/faker/movies/back_to_the_future.rb +28 -0
  99. data/lib/faker/movies/ghostbusters.rb +28 -0
  100. data/lib/faker/movies/harry_potter.rb +54 -0
  101. data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +69 -0
  102. data/lib/faker/movies/hobbit.rb +37 -0
  103. data/lib/faker/movies/lebowski.rb +27 -0
  104. data/lib/faker/movies/lord_of_the_rings.rb +28 -0
  105. data/lib/faker/movies/movie.rb +9 -0
  106. data/lib/faker/movies/princess_bride.rb +19 -0
  107. data/lib/faker/movies/star_wars.rb +97 -6
  108. data/lib/faker/movies/v_for_vendetta.rb +29 -0
  109. data/lib/faker/music/grateful_dead.rb +18 -0
  110. data/lib/faker/music/phish.rb +9 -0
  111. data/lib/faker/music/rock_band.rb +9 -0
  112. data/lib/faker/music/umphreys_mcgee.rb +9 -0
  113. data/lib/faker/sports/basketball.rb +36 -0
  114. data/lib/faker/sports/football.rb +45 -0
  115. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +9 -0
  116. data/lib/faker/tv_shows/bojack_horseman.rb +28 -0
  117. data/lib/faker/tv_shows/breaking_bad.rb +18 -0
  118. data/lib/faker/tv_shows/buffy.rb +45 -0
  119. data/lib/faker/tv_shows/community.rb +19 -0
  120. data/lib/faker/tv_shows/dr_who.rb +78 -2
  121. data/lib/faker/tv_shows/dumb_and_dumber.rb +28 -0
  122. data/lib/faker/tv_shows/family_guy.rb +28 -0
  123. data/lib/faker/tv_shows/friends.rb +27 -0
  124. data/lib/faker/tv_shows/game_of_thrones.rb +46 -0
  125. data/lib/faker/tv_shows/hey_arnold.rb +27 -0
  126. data/lib/faker/tv_shows/how_i_met_your_mother.rb +37 -0
  127. data/lib/faker/tv_shows/michael_scott.rb +13 -0
  128. data/lib/faker/tv_shows/new_girl.rb +19 -0
  129. data/lib/faker/tv_shows/parks_and_rec.rb +18 -0
  130. data/lib/faker/tv_shows/rick_and_morty.rb +28 -0
  131. data/lib/faker/tv_shows/ru_paul.rb +18 -0
  132. data/lib/faker/tv_shows/seinfeld.rb +28 -0
  133. data/lib/faker/tv_shows/silicon_valley.rb +75 -0
  134. data/lib/faker/tv_shows/simpsons.rb +28 -0
  135. data/lib/faker/tv_shows/south_park.rb +19 -0
  136. data/lib/faker/tv_shows/star_trek.rb +36 -0
  137. data/lib/faker/tv_shows/stargate.rb +28 -0
  138. data/lib/faker/tv_shows/stranger_things.rb +19 -0
  139. data/lib/faker/tv_shows/the_expanse.rb +36 -0
  140. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +28 -0
  141. data/lib/faker/tv_shows/the_it_crowd.rb +37 -0
  142. data/lib/faker/tv_shows/the_thick_of_it.rb +28 -0
  143. data/lib/faker/tv_shows/twin_peaks.rb +28 -0
  144. data/lib/faker/tv_shows/venture_bros.rb +38 -0
  145. data/lib/faker/version.rb +1 -1
  146. data/lib/locales/en-CA.yml +1 -1
  147. data/lib/locales/en-TH.yml +360 -0
  148. data/lib/locales/en/color.yml +1 -1
  149. data/lib/locales/en/dr_who.yml +1 -1
  150. data/lib/locales/en/science.yml +1 -1
  151. data/lib/locales/ja.yml +8 -9
  152. data/lib/locales/th.yml +380 -0
  153. metadata +40 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5587b3da998c6565466a5886c285dc46218d0c6be32bbc9d1578b2493ccca0a
4
- data.tar.gz: da07c93a781ccaf2f57b79a220f05905913b11261d6c324ab54e63f7c4f757d3
3
+ metadata.gz: 74df7e5e60856bfe1283a1e8de2b425e3b5617dfc9de2a05d651ab7ef69a35c0
4
+ data.tar.gz: 53b1457eb640182a15c4a34eb909aa252bd2f34b3990ef28ff2e8390b8417638
5
5
  SHA512:
6
- metadata.gz: e5e2770457c5eabde0476cbb1a6cd320c633ceb0dbb734636569dbd84471df2d85f47f1664f597a65ccfedda1af67340904b2cf64e3798edfa83481d11015a39
7
- data.tar.gz: 16721c3cd11278e59c6df91b5a99f507c938e705d1eb9e20bd2fb26811819b5c781abf639d7ac8ab79b11ee3d7fea56c7d7ef876054c177e597116a967c41375
6
+ metadata.gz: b5f3096b849d9aca43c94143b40411b52b29ea5c67468dd8a3f880d684ed7df02f4128281ffe36d8d144a3258324e64b3d7f3095177bee0cee066fa309beb14e
7
+ data.tar.gz: b303d58bc31496ad5913d273ab05b08b0dd8d45560725e15fd7c44200b0afb674671a2c70e3a291aad65a39367d3bd5b5ca63c206f219df8347fe260d0e41a4a
@@ -1,5 +1,131 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.6.0](https://github.com/faker-ruby/faker/tree/v2.6.0) (2019-10-10)
4
+
5
+ This version:
6
+ - adds `Faker::Date.in_date_period`
7
+ - adds `Faker::WorldCup` YARD docs
8
+ - updates local dependencies
9
+
10
+ ## Documentation
11
+
12
+ - [PR #1789](https://github.com/faker-ruby/faker/pull/1789) Faker::WorldCup YARD docs [@ashishra0](https://github.com/ashishra0)
13
+
14
+ ## Feature Request
15
+
16
+ - [PR #1755](https://github.com/faker-ruby/faker/pull/1755) Add Faker::Date.in_date_period [@AmrAdelKhalil](https://github.com/AmrAdelKhalil)
17
+
18
+ ## Update local dependencies
19
+
20
+ The following development dependencies were updated:
21
+ - Update rake requirement from = 12.3.3 to = 13.0.0 (#1776)
22
+ - Update minitest requirement from = 5.12.0 to = 5.12.2 (#1775)
23
+ - Update test-unit requirement from = 3.3.3 to = 3.3.4 (#1774)
24
+
25
+ ------------------------------------------------------------------------------
26
+
27
+ ## [v2.5.0](https://github.com/faker-ruby/faker/tree/v2.5.0) (2019-30-09)
28
+
29
+ This version introduces:
30
+ - locales for Thai language - the mother language in Thailand
31
+ - YARD documentation for faker interfaces
32
+ - locales updates or fixes
33
+
34
+ ## Feature Request
35
+
36
+ - [PR #1773](https://github.com/faker-ruby/faker/pull/1773) Two new locales added: th and en-th [@kodram](https://github.com/kodram)
37
+
38
+ ## Documentation
39
+
40
+ - [PR #1771](https://github.com/faker-ruby/faker/pull/1771) Fix some rubocop comments that were showing up in YARD docs. [@connorshea](https://github.com/connorshea)
41
+ - [PR #1767](https://github.com/faker-ruby/faker/pull/1767) Fix two incorrect flexible method calls. [@connorshea](https://github.com/connorshea)
42
+ - [PR #1761](https://github.com/faker-ruby/faker/pull/1761) Add YARD docs for the Basketball and Football fakers. [@connorshea](https://github.com/connorshea)
43
+ - [PR #1768](https://github.com/faker-ruby/faker/pull/1768) Add YARD docs for Faker::Restaurant. [@connorshea](https://github.com/connorshea)
44
+ - [PR #1759](https://github.com/faker-ruby/faker/pull/1759) Add YARD docs for all remaining TV Shows [@connorshea](https://github.com/connorshea)
45
+ - [PR #1758](https://github.com/faker-ruby/faker/pull/1758) Add YARD docs for Doctor Who and fix a method name. [@connorshea](https://github.com/connorshea)
46
+ - [PR #1756](https://github.com/faker-ruby/faker/pull/1756) Add more miscellaneous YARD docs [@connorshea](https://github.com/connorshea)
47
+ - [PR #1753](https://github.com/faker-ruby/faker/pull/1753) Add YARD docs for Date, Time, and Number [@connorshea](https://github.com/connorshea)
48
+
49
+ ## Update locales
50
+
51
+ - [PR #1764](https://github.com/faker-ruby/faker/pull/1764) Remove "mint green" from color [@ro-savage](https://github.com/ro-savage)
52
+ - [PR #1751](https://github.com/faker-ruby/faker/pull/1751) fix from Color.name to Color.color_name [@4geru](https://github.com/4geru)
53
+
54
+ ## Update local dependencies
55
+
56
+ The following development dependencies were updated:
57
+ - Update minitest requirement from = 5.11.3 to = 5.12.0 (#1763)
58
+
59
+ ------------------------------------------------------------------------------
60
+
61
+ ## [v2.4.0](https://github.com/faker-ruby/faker/tree/v2.4.0) (2019-19-09)
62
+
63
+ ## Documentation
64
+
65
+ - [PR #1750](https://github.com/faker-ruby/faker/pull/1750) add only japanese word spec [@4geru](https://github.com/4geru)
66
+ - [PR #1740](https://github.com/faker-ruby/faker/pull/1740) Add more YARD docs [@connorshea](https://github.com/connorshea)
67
+ - [PR #1747](https://github.com/faker-ruby/faker/pull/1747) Fix PR links [@geniou](https://github.com/geniou)
68
+
69
+ ## Feature Request
70
+
71
+ - [PR #1742](https://github.com/faker-ruby/faker/pull/1742) Add Faker::Blockchain::Aeternity [@2pd](https://github.com/2pd)
72
+
73
+ ## Update locales
74
+
75
+ - [PR #1743](https://github.com/faker-ruby/faker/pull/1743) Fix another ambiguity in element_symbol field [@psibi](https://github.com/psibi)
76
+ - [PR #1748](https://github.com/faker-ruby/faker/pull/1748) fix typo from bread to breed [@4geru](https://github.com/4geru)
77
+ - [PR #1752](https://github.com/faker-ruby/faker/pull/1752) fix creature i18n path in japanese [@4geru](https://github.com/4geru)
78
+
79
+ ## Update local dependencies
80
+
81
+ The following development dependencies were updated:
82
+ - Update simplecov requirement from = 0.17.0 to = 0.17.1 (#1749)
83
+
84
+ ------------------------------------------------------------------------------
85
+
86
+ ## [v2.3.0](https://github.com/faker-ruby/faker/tree/v2.3.0) (2019-12-09)
87
+
88
+ ## Documentation
89
+
90
+ - [PR #1741](https://github.com/faker-ruby/faker/pull/1741) Fix the .gitignore for YARD. [@connorshea](https://github.com/connorshea)
91
+ - [PR #1553](https://github.com/faker-ruby/faker/pull/1553) Yard powered docs [@Zeragamba](https://github.com/Zeragamba) [@connorshea](https://github.com/connorshea)
92
+ - [PR #1727](https://github.com/faker-ruby/faker/pull/1727) Remove Football documentation from wrong category [@lucasqueiroz](https://github.com/lucasqueiroz)
93
+
94
+ ## Feature Request
95
+
96
+ - [PR #1738](https://github.com/faker-ruby/faker/pull/1738) Add mock data for Apple OAuth [@dzunk](https://github.com/dzunk)
97
+
98
+ ## Update locales
99
+
100
+ - [PR #1723](https://github.com/faker-ruby/faker/pull/1723) Add pokemon name in Johto area [@mathieujobin](https://github.com/mathieujobin)
101
+ - [PR #1732](https://github.com/faker-ruby/faker/pull/1732) Quebec province postal codes starts by [GHJ], adding missing two [@Ryutooooo](https://github.com/Ryutooooo)
102
+
103
+ ------------------------------------------------------------------------------
104
+
105
+ ## [v2.2.2](https://github.com/faker-ruby/faker/tree/v2.2.2) (2019-05-09)
106
+
107
+ ## Bug/Fixes
108
+
109
+ - [PR #1717](https://github.com/faker-ruby/faker/pull/1717) Fix ambiguity in element_symbol field [@psibi](https://github.com/psibi)
110
+
111
+ ## Chores
112
+
113
+ - [PR #1724](https://github.com/faker-ruby/faker/pull/1724) Include rubocop-faker autocorrect in deprecation [@koic](https://github.com/koic)
114
+
115
+ ## Documentation
116
+
117
+ - [PR #1726](https://github.com/faker-ruby/faker/pull/1726) Include 2.x breaking return value change in changelog [@zorab47](https://github.com/zorab47)
118
+ - [PR #1722](https://github.com/faker-ruby/faker/pull/1722) Fix examples in the Dota docs [@bzf](https://github.com/bzf)
119
+
120
+ ## Update local dependencies
121
+
122
+ The following development dependencies were updated:
123
+ - rake requirement from = 12.3.1 to = 12.3.3 (#1719)
124
+ - rubocop requirement from = 0.59.1 to = 0.74.0 (#1721)
125
+ - simplecov requirement from = 0.16.1 to = 0.17.0 (#1718)
126
+
127
+ ------------------------------------------------------------------------------
128
+
3
129
  ## [v2.2.1](https://github.com/faker-ruby/faker/tree/v2.2.1) (2019-30-08)
4
130
 
5
131
  ## Bug/Fixes
@@ -202,6 +328,10 @@ Version 2 has several `breaking changes`. We replaced positional arguments with
202
328
  - `Faker::WorldCup.roster(country = nil, type = nil)` becomes `Faker::WorldCup.roster(country: nil, type: nil)`
203
329
  - `Faker::Movies::StarWars.quote(character = nil)` becomes `Faker::Movies::StarWars.quote(character: nil)`
204
330
 
331
+ Additionally the following methods changed return values:
332
+
333
+ - `Faker::Number.number` now returns `Numeric` instead of `String` (see [PR #510](https://github.com/faker-ruby/faker/pull/510))
334
+
205
335
  ### Bug/Fixes
206
336
 
207
337
  - [PR #1660](https://github.com/stympy/faker/pull/1660) Update FillMurray Links To Include www [@RaymondFallon](https://github.com/RaymondFallon)
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  # Faker
5
5
  [![Build Status](https://travis-ci.org/faker-ruby/faker.svg?branch=master)](https://travis-ci.org/faker-ruby/faker)
6
6
  [![Gem Version](https://badge.fury.io/rb/faker.svg)](https://badge.fury.io/rb/faker)
7
- [![Inline docs](http://inch-ci.org/github/stympy/faker.svg?branch=master)](http://inch-ci.org/github/stympy/faker)
7
+ [![Inline docs](https://inch-ci.org/github/faker-ruby/faker.svg?branch=master)](https://inch-ci.org/github/faker-ruby/faker)
8
8
  [![Test Coverage](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/test_coverage)](https://codeclimate.com/github/stympy/faker/test_coverage)
9
9
  [![Maintainability](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/maintainability)](https://codeclimate.com/github/stympy/faker/maintainability)
10
10
 
@@ -161,7 +161,6 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
161
161
  - [Faker::Fillmurray](doc/default/fillmurray.md)
162
162
  - [Faker::Finance](doc/default/finance.md)
163
163
  - [Faker::Food](doc/default/food.md)
164
- - [Faker::Football](doc/default/football.md)
165
164
  - [Faker::FunnyName](doc/default/funny_name.md)
166
165
  - [Faker::Gender](doc/default/gender.md)
167
166
  - [Faker::GreekPhilosophers](doc/default/greek_philosophers.md)
@@ -212,6 +211,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
212
211
  - [Faker::WorldCup](doc/default/world_cup.md)
213
212
 
214
213
  ### Blockchain
214
+ - [Faker::Blockchain::Aeternity](doc/blockchain/aeternity.md)
215
215
  - [Faker::Blockchain::Bitcoin](doc/blockchain/bitcoin.md)
216
216
  - [Faker::Blockchain::Ethereum](doc/blockchain/ethereum.md)
217
217
  - [Faker::Blockchain::Tezos](doc/blockchain/tezos.md)
@@ -251,6 +251,40 @@ module Faker
251
251
 
252
252
  private
253
253
 
254
+ def warn_for_deprecated_arguments
255
+ keywords = []
256
+ yield(keywords)
257
+
258
+ return if keywords.empty?
259
+
260
+ method_name = caller.first.match(/`(?<method_name>.*)'/)[:method_name]
261
+
262
+ keywords.each.with_index(1) do |keyword, index|
263
+ i = case index
264
+ when 1 then '1st'
265
+ when 2 then '2nd'
266
+ when 3 then '3rd'
267
+ else "#{index}th"
268
+ end
269
+
270
+ warn_with_uplevel(<<~MSG, uplevel: 5)
271
+ Passing `#{keyword}` with the #{i} argument of `#{method_name}` is deprecated. Use keyword argument like `#{method_name}(#{keyword}: ...)` instead.
272
+ MSG
273
+ end
274
+
275
+ warn(<<~MSG)
276
+
277
+ To automatically update from positional arguments to keyword arguments,
278
+ install rubocop-faker and run:
279
+
280
+ rubocop \\
281
+ --require rubocop-faker \\
282
+ --only Faker/DeprecatedArguments \\
283
+ --auto-correct
284
+
285
+ MSG
286
+ end
287
+
254
288
  # Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
255
289
  def warn_with_uplevel(message, uplevel: 1)
256
290
  at = parse_caller(caller[uplevel]).join(':')
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Blockchain
5
+ class Aeternity < Base
6
+ class << self
7
+ ##
8
+ # Produces a random Aeternity wallet address
9
+ #
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::Blockchain::Aeternity.address
14
+ # #=> "ak_zvU8YQLagjcfng7Tg8yCdiZ1rpiWNp1PBn3vtUs44utSvbJVR"
15
+ #
16
+ def address
17
+ 'ak_' + rand_strings
18
+ end
19
+
20
+ ##
21
+ # Produces a random Aeternity transaction
22
+ #
23
+ # @return [String]
24
+ #
25
+ # @example
26
+ # Faker::Blockchain::Aeternity.transaction
27
+ # #=> "th_147nDP22h3pHrLt2qykTH4txUwQh1ccaXp"
28
+ #
29
+ def transaction
30
+ 'th_' + rand_strings(51)
31
+ end
32
+
33
+ ##
34
+ # Produces a random Aeternity contract
35
+ #
36
+ # @return [String]
37
+ #
38
+ # @example
39
+ # Faker::Blockchain::Aeternity.contract
40
+ # #=> "ct_Hk2JsNeWGEYQEHHQCfcBeGrwbhtYSwFTPdDhW2SvjFYVojyhW"
41
+ #
42
+ def contract
43
+ 'ct_' + rand_strings
44
+ end
45
+
46
+ ##
47
+ # Produces a random Aeternity oracle
48
+ #
49
+ # @return [String]
50
+ #
51
+ # @example
52
+ # Faker::Blockchain::Aeternity.oracle
53
+ # #=> "ok_28QDg7fkF5qiKueSdUvUBtCYPJdmMEoS73CztzXCRAwMGKHKZh"
54
+ #
55
+ def oracle
56
+ 'ok_' + rand_strings(51)
57
+ end
58
+
59
+ protected
60
+
61
+ def rand_strings(length = 50)
62
+ hex_alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
63
+ var = +''
64
+ length.times { var << sample(shuffle(hex_alphabet.split(''))) }
65
+ var
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -7,21 +7,47 @@ module Faker
7
7
  class Blockchain
8
8
  class Bitcoin < Base
9
9
  class << self
10
+ # @private
10
11
  PROTOCOL_VERSIONS = {
11
12
  main: 0,
12
13
  testnet: 111
13
14
  }.freeze
14
15
 
16
+ ##
17
+ # Produces a Bitcoin wallet address
18
+ #
19
+ # @return [String]
20
+ #
21
+ # @example
22
+ # Faker::Blockchain::Bitcoin.address
23
+ # #=> "147nDP22h3pHrLt2qykTH4txUwQh1ccaXp"
24
+ #
25
+ # @faker.version 1.9.2
15
26
  def address
16
27
  address_for(:main)
17
28
  end
18
29
 
30
+ ##
31
+ # Produces a Bitcoin testnet address
32
+ #
33
+ # @return [String]
34
+ #
35
+ # @example
36
+ # Faker::Blockchain::Bitcoin.testnet_address
37
+ # #=> "n4YjRyYD6V6zREpk6opqESDqD3KYnMdVEB"
38
+ #
39
+ # @faker.version 1.9.2
19
40
  def testnet_address
20
41
  address_for(:testnet)
21
42
  end
22
43
 
23
44
  protected
24
45
 
46
+ ##
47
+ # Generates a random Bitcoin address for the given network
48
+ #
49
+ # @param network [Symbol] The name of network protocol to generate an address for
50
+ # @return [String] A Bitcoin address
25
51
  def address_for(network)
26
52
  version = PROTOCOL_VERSIONS.fetch(network)
27
53
  packed = version.chr + Faker::Config.random.bytes(20)
@@ -4,6 +4,16 @@ module Faker
4
4
  class Blockchain
5
5
  class Ethereum < Base
6
6
  class << self
7
+ ##
8
+ # Produces a random Ethereum wallet address
9
+ #
10
+ # @return [String]
11
+ #
12
+ # @example
13
+ # Faker::Blockchain::Ethereum.address
14
+ # #=> "0xd392b0c0500700d02d27ab30805ec80ddd3320ff"
15
+ #
16
+ # @faker.version 1.9.1
7
17
  def address
8
18
  hex_alphabet = '0123456789abcdef'
9
19
  var = +'0x'
@@ -7,38 +7,94 @@ module Faker
7
7
  class Blockchain
8
8
  class Tezos < Base
9
9
  class << self
10
+ # @private
10
11
  PREFIXES = {
11
- tz1: [6, 161, 159],
12
- KT1: [2, 90, 121],
13
- edpk: [13, 15, 37, 217],
14
- edsk: [13, 15, 58, 7],
12
+ tz1: [6, 161, 159],
13
+ KT1: [2, 90, 121],
14
+ edpk: [13, 15, 37, 217],
15
+ edsk: [13, 15, 58, 7],
15
16
  edsig: [9, 245, 205, 134, 18],
16
- B: [1, 52],
17
- o: [5, 116]
17
+ B: [1, 52],
18
+ o: [5, 116]
18
19
  }.freeze
19
20
 
21
+ ##
22
+ # Produces a random Tezos account address
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Blockchain::Tezos.account
28
+ # #=> "tz1eUsgK6aj752Fbxwk5sAoEFvSDnPjZ4qvk"
29
+ #
30
+ # @faker.version 1.9.2
20
31
  def account
21
32
  encode_tz(:tz1, 20)
22
33
  end
23
34
 
35
+ ##
36
+ # Produces a random Tezos contract
37
+ #
38
+ # @return [String]
39
+ #
40
+ # @example
41
+ # Faker::Blockchain::Tezos.contract
42
+ # #=> "KT1MroqeP15nnitB4CnNfkqHYa2NErhPPLWF"
43
+ #
44
+ # @faker.version 1.9.2
24
45
  def contract
25
46
  encode_tz(:KT1, 20)
26
47
  end
27
48
 
49
+ ##
50
+ # Produces a random Tezos operation
51
+ #
52
+ # @return [String]
53
+ #
54
+ # @example
55
+ # Faker::Blockchain::Tezos.operation
56
+ # #=> "onygWYXJX3xNstFLv9PcCrhQdCkENC795xwSinmTEc1jsDN4VDa"
57
+ #
58
+ # @faker.version 1.9.2
28
59
  def operation
29
60
  encode_tz(:o, 32)
30
61
  end
31
62
 
63
+ ##
64
+ # Produces a random Tezos block
65
+ #
66
+ # @return [String]
67
+ #
68
+ # @example
69
+ # Faker::Blockchain::Tezos.block
70
+ # #=> "BMbhs2rkY1dvAkAyRytvPsjFQ2RiPrBhYkxvWpY65dzkdSuw58a"
71
+ #
72
+ # @faker.version 1.9.4
32
73
  def block
33
74
  encode_tz(:B, 32)
34
75
  end
35
76
 
77
+ ##
78
+ # Produces a random Tezos signature
79
+ #
80
+ # @return [String]
81
+ #
82
+ # @example
83
+ # Faker::Blockchain::Tezos.signature
84
+ # #=> "edsigu165B7VFf3Dpw2QABVzEtCxJY2gsNBNcE3Ti7rRxtDUjqTFRpg67EdAQmY6YWPE5tKJDMnSTJDFu65gic8uLjbW2YwGvAZ"
85
+ #
86
+ # @faker.version 1.9.2
36
87
  def signature
37
88
  encode_tz(:edsig, 64)
38
89
  end
39
90
 
40
91
  protected
41
92
 
93
+ ##
94
+ # @param prefix [Symbol]
95
+ # @param payload_size [Integer] The size of the payload
96
+ #
97
+ # @return [String]
42
98
  def encode_tz(prefix, payload_size)
43
99
  prefix = PREFIXES.fetch(prefix)
44
100
  packed = prefix.map(&:chr).join('') + Faker::Config.random.bytes(payload_size)