faker 2.1.2 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -7
  3. data/README.md +2 -2
  4. data/lib/faker.rb +22 -1
  5. data/lib/faker/books/dune.rb +12 -2
  6. data/lib/faker/books/lovecraft.rb +54 -7
  7. data/lib/faker/default/address.rb +30 -5
  8. data/lib/faker/default/alphanumeric.rb +45 -7
  9. data/lib/faker/default/app.rb +16 -1
  10. data/lib/faker/default/avatar.rb +24 -1
  11. data/lib/faker/default/bank.rb +12 -2
  12. data/lib/faker/default/boolean.rb +6 -1
  13. data/lib/faker/default/chile_rut.rb +20 -2
  14. data/lib/faker/default/code.rb +22 -3
  15. data/lib/faker/default/commerce.rb +26 -3
  16. data/lib/faker/default/company.rb +12 -2
  17. data/lib/faker/default/crypto_coin.rb +18 -3
  18. data/lib/faker/default/date.rb +48 -5
  19. data/lib/faker/default/demographic.rb +6 -1
  20. data/lib/faker/default/driving_licence.rb +20 -4
  21. data/lib/faker/default/file.rb +36 -2
  22. data/lib/faker/default/fillmurray.rb +16 -1
  23. data/lib/faker/default/finance.rb +6 -1
  24. data/lib/faker/default/hipster.rb +78 -6
  25. data/lib/faker/default/id_number.rb +12 -2
  26. data/lib/faker/default/internet.rb +124 -13
  27. data/lib/faker/default/invoice.rb +22 -3
  28. data/lib/faker/default/json.rb +26 -2
  29. data/lib/faker/default/lorem.rb +120 -10
  30. data/lib/faker/default/lorem_flickr.rb +69 -5
  31. data/lib/faker/default/lorem_pixel.rb +26 -1
  32. data/lib/faker/default/markdown.rb +10 -1
  33. data/lib/faker/default/measurement.rb +48 -8
  34. data/lib/faker/default/name.rb +6 -1
  35. data/lib/faker/default/nhs.rb +6 -1
  36. data/lib/faker/default/number.rb +81 -11
  37. data/lib/faker/default/omniauth.rb +84 -5
  38. data/lib/faker/default/phone_number.rb +6 -1
  39. data/lib/faker/default/placeholdit.rb +24 -1
  40. data/lib/faker/default/relationship.rb +6 -1
  41. data/lib/faker/default/source.rb +22 -3
  42. data/lib/faker/default/string.rb +6 -1
  43. data/lib/faker/default/stripe.rb +24 -4
  44. data/lib/faker/default/time.rb +68 -4
  45. data/lib/faker/default/twitter.rb +26 -3
  46. data/lib/faker/default/types.rb +38 -5
  47. data/lib/faker/default/vehicle.rb +22 -3
  48. data/lib/faker/default/world_cup.rb +16 -2
  49. data/lib/faker/games/dota.rb +6 -1
  50. data/lib/faker/movies/star_wars.rb +6 -1
  51. data/lib/faker/version.rb +1 -1
  52. metadata +5 -5
@@ -5,23 +5,87 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_COLORIZATIONS = %w[red green blue].freeze
7
7
 
8
- def image(size: '300x300', search_terms: [], match_all: false)
8
+ # rubocop:disable Metrics/ParameterLists
9
+ def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false)
10
+ # rubocop:enable Metrics/ParameterLists
11
+ if legacy_size != NOT_GIVEN
12
+ warn_with_uplevel 'Passing `size` with the 1st argument of `LoremFlickr.image` is deprecated. Use keyword argument like `LoremFlickr.image(size: ...)` instead.', uplevel: 1
13
+ size = legacy_size
14
+ end
15
+ if legacy_search_terms != NOT_GIVEN
16
+ warn_with_uplevel 'Passing `search_terms` with the 2nd argument of `LoremFlickr.image` is deprecated. Use keyword argument like `LoremFlickr.image(search_terms: ...)` instead.', uplevel: 1
17
+ search_terms = legacy_search_terms
18
+ end
19
+ if legacy_match_all != NOT_GIVEN
20
+ warn_with_uplevel 'Passing `match_all` with the 3rd argument of `LoremFlickr.image` is deprecated. Use keyword argument like `LoremFlickr.image(match_all: ...)` instead.', uplevel: 1
21
+ match_all = legacy_match_all
22
+ end
23
+
9
24
  build_url(size, nil, search_terms, match_all)
