Module: Html

Defined in:
lib/aipim-rails/html.rb

Class Method Summary collapse

Class Method Details

.colorize(str) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/aipim-rails/html.rb', line 18

def self.colorize(str)
	str = get_tag_quotes(str)
	str = get_tag_color(str, "Dado ", "tag-given")
	str = get_tag_color(str, "Quando ", "tag-when")
	str = get_tag_color(str, "Então ", "tag-then")
	str = get_tag_color(str, "E ", "tag-and")
end

.features(features) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/aipim-rails/html.rb', line 58

def self.features(features)

	features.each_with_index do |feature, i| 
		output = File.open("aipim/html/"+feature[:filename]+".html", "w")
		output.puts '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<META http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link href="bootstrap.min.css" rel="stylesheet">
	<link href="costum/costum.css" rel="stylesheet">
	<script src="jquery-1.9.1.js"></script>
	<script src="costum/costum.js"></script>
</head>
<body>
<div class="panel panel-default scenario-index-panel">
	<div class="panel-body scenario-index-body">
		<ul class="list-unstyled">'
		features.each_with_index do |t, j|
			output.puts '
			<li><a href="'+t[:filename]+'.html">'+(j+1).to_s+'. '+t[:feature_name]+'</a></li>'
			if i == j
				output.puts '
				<li>
					<ul class="list-unstyled features-link">'
				feature[:scenarios].each_with_index do |scenario,k|
					output.puts '
						<li><a href="#">'+(j+1).to_s+'.'+(k+1).to_s+'. '+scenario[:name]+'</a></li>'
				end
				output.puts '
					</ul>
				</li>'
			end
		end
		output.puts '
		</ul>
	</div>
</div>'

		feature[:scenarios].each_with_index do |scenario,j|

			output.puts '
<div class="panel panel-default scenario-panel">
	<div class="panel-heading scenario-name">
   		<h3 class="panel-title">'+(i+1).to_s+'.'+(j+1).to_s+'. '+scenario[:name]+'<span class="pull-right"><a href="#">[índice]</a></span></h3>
 		</div>
 		<div class="panel-body scenario-body">
		<ul class="list-unstyled">'
			scenario[:steps].each do |step|
				output.puts '
			<li>'+colorize(step)+'</li>'
        	end

        	output.puts '
	    </ul>
	</div>
 		
 		<div class="panel-footer scenario-screenshot">
 			<a href="../screenshots/'+feature[:filename]+'/'+scenario[:screenshot]+'"><img src="../screenshots/'+feature[:filename]+'/'+scenario[:screenshot]+'" /></a>
 		</div>
</div>'

		end

		output.puts '	
</body>
</html>'

		output.close
	end
end

.get_tag_color(str, word, classname) ⇒ Object



5
6
7
# File 'lib/aipim-rails/html.rb', line 5

def self.get_tag_color(str, word, classname)
	str.gsub(word,'<font class="'+classname+'">'+word+'</font>')
end

.get_tag_quotes(str) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/aipim-rails/html.rb', line 9

def self.get_tag_quotes(str)
	quotes = []
	tquotes = str.scan(/"([^"]*)"/)
	tquotes.each { |t| quotes << t[0] }
	quotes = quotes.uniq
	quotes.each { |t| str = str.gsub('"'+t+'"', '"<font class="tag-quotes">'+t+'</font>"') }
	str
end

.index(features) ⇒ Object



27
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
# File 'lib/aipim-rails/html.rb', line 27

def self.index(features)

	output = File.open("aipim/html/index.html", "w")
	output.puts '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<META http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link href="bootstrap.min.css" rel="stylesheet">
	<link href="costum/costum.css" rel="stylesheet">
	<script src="jquery-1.9.1.js"></script>
	<script src="costum/costum.js"></script>
</head>
<body>
<div class="panel panel-default scenario-index-panel">
	<div class="panel-body scenario-index-body">
		<ul class="list-unstyled">'
	features.each_with_index do |feature,i|
		output.puts '
			<li><a href="'+feature[:filename]+'.html">'+(i+1).to_s+'. '+feature[:feature_name]+'</a></li>'
	end
	output.puts '
		</ul>
	</div>
</div>
</body>
</html>'

	output.close
end