rfauxfactory 0.1.0 → 0.1.1

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: f9d9a10ac723208b86ebdf0890310a4ad010a86f
4
- data.tar.gz: 6e484b256fc98a51e007f44de03d6b8440f8ddf9
3
+ metadata.gz: 87088e443eed440c16e2b0f5e354ccd8462ebb1c
4
+ data.tar.gz: 9fb7f213fe858abbbdf135b9468c41a201f1c112
5
5
  SHA512:
6
- metadata.gz: 2d09578f209acd7d3519d2dead059e5a19f32a1757f44ae342f8e18049a9ec73efb526807ae31803b95695324c1586ec465b6381ba0b5034b8ae66a2a5f365ab
7
- data.tar.gz: a4e8fb2f8d0b7c850244d5d154da96f709e2360512f290eb45f55eba2567213ccce47a3520551496ab335e3007798bb919192a2219d5a0f6f910ed8a9d7a2d1d
6
+ metadata.gz: b1080680f3db125fc47183b1ed344c2c7d329d88157b1cc36489877889d7f923e529986a876e7146580a02af7bc11dbd59ef8515696756e5db5a10946340d802
7
+ data.tar.gz: 58daee872fc462e3cb62982c5d74bdff4ef97bce339130a43bd385591adca43fc552978c861ea1e9d1fa2423cae6969643fdfc44e453925277d3b007fc3b48b3
data/README.rst ADDED
@@ -0,0 +1,82 @@
1
+ RFauxFactory
2
+ ============
3
+
4
+ .. image:: https://badge.fury.io/rb/rfauxfactory.svg
5
+ :target: https://badge.fury.io/rb/rfauxfactory
6
+
7
+ Generates random data for your tests. Ruby port for https://github.com/omaciel/fauxfactory.
8
+
9
+ Install RFauxFactory
10
+
11
+ .. code-block:: bash
12
+
13
+ gem install rfauxfactory
14
+
15
+
16
+ Generate Strings with default length=10
17
+ +++++++++++++++++++++++++++++++++++++++
18
+
19
+ .. code-block:: ruby
20
+
21
+ RFauxFactory.gen_alpha => "iqXfCtcmOl"
22
+ RFauxFactory.gen_latin1 => "âÍûçùÈíÂãÚ"
23
+ RFauxFactory.gen_cjk => "柕鈭鳬鴝藂豲醘晓怰匜"
24
+ RFauxFactory.gen_utf8 => "빣졤𣀣𐜖𦝅Í샆𩀛ꢮ켆"
25
+ RFauxFactory.gen_cyrillic => "РӅӪѹёӖЀљҸѤ"
26
+ RFauxFactory.gen_alphanumeric => "2WKLdDNfrO"
27
+ RFauxFactory.gen_numeric_string => "7667510623"
28
+ RFauxFactory.gen_special => "(`|,\\/^$/."
29
+ RFauxFactory.gen_html => "<applet>tFyFHLasnN</applet>"
30
+
31
+
32
+ Generate Strings with custom length
33
+ +++++++++++++++++++++++++++++++++++
34
+
35
+ .. code-block:: ruby
36
+
37
+ RFauxFactory.gen_alpha 20 => "gtUAteMlmjfXivTEOXNL"
38
+
39
+ # or
40
+
41
+ RFauxFactory.gen_alpha length=20 => "YPxOXgWMrATxvHnCKmcy"
42
+
43
+
44
+ Generate Strings with the general gen_string function
45
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++
46
+
47
+ allowed string types are:
48
+
49
+ - alpha
50
+ - alphanumeric
51
+ - cjk
52
+ - html
53
+ - latin1
54
+ - numeric
55
+ - utf8
56
+ - punctuation
57
+
58
+ .. code-block:: ruby
59
+
60
+ RFauxFactory.gen_string :alpha => "WXWkJJsgHB"
61
+ RFauxFactory.gen_string :latin1 => "ÅÔÍÅõéþêÃÑ"
62
+ RFauxFactory.gen_string :cjk => "娎咅巁蹐猳瑣呺鮘桼汿"
63
+ RFauxFactory.gen_string :utf8 => "衊𖣋䰛𤬱㱹筠𖡇𫑴軈𨳈"
64
+ RFauxFactory.gen_string :cyrillic => "БӮҨӠѴҞӘӦѱН"
65
+ RFauxFactory.gen_string :alphanumeric => "cJ4iapthI8"
66
+ RFauxFactory.gen_string :numeric => "8572742737"
67
+ RFauxFactory.gen_string :punctuation => ">-}{%(``%]"
68
+ RFauxFactory.gen_string :html => "<big>WNoQefDcmE</big>"
69
+
70
+ # or with custom length
71
+
72
+ RFauxFactory.gen_string :alpha, 20 => "TuxtvmNwrfbuGaaQSEnM"
73
+
74
+
75
+ Generate bool values:
76
+ +++++++++++++++++++++
77
+
78
+ .. code-block:: ruby
79
+
80
+ RFauxFactory.gen_boolean => false
81
+ RFauxFactory.gen_boolean => true
82
+ RFauxFactory.gen_boolean => true
@@ -1,11 +1,9 @@
1
1
  module RFauxFactory
2
- N_BYTES = [42].pack('i').size
3
- N_BITS = N_BYTES * 16
4
- MAX_INT = 2**(N_BITS - 2) - 1
2
+ MAX_INT = 2**(1.size * 8 - 2) - 1
5
3
  MIN_INT = -MAX_INT - 1
6
4
  ASCII_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'.freeze
7
5
  ASCII_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.freeze
8
- PUNCTUATION = '!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~'.freeze
6
+ PUNCTUATION = %q(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~).freeze
9
7
  ASCII_LETTERS = ASCII_LOWERCASE + ASCII_UPPERCASE
10
8
  DIGITS = '0123456789'.freeze
11
9
  ALPHANUMERIC = ASCII_LETTERS + DIGITS
@@ -1,3 +1,3 @@
1
1
  module RFauxFactory
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
data/lib/rfauxfactory.rb CHANGED
@@ -76,10 +76,6 @@ module RFauxFactory
76
76
  "<#{html_tag}>#{gen_alpha(length)}</#{html_tag}>"
77
77
  end
78
78
 
79
- def gen_boolean
80
- [true, false].sample
81
- end
82
-
83
79
  def gen_special(length = 10)
84
80
  positive_int! length
85
81
  gen_string_from_letters length, PUNCTUATION
@@ -101,5 +97,10 @@ module RFauxFactory
101
97
  raise ArgumentError, "str_type: #{str_type} not supported" unless func_str_types.key?(str_type)
102
98
  send(func_str_types[str_type], length)
103
99
  end
100
+
101
+ # Return a random Boolean value.
102
+ def gen_boolean
103
+ [true, false].sample
104
+ end
104
105
  end
105
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfauxfactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Og Maciel
@@ -63,7 +63,7 @@ files:
63
63
  - ".rubocop.yml"
64
64
  - Gemfile
65
65
  - LICENSE
66
- - README.md
66
+ - README.rst
67
67
  - Rakefile
68
68
  - bin/console
69
69
  - bin/setup
data/README.md DELETED
@@ -1,2 +0,0 @@
1
- # RFauxFactory
2
- Generates random data for your tests. Ruby port for https://github.com/omaciel/fauxfactory.