rfauxfactory 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/README.rst +75 -0
- data/lib/rfauxfactory/version.rb +1 -1
- data/lib/rfauxfactory.rb +20 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02b7bd9150e8aa01992540564645e23515e8ef63
|
4
|
+
data.tar.gz: 4b58b11c07cfd47cbcba4b0934fd006cb945f440
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c697b35fbedcf5c67ce07b066f94bc448637f86f36f2dd23740ac8756fb4b8de0bbd895a0e75141ddcc1226512ce7ab671080ae60160c9cff224981ad6e8bb0e
|
7
|
+
data.tar.gz: 5701b714feded6ff6d557bb9caf5803d95160143aae8e2c60759429b9fd3738c1eca739045560822447d216e67d7a03852cb6bfd3e75f9634512b65eca9d1a8d
|
data/README.rst
CHANGED
@@ -74,6 +74,81 @@ allowed string types are:
|
|
74
74
|
|
75
75
|
RFauxFactory.gen_string :alpha, 20 => "TuxtvmNwrfbuGaaQSEnM"
|
76
76
|
|
77
|
+
Generate Strings of all the supported types
|
78
|
+
+++++++++++++++++++++++++++++++++++++++++++
|
79
|
+
|
80
|
+
- With default fixed length 10:
|
81
|
+
|
82
|
+
.. code-block:: ruby
|
83
|
+
|
84
|
+
RFauxFactory.gen_strings
|
85
|
+
=> {:alpha=>"RoRHnHUkPO",
|
86
|
+
:alphanumeric=>"nr6SVx2up1",
|
87
|
+
:cjk=>"勷笃儽痖跂飣煾籄綔庋",
|
88
|
+
:cyrillic=>"ҕФҒқьѾљһІЏ",
|
89
|
+
:html=>"<big>YhtxODnoFs</big>",
|
90
|
+
:latin1=>"ÝäÈØÓÌãÝÙÌ",
|
91
|
+
:numeric=>"6684366145",
|
92
|
+
:utf8=>"㓆녵냔𫣾𝝙𦚾쬠𗧛䰢쭱",
|
93
|
+
:punctuation=>"{<;%-:\\<_]"}
|
94
|
+
|
95
|
+
|
96
|
+
- With custom fixed length:
|
97
|
+
|
98
|
+
.. code-block:: ruby
|
99
|
+
|
100
|
+
RFauxFactory.gen_strings 20
|
101
|
+
=> {:alpha=>"tXuyblxhHVvxSStxHRqe",
|
102
|
+
:alphanumeric=>"EbBUUPl7xZP7OC1uZi5B",
|
103
|
+
:cjk=>"圠黄炵鍁寥礟瓢丽粐遵暋歞乽匨霜謟姈迴楩螯",
|
104
|
+
:cyrillic=>"ѻҢӍҩӷѣӼ҈ңФфѡӮЖѽҧѴџӋҎ",
|
105
|
+
:html=>"<span>YMDuJumImvDvxKocHUwE</span>",
|
106
|
+
:latin1=>"ïõêáÃÁÄÃõäêúÈÀÛÃúýïå",
|
107
|
+
:numeric=>"66662825266228221074",
|
108
|
+
:utf8=>"𠲹橝𨖟𐌿𬩱𡁲𤅽㺷𪯠𨨮𢡙𪵾獄𦩸𑈂𤉪𗔋妶ꯡಖ",
|
109
|
+
:punctuation=>"\\,&{($|>`@_^!_{&$=]>"}
|
110
|
+
|
111
|
+
- With custom range length:
|
112
|
+
|
113
|
+
.. code-block:: ruby
|
114
|
+
|
115
|
+
RFauxFactory.gen_strings (3..30)
|
116
|
+
=> {:alpha=>"humyNICJnf",
|
117
|
+
:alphanumeric=>"hWraGEsBPrELdKI0x0CVpRMak",
|
118
|
+
:cjk=>"烩稟醎渍葼釃枆鄴锐窫角菧妻慗饏镂鮺镬嬦",
|
119
|
+
:cyrillic=>"хђѫӬӷӮюЕѸ",
|
120
|
+
:html=>"<blink>yweAKvPxpTQAzRWCDAmxiyJ</blink>",
|
121
|
+
:latin1=>"ÁóÁ",
|
122
|
+
:numeric=>"626134543753572648033525",
|
123
|
+
:utf8=>"ⱴ嫆𡋹𡗸",
|
124
|
+
:punctuation=>"&@;??}:|\\@\"`[.+\\+|"}
|
125
|
+
|
126
|
+
- With excluding some string types:
|
127
|
+
|
128
|
+
.. code-block:: ruby
|
129
|
+
|
130
|
+
RFauxFactory.gen_strings exclude: [:html, :punctuation]
|
131
|
+
=> {:alpha=>"IBlbvJkYQP",
|
132
|
+
:alphanumeric=>"3KZHRSgbcB",
|
133
|
+
:cjk=>"儫魹咳崙訔船鲓撊郸猡",
|
134
|
+
:cyrillic=>"ӡҁӇѯӇӫэЗыѳ",
|
135
|
+
:latin1=>"ìÜóÌáÓÛéÀâ",
|
136
|
+
:numeric=>"8140474314",
|
137
|
+
:utf8=>"𫐖𦷘𣒣瑩竰誎請𠼎粢裤"}
|
138
|
+
|
139
|
+
|
140
|
+
- We can also combine length and exclude options:
|
141
|
+
|
142
|
+
.. code-block:: ruby
|
143
|
+
|
144
|
+
RFauxFactory.gen_strings (3..30), exclude: [:html, :punctuation]
|
145
|
+
=> {:alpha=>"aLc",
|
146
|
+
:alphanumeric=>"wbfFxoQrL4TOpd8r5",
|
147
|
+
:cjk=>"灢汍袌姩饇狶肌胃穨煍灔舨纡訴鷂彜窟趫",
|
148
|
+
:cyrillic=>"ҥӤѪѦҫОПӿ",
|
149
|
+
:latin1=>"ÌÙÕðñúÚõáÌÉ",
|
150
|
+
:numeric=>"01526437887562321",
|
151
|
+
:utf8=>"柚ᖹ𪮅捰Ʋ"}
|
77
152
|
|
78
153
|
Generate bool values:
|
79
154
|
+++++++++++++++++++++
|
data/lib/rfauxfactory/version.rb
CHANGED
data/lib/rfauxfactory.rb
CHANGED
@@ -32,9 +32,20 @@ module RFauxFactory
|
|
32
32
|
end.join
|
33
33
|
end
|
34
34
|
|
35
|
-
def positive_int!(length)
|
36
|
-
raise TypeError,
|
37
|
-
raise ArgumentError,
|
35
|
+
def positive_int!(length, name: 'length')
|
36
|
+
raise TypeError, "#{name} is not of type Integer" unless length.is_a?(Integer)
|
37
|
+
raise ArgumentError, "#{name} must be a positive integer" unless length > 0
|
38
|
+
end
|
39
|
+
|
40
|
+
def positive_int_or_range!(length)
|
41
|
+
raise TypeError, "length must be Integer or Range" unless length.is_a?(Integer) || length.is_a?(Range)
|
42
|
+
if length.is_a?(Integer)
|
43
|
+
positive_int! length
|
44
|
+
else
|
45
|
+
raise ArgumentError, "Bad length range" if length.size.nil? || length.size.zero?
|
46
|
+
positive_int! length.first, name: 'length.first'
|
47
|
+
positive_int! length.last, name: 'length.last'
|
48
|
+
end
|
38
49
|
end
|
39
50
|
|
40
51
|
public
|
@@ -100,13 +111,12 @@ module RFauxFactory
|
|
100
111
|
end
|
101
112
|
|
102
113
|
# Generates a list of different input strings.
|
103
|
-
def gen_strings(length =
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
str_length = length.nil? ? rand((min_length..max_length)) : length
|
114
|
+
def gen_strings(length = 10, exclude: [])
|
115
|
+
positive_int_or_range! length
|
116
|
+
raise TypeError, "exclude must be an Array" unless exclude.is_a?(Array)
|
117
|
+
str_types = RFauxFactory::STRING_TYPES.keys.reject { |str_type| exclude.include?(str_type) }
|
118
|
+
str_types.map do |str_type|
|
119
|
+
str_length = length.is_a?(Range) ? rand(length) : length
|
110
120
|
[str_type, gen_string(str_type, str_length)]
|
111
121
|
end.to_h
|
112
122
|
end
|
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.4
|
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-03-
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|