10
25
  end
11
26
 
12
- def grayscale_image(size: '300x300', search_terms: ['all'], match_all: false)
27
+ # rubocop:disable Metrics/ParameterLists
28
+ def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
29
+ # rubocop:enable Metrics/ParameterLists
30
+ if legacy_size != NOT_GIVEN
31
+ warn_with_uplevel 'Passing `size` with the 1st argument of `LoremFlickr.grayscale_image` is deprecated. Use keyword argument like `LoremFlickr.grayscale_image(size: ...)` instead.', uplevel: 1
32
+ size = legacy_size
33
+ end
34
+ if legacy_search_terms != NOT_GIVEN
35
+ warn_with_uplevel 'Passing `search_terms` with the 2nd argument of `LoremFlickr.grayscale_image` is deprecated. Use keyword argument like `LoremFlickr.grayscale_image(search_terms: ...)` instead.', uplevel: 1
36
+ search_terms = legacy_search_terms
37
+ end
38
+ if legacy_match_all != NOT_GIVEN
39
+ warn_with_uplevel 'Passing `match_all` with the 3rd argument of `LoremFlickr.grayscale_image` is deprecated. Use keyword argument like `LoremFlickr.grayscale_image(match_all: ...)` instead.', uplevel: 1
40
+ match_all = legacy_match_all
41
+ end
42
+
13
43
  raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any?
14
44
 
15
45
  build_url(size, 'g', search_terms, match_all)
16
46
  end
17
47
 
18
- def pixelated_image(size: '300x300', search_terms: ['all'], match_all: false)
48
+ # rubocop:disable Metrics/ParameterLists
49
+ def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
50
+ # rubocop:enable Metrics/ParameterLists
51
+ if legacy_size != NOT_GIVEN
52
+ warn_with_uplevel 'Passing `size` with the 1st argument of `LoremFlickr.pixelated_image` is deprecated. Use keyword argument like `LoremFlickr.pixelated_image(size: ...)` instead.', uplevel: 1
53
+ size = legacy_size
54
+ end
55
+ if legacy_search_terms != NOT_GIVEN
56
+ warn_with_uplevel 'Passing `search_terms` with the 2nd argument of `LoremFlickr.pixelated_image` is deprecated. Use keyword argument like `LoremFlickr.pixelated_image(search_terms: ...)` instead.', uplevel: 1
57
+ search_terms = legacy_search_terms
58
+ end
59
+ if legacy_match_all != NOT_GIVEN
60
+ warn_with_uplevel 'Passing `match_all` with the 3rd argument of `LoremFlickr.pixelated_image` is deprecated. Use keyword argument like `LoremFlickr.pixelated_image(match_all: ...)` instead.', uplevel: 1
61
+ match_all = legacy_match_all
62
+ end
63
+
19
64
  raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any?
20
65
 
21
66
  build_url(size, 'p', search_terms, match_all)
22
67
  end
23
68
 
