require 'aipim/parser_helper' module Parser def self.init(filename) read_links(filename) read_content(filename) end def self.read_line(file) line = file.gets line = line.gsub("\n", "") unless line.nil? line end def self.read_links(filename) cenario_counter = 1 file = File.new(filename, "r") while(line = read_line(file)) if ParserHelper.is_cenario?(line) puts "[#{cenario_counter}. #{ParserHelper.get_cenario(line)}](#) " cenario_counter = cenario_counter+1 end end file.close end def self.read_content(filename) file = File.new(filename, "r") screenshot = false cenario_counter = 1 result = %x[ls screenshots/].split("\n") counter_screenshot = 0 line = read_line(file) while (line) if !ParserHelper.is_comando?(line) && !(line.gsub(" ", "") == "") puts "#{line} " line = read_line(file) elsif ParserHelper.is_marcacao?(line) screenshot = true line = read_line(file) elsif ParserHelper.is_funcionalidade?(line) puts "# #{ParserHelper.get_funcionalidade(line)} #" line = read_line(file) elsif ParserHelper.is_cenario?(line) puts "> ## #{cenario_counter}. #{ParserHelper.get_cenario(line)} ##" cenario_counter = cenario_counter+1 while ((line = read_line(file)) && !ParserHelper.is_comando?(line)) if !(line.gsub(" ", "") == "") puts "> #{line} " end end if screenshot puts '> [![Alt text](screenshots/'+result[counter_screenshot].to_s+')](screenshots/'+result[counter_screenshot].to_s+') ' counter_screenshot = counter_screenshot+1 screenshot = false end puts '' puts '' puts '' elsif ParserHelper.is_contexto?(line) puts "## Contexto : #{ParserHelper.get_contexto(line)} ##" line = read_line(file) else line = read_line(file) end end file.close end end