module Parser

Public Class Methods

init(filename) click to toggle source
# File lib/aipim/parser.rb, line 5
def self.init(filename)
        read_links(filename)
        read_content(filename)
end
read_content(filename) click to toggle source
# File lib/aipim/parser.rb, line 28
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
read_line(file) click to toggle source
# File lib/aipim/parser.rb, line 10
def self.read_line(file)
        line = file.gets
        line = line.gsub("\n", "") unless line.nil?
        line
end