24
- def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
69
+ # rubocop:disable Metrics/ParameterLists
70
+ def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
71
+ # rubocop:enable Metrics/ParameterLists
72
+ if legacy_size != NOT_GIVEN
73
+ warn_with_uplevel 'Passing `size` with the 1st argument of `LoremFlickr.colorized_image` is deprecated. Use keyword argument like `LoremFlickr.colorized_image(size: ...)` instead.', uplevel: 1
74
+ size = legacy_size
75
+ end
76
+ if legacy_color != NOT_GIVEN
77
+ warn_with_uplevel 'Passing `color` with the 2nd argument of `LoremFlickr.colorized_image` is deprecated. Use keyword argument like `LoremFlickr.colorized_image(color: ...)` instead.', uplevel: 1
78
+ color = legacy_color
79
+ end
80
+ if legacy_search_terms != NOT_GIVEN
81
+ warn_with_uplevel 'Passing `search_terms` with the 3rd argument of `LoremFlickr.colorized_image` is deprecated. Use keyword argument like `LoremFlickr.colorized_image(search_terms: ...)` instead.', uplevel: 1
82
+ search_terms = legacy_search_terms
83
+ end
84
+ if legacy_match_all != NOT_GIVEN
85
+ warn_with_uplevel 'Passing `match_all` with the 4th argument of `LoremFlickr.colorized_image` is deprecated. Use keyword argument like `LoremFlickr.colorized_image(match_all: ...)` instead.', uplevel: 1
86
+ match_all = legacy_match_all
87
+ end
88
+
25
89
  raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any?
26
90
  raise ArgumentError, "Supported colorizations are #{SUPPORTED_COLORIZATIONS.join(', ')}" unless SUPPORTED_COLORIZATIONS.include?(color)
27
91
 
@@ -33,7 +97,7 @@ module Faker
33
97
  def build_url(size, format, search_terms, match_all)
34
98
  raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
35
99
 
36
- url_parts = ['http://loremflickr.com']
100
+ url_parts = ['https://loremflickr.com']
37
101
  url_parts << format
38
102
  url_parts += size.split('x')
39
103
  url_parts << search_terms.compact.join(',') if search_terms.any?
@@ -18,7 +18,32 @@ module Faker
18
18
  transport].freeze
19
19
 
20
20
  # rubocop:disable Metrics/ParameterLists
21
- def image(size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true)
21
+ def image(legacy_size = NOT_GIVEN, legacy_is_gray = NOT_GIVEN, legacy_category = NOT_GIVEN, legacy_number = NOT_GIVEN, legacy_text = NOT_GIVEN, legacy_secure = NOT_GIVEN, size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true)
22
+ if legacy_size != NOT_GIVEN
23
+ warn_with_uplevel 'Passing `size` with the 1st argument of `LoremPixel.image` is deprecated. Use keyword argument like `LoremPixel.image(size: ...)` instead.', uplevel: 1
24
+ size = legacy_size
25
+ end
26
+ if legacy_is_gray != NOT_GIVEN
27
+ warn_with_uplevel 'Passing `is_gray` with the 2nd argument of `LoremPixel.image` is deprecated. Use keyword argument like `LoremPixel.image(is_gray: ...)` instead.', uplevel: 1
28
+ is_gray = legacy_is_gray
29
+ end
30
+ if legacy_category != NOT_GIVEN
31
+ warn_with_uplevel 'Passing `category` with the 3rd argument of `LoremPixel.image` is deprecated. Use keyword argument like `LoremPixel.image(category: ...)` instead.', uplevel: 1
32
+ category = legacy_category
33
+ end
34
+ if legacy_number != NOT_GIVEN
35
+ warn_with_uplevel 'Passing `number` with the 4th argument of `LoremPixel.image` is deprecated. Use keyword argument like `LoremPixel.image(number: ...)` instead.', uplevel: 1
36
+ number = legacy_number
37
+ end
38
+ if legacy_text != NOT_GIVEN
39
+ warn_with_uplevel 'Passing `text` with the 5th argument of `LoremPixel.image` is deprecated. Use keyword argument like `LoremPixel.image(text: ...)` instead.', uplevel: 1
40
+ text = legacy_text
41
+ end
42
+ if legacy_secure != NOT_GIVEN
43
+ warn_with_uplevel 'Passing `secure` with the 6th argument of `LoremPixel.image` is deprecated. Use keyword argument like `LoremPixel.image(secure: ...)` instead.', uplevel: 1
44
+ secure = legacy_secure
45
+ end
46
+
22
47
  raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
