aipim-rails 0.0.157 → 0.0.159
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/aipim +51 -29
- data/lib/aipim-rails.rb +1 -2
- data/lib/aipim-rails/convert_to_html.rb +4 -7
- data/lib/aipim-rails/parser.rb +26 -23
- data/lib/aipim-rails/parser_helper.rb +10 -10
- data/lib/assets/header.html +10 -0
- metadata +3 -3
- data/lib/aipim-rails/markdown.rb +0 -74
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8363207fbab12be164815cbdd1353fc42cddba30
|
4
|
+
data.tar.gz: b5648bf5e94b2cbeee7a63df04ff0b8dfbf5b5ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dbe790b4da00ffd1b215b450948b0514d5e0a16c705a96333068431e3e06492ab8ca22918ef571c36cbeca422187c492d4e4c08fd1252d4af7eab50452cdf8a
|
7
|
+
data.tar.gz: 0450df6b507ad3ad177215afb2e83855816ebf5d1e04c9ba80ff37550c27c5dbd27a11f5e5fdd4a81563214a8e4d1db1e6a9340df7aebd8bee25f43b3d5654d7
|
data/bin/aipim
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'aipim-rails'
|
4
4
|
|
5
|
+
# root do aipim
|
5
6
|
path = File.expand_path(File.dirname(__FILE__))+"/../"
|
6
7
|
|
8
|
+
# pegar o nome dos arquivos das features
|
7
9
|
def get_files
|
8
10
|
files = []
|
9
11
|
ARGV.delete_at(0)
|
@@ -20,57 +22,77 @@ def get_files
|
|
20
22
|
end
|
21
23
|
|
22
24
|
if ARGV[0] == 'generate'
|
25
|
+
# Cria a pasta do aipim
|
23
26
|
system('mkdir -p aipim')
|
27
|
+
# Cria pasta screenshot
|
24
28
|
system('mkdir -p aipim/screenshots')
|
29
|
+
# Cria um arquivo em branco para o github nao encher o saco
|
25
30
|
system('touch aipim/screenshots/empty')
|
31
|
+
# Cria a pasta das paginas html geradas pelo aipim
|
26
32
|
system('mkdir -p aipim/html')
|
33
|
+
# Cria a pasta costum do HTML
|
27
34
|
system('mkdir -p aipim/html/costum')
|
35
|
+
system('cp -n '+path+'lib/assets/costum.css aipim/html/costum')
|
36
|
+
system('cp -n '+path+'lib/assets/costum.js aipim/html/costum')
|
37
|
+
# Bootstrap
|
28
38
|
system('cp '+path+'lib/assets/bootstrap.min.css aipim/html')
|
39
|
+
# jQuery
|
29
40
|
system('cp '+path+'lib/assets/jquery-1.9.1.js aipim/html')
|
30
|
-
system('cp '+path+'lib/assets/costum.css aipim/html/costum')
|
31
|
-
system('cp '+path+'lib/assets/costum.js aipim/html/costum')
|
32
41
|
|
33
|
-
|
34
|
-
width
|
42
|
+
# resolucao padrão
|
43
|
+
width = "1366"
|
35
44
|
height = "768"
|
45
|
+
screenshot = true
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
47
|
+
# argumentos
|
48
|
+
ARGV.each_with_index do |arg, i|
|
49
|
+
if i > 0
|
50
|
+
# argumento da resolucao
|
51
|
+
if ARGV[i] == '--resolution'
|
52
|
+
width = ARGV[i+1].split("x")[0]
|
53
|
+
height = ARGV[i+1].split("x")[1]
|
54
|
+
# argumento do screenshot
|
55
|
+
elsif ARGV[i] == '--no-screenshot'
|
56
|
+
screenshot = false
|
57
|
+
end
|
58
|
+
end
|
40
59
|
end
|
41
60
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
61
|
+
if screenshot
|
62
|
+
# le o arquivo de configuracao do screenshot
|
63
|
+
f = File.open(path+'lib/webdriver/screenshot.rb', "r")
|
64
|
+
# salva tudo numa string
|
65
|
+
f_str = ""
|
66
|
+
f.each_line {|line| f_str = f_str + line}
|
67
|
+
# substitui os valores da resolucao
|
68
|
+
f_str = f_str.gsub("SCREENSHOT_HEIGHT", height).gsub("SCREENSHOT_WIDTH", width)
|
69
|
+
f.close
|
70
|
+
# abre o arquivo de configuracao do screenshot na pasta do cucumber
|
71
|
+
f = File.open("features/support/screenshot.rb", "w")
|
72
|
+
# coloca a string nesse arquivo
|
73
|
+
f.puts f_str
|
74
|
+
f.close
|
75
|
+
else
|
76
|
+
system('rm -f features/support/screenshot.rb')
|
77
|
+
end
|
50
78
|
|
51
79
|
elsif ARGV[0] == 'html'
|
80
|
+
# remove os htmls antigos
|
52
81
|
%x[rm -f aipim/html/*.feature.html]
|
53
|
-
|
82
|
+
# pega o nome das features
|
54
83
|
files = get_files
|
55
|
-
|
56
|
-
features << Parser.init(f)
|
57
|
-
end
|
58
|
-
ConvertToHtml.index(features)
|
59
|
-
ConvertToHtml.init(features)
|
60
|
-
|
61
|
-
elsif ARGV[0] == 'markdown' || ARGV[0] == 'md'
|
62
|
-
%x[rm -rf aipim/markdown]
|
63
|
-
%x[mkdir -p aipim/markdown]
|
84
|
+
# recebe o features master
|
64
85
|
features = []
|
65
|
-
files = get_files
|
66
86
|
files.each do |f|
|
67
87
|
features << Parser.init(f)
|
68
88
|
end
|
69
|
-
|
89
|
+
# gera a index do relatorio
|
90
|
+
ConvertToHtml.index(features)
|
91
|
+
# geara o html das features
|
92
|
+
ConvertToHtml.features(features)
|
70
93
|
|
94
|
+
# nao serve para nada!! é śó de DEBUG!!
|
71
95
|
elsif ARGV[0] == 'parser'
|
72
|
-
%x[rm -rf aipim/markdown]
|
73
|
-
%x[mkdir -p aipim/markdown]
|
74
96
|
files = get_files
|
75
97
|
files.each do |f|
|
76
98
|
puts "Tentando abrir arquivo #{f}"
|
data/lib/aipim-rails.rb
CHANGED
@@ -27,7 +27,6 @@ module ConvertToHtml
|
|
27
27
|
def self.index(features)
|
28
28
|
|
29
29
|
output = File.open("aipim/html/index.html", "w")
|
30
|
-
|
31
30
|
output.puts '
|
32
31
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
33
32
|
<html>
|
@@ -38,14 +37,13 @@ module ConvertToHtml
|
|
38
37
|
<script src="jquery-1.9.1.js"></script>
|
39
38
|
<script src="costum/costum.js"></script>
|
40
39
|
</head>
|
41
|
-
<body>
|
42
|
-
output.puts '
|
40
|
+
<body>
|
43
41
|
<div class="panel panel-default scenario-index-panel">
|
44
42
|
<div class="panel-body scenario-index-body">
|
45
43
|
<ul class="list-unstyled">'
|
46
44
|
features.each_with_index do |feature,i|
|
47
45
|
output.puts '
|
48
|
-
<li><a href="
|
46
|
+
<li><a href="'+feature[:filename]+'.html">'+(i+1).to_s+'. '+feature[:feature_name]+'</a></li>'
|
49
47
|
end
|
50
48
|
output.puts '
|
51
49
|
</ul>
|
@@ -57,7 +55,7 @@ module ConvertToHtml
|
|
57
55
|
output.close
|
58
56
|
end
|
59
57
|
|
60
|
-
def self.
|
58
|
+
def self.features(features)
|
61
59
|
|
62
60
|
features.each_with_index do |feature, i|
|
63
61
|
output = File.open("aipim/html/"+feature[:filename]+".html", "w")
|
@@ -72,8 +70,7 @@ module ConvertToHtml
|
|
72
70
|
<script src="jquery-1.9.1.js"></script>
|
73
71
|
<script src="costum/costum.js"></script>
|
74
72
|
</head>
|
75
|
-
<body>
|
76
|
-
output.puts '
|
73
|
+
<body>
|
77
74
|
<div class="panel panel-default scenario-index-panel">
|
78
75
|
<div class="panel-body scenario-index-body">
|
79
76
|
<ul class="list-unstyled">'
|
data/lib/aipim-rails/parser.rb
CHANGED
@@ -8,37 +8,40 @@ module Parser
|
|
8
8
|
|
9
9
|
|
10
10
|
def self.tag_screenshot(line,file,workset)
|
11
|
-
if line && ParserHelper.
|
11
|
+
if line && ParserHelper.is_tag?(line) && ParserHelper.is_screenshot?(line)
|
12
12
|
workset[:screenshot] = true
|
13
13
|
line = ParserHelper::read_line(file)
|
14
14
|
end
|
15
|
-
return line,
|
15
|
+
return line, workset
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.tag_feature(line,file,workset)
|
19
|
-
if line && ParserHelper.
|
20
|
-
|
21
|
-
|
19
|
+
if line && ParserHelper.is_feature?(line)
|
20
|
+
|
21
|
+
workset[:feature_name] = ParserHelper.get_feature(line)
|
22
|
+
|
23
|
+
while ((line = ParserHelper::read_line(file)) && !ParserHelper.is_command?(line))
|
22
24
|
workset[:feature_description] << line if !(line.gsub(" ", "") == "")
|
23
25
|
end
|
26
|
+
|
24
27
|
end
|
25
|
-
return line,
|
28
|
+
return line, workset
|
26
29
|
end
|
27
30
|
|
28
31
|
def self.tag_context(line,file,workset)
|
29
|
-
if line && ParserHelper.
|
30
|
-
while ((line = ParserHelper::read_line(file)) && !ParserHelper.
|
32
|
+
if line && ParserHelper.is_context?(line)
|
33
|
+
while ((line = ParserHelper::read_line(file)) && !ParserHelper.is_command?(line))
|
31
34
|
workset[:context_description] << line if !(line.gsub(" ", "") == "")
|
32
35
|
end
|
33
36
|
end
|
34
|
-
return line,
|
37
|
+
return line, workset
|
35
38
|
end
|
36
39
|
|
37
40
|
def self.tag_scenario(line,file,workset)
|
38
|
-
if line && ParserHelper.
|
39
|
-
scenario_name = ParserHelper.
|
41
|
+
if line && ParserHelper.is_scenario?(line)
|
42
|
+
scenario_name = ParserHelper.get_scenario(line)
|
40
43
|
scenario_steps = []
|
41
|
-
while ((line = ParserHelper::read_line(file)) && !ParserHelper.
|
44
|
+
while ((line = ParserHelper::read_line(file)) && !ParserHelper.is_command?(line))
|
42
45
|
scenario_steps << line if !(line.gsub(" ", "") == "")
|
43
46
|
end
|
44
47
|
if workset[:screenshot]
|
@@ -48,7 +51,16 @@ module Parser
|
|
48
51
|
end
|
49
52
|
workset[:scenarios] << {name: scenario_name, steps: scenario_steps, screenshot: screenshot}
|
50
53
|
end
|
51
|
-
return line,
|
54
|
+
return line, workset
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.process_tags(line, file, workset)
|
58
|
+
line, workset = tag_screenshot(line, file, workset)
|
59
|
+
line, workset = tag_feature(line, file, workset)
|
60
|
+
line, workset = tag_context(line, file, workset)
|
61
|
+
line, workset = tag_scenario(line, file, workset)
|
62
|
+
line = ParserHelper::read_line(file) unless ParserHelper.is_command?(line)
|
63
|
+
return line, workset
|
52
64
|
end
|
53
65
|
|
54
66
|
def self.parser(filename)
|
@@ -72,16 +84,7 @@ module Parser
|
|
72
84
|
|
73
85
|
line = ParserHelper::read_line(file)
|
74
86
|
while (line)
|
75
|
-
|
76
|
-
line, file, workset = tag_screenshot(line, file, workset)
|
77
|
-
|
78
|
-
line, file, workset = tag_feature(line, file, workset)
|
79
|
-
|
80
|
-
line, file, workset = tag_context(line, file, workset)
|
81
|
-
|
82
|
-
line, file, workset = tag_scenario(line, file, workset)
|
83
|
-
|
84
|
-
line = ParserHelper::read_line(file) unless ParserHelper.is_comando?(line)
|
87
|
+
line, workset = process_tags(line,file,workset)
|
85
88
|
end
|
86
89
|
file.close
|
87
90
|
|
@@ -1,34 +1,34 @@
|
|
1
1
|
module ParserHelper
|
2
2
|
|
3
|
-
def self.
|
4
|
-
|
3
|
+
def self.is_command?(line)
|
4
|
+
is_feature?(line) || is_scenario?(line) || is_context?(line) || is_tag?(line)
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.
|
7
|
+
def self.is_feature?(line)
|
8
8
|
return line =~ /Funcionalidade:.*/
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.
|
11
|
+
def self.get_feature(line)
|
12
12
|
line.gsub("Funcionalidade:", '').split(' ').join(' ')
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
15
|
+
def self.is_scenario?(line)
|
16
16
|
return line =~ /Cenário:.*/
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.
|
19
|
+
def self.get_scenario(line)
|
20
20
|
line.gsub("Cenário:", '').split(' ').join(' ')
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.
|
23
|
+
def self.is_context?(line)
|
24
24
|
return true if line =~ /Contexto:.*/
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.
|
27
|
+
def self.get_context(line)
|
28
28
|
line.gsub("Contexto:", '').split(' ').join(' ')
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.
|
31
|
+
def self.is_tag?(line)
|
32
32
|
return true if line =~ /@.*/
|
33
33
|
end
|
34
34
|
|
@@ -36,7 +36,7 @@ module ParserHelper
|
|
36
36
|
return (line.include? "@screenshot") && (line.include? "@javascript")
|
37
37
|
end
|
38
38
|
|
39
|
-
def self.
|
39
|
+
def self.is_comment?(line)
|
40
40
|
return true if line =~ /#.*/
|
41
41
|
end
|
42
42
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
5
|
+
<link href="bootstrap.min.css" rel="stylesheet">
|
6
|
+
<link href="costum/costum.css" rel="stylesheet">
|
7
|
+
<script src="jquery-1.9.1.js"></script>
|
8
|
+
<script src="costum/costum.js"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aipim-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.159
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facta TI
|
@@ -46,15 +46,15 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- lib/aipim-rails.rb
|
49
|
-
- lib/aipim-rails/markdown.rb
|
50
49
|
- lib/aipim-rails/parser.rb
|
51
50
|
- lib/aipim-rails/parser_helper.rb
|
51
|
+
- lib/aipim-rails/convert_to_html.rb
|
52
52
|
- lib/webdriver/screenshot.rb
|
53
53
|
- lib/assets/bootstrap.min.css
|
54
54
|
- lib/assets/jquery-1.9.1.js
|
55
55
|
- lib/assets/costum.css
|
56
56
|
- lib/assets/costum.js
|
57
|
-
- lib/
|
57
|
+
- lib/assets/header.html
|
58
58
|
- bin/aipim
|
59
59
|
homepage: http://rubygems.org/gems/aipim
|
60
60
|
licenses:
|
data/lib/aipim-rails/markdown.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'aipim-rails/parser'
|
2
|
-
|
3
|
-
module Markdown
|
4
|
-
|
5
|
-
def self.init(features)
|
6
|
-
features.each_with_index do |feature, i|
|
7
|
-
output = File.new("aipim/markdown/#{feature[:filename]}", "w")
|
8
|
-
write_feature(feature, output)
|
9
|
-
output.close
|
10
|
-
end
|
11
|
-
#read_content(filename)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.write_feature(feature, output)
|
15
|
-
feature[:scenarios].each_with_index do |scenario, i|
|
16
|
-
output.puts "[#{i+1}. #{scenario[:name]}](#) "
|
17
|
-
end
|
18
|
-
output.puts ''
|
19
|
-
output.puts "# #{feature[:feature_name]} #"
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.read_content(features, output)
|
23
|
-
|
24
|
-
|
25
|
-
file = File.new("features/"+filename, "r")
|
26
|
-
output = File.new("aipim/markdown/"+filename+".md", "a")
|
27
|
-
|
28
|
-
is_screenshot = false; scenario_counter = 1; screenshot_counter = 0
|
29
|
-
screenshots = %x[\ls aipim/screenshots/#{filename}].split("\n")
|
30
|
-
|
31
|
-
output.puts ""
|
32
|
-
line = ParserHelper.read_line(file)
|
33
|
-
while (line)
|
34
|
-
|
35
|
-
if !ParserHelper.is_comando?(line) && !(line.gsub(" ", "") == "")
|
36
|
-
output.puts " #{line} "
|
37
|
-
line = ParserHelper.read_line(file)
|
38
|
-
|
39
|
-
elsif ParserHelper.is_marcacao?(line) && ParserHelper.is_screenshot?(line)
|
40
|
-
is_screenshot = true
|
41
|
-
line = ParserHelper.read_line(file)
|
42
|
-
|
43
|
-
elsif ParserHelper.is_funcionalidade?(line)
|
44
|
-
output.puts "# #{ParserHelper.get_funcionalidade(line)} #"
|
45
|
-
line = ParserHelper.read_line(file)
|
46
|
-
|
47
|
-
elsif ParserHelper.is_cenario?(line)
|
48
|
-
output.puts "> ## #{scenario_counter}. #{ParserHelper.get_cenario(line)} ##"
|
49
|
-
scenario_counter = scenario_counter+1
|
50
|
-
while ((line = ParserHelper.read_line(file)) && !ParserHelper.is_comando?(line))
|
51
|
-
output.puts "> #{line} " if !(line.gsub(" ", "") == "")
|
52
|
-
end
|
53
|
-
if is_screenshot
|
54
|
-
output.puts '> [![Alt text](../screenshots/'+filename+'/'+screenshots[screenshot_counter].to_s+')](../screenshots/'+filename+'/'+screenshots[screenshot_counter].to_s+') '
|
55
|
-
screenshot_counter = screenshot_counter+1
|
56
|
-
is_screenshot = false
|
57
|
-
end
|
58
|
-
output.puts ''
|
59
|
-
|
60
|
-
elsif ParserHelper.is_contexto?(line)
|
61
|
-
output.puts "## Contexto : #{ParserHelper.get_contexto(line)} ##"
|
62
|
-
line = ParserHelper.read_line(file)
|
63
|
-
|
64
|
-
else
|
65
|
-
line = ParserHelper.read_line(file)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
file.close
|
69
|
-
output.close
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|