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 +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +6 -0
- data/lib/rfauxfactory/version.rb +1 -1
- data/lib/rfauxfactory.rb +26 -13
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d284e51e2e0260791c79c389e9f281ce3b6cc248
|
4
|
+
data.tar.gz: 4fb2ac703f957fff9c7592b903bb2d9ff771916c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aa3c1c4163888f0e211e435daeda3ffa1c1f431edeee93052f7f57768bfa0b875a3aac6f58d9e70c525c14f075279f5dfa4e609020344cfb0114f7cf29b113e
|
7
|
+
data.tar.gz: 809c4afbd96f34ceecbc6d9d17ed58673f5baee42942a37ce2d7b8438cecb5630cbc964727e3ccd23aaf85637cfd4286373f4d42d51d47e449a26919e0f308c5
|
data/.rubocop.yml
CHANGED
data/.travis.yml
ADDED
data/lib/rfauxfactory/version.rb
CHANGED
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
97
|
-
|
98
|
-
|
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.
|
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-
|
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
|