ffaker 2.16.0 → 2.17.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.
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
11
11
 
12
12
  s.name = 'ffaker'
13
13
  s.version = FFaker::VERSION
14
- s.date = '2020-07-26'
15
- s.required_ruby_version = '>= 2.4'
14
+ s.date = '2020-08-17'
15
+ s.required_ruby_version = '>= 2.5'
16
16
 
17
17
  s.license = 'MIT'
18
18
 
@@ -8,7 +8,7 @@ module FFaker
8
8
 
9
9
  BASE_LIB_PATH = File.expand_path(__dir__)
10
10
 
11
- LETTERS = [*'a'..'z'].freeze
11
+ LETTERS = Array('a'..'z').freeze
12
12
 
13
13
  HEX = %w[0 1 2 3 4 5 6 7 8 9 A B C D E F].freeze
14
14
 
@@ -197,6 +197,7 @@ module FFaker
197
197
  autoload :Unit, 'ffaker/unit'
198
198
  autoload :UnitEnglish, 'ffaker/unit_english'
199
199
  autoload :UnitMetric, 'ffaker/unit_metric'
200
+ autoload :VERSION, 'version'
200
201
  autoload :Vehicle, 'ffaker/vehicle'
201
202
  autoload :Venue, 'ffaker/venue'
202
203
  autoload :Youtube, 'ffaker/youtube'
@@ -1,32 +1,32 @@
1
- flacd
2
- mp3d
3
- wavd
4
- bmpd
5
- gifd
6
- jpegd
7
- jpgd
8
- pngd
9
- tiffd
10
- cssd
11
- csvd
12
- htmld
13
- jsd
14
- jsond
15
- txtd
16
- mp4d
17
- avid
18
- movd
19
- webmd
20
- docd
21
- docxd
22
- xlsd
23
- xlsxd
24
- pptd
25
- pptxd
26
- odtd
27
- odsd
28
- odpd
29
- pagesd
30
- numbersd
31
- keyd
1
+ flac
2
+ mp3
3
+ wav
4
+ bmp
5
+ gif
6
+ jpeg
7
+ jpg
8
+ png
9
+ tiff
10
+ css
11
+ csv
12
+ html
13
+ js
14
+ json
15
+ txt
16
+ mp4
17
+ avi
18
+ mov
19
+ webm
20
+ doc
21
+ docx
22
+ xls
23
+ xlsx
24
+ ppt
25
+ pptx
26
+ odt
27
+ ods
28
+ odp
29
+ pages
30
+ numbers
31
+ key
32
32
  pdf
@@ -5,8 +5,6 @@ module FFaker
5
5
  extend ModuleUtils
6
6
  extend self
7
7
 
8
- SLUG_DELIMITERS = %w[- _ .].freeze
9
-
10
8
  def extension
11
9
  fetch_sample(EXTENSION)
12
10
  end
@@ -15,11 +13,13 @@ module FFaker
15
13
  fetch_sample(MIME_TYPE)
16
14
  end
17
15
 
18
- def file_name(dir = nil, name = nil, ext = nil, directory_separator = '/')
19
- dir ||= Internet.slug
20
- name ||= Lorem.word.downcase
21
- ext ||= extension
22
- [dir, name].join(directory_separator) + ".#{ext}"
16
+ def directory(directory_separator = File::SEPARATOR)
17
+ Lorem.words.join(directory_separator)
18
+ end
19
+
20
+ def file_name(dir = directory, name = Lorem.word.downcase,
21
+ ext = extension, directory_separator = File::SEPARATOR)
22
+ "#{dir}#{directory_separator}#{name}.#{ext}"
23
23
  end
24
24
  end
25
25
  end
@@ -10,7 +10,7 @@ module FFaker
10
10
  def rrn
11
11
  birth = fetch_sample(Date.new(1970, 1, 1)..Date.new(1999, 12, 31)).strftime('%y%d%m')
12
12
  sex = fetch_sample([1, 2])
