faker 2.3.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +118 -2
  3. data/README.md +5 -1
  4. data/lib/faker/blockchain/aeternity.rb +70 -0
  5. data/lib/faker/default/app.rb +2 -1
  6. data/lib/faker/default/appliance.rb +18 -0
  7. data/lib/faker/default/avatar.rb +2 -1
  8. data/lib/faker/default/chuck_norris.rb +1 -1
  9. data/lib/faker/default/date.rb +83 -2
  10. data/lib/faker/default/dessert.rb +27 -0
  11. data/lib/faker/default/device.rb +54 -0
  12. data/lib/faker/default/driving_licence.rb +2 -2
  13. data/lib/faker/default/electrical_components.rb +27 -0
  14. data/lib/faker/default/greek_philosophers.rb +18 -0
  15. data/lib/faker/default/id_number.rb +29 -0
  16. data/lib/faker/default/industry_segments.rb +36 -0
  17. data/lib/faker/default/internet.rb +4 -1
  18. data/lib/faker/default/marketing.rb +9 -0
  19. data/lib/faker/default/military.rb +45 -0
  20. data/lib/faker/default/nation.rb +48 -5
  21. data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
  22. data/lib/faker/default/number.rb +124 -0
  23. data/lib/faker/default/restaurant.rb +54 -2
  24. data/lib/faker/default/science.rb +27 -0
  25. data/lib/faker/default/subscription.rb +45 -0
  26. data/lib/faker/default/superhero.rb +45 -0
  27. data/lib/faker/default/time.rb +85 -8
  28. data/lib/faker/default/world_cup.rb +50 -0
  29. data/lib/faker/games/dota.rb +47 -0
  30. data/lib/faker/games/heroes.rb +27 -0
  31. data/lib/faker/games/heroes_of_the_storm.rb +36 -0
  32. data/lib/faker/games/league_of_legends.rb +54 -0
  33. data/lib/faker/games/myst.rb +45 -0
  34. data/lib/faker/games/pokemon.rb +27 -0
  35. data/lib/faker/games/sonic_the_hedgehog.rb +27 -0
  36. data/lib/faker/games/witcher.rb +54 -0
  37. data/lib/faker/games/world_of_warcraft.rb +18 -0
  38. data/lib/faker/games/zelda.rb +1 -1
  39. data/lib/faker/japanese_media/dragon_ball.rb +9 -0
  40. data/lib/faker/japanese_media/one_piece.rb +54 -0
  41. data/lib/faker/japanese_media/sword_art_online.rb +36 -0
  42. data/lib/faker/movies/back_to_the_future.rb +28 -0
  43. data/lib/faker/movies/ghostbusters.rb +28 -0
  44. data/lib/faker/movies/harry_potter.rb +54 -0
  45. data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +69 -0
  46. data/lib/faker/movies/hobbit.rb +37 -0
  47. data/lib/faker/movies/lebowski.rb +27 -0
  48. data/lib/faker/movies/lord_of_the_rings.rb +28 -0
  49. data/lib/faker/movies/movie.rb +9 -0
  50. data/lib/faker/movies/princess_bride.rb +19 -0
  51. data/lib/faker/movies/star_wars.rb +94 -0
  52. data/lib/faker/movies/v_for_vendetta.rb +29 -0
  53. data/lib/faker/music/grateful_dead.rb +18 -0
  54. data/lib/faker/music/phish.rb +9 -0
  55. data/lib/faker/music/rock_band.rb +9 -0
  56. data/lib/faker/music/umphreys_mcgee.rb +9 -0
  57. data/lib/faker/sports/basketball.rb +36 -0
  58. data/lib/faker/sports/football.rb +45 -0
  59. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +9 -0
  60. data/lib/faker/tv_shows/bojack_horseman.rb +28 -0
  61. data/lib/faker/tv_shows/buffy.rb +45 -0
  62. data/lib/faker/tv_shows/community.rb +19 -0
  63. data/lib/faker/tv_shows/dr_who.rb +78 -2
  64. data/lib/faker/tv_shows/dumb_and_dumber.rb +28 -0
  65. data/lib/faker/tv_shows/family_guy.rb +28 -0
  66. data/lib/faker/tv_shows/friends.rb +27 -0
  67. data/lib/faker/tv_shows/game_of_thrones.rb +46 -0
  68. data/lib/faker/tv_shows/hey_arnold.rb +27 -0
  69. data/lib/faker/tv_shows/how_i_met_your_mother.rb +37 -0
  70. data/lib/faker/tv_shows/michael_scott.rb +13 -0
  71. data/lib/faker/tv_shows/new_girl.rb +19 -0
  72. data/lib/faker/tv_shows/parks_and_rec.rb +18 -0
  73. data/lib/faker/tv_shows/rick_and_morty.rb +28 -0
  74. data/lib/faker/tv_shows/ru_paul.rb +18 -0
  75. data/lib/faker/tv_shows/seinfeld.rb +28 -0
  76. data/lib/faker/tv_shows/silicon_valley.rb +75 -0
  77. data/lib/faker/tv_shows/simpsons.rb +28 -0
  78. data/lib/faker/tv_shows/south_park.rb +19 -0
  79. data/lib/faker/tv_shows/star_trek.rb +36 -0
  80. data/lib/faker/tv_shows/stargate.rb +28 -0
  81. data/lib/faker/tv_shows/stranger_things.rb +19 -0
  82. data/lib/faker/tv_shows/the_expanse.rb +36 -0
  83. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +28 -0
  84. data/lib/faker/tv_shows/the_it_crowd.rb +37 -0
  85. data/lib/faker/tv_shows/the_thick_of_it.rb +28 -0
  86. data/lib/faker/tv_shows/twin_peaks.rb +28 -0
  87. data/lib/faker/tv_shows/venture_bros.rb +38 -0
  88. data/lib/faker/version.rb +1 -1
  89. data/lib/locales/en-CA.yml +1 -0
  90. data/lib/locales/en-TH.yml +360 -0
  91. data/lib/locales/en/color.yml +1 -1
  92. data/lib/locales/en/dr_who.yml +1 -1
  93. data/lib/locales/en/science.yml +1 -1
  94. data/lib/locales/en/super_smash_bros.yml +1 -0
  95. data/lib/locales/fr-CA.yml +1 -1
  96. data/lib/locales/ja.yml +11 -8
  97. data/lib/locales/th.yml +380 -0
  98. metadata +26 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bec55e97c49aba2834c60f979ddfbbba32d561b6300640059e10b74f4f64a11
