rfauxfactory 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87088e443eed440c16e2b0f5e354ccd8462ebb1c
4
- data.tar.gz: 9fb7f213fe858abbbdf135b9468c41a201f1c112
3
+ metadata.gz: d284e51e2e0260791c79c389e9f281ce3b6cc248
4
+ data.tar.gz: 4fb2ac703f957fff9c7592b903bb2d9ff771916c
5
5
  SHA512:
6
- metadata.gz: b1080680f3db125fc47183b1ed344c2c7d329d88157b1cc36489877889d7f923e529986a876e7146580a02af7bc11dbd59ef8515696756e5db5a10946340d802
7
- data.tar.gz: 58daee872fc462e3cb62982c5d74bdff4ef97bce339130a43bd385591adca43fc552978c861ea1e9d1fa2423cae6969643fdfc44e453925277d3b007fc3b48b3
6
+ metadata.gz: 1aa3c1c4163888f0e211e435daeda3ffa1c1f431edeee93052f7f57768bfa0b875a3aac6f58d9e70c525c14f075279f5dfa4e609020344cfb0114f7cf29b113e
7
+ data.tar.gz: 809c4afbd96f34ceecbc6d9d17ed58673f5baee42942a37ce2d7b8438cecb5630cbc964727e3ccd23aaf85637cfd4286373f4d42d51d47e449a26919e0f308c5
data/.rubocop.yml CHANGED
@@ -16,6 +16,9 @@ LineLength:
16
16
  MethodLength:
17
17
  Max: 20
18
18
 
19
+ ClassLength:
20
+ Max: 200
21
+
19
22
  ModuleLength:
20
23
  Enabled: false
21
24
 
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2
5
+ before_install: gem install bundler
6
+ script: "bundle exec rake"
@@ -1,3 +1,3 @@
1
1
  module RFauxFactory
2
- VERSION = "0.1.1".freeze
2
+ VERSION = "0.1.2".freeze
3
3
  end
data/lib/rfauxfactory.rb CHANGED
@@ -3,6 +3,18 @@ require "rfauxfactory/constants"
3
3
 
4
4
  # The python FauxFactory port
5
5
  module RFauxFactory
6
+ STRING_TYPES = {
7
+ 'alpha': :gen_alpha,
8
+ 'alphanumeric': :gen_alphanumeric,
9
+ 'cjk': :gen_cjk,
10
+ 'cyrillic': :gen_cyrillic,
11
+ 'html': :gen_html,
12
+ 'latin1': :gen_latin1,
13
+ 'numeric': :gen_numeric_string,
14
+ 'utf8': :gen_utf8,
15
+ 'punctuation': :gen_special
16
+ }.freeze
17
+
6
18
  class << self
7
19
  private
8
20
 
@@ -83,19 +95,20 @@ module RFauxFactory
83
95
 
84
96
  # A simple wrapper that calls other string generation methods.
85
97
  def gen_string(str_type, length = 10)
86
- func_str_types = {
87
- 'alpha': :gen_alpha,
88
- 'alphanumeric': :gen_alphanumeric,
89
- 'cjk': :gen_cjk,
90
- 'cyrillic': :gen_cyrillic,
91
- 'html': :gen_html,
92
- 'latin1': :gen_latin1,
93
- 'numeric': :gen_numeric_string,
94
- 'utf8': :gen_utf8,
95
- 'punctuation': :gen_special
96
- }
97
- raise ArgumentError, "str_type: #{str_type} not supported" unless func_str_types.key?(str_type)
98
- send(func_str_types[str_type], length)
98
+ raise ArgumentError, "str_type: #{str_type} not supported" unless RFauxFactory::STRING_TYPES.key?(str_type)
99
+ send(RFauxFactory::STRING_TYPES[str_type], length)
100
+ end
101
+
102
+ # Generates a list of different input strings.
103
+ def gen_strings(length = nil, exclude: [], min_length: 3, max_length: 30)
104
+ raise ArgumentError, "exclude must be an Array" unless exclude.is_a?(Array)
105
+ positive_int! min_length
106
+ positive_int! max_length
107
+ raise ArgumentError, "max_length must be greater than min_length" unless max_length > min_length
108
+ RFauxFactory::STRING_TYPES.keys.reject { |str_type| exclude.include?(str_type) }.map do |str_type|
109
+ str_length = length.nil? ? rand((min_length..max_length)) : length
110
+ [str_type, gen_string(str_type, str_length)]
111
+ end.to_h
99
112
  end
100
113
 
101
114
  # Return a random Boolean value.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfauxfactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Og Maciel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-27 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rubocop.yml"
64
+ - ".travis.yml"
64
65
  - Gemfile
65
66
  - LICENSE
66
67
  - README.rst