23
48
  raise ArgumentError, "Supported categories are #{SUPPORTED_CATEGORIES.join(', ')}" unless category.nil? || SUPPORTED_CATEGORIES.include?(category)
24
49
  raise ArgumentError, 'Category required when number is passed' if !number.nil? && category.nil?
@@ -59,7 +59,16 @@ module Faker
59
59
  send(method_list[rand(0..method_list.length - 1)])
60
60
  end
61
61
 
62
- def sandwich(sentences: 3, repeat: 1)
62
+ def sandwich(legacy_sentences = NOT_GIVEN, legacy_repeat = NOT_GIVEN, sentences: 3, repeat: 1)
63
+ if legacy_sentences != NOT_GIVEN
64
+ warn_with_uplevel 'Passing `sentences` with the 1st argument of `Markdown.sandwich` is deprecated. Use keyword argument like `Markdown.sandwich(sentences: ...)` instead.', uplevel: 1
65
+ sentences = legacy_sentences
66
+ end
67
+ if legacy_repeat != NOT_GIVEN
68
+ warn_with_uplevel 'Passing `repeat` with the 2nd argument of `Markdown.sandwich` is deprecated. Use keyword argument like `Markdown.sandwich(repeat: ...)` instead.', uplevel: 1
69
+ repeat = legacy_repeat
70
+ end
71
+
63
72
  text_block = []
64
73
  text_block << headers
65
74
  repeat.times do
@@ -6,35 +6,75 @@ module Faker
6
6
  ALL = 'all'
7
7
  NONE = 'none'
8
8
 
9
- def height(amount: rand(10))
9
+ def height(legacy_amount = NOT_GIVEN, amount: rand(10))
10
+ if legacy_amount != NOT_GIVEN
11
+ warn_with_uplevel 'Passing `amount` with the 1st argument of `Measurement.height` is deprecated. Use keyword argument like `Measurement.height(amount: ...)` instead.', uplevel: 1
12
+ amount = legacy_amount
13
+ end
14
+
10
15
  define_measurement_locale(amount, 'height')
11
16
  end
12
17
 
13
- def length(amount: rand(10))
18
+ def length(legacy_amount = NOT_GIVEN, amount: rand(10))
19
+ if legacy_amount != NOT_GIVEN
20
+ warn_with_uplevel 'Passing `amount` with the 1st argument of `Measurement.length` is deprecated. Use keyword argument like `Measurement.length(amount: ...)` instead.', uplevel: 1
21
+ amount = legacy_amount
22
+ end
23
+
14
24
  define_measurement_locale(amount, 'length')
15
25
  end
16
26
 
17
- def volume(amount: rand(10))
27
+ def volume(legacy_amount = NOT_GIVEN, amount: rand(10))
28
+ if legacy_amount != NOT_GIVEN
29
+ warn_with_uplevel 'Passing `amount` with the 1st argument of `Measurement.volume` is deprecated. Use keyword argument like `Measurement.volume(amount: ...)` instead.', uplevel: 1
30
+ amount = legacy_amount
31
+ end
32
+
18
33
  define_measurement_locale(amount, 'volume')
19
34
  end
20
35
 
21
- def weight(amount: rand(10))
36
+ def weight(legacy_amount = NOT_GIVEN, amount: rand(10))
37
+ if legacy_amount != NOT_GIVEN
38
+ warn_with_uplevel 'Passing `amount` with the 1st argument of `Measurement.weight` is deprecated. Use keyword argument like `Measurement.weight(amount: ...)` instead.', uplevel: 1
39
+ amount = legacy_amount
40
+ end
41
+
22
42
  define_measurement_locale(amount, 'weight')
23
43
  end
24
44
 
