Class: Jfuzz::StringGenerator

Inherits:
Generator show all
Defined in:
lib/jfuzz/generators/string_generator.rb

Constant Summary collapse

DATE =
"date"
DATE_TIME =
"date-time"
DATE_REGEXP =
/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
TIME_REGEXP =
/\A(\d{2}):(\d{2}):(\d{2})\z/
DATE_TIME_REGEXP =
/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-2][0-9]:[0-5][0-9]:[0-5][0-9](\.[0-9]+)?(Z|[\-+][0-9]{2}:[0-5][0-9])$/
FORMATS =
{
  DATE => DATE_REGEXP,
  DATE_TIME => DATE_TIME_REGEXP,
}.freeze
CHARSET =
Array("A".."Z") + Array("a".."z") + Array(0..9)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

#initialize, #try_generate

Constructor Details

This class inherits a constructor from Jfuzz::Generator

Class Method Details

.typeObject



33
34
35
# File 'lib/jfuzz/generators/string_generator.rb', line 33

def self.type
  "string"
end

Instance Method Details

#generateObject



23
24
25
26
27
28
29
30
31
# File 'lib/jfuzz/generators/string_generator.rb', line 23

def generate
  if format?
    return generate_from_format
  elsif pattern?
    return generate_from_pattern
  end

  generate_string
end