4
- data.tar.gz: 60197e5cfab12ef29607bfb817a86fb14db6757d3868afbc5dd2a2751412e070
3
+ metadata.gz: 6cacd4170df63c267efee25b7e575509b1ff16528a143a916e90c6381bd48a8b
4
+ data.tar.gz: 7165d20574c9994f703d6c5b473b42125c27421754c7e387e3d34d5c174307e7
5
5
  SHA512:
6
- metadata.gz: 6163f75344392f843e01d14ff8ddb484c40ad7b8b055a1e7a3be1cfebb972b5e5244ac4f61b424862d997bee39c4d3b61d1b605aebad6f6534e771acb32ca380
7
- data.tar.gz: 93310c967dc3daa9a664d456978a636b7bc01122fbbe4a1c565206db401bfcdadee214d01c0e4b2b22be4c001cdf255de5f46762df2cb16d9f4e5fcb2c006418
6
+ metadata.gz: 5fc24fc4438f8737f09597f0f8b7be162f5d609c3e8b7799423eae173635d0762688f51e4790e915913e6e263ba9dbb45f6f02829f4ff5cf1fab724e4118acbd
7
+ data.tar.gz: ca6e471b882bca1b98ab777d6dfdf8798f4cb061d4c98781a8e93869d979ba8eefdf98541387fa309d745cd67fcb5a91b7adc8a23f647da3c8a705291b5f1989
@@ -1,5 +1,121 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.7.0](https://github.com/faker-ruby/faker/tree/v2.7.0) (2019-11-01)
4
+
5
+ This version:
6
+ - adds `Faker::IDNumber.chilean_id`
7
+ - updates some translations/locales
8
+ - updates local dependencies
9
+ - adds SemVer badge
10
+
11
+ ## Documentation
12
+
13
+ - [PR #1814](https://github.com/faker-ruby/faker/pull/1814) Add Discord link [@vbrazo](https://github.com/vbrazo)
14
+ - [PR #1289](https://github.com/faker-ruby/faker/pull/1289) Add SemVer compatibility badge to README [@greysteil](https://github.com/greysteil)
15
+
16
+ ## Feature Request
17
+
18
+ - [PR #1819](https://github.com/faker-ruby/faker/pull/1819) Adding chilean_id in Faker::IDNumber [@cristofer](https://github.com/cristofer)
19
+
20
+ ## Update locales
21
+
22
+ - [PR #1824](https://github.com/faker-ruby/faker/pull/1824) Added Canadian Country Code [@clinch](https://github.com/clinch)
23
+ - [PR #1817](https://github.com/faker-ruby/faker/pull/1817) Add Japanese animal names [@shouichi](https://github.com/shouichi)
24
+ - [PR #1816](https://github.com/faker-ruby/faker/pull/1816) Add Japanese bank names [@shouichi](https://github.com/shouichi)
25
+ - [PR #1813](https://github.com/faker-ruby/faker/pull/1813) Translate Canadian provinces for fr-CA [@Bhacaz](https://github.com/Bhacaz)
26
+ - [PR #1806](https://github.com/faker-ruby/faker/pull/1806) Add Terry Bogard to Super Smash Bros. options [@clinch](https://github.com/clinch)
27
+
28
+ ## Update local dependencies
29
+
30
+ - Update rubocop requirement from = 0.75.0 to = 0.75.1 (#1811)
31
+ - Update rubocop requirement from = 0.75.1 to = 0.76.0 (#1822)
32
+ - Update minitest requirement from = 5.12.2 to = 5.13.0 (#1823)
33
+
34
+ ------------------------------------------------------------------------------
35
+
36
+ ## [v2.6.0](https://github.com/faker-ruby/faker/tree/v2.6.0) (2019-10-10)
37
+
38
+ This version:
39
+ - adds `Faker::Date.in_date_period`
40
+ - adds `Faker::WorldCup` YARD docs
41
+ - updates local dependencies
42
+
43
+ ## Documentation
44
+
45
+ - [PR #1789](https://github.com/faker-ruby/faker/pull/1789) Faker::WorldCup YARD docs [@ashishra0](https://github.com/ashishra0)
46
+
47
+ ## Feature Request
48
+
49
+ - [PR #1755](https://github.com/faker-ruby/faker/pull/1755) Add Faker::Date.in_date_period [@AmrAdelKhalil](https://github.com/AmrAdelKhalil)
50
+
51
+ ## Update local dependencies
52
+
53
+ The following development dependencies were updated:
54
+ - Update rake requirement from = 12.3.3 to = 13.0.0 (#1776)
55
+ - Update minitest requirement from = 5.12.0 to = 5.12.2 (#1775)
56
+ - Update test-unit requirement from = 3.3.3 to = 3.3.4 (#1774)
57
+
58
+ ------------------------------------------------------------------------------
59
+
60
+ ## [v2.5.0](https://github.com/faker-ruby/faker/tree/v2.5.0) (2019-30-09)
61
+
62
+ This version introduces:
63
+ - locales for Thai language - the mother language in Thailand
64
+ - YARD documentation for faker interfaces
65
+ - locales updates or fixes
66
+
67
+ ## Feature Request
68
+
69
+ - [PR #1773](https://github.com/faker-ruby/faker/pull/1773) Two new locales added: th and en-th [@kodram](https://github.com/kodram)
70
+
71
+ ## Documentation
72
+
73
+ - [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)
74
+ - [PR #1767](https://github.com/faker-ruby/faker/pull/1767) Fix two incorrect flexible method calls. [@connorshea](https://github.com/connorshea)
75
+ - [PR #1761](https://github.com/faker-ruby/faker/pull/1761) Add YARD docs for the Basketball and Football fakers. [@connorshea](https://github.com/connorshea)
76
+ - [PR #1768](https://github.com/faker-ruby/faker/pull/1768) Add YARD docs for Faker::Restaurant. [@connorshea](https://github.com/connorshea)
77
+ - [PR #1759](https://github.com/faker-ruby/faker/pull/1759) Add YARD docs for all remaining TV Shows [@connorshea](https://github.com/connorshea)
78
+ - [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)
79
+ - [PR #1756](https://github.com/faker-ruby/faker/pull/1756) Add more miscellaneous YARD docs [@connorshea](https://github.com/connorshea)
80
+ - [PR #1753](https://github.com/faker-ruby/faker/pull/1753) Add YARD docs for Date, Time, and Number [@connorshea](https://github.com/connorshea)
81
+
82
+ ## Update locales
83
+
84
+ - [PR #1764](https://github.com/faker-ruby/faker/pull/1764) Remove "mint green" from color [@ro-savage](https://github.com/ro-savage)
85
+ - [PR #1751](https://github.com/faker-ruby/faker/pull/1751) fix from Color.name to Color.color_name [@4geru](https://github.com/4geru)
86
+
87
+ ## Update local dependencies
88
+
89
+ The following development dependencies were updated:
90
+ - Update minitest requirement from = 5.11.3 to = 5.12.0 (#1763)
91
+
92
+ ------------------------------------------------------------------------------
93
+
94
+ ## [v2.4.0](https://github.com/faker-ruby/faker/tree/v2.4.0) (2019-19-09)
95
+
96
+ ## Documentation
97
+
98
+ - [PR #1750](https://github.com/faker-ruby/faker/pull/1750) add only japanese word spec [@4geru](https://github.com/4geru)
99
+ - [PR #1740](https://github.com/faker-ruby/faker/pull/1740) Add more YARD docs [@connorshea](https://github.com/connorshea)
100
+ - [PR #1747](https://github.com/faker-ruby/faker/pull/1747) Fix PR links [@geniou](https://github.com/geniou)
101
+
102
+ ## Feature Request
103
+
104
+ - [PR #1742](https://github.com/faker-ruby/faker/pull/1742) Add Faker::Blockchain::Aeternity [@2pd](https://github.com/2pd)
105
+
106
+ ## Update locales
107
+
108
+ - [PR #1743](https://github.com/faker-ruby/faker/pull/1743) Fix another ambiguity in element_symbol field [@psibi](https://github.com/psibi)
109
+ - [PR #1748](https://github.com/faker-ruby/faker/pull/1748) fix typo from bread to breed [@4geru](https://github.com/4geru)
110
+ - [PR #1752](https://github.com/faker-ruby/faker/pull/1752) fix creature i18n path in japanese [@4geru](https://github.com/4geru)
111
+
112
+ ## Update local dependencies
113
+
114
+ The following development dependencies were updated:
115
+ - Update simplecov requirement from = 0.17.0 to = 0.17.1 (#1749)
116
+
117
+ ------------------------------------------------------------------------------
118
+
3
119
  ## [v2.3.0](https://github.com/faker-ruby/faker/tree/v2.3.0) (2019-12-09)
4
120
 
5
121
  ## Documentation
@@ -14,8 +130,8 @@
14
130
 
15
131
  ## Update locales
16
132
 
17
- - [PR #1732](https://github.com/faker-ruby/faker/pull/1732) Add pokemon name in Johto area [@mathieujobin](https://github.com/mathieujobin)
18
- - [PR #1723](https://github.com/faker-ruby/faker/pull/1723) Quebec province postal codes starts by [GHJ], adding missing two [@Ryutooooo](https://github.com/Ryutooooo)
133
+ - [PR #1723](https://github.com/faker-ruby/faker/pull/1723) Add pokemon name in Johto area [@mathieujobin](https://github.com/mathieujobin)
134
+ - [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)
19
135
 
20
136
  ------------------------------------------------------------------------------
21
137
 
data/README.md CHANGED
@@ -4,9 +4,10 @@
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
+ [![SemVer compatibility](https://api.dependabot.com/badges/compatibility_score?dependency-name=faker&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=faker&package-manager=bundler&version-scheme=semver)
10
11
 
11
12
  This gem is a port of [Perl's Data::Faker library](https://metacpan.org/pod/Data::Faker) that generates fake data.
12
13
 
@@ -211,6 +212,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
211
212
  - [Faker::WorldCup](doc/default/world_cup.md)
212
213
 
213
214
  ### Blockchain
215
+ - [Faker::Blockchain::Aeternity](doc/blockchain/aeternity.md)
214
216
  - [Faker::Blockchain::Bitcoin](doc/blockchain/bitcoin.md)
215
217
  - [Faker::Blockchain::Ethereum](doc/blockchain/ethereum.md)
216
218
  - [Faker::Blockchain::Tezos](doc/blockchain/tezos.md)
@@ -359,5 +361,7 @@ See [CONTRIBUTING.md](https://github.com/stympy/faker/blob/master/CONTRIBUTING.m
359
361
  ## Contact
360
362
  Comments and feedback are welcome. Send an email to Benjamin Curtis via the [google group](http://groups.google.com/group/ruby-faker).
361
363
 
364
+ You can also join our [discord channel](https://discord.gg/RMumTwB) to discuss anything regarding improvements or feature requests.
365
+
362
366
  ## License
363
367
  This code is free to use under the terms of the MIT license.
@@ -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
@@ -42,6 +42,8 @@ module Faker
42
42
  parse('app.author')
43
43
  end
44
44
 
45
+ # rubocop:disable Metrics/ParameterLists
46
+
45
47
  ##
46
48
  # Produces a String representing a semantic version identifier.
47
49
  #
@@ -60,7 +62,6 @@ module Faker
60
62
  # Faker::App.semantic_version(patch: 5..6) #=> "7.2.6"
61
63
  #
62
64
  # @faker.version 1.4.3
63
- # rubocop:disable Metrics/ParameterLists
64
65
  def semantic_version(legacy_major = NOT_GIVEN, legacy_minor = NOT_GIVEN, legacy_patch = NOT_GIVEN, major: 0..9, minor: 0..9, patch: 1..9)
65
66
  # rubocop:enable Metrics/ParameterLists
66
67
  warn_for_deprecated_arguments do |keywords|
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class Appliance < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of an appliance brand.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Appliance.brand #=> "Bosch"
13
+ #
14
+ # @faker.version 1.9.0
6
15
  def brand
7
16
  fetch('appliance.brand')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the name of a type of appliance equipment.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Appliance.equipment #=> "Appliance plug"
26
+ #
27
+ # @faker.version 1.9.0
10
28
  def equipment
11
29
  fetch('appliance.equipment')
12
30
  end
@@ -6,6 +6,8 @@ module Faker
6
6
  # @private
7
7
  SUPPORTED_FORMATS = %w[png jpg bmp].freeze
8
8
 
9
+ # rubocop:disable Metrics/ParameterLists
10
+
9
11
  ##
10
12
  # Produces a URL for an avatar from robohash.org
11
13
  #
@@ -36,7 +38,6 @@ module Faker
36
38
  # #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1&bgset=bg1"
37
39
  #
38
40
  # @faker.version 1.4.3
39
- # rubocop:disable Metrics/ParameterLists
40
41
  def image(legacy_slug = NOT_GIVEN, legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_set = NOT_GIVEN, legacy_bgset = NOT_GIVEN, slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil)
41
42
  # rubocop:enable Metrics/ParameterLists
42
43
  warn_for_deprecated_arguments do |keywords|
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Faker
4
4
  class ChuckNorris < Base
5
- flexible :name
5
+ flexible :chuck_norris
6
6
 
7
7
  class << self
8
8
  # from: https://github.com/jenkinsci/chucknorris-plugin/blob/master/src/main/java/hudson/plugins/chucknorris/FactGenerator.java
@@ -3,6 +3,18 @@
3
3
  module Faker
4
4
  class Date < Base
5
5
  class << self
6
+ ##
7
+ # Produce a random date between two dates.
8
+ #
9
+ # @param from [Date] The start of the usable date range.
10
+ # @param to [Date] The end of the usable date range.
11
+ # @return [Date]
12
+ #
13
+ # @example
14
+ # Faker::Date.between(from: 2.days.ago, to: Date.today)
15
+ # #=> #<Date: 2014-09-24>
16
+ #
17
+ # @faker.version 1.0.0
6
18
  def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:)
7
19
  warn_for_deprecated_arguments do |keywords|
8
20
  keywords << :from if legacy_from != NOT_GIVEN
@@ -16,8 +28,21 @@ module Faker
16
28
  end
17
29
 
18
30
  # rubocop:disable Metrics/ParameterLists
31
+
32
+ ##
33
+ # Produce a random date between two dates.
34
+ #
35
+ # @param from [Date] The start of the usable date range.
36
+ # @param to [Date] The end of the usable date range.
37
+ # @param excepted [Date] A date to exclude.
38
+ # @return [Date]
39
+ #
40
+ # @example
41
+ # Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today)
42
+ # #=> #<Date: 2014-10-03>
43
+ #
44
+ # @faker.version 1.6.2
19
45
  def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:)
20
- # rubocop:enable Metrics/ParameterLists
21
46
  warn_for_deprecated_arguments do |keywords|
22
47
  keywords << :from if legacy_from != NOT_GIVEN
23
48
  end
@@ -37,7 +62,18 @@ module Faker
37
62
  break date.to_date if date != excepted
38
63
  end
39
64
  end
40
-
65
+ # rubocop:enable Metrics/ParameterLists
66
+
67
+ ##
68
+ # Produce a random date in the future (up to N days).
69
+ #
70
+ # @param days [Integer] The maximum number of days to go into the future.
71
+ # @return [Date]
72
+ #
73
+ # @example
74
+ # Faker::Date.forward(days: 23) #=> #<Date: 2014-10-03>
75
+ #
76
+ # @faker.version 1.0.0
41
77
  def forward(legacy_days = NOT_GIVEN, days: 365)
42
78
  warn_for_deprecated_arguments do |keywords|
43
79
  keywords << :days if legacy_days != NOT_GIVEN
@@ -49,6 +85,16 @@ module Faker
49
85
  between(from: from, to: to).to_date
50
86
  end
51
87
 
88
+ ##
89
+ # Produce a random date in the past (up to N days).
90
+ #
91
+ # @param days [Integer] The maximum number of days to go into the past.
92
+ # @return [Date]
93
+ #
94
+ # @example
95
+ # Faker::Date.backward(days: 14) #=> #<Date: 2019-09-12>
96
+ #
97
+ # @faker.version 1.0.0
52
98
  def backward(legacy_days = NOT_GIVEN, days: 365)
53
99
  warn_for_deprecated_arguments do |keywords|
54
100
  keywords << :days if legacy_days != NOT_GIVEN
@@ -60,6 +106,17 @@ module Faker
60
106
  between(from: from, to: to).to_date
61
107
  end
62
108
 
109
+ ##
110
+ # Produce a random date in the past (up to N days).
111
+ #
112
+ # @param min_age [Integer] The minimum age that the birthday would imply.
113
+ # @param max_age [Integer] The maximum age that the birthday would imply.
114
+ # @return [Date]
115
+ #
116
+ # @example
117
+ # Faker::Date.birthday(min_age: 18, max_age: 65) #=> #<Date: 1986-03-28>
118
+ #
119
+ # @faker.version 1.4.3
63
120
  def birthday(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
64
121
  warn_for_deprecated_arguments do |keywords|
65
122
  keywords << :min_age if legacy_min_age != NOT_GIVEN
@@ -76,6 +133,30 @@ module Faker
76
133
  between(from: from, to: to).to_date
77
134
  end
78
135
 
136
+ ##
137
+ # Produces a date in the year and/or month specified.
138
+ #
139
+ # @param month [Integer] represents the month of the date
140
+ # @param year [Integer] represents the year of the date
141
+ # @return [Date]
142
+ #
143
+ # @example
144
+ # Faker::Date.in_date_period #=> #<Date: 2019-09-01>
145
+ #
146
+ # @example
147
+ # Faker::Date.in_date_period(year: 2018, month: 2) #=> #<Date: 2018-02-26>
148
+ #
149
+ # @example
150
+ # Faker::Date.in_date_period(month: 2) #=> #<Date: 2019-02-26>
151
+ #
152
+ # @faker.version next
153
+ def in_date_period(month: nil, year: ::Date.today.year)
154
+ from = ::Date.new(year, month || 1, 1)
155
+ to = ::Date.new(year, month || 12, ::Date.civil(year, month || 12, -1).day)
156
+
157
+ between(from: from, to: to).to_date
158
+ end
159
+
79
160
  private
80
161
 
81
162
  def birthday_date(date, age)
@@ -5,14 +5,41 @@ module Faker
5
5
  flexible :dessert
6
6
 
7
7
  class << self
8
+ ##
9
+ # Produces the name of a dessert variety.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Dessert.variety #=> "Cake"
15
+ #
16
+ # @faker.version 1.8.0
8
17
  def variety
9
18
  fetch('dessert.variety')
10
19
  end
11
20
 
21
+ ##
22
+ # Produces the name of a dessert topping.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Dessert.topping #=> "Gummy Bears"
28
+ #
29
+ # @faker.version 1.8.0
12
30
  def topping
13
31
  fetch('dessert.topping')
14
32
  end
15
33
 
34
+ ##
35
+ # Produces the name of a dessert flavor.
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::Dessert.flavor #=> "Salted Caramel"
41
+ #
42
+ # @faker.version 1.8.0
16
43
  def flavor
17
44
  fetch('dessert.flavor')
18
45
  end