25
- def metric_height(amount: rand(10))
45
+ def metric_height(legacy_amount = NOT_GIVEN, amount: rand(10))
46
+ if legacy_amount != NOT_GIVEN
47
+ warn_with_uplevel 'Passing `amount` with the 1st argument of `Measurement.metric_height` is deprecated. Use keyword argument like `Measurement.metric_height(amount: ...)` instead.', uplevel: 1
48
+ amount = legacy_amount
49
+ end
50
+
26
51
  define_measurement_locale(amount, 'metric_height')
27
52
  end
28
53
 
29
- def metric_length(amount: rand(10))
54
+ def metric_length(legacy_amount = NOT_GIVEN, amount: rand(10))
55
+ if legacy_amount != NOT_GIVEN
56
+ warn_with_uplevel 'Passing `amount` with the 1st argument of `Measurement.metric_length` is deprecated. Use keyword argument like `Measurement.metric_length(amount: ...)` instead.', uplevel: 1
57
+ amount = legacy_amount
58
+ end
59
+
30
60
  define_measurement_locale(amount, 'metric_length')
31
61
  end
32
62
 
33
- def metric_volume(amount: rand(10))
63
+ def metric_volume(legacy_amount = NOT_GIVEN, amount: rand(10))
64
+ if legacy_amount != NOT_GIVEN
65
+ warn_with_uplevel 'Passing `amount` with the 1st argument of `Measurement.metric_volume` is deprecated. Use keyword argument like `Measurement.metric_volume(amount: ...)` instead.', uplevel: 1
66
+ amount = legacy_amount
67
+ end
68
+
34
69
  define_measurement_locale(amount, 'metric_volume')
35
70
  end
36
71
 
37
- def metric_weight(amount: rand(10))
72
+ def metric_weight(legacy_amount = NOT_GIVEN, amount: rand(10))
73
+ if legacy_amount != NOT_GIVEN
74
+ warn_with_uplevel 'Passing `amount` with the 1st argument of `Measurement.metric_weight` is deprecated. Use keyword argument like `Measurement.metric_weight(amount: ...)` instead.', uplevel: 1
75
+ amount = legacy_amount
76
+ end
77
+
38
78
  define_measurement_locale(amount, 'metric_weight')
39
79
  end
40
80
 
@@ -46,7 +46,12 @@ module Faker
46
46
  fetch('name.suffix')
47
47
  end
48
48
 
49
- def initials(number: 3)
49
+ def initials(legacy_number = NOT_GIVEN, number: 3)
50
+ if legacy_number != NOT_GIVEN
51
+ warn_with_uplevel 'Passing `number` with the 1st argument of `Name.initials` is deprecated. Use keyword argument like `Name.initials(number: ...)` instead.', uplevel: 1
52
+ number = legacy_number
53
+ end
54
+
50
55
  (0...number).map { rand(65..90).chr }.join
51
56
  end
52
57
  end
@@ -15,7 +15,12 @@ module Faker
15
15
  .join('')
16
16
  end
17
17
 
18
- def check_digit(number: 0)
18
+ def check_digit(legacy_number = NOT_GIVEN, number: 0)
19
+ if legacy_number != NOT_GIVEN
20
+ warn_with_uplevel 'Passing `number` with the 1st argument of `NationalHealthService.check_digit` is deprecated. Use keyword argument like `NationalHealthService.check_digit(number: ...)` instead.', uplevel: 1
21
+ number = legacy_number
22
+ end
23
+
19
24
  sum = 0
20
25
  number.to_s.chars.each_with_index do |digit, idx|
21
26
  position = idx + 1
@@ -3,19 +3,34 @@
3
3
  module Faker
4
4
  class Number < Base
5
5
  class << self
