Sha256: 4574d5e3039d36ae63023922a106b6c592db79578ccf03bb9a887cd2d16386f0

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
aipim-rails-0.0.9 lib/aipim-rails/parser.rb
aipim-0.0.8 lib/aipim/parser.rb