13
- loc = FFaker.numerify("#{fetch_sample([*'00'..'95'])}###")
13
+ loc = FFaker.numerify("#{fetch_sample(Array('00'..'95'))}###")
14
14
  a, b, c, d, e, f, g, h, i, j, k, l = "#{birth}#{sex}#{loc}".split(//).map(&:to_i)
15
15
  checksum = (11 - (2 * a + 3 * b + 4 * c + 5 * d + 6 * e + 7 * f + 8 * g + 9 * h + 2 * i + 3 * j + 4 * k + 5 * l) % 11) % 10
16
16
  "#{birth}-#{sex}#{loc}#{checksum}"
@@ -9,7 +9,7 @@ module FFaker
9
9
 
10
10
  CONSONANTS = %w[B C D F G H J K L M N P Q R S T V W X Y Z].freeze
11
11
  VOWELS = %w[A E I O U].freeze
12
- HOMOCLAVE = CONSONANTS + VOWELS + [*'0'..'9']
12
+ HOMOCLAVE = CONSONANTS + VOWELS + Array('0'..'9')
13
13
 
14
14
  # http://es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico)
15
15
  # Registro Federal de Contribuyentes (R.F.C.) para persona física
@@ -5,7 +5,7 @@ module FFaker
5
5
  extend ModuleUtils
6
6
  extend self
7
7
 
8
- BYTE = [*'0'..'255'].freeze
8
+ BYTE = Array('0'..'255').freeze
9
9
  HOSTS = %w[gmail.com yahoo.com hotmail.com].freeze
10
10
  DISPOSABLE_HOSTS = %w[
11
11
  mailinator.com suremail.info spamherelots.com binkmail.com safetymail.info
@@ -9,7 +9,7 @@ module FFaker
9
9
  extend ModuleUtils
10
10
  extend self
11
11
 
12
- BYTE = [*'0'..'255'].freeze
12
+ BYTE = Array('0'..'255').freeze
13
13
  HOSTS = %w[gmail.com yahoo.com hotmail.com spray.se passagen.se].freeze
14
14
  DOMAIN_SUFFIXES = %w[se nu com].freeze
15
15
  DISPOSABLE_HOSTS = %w[
@@ -14,8 +14,8 @@ module FFaker
14
14
 
15
15
  COUNTRY_PREFIX = '+55'
16
16
  AREA_CODE = [
17
- 10..19, 21..22, 24, 27..28, 31..35, 37..38, 41..49,
18
- 51..54, 55, 61..69, 71..75, 77, 79, 81..89, 91..99
17
+ 11..19, 21..22, 24, 27..28, 31..35, 37..38, 41..49,
18
+ 51, 53..55, 61..69, 71, 73..75, 77, 79, 81..89, 91..99
19
19
  ].flat_map { |x| Array(x) }.map(&:to_s).freeze
20
20
 
21
21
  HOME_WORK_PHONE_PREFIX = %w[2 3 4 5].freeze
@@ -16,9 +16,7 @@ module FFaker
16
16
  third_group = rand(1..9999)
17
17
 
18
18
  group_numbers = [first_group, second_group, third_group]
19
- result = format('%.3d-%.2d-%.4d', *group_numbers)
20
-
21
- result
19
+ format('%.3d-%.2d-%.4d', *group_numbers)
22
20
  end
23
21
  end
24
22
  end
@@ -8,10 +8,10 @@ module FFaker
8
8
  BACKSLASH = '\\'
9
9
  DASH = '-'
10
10
 
11
- LOWERS = [*'a'..'z'].freeze
12
- UPPERS = [*'A'..'Z'].freeze
11
+ LOWERS = Array('a'..'z').freeze
12
+ UPPERS = Array('A'..'Z').freeze
13
13
  LETTERS = LOWERS + UPPERS
14
- NUMBERS = [*'0'..'9'].freeze
14
+ NUMBERS = Array('0'..'9').freeze
15
15
  WORD_CHARS = LETTERS + NUMBERS + ['_']
16
16
  SPACES = [' ', "\t"].freeze
17
17
  ESCAPEABLE_CHARS = ['\\', '/', '.', '(', ')', '[', ']', '{', '}'].freeze
@@ -34,7 +34,7 @@ module FFaker
34
34
  while tokens.any?
35
35
  token = tokens.shift
36
36
  if token == DASH && tokens.first && result.last
37
- result += [*result.pop..tokens.shift]
37
+ result += Array(result.pop..tokens.shift)
38
38
  elsif token == BACKSLASH
39
39
  result << special(tokens.shift)
40
40
  else
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ostruct'
4
-
5
3
  module FFaker
6
4
  module Unit
7
5
  extend ModuleUtils
@@ -10,9 +8,10 @@ module FFaker
10
8
  TIME_UNITS = [
11
9
  { name: 'Years', abbreviation: 'yr' },
12
10
  { name: 'Days', abbreviation: 'd' },
13
- { name: 'Hours', abbreviation: 'Minutes' },
11
+ { name: 'Hours', abbreviation: 'h' },
12
+ { name: 'Minutes', abbreviation: 'm' },
14
13
  { name: 'Seconds', abbreviation: 's' },
15
- { name: 'Milliseconds', abbreviation: 'msec' }
14
+ { name: 'Milliseconds', abbreviation: 'ms' }
16
15
  ].freeze
17
16
  TEMPERATURE_UNITS = [
18
17
  { name: 'Kelvin', abbreviation: 'K' },
@@ -21,29 +20,29 @@ module FFaker
21
20
  ].freeze
22
21
 
23
22
  def time_name
24
- time.name
23
+ time[:name]
25
24
  end
26
25
 
27
26
  def time_abbr
28
- time.abbreviation
27
+ time[:abbreviation]
29
28
  end
30
29
 
31
30
  def temperature_name
32
- temperature.name
31
+ temperature[:name]
33
32
  end
34
33
 
35
34
  def temperature_abbr
36
- temperature.abbreviation
35
+ temperature[:abbreviation]
37
36
  end
38
37
 
39
38
  private
40
39
 
41
40
  def time
42
- OpenStruct.new(fetch_sample(TIME_UNITS))
41
+ fetch_sample(TIME_UNITS)
43
42
  end
44
43
 
45
44
  def temperature
46
- OpenStruct.new(fetch_sample(TEMPERATURE_UNITS))
45
+ fetch_sample(TEMPERATURE_UNITS)
47
46
  end
48
47
  end
49
48
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ffaker/unit'
4
- require 'ostruct'
5
4
 
6
5
  module FFaker
7
6
  module UnitEnglish
@@ -15,7 +14,7 @@ module FFaker
15
14
  { name: 'foot', abbreviation: 'ft' },
16
15
  { name: 'yard', abbreviation: 'yd' },
17
16
  { name: 'furlong', abbreviation: 'fur' },
18
- { name: 'mile', abbreviation: 'm' }
17
+ { name: 'mile', abbreviation: 'mi' }
19
18
  ].freeze
20
19
  MASS_UNITS = [
21
20
  { name: 'grains', abbreviation: 'gr' },
@@ -36,75 +35,75 @@ module FFaker
36
35
  { name: 'cubic yard', abbreviation: 'CY' }
37
36
  ].freeze
38
37
  AREA_UNITS = [
39
- { name: 'square inch', abbreviation: 'sq. in' },
38
+ { name: 'square inch', abbreviation: 'sq in' },
40
39
  { name: 'square foot', abbreviation: 'sq ft' },
41
40
  { name: 'square yard', abbreviation: 'sq yd' },
42
41
  { name: 'acre', abbreviation: 'ac' },
43
42
  { name: 'section', abbreviation: 's' },
44
43
  { name: 'square mile', abbreviation: 'sq mi' },
45
- { name: 'township', abbreviation: 'Twp' }
44
+ { name: 'township', abbreviation: 'twp' }
46
45
  ].freeze
47
46
 
48
47
  def mass_name
49
- mass.name
48
+ mass[:name]
50
49
  end
51
50
 
52
51
  def mass_abbr
53
- mass.abbreviation
52
+ mass[:abbreviation]
54
53
  end
55
54
 
56
55
  def length_name
57
- length.name
56
+ length[:name]
58
57
  end
59
58
 
60
59
  def length_abbr
61
- length.abbreviation
60
+ length[:abbreviation]
62
61
  end
63
62
 
64
63
  def liquid_name
65
- liquid.name
64
+ liquid[:name]
66
65
  end
67
66
 
68
67
  def liquid_abbr
69
- liquid.abbreviation
68
+ liquid[:abbreviation]
70
69
  end
71
70
 
72
71
  def volume_name
73
- volume.name
72
+ volume[:name]
74
73
  end
75
74
 
76
75
  def volume_abbr
77
- volume.abbreviation
76
+ volume[:abbreviation]
78
77
  end
79
78
 
80
79
  def area_name
81
- area.name
80
+ area[:name]
82
81
  end
83
82
 
84
83
  def area_abbr
85
- area.abbreviation
84
+ area[:abbreviation]
86
85
  end
87
86
 
88
87
  private
89
88
 
90
89
  def length
91
- OpenStruct.new(fetch_sample(LENGTH_UNITS))
90
+ fetch_sample(LENGTH_UNITS)
92
91
  end
93
92
 
94
93
  def mass
95
- OpenStruct.new(fetch_sample(MASS_UNITS))
94
+ fetch_sample(MASS_UNITS)
96
95
  end
97
96
 
98
97
  def liquid
99
- OpenStruct.new(fetch_sample(LIQUID_UNITS))
98
+ fetch_sample(LIQUID_UNITS)
100
99
  end
101
100
 
102
101
  def volume
103
- OpenStruct.new(fetch_sample(VOLUME_UNITS))
102
+ fetch_sample(VOLUME_UNITS)
104
103
  end
105
104
 
106
105
  def area
107
- OpenStruct.new(fetch_sample(AREA_UNITS))
106
+ fetch_sample(AREA_UNITS)
108
107
  end
109
108
  end
110
109
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ffaker/unit'
4
- require 'ostruct'
5
4
 
6
5
  module FFaker
7
6
  module UnitMetric
@@ -37,65 +36,65 @@ module FFaker
37
36
  ].freeze
38
37
 
39
38
  def mass_name
40
- mass.name
39
+ mass[:name]
41
40
  end
42
41
 
43
42
  def mass_abbr
44
- mass.abbreviation
43
+ mass[:abbreviation]
45
44
  end
46
45
 
47
46
  def length_name
48
- length.name
47
+ length[:name]
49
48
  end
50
49
 
51
50
  def length_abbr
52
- length.abbreviation
51
+ length[:abbreviation]
53
52
  end
54
53
 
55
54
  def liquid_name
56
- liquid.name
55
+ liquid[:name]
57
56
  end
58
57
 
59
58
  def liquid_abbr
60
- liquid.abbreviation
59
+ liquid[:abbreviation]
61
60
  end
62
61
 
63
62
  def volume_name
64
- volume.name
63
+ volume[:name]
65
64
  end
66
65
 
67
66
  def volume_abbr
68
- volume.abbreviation
67
+ volume[:abbreviation]
69
68
  end
70
69
 
71
70
  def area_name
72
- area.name
71
+ area[:name]
73
72
  end
74
73
 
75
74
  def area_abbr
76
- area.abbreviation
75
+ area[:abbreviation]
77
76
  end
78
77
 
79
78
  private
80
79
 
81
80
  def length
82
- OpenStruct.new(fetch_sample(LENGTH_UNITS))
81
+ fetch_sample(LENGTH_UNITS)
83
82
  end
84
83
 
85
84
  def mass
86
- OpenStruct.new(fetch_sample(MASS_UNITS))
85
+ fetch_sample(MASS_UNITS)
87
86
  end
88
87
 
89
88
  def liquid
90
- OpenStruct.new(fetch_sample(LIQUID_UNITS))
89
+ fetch_sample(LIQUID_UNITS)
91
90
  end
92
91
 
93
92
  def volume
94
- OpenStruct.new(fetch_sample(VOLUME_UNITS))
93
+ fetch_sample(VOLUME_UNITS)
95
94
  end
96
95
 
97
96
  def area
98
- OpenStruct.new(fetch_sample(AREA_UNITS))
97
+ fetch_sample(AREA_UNITS)
99
98
  end
100
99
  end
101
100
  end