6
- def number(digits: 10)
6
+ def number(legacy_digits = NOT_GIVEN, digits: 10)
7
+ if legacy_digits != NOT_GIVEN
8
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Number.number` is deprecated. Use keyword argument like `Number.number(digits: ...)` instead.', uplevel: 1
9
+ digits = legacy_digits
10
+ end
11
+
7
12
  return if digits < 1
8
- return 0 if digits == 1
13
+ return rand(0..9).round if digits == 1
9
14
 
10
15
  # Ensure the first digit is not zero
11
16
  ([non_zero_digit] + generate(digits - 1)).join.to_i
12
17
  end
13
18
 
14
- def leading_zero_number(digits: 10)
19
+ def leading_zero_number(legacy_digits = NOT_GIVEN, digits: 10)
20
+ if legacy_digits != NOT_GIVEN
21
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Number.leading_zero_number` is deprecated. Use keyword argument like `Number.leading_zero_number(digits: ...)` instead.', uplevel: 1
22
+ digits = legacy_digits
23
+ end
24
+
15
25
  '0' + (2..digits).collect { digit }.join
16
26
  end
17
27
 
18
- def decimal_part(digits: 10)
28
+ def decimal_part(legacy_digits = NOT_GIVEN, digits: 10)
29
+ if legacy_digits != NOT_GIVEN
30
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Number.decimal_part` is deprecated. Use keyword argument like `Number.decimal_part(digits: ...)` instead.', uplevel: 1
31
+ digits = legacy_digits
32
+ end
33
+
19
34
  num = ''
20
35
  if digits > 1
21
36
  num = non_zero_digit
@@ -24,7 +39,16 @@ module Faker
24
39
  leading_zero_number(digits: digits) + num.to_s
25
40
  end
26
41
 
27
- def decimal(l_digits: 5, r_digits: 2)
42
+ def decimal(legacy_l_digits = NOT_GIVEN, legacy_r_digits = NOT_GIVEN, l_digits: 5, r_digits: 2)
43
+ if legacy_l_digits != NOT_GIVEN
44
+ warn_with_uplevel 'Passing `l_digits` with the 1st argument of `Number.decimal` is deprecated. Use keyword argument like `Number.decimal(l_digits: ...)` instead.', uplevel: 1
45
+ l_digits = legacy_l_digits
46
+ end
47
+ if legacy_r_digits != NOT_GIVEN
48
+ warn_with_uplevel 'Passing `r_digits` with the 2nd argument of `Number.decimal` is deprecated. Use keyword argument like `Number.decimal(r_digits: ...)` instead.', uplevel: 1
49
+ r_digits = legacy_r_digits
50
+ end
51
+
28
52
  l_d = number(digits: l_digits)
29
53
  r_d = if r_digits == 1
30
54
  generate(r_digits)
@@ -44,34 +68,80 @@ module Faker
44
68
  rand(10)
45
69
  end
46
70
 
47
- def hexadecimal(digits: 6)
71
+ def hexadecimal(legacy_digits = NOT_GIVEN, digits: 6)
72
+ if legacy_digits != NOT_GIVEN
73
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Number.hexadecimal` is deprecated. Use keyword argument like `Number.hexadecimal(digits: ...)` instead.', uplevel: 1
74
+ digits = legacy_digits
75
+ end
76
+
48
77
  hex = ''
49
78
  digits.times { hex += rand(15).to_s(16) }
50
79
  hex
51
80
  end
52
81
 
53
- def normal(mean: 1, standard_deviation: 1)
82
+ def normal(legacy_mean = NOT_GIVEN, legacy_standard_deviation = NOT_GIVEN, mean: 1, standard_deviation: 1)
83
+ if legacy_mean != NOT_GIVEN
84
+ warn_with_uplevel 'Passing `mean` with the 1st argument of `Number.normal` is deprecated. Use keyword argument like `Number.normal(mean: ...)` instead.', uplevel: 1
85
+ mean = legacy_mean
86
+ end
87
+ if legacy_standard_deviation != NOT_GIVEN
88
+ warn_with_uplevel 'Passing `standard_deviation` with the 2nd argument of `Number.normal` is deprecated. Use keyword argument like `Number.normal(standard_deviation: ...)` instead.', uplevel: 1
89
+ standard_deviation = legacy_standard_deviation
90
+ end
91
+
54
92
  theta = 2 * Math::PI * rand
