class Rspec::Usecases::Generator::DebugGenerator
Debug Generator
helps to visualize the data that is collected from use cases
Public Instance Methods
generate()
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 25 def generate print_document_header print_groups(document.groups) end
run()
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 10 def run @key_width = 30 @indent_size = 0 generate print_output if options.printable? return unless options.writable? write_file(options.file) open_file_in_vscode(options.file) if options.openable? end
Private Instance Methods
green(value)
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 92 def green(value) "\033[32m#{value}\033[0m" end
indent()
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 96 def indent @indent_size += 2 end
indentation()
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 88 def indentation ' ' * @indent_size end
kv(key, value, key_width = @key_width)
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 83 def kv(key, value, key_width = @key_width) key_width -= @indent_size write_line "#{indentation}#{green(key.to_s.ljust(key_width))}: #{value}" end
outdent()
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 100 def outdent @indent_size -= 2 end
print_document_header()
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 32 def print_document_header write_line '*' * 100 kv 'Title', document.title if document.title kv 'Description', document.description if document.description end
print_groups(groups)
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 38 def print_groups(groups) groups.each { |usecase| print_usecase(usecase) } end
print_usecase(usecase)
click to toggle source
# File lib/rspec/usecases/generator/debug_generator.rb, line 42 def print_usecase(usecase) print_usecase_header(usecase) indent usecase.contents.each { |content| print_usecase_content(content) } print_groups(usecase.groups) outdent end
print_usecase_content(content)
click to toggle source
rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
# File lib/rspec/usecases/generator/debug_generator.rb, line 64 def print_usecase_content(content) write_line '-' * 100 kv 'Title' , content.title if content.title != '' kv 'Type' , content.type if content.type != '' # Used by outcome kv 'Note' , content.note if content.respond_to?('note') && content.note != '' # Used by code kv 'Code' , content.code if content.respond_to?('code') && content.code != '' kv 'Code Type', content.code_type if content.respond_to?('code_type') && content.code_type != '' wl content.source if content.respond_to?('source') && content.source != '' end
print_usecase_header(usecase)
click to toggle source
rubocop:disable Metrics/AbcSize
# File lib/rspec/usecases/generator/debug_generator.rb, line 52 def print_usecase_header(usecase) write_line '=' * 100 kv 'Key' , usecase.key if usecase.key kv 'Title' , usecase.title if usecase.title kv 'Deep Title' , usecase.deep_title if usecase.deep_title kv 'Summary' , usecase.summary if usecase.summary kv 'Usage' , usecase.usage if usecase.usage kv 'Usage Description', usecase.usage_description if usecase.usage_description end
wl(value)
click to toggle source
rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
# File lib/rspec/usecases/generator/debug_generator.rb, line 79 def wl(value) write_line "#{indentation}#{value}" end