Module: FuzzBert::Generators
- Defined in:
- lib/fuzzbert/generators.rb
Class Method Summary collapse
- .cycle(range) ⇒ Object
- .fixed(data) ⇒ Object
- .random(limit = 1024) ⇒ Object
- .random_b64(limit = 1024) ⇒ Object
- .random_b64_fixlen(len) ⇒ Object
- .random_fixlen(len) ⇒ Object
- .random_hex(limit = 1024) ⇒ Object
- .random_hex_fixlen(len) ⇒ Object
- .sample(ary) ⇒ Object
Class Method Details
.cycle(range) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/fuzzbert/generators.rb', line 31 def cycle(range) ary = range.to_a i = 0 lambda do ret = ary[i] i = (i + 1) % ary.size ret end end |
.fixed(data) ⇒ Object
41 42 43 |
# File 'lib/fuzzbert/generators.rb', line 41 def fixed(data) -> { data } end |
.random(limit = 1024) ⇒ Object
7 8 9 |
# File 'lib/fuzzbert/generators.rb', line 7 def random(limit=1024) -> { random_bytes(limit) { |data| data } } end |
.random_b64(limit = 1024) ⇒ Object
11 12 13 |
# File 'lib/fuzzbert/generators.rb', line 11 def random_b64(limit=1024) -> { random_bytes(b64_len(limit)) { |data| Base64.encode64(data) } } end |
.random_b64_fixlen(len) ⇒ Object
23 24 25 |
# File 'lib/fuzzbert/generators.rb', line 23 def random_b64_fixlen(len) -> { random_bytes_fixlen(b64_len(len)) { |data| Base64.encode(data) } } end |
.random_fixlen(len) ⇒ Object
19 20 21 |
# File 'lib/fuzzbert/generators.rb', line 19 def random_fixlen(len) -> { random_bytes_fixlen(len) { |data| data } } end |
.random_hex(limit = 1024) ⇒ Object
15 16 17 |
# File 'lib/fuzzbert/generators.rb', line 15 def random_hex(limit=1024) -> { random_bytes(hex_len(limit)) { |data| data.unpack("H*")[0] } } end |
.random_hex_fixlen(len) ⇒ Object
27 28 29 |
# File 'lib/fuzzbert/generators.rb', line 27 def random_hex_fixlen(len) -> { random_bytes_fixlen(hex_len(len)) { |data| data.unpack("H*")[0] } } end |
.sample(ary) ⇒ Object
45 46 47 |
# File 'lib/fuzzbert/generators.rb', line 45 def sample(ary) -> { ary.sample } end |