55
93
  rho = Math.sqrt(-2 * Math.log(1 - rand))
56
94
  scale = standard_deviation * rho
57
95
  mean + scale * Math.cos(theta)
58
96
  end
59
97
 
60
- def between(from: 1.00, to: 5000.00)
98
+ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
99
+ if legacy_from != NOT_GIVEN
100
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Number.between` is deprecated. Use keyword argument like `Number.between(from: ...)` instead.', uplevel: 1
101
+ from = legacy_from
102
+ end
103
+ if legacy_to != NOT_GIVEN
104
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Number.between` is deprecated. Use keyword argument like `Number.between(to: ...)` instead.', uplevel: 1
105
+ to = legacy_to
106
+ end
107
+
61
108
  Faker::Base.rand_in_range(from, to)
62
109
  end
63
110
 
64
- def within(range: 1.00..5000.00)
111
+ def within(legacy_range = NOT_GIVEN, range: 1.00..5000.00)
112
+ if legacy_range != NOT_GIVEN
113
+ warn_with_uplevel 'Passing `range` with the 1st argument of `Number.within` is deprecated. Use keyword argument like `Number.within(range: ...)` instead.', uplevel: 1
114
+ range = legacy_range
115
+ end
116
+
65
117
  between(from: range.min, to: range.max)
66
118
  end
67
119
 
68
- def positive(from: 1.00, to: 5000.00)
120
+ def positive(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
121
+ if legacy_from != NOT_GIVEN
122
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Number.positive` is deprecated. Use keyword argument like `Number.positive(from: ...)` instead.', uplevel: 1
123
+ from = legacy_from
124
+ end
125
+ if legacy_to != NOT_GIVEN
126
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Number.positive` is deprecated. Use keyword argument like `Number.positive(to: ...)` instead.', uplevel: 1
127
+ to = legacy_to
128
+ end
129
+
69
130
  random_number = between(from: from, to: to)
70
131
 
71
132
  greater_than_zero(random_number)
72
133
  end
73
134
 
74
- def negative(from: -5000.00, to: -1.00)
135
+ def negative(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: -5000.00, to: -1.00)
136
+ if legacy_from != NOT_GIVEN
137
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Number.negative` is deprecated. Use keyword argument like `Number.negative(from: ...)` instead.', uplevel: 1
138
+ from = legacy_from
139
+ end
140
+ if legacy_to != NOT_GIVEN
141
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Number.negative` is deprecated. Use keyword argument like `Number.negative(to: ...)` instead.', uplevel: 1
142
+ to = legacy_to
143
+ end
144
+
75
145
  random_number = between(from: from, to: to)
76
146
 
77
147
  less_than_zero(random_number)
@@ -15,7 +15,22 @@ module Faker
15
15
  end
16
16
 
17
17
  class << self
18
- def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)
18
+ # rubocop:disable Metrics/ParameterLists
19
+ def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 9).to_s)
20
+ # rubocop:enable Metrics/ParameterLists
21
+ if legacy_name != NOT_GIVEN
22
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(name: ...)` instead.', uplevel: 1
23
+ name = legacy_name
24
+ end
25
+ if legacy_email != NOT_GIVEN
26
+ warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(email: ...)` instead.', uplevel: 1
27
+ email = legacy_email
28
+ end
29
+ if legacy_uid != NOT_GIVEN
30
+ warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(uid: ...)` instead.', uplevel: 1
31
+ uid = legacy_uid
32
+ end
33
+
19
34
  auth = Omniauth.new(name: name, email: email)
20
35
  {
21
36
  provider: 'google_oauth2',
@@ -64,7 +79,26 @@ module Faker
64
79
  }
65
80
  end
66
81
 
67
- def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
82
+ # rubocop:disable Metrics/ParameterLists
83
+ def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
84
+ # rubocop:enable Metrics/ParameterLists
85
+ if legacy_name != NOT_GIVEN
86
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(name: ...)` instead.', uplevel: 1
87
+ name = legacy_name
88
+ end
89
+ if legacy_email != NOT_GIVEN
90
+ warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(email: ...)` instead.', uplevel: 1
91
+ email = legacy_email
92
+ end
93
+ if legacy_username != NOT_GIVEN
94
+ warn_with_uplevel 'Passing `username` with the 3rd argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(username: ...)` instead.', uplevel: 1
95
+ username = legacy_username
96
+ end
97
+ if legacy_uid != NOT_GIVEN
98
+ warn_with_uplevel 'Passing `uid` with the 4th argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(uid: ...)` instead.', uplevel: 1
99
+ uid = legacy_uid
100
+ end
101
+
68
102
  auth = Omniauth.new(name: name, email: email)
