Module: Parser

Defined in:
lib/aipim/parser.rb

Class Method Summary collapse

Class Method Details

.init(filename) ⇒ Object



5
6
7
8
# File 'lib/aipim/parser.rb', line 5

def self.init(filename)
	read_links(filename)
	read_content(filename)
end

.read_content(filename) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# 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) ⇒ Object



10
11
12
13
14
# File 'lib/aipim/parser.rb', line 10

def self.read_line(file)
	line = file.gets
	line = line.gsub("\n", "") unless line.nil?
	line
end


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/aipim/parser.rb', line 16

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