69
103
  username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
70
104
  {
@@ -106,7 +140,22 @@ module Faker
106
140
  }
107
141
  end
108
142
 
109
- def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
143
+ # rubocop:disable Metrics/ParameterLists
144
+ def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
145
+ # rubocop:enable Metrics/ParameterLists
146
+ if legacy_name != NOT_GIVEN
147
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(name: ...)` instead.', uplevel: 1
148
+ name = legacy_name
149
+ end
150
+ if legacy_nickname != NOT_GIVEN
151
+ warn_with_uplevel 'Passing `nickname` with the 2nd argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(nickname: ...)` instead.', uplevel: 1
152
+ nickname = legacy_nickname
153
+ end
154
+ if legacy_uid != NOT_GIVEN
155
+ warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(uid: ...)` instead.', uplevel: 1
156
+ uid = legacy_uid
157
+ end
158
+
110
159
  auth = Omniauth.new(name: name)
111
160
  nickname ||= auth.name.downcase.delete(' ')
112
161
  location = city_state
@@ -179,7 +228,22 @@ module Faker
179
228
  }
180
229
  end
181
230
 
182
- def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s)
231
+ # rubocop:disable Metrics/ParameterLists
232
+ def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 6).to_s)
233
+ # rubocop:enable Metrics/ParameterLists
234
+ if legacy_name != NOT_GIVEN
235
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(name: ...)` instead.', uplevel: 1
236
+ name = legacy_name
237
+ end
238
+ if legacy_email != NOT_GIVEN
239
+ warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(email: ...)` instead.', uplevel: 1
240
+ email = legacy_email
241
+ end
242
+ if legacy_uid != NOT_GIVEN
243
+ warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(uid: ...)` instead.', uplevel: 1
244
+ uid = legacy_uid
245
+ end
246
+
183
247
  auth = Omniauth.new(name: name, email: email)
184
248
  first_name = auth.first_name.downcase
185
249
  last_name = auth.last_name.downcase
@@ -242,7 +306,22 @@ module Faker
242
306
  }
243
307
  end
244
308
 
245
- def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s)
309
+ # rubocop:disable Metrics/ParameterLists
310
+ def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 8).to_s)
311
+ # rubocop:enable Metrics/ParameterLists
312
+ if legacy_name != NOT_GIVEN
313
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(name: ...)` instead.', uplevel: 1
314
+ name = legacy_name
315
+ end
316
+ if legacy_email != NOT_GIVEN
317
+ warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(email: ...)` instead.', uplevel: 1
318
+ email = legacy_email
319
+ end
320
+ if legacy_uid != NOT_GIVEN
321
+ warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(uid: ...)` instead.', uplevel: 1
322
+ uid = legacy_uid
323
+ end
324
+
246
325
  auth = Omniauth.new(name: name, email: email)
247
326
  login = auth.name.downcase.tr(' ', '-')
248
327
  html_url = "https://github.com/#{login}"