aipim-rails 0.0.41 → 0.0.139
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/aipim +64 -24
- data/lib/aipim-rails.rb +2 -1
- data/lib/aipim-rails/convert_to_html.rb +80 -42
- data/lib/aipim-rails/markdown.rb +80 -0
- data/lib/aipim-rails/parser.rb +38 -49
- data/lib/aipim-rails/parser_helper.rb +5 -1
- data/lib/{bootstrap.min.css → assets/bootstrap.min.css} +0 -0
- data/lib/{jquery-1.9.1.js → assets/jquery-1.9.1.js} +0 -0
- data/lib/{screenshot.rb → webdriver/screenshot.rb} +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66cc36bbb83ffc547d9b6ac6c823141c6206cec1
|
4
|
+
data.tar.gz: 7788f2f905779cb197ccd152175430c4b905f8c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07df864bea816e58ffb93e426e1d76124f5be9ba8a82ea747fa82ab26351bbcedf1da87cd6e664ebab1e8245dc343447ff5243164594049c95014bb05f92f47c
|
7
|
+
data.tar.gz: 85be949fbd51bd35be514bdc428a304e5bb7028cfd2eafa5e6030e71a926566c2b58a23a52eac66df64fb4fa14b54012c040c6e47c53a49525fe4a35cfd31591
|
data/bin/aipim
CHANGED
@@ -4,42 +4,82 @@ require 'aipim-rails'
|
|
4
4
|
|
5
5
|
path = File.expand_path(File.dirname(__FILE__))+"/../"
|
6
6
|
|
7
|
-
|
8
|
-
system('mkdir -p aipim')
|
9
|
-
system('mkdir -p aipim/screenshots')
|
10
|
-
system('cp '+path+'lib/screenshot.rb features/support/')
|
11
|
-
|
12
|
-
elsif ARGV[0] == 'html'
|
13
|
-
%x[rm -rf aipim/markdown]
|
7
|
+
def get_files
|
14
8
|
files = []
|
15
9
|
ARGV.delete_at(0)
|
16
10
|
ARGV.each do |arg|
|
17
11
|
ls = %x[ls #{arg}].split("\n")
|
18
12
|
ls.each do |f|
|
19
|
-
f = f.split(
|
20
|
-
f.delete_at(0)
|
21
|
-
f = f
|
13
|
+
f = f.split("/")
|
14
|
+
f.delete_at(0) if f[0] == "features"
|
15
|
+
f = f[0]
|
22
16
|
files << f if !(f =~ /.feature\z/).nil?
|
23
17
|
end
|
24
18
|
end
|
25
|
-
files
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
files
|
20
|
+
end
|
21
|
+
|
22
|
+
if ARGV[0] == 'generate'
|
23
|
+
system('mkdir -p aipim')
|
24
|
+
system('mkdir -p aipim/screenshots')
|
25
|
+
|
26
|
+
width = "1024"
|
27
|
+
height = "768"
|
28
|
+
|
29
|
+
unless ARGV[1].nil?
|
30
|
+
width = ARGV[1].split("x")[0]
|
31
|
+
height = ARGV[1].split("x")[1]
|
32
|
+
end
|
33
|
+
|
34
|
+
f = File.open(path+'lib/webdriver/screenshot.rb', "r")
|
35
|
+
f_str = ""
|
36
|
+
f.each_line {|line| f_str = f_str + line}
|
37
|
+
f_str = f_str.gsub("SCREENSHOT_HEIGHT", height).gsub("SCREENSHOT_WIDTH", width)
|
38
|
+
f.close
|
39
|
+
f = File.open("features/support/screenshot.rb", "w")
|
40
|
+
f.puts f_str
|
41
|
+
f.close
|
42
|
+
|
43
|
+
elsif ARGV[0] == 'html'
|
44
|
+
%x[rm -rf aipim/html]
|
45
|
+
%x[mkdir -p aipim/html]
|
46
|
+
features = []
|
47
|
+
files = get_files
|
48
|
+
files.each do |f|
|
49
|
+
features << Parser.init(f)
|
50
|
+
end
|
51
|
+
ConvertToHtml.init(features)
|
52
|
+
system('cp '+path+'lib/assets/bootstrap.min.css aipim/html')
|
53
|
+
system('cp '+path+'lib/assets/jquery-1.9.1.js aipim/html')
|
29
54
|
|
30
55
|
elsif ARGV[0] == 'markdown' || ARGV[0] == 'md'
|
31
56
|
%x[rm -rf aipim/markdown]
|
32
57
|
%x[mkdir -p aipim/markdown]
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
58
|
+
features = []
|
59
|
+
files = get_files
|
60
|
+
files.each do |f|
|
61
|
+
features << Parser.init(f)
|
62
|
+
end
|
63
|
+
Markdown.init(features)
|
64
|
+
|
65
|
+
elsif ARGV[0] == 'parser'
|
66
|
+
%x[rm -rf aipim/markdown]
|
67
|
+
%x[mkdir -p aipim/markdown]
|
68
|
+
files = get_files
|
69
|
+
files.each do |f|
|
70
|
+
puts "Tentando abrir arquivo #{f}"
|
71
|
+
feature = Parser.init(f)
|
72
|
+
puts "Feature name: #{feature[:feature_name]}"
|
73
|
+
puts "Feature description: "
|
74
|
+
feature[:feature_description].each {|t| puts t}
|
75
|
+
puts "Context name: #{feature[:context_name]}"
|
76
|
+
puts "Context description"
|
77
|
+
feature[:context_description].each {|t| puts t}
|
78
|
+
feature[:scenarios].each do |scenario|
|
79
|
+
puts "----------------------------------------------"
|
80
|
+
puts scenario[:name]
|
81
|
+
scenario[:steps].each {|step| puts step}
|
42
82
|
end
|
43
83
|
end
|
44
|
-
|
84
|
+
|
45
85
|
end
|
data/lib/aipim-rails.rb
CHANGED
@@ -1,50 +1,88 @@
|
|
1
|
-
require '
|
1
|
+
require 'aipim-rails/parser_helper'
|
2
2
|
|
3
3
|
module ConvertToHtml
|
4
4
|
|
5
|
-
def self.
|
6
|
-
|
7
|
-
markdown.render(File.read("aipim/markdown/"+filename+".md"))
|
5
|
+
def self.get_tag_color(str, word, classname)
|
6
|
+
str.gsub(word,'<font class="'+classname+'">'+word+'</font>')
|
8
7
|
end
|
9
8
|
|
10
|
-
def self.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
9
|
+
def self.get_tag_quotes(str)
|
10
|
+
quotes = []
|
11
|
+
tquotes = str.scan(/"([^"]*)"/)
|
12
|
+
tquotes.each { |t| quotes << t[0] }
|
13
|
+
quotes = quotes.uniq
|
14
|
+
quotes.each { |t| str = str.gsub('"'+t+'"', '"<font class="tag-quotes">'+t+'</font>"') }
|
15
|
+
str
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.colorize(str)
|
19
|
+
str = get_tag_quotes(str)
|
20
|
+
str = get_tag_color(str, "Dado ", "tag-given")
|
21
|
+
str = get_tag_color(str, "Quando ", "tag-when")
|
22
|
+
str = get_tag_color(str, "Então ", "tag-then")
|
23
|
+
str = get_tag_color(str, "E ", "tag-and")
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.init(features)
|
27
|
+
|
28
|
+
features.each do |feature|
|
29
|
+
output = File.open("aipim/html/"+feature[:filename]+".html", "w")
|
30
|
+
|
31
|
+
output.puts '
|
32
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
33
|
+
<html>
|
34
|
+
<head>
|
35
|
+
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
36
|
+
<link href="bootstrap.min.css" rel="stylesheet">
|
37
|
+
<link href="../costum.css" rel="stylesheet">
|
38
|
+
<script src="jquery-1.9.1.js"></script>
|
39
|
+
<script src="../costum.js"></script>
|
40
|
+
</head>
|
41
|
+
<body>'
|
42
|
+
|
43
|
+
output.puts '
|
44
|
+
<div class="panel panel-default scenario-index-panel">
|
45
|
+
<div class="panel-body scenario-index-body">
|
46
|
+
<ul class="list-unstyled">'
|
47
|
+
feature[:scenarios].each_with_index do |scenario,i|
|
48
|
+
output.puts '
|
49
|
+
<li><a href="#">'+(i+1).to_s+'. '+scenario[:name]+'</a></li>'
|
50
|
+
end
|
51
|
+
output.puts '
|
52
|
+
</ul>
|
53
|
+
</div>
|
54
|
+
</div>'
|
55
|
+
|
56
|
+
feature[:scenarios].each_with_index do |scenario,i|
|
57
|
+
|
58
|
+
output.puts '
|
59
|
+
<div class="panel panel-default scenario-panel">
|
60
|
+
<div class="panel-heading scenario-name">
|
61
|
+
<h3 class="panel-title">'+(i+1).to_s+'. '+scenario[:name]+'<span class="pull-right"><a href="#">[índice]</a></span></h3>
|
62
|
+
</div>
|
63
|
+
<div class="panel-body scenario-body">
|
64
|
+
<ul class="list-unstyled">'
|
65
|
+
|
66
|
+
scenario[:steps].each do |step|
|
67
|
+
output.puts '<li>'+colorize(step)+'</li>'
|
68
|
+
end
|
69
|
+
|
70
|
+
output.puts '
|
71
|
+
</ul>
|
72
|
+
</div>
|
73
|
+
<div class="panel-footer scenario-screenshot">
|
74
|
+
<img src="../screenshots/'+feature[:filename]+'/'+scenario[:screenshot]+'" />
|
75
|
+
</div>
|
76
|
+
</div>'
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
output.puts '
|
81
|
+
</body>
|
82
|
+
</html>'
|
83
|
+
|
84
|
+
output.close
|
85
|
+
end
|
48
86
|
end
|
49
87
|
|
50
88
|
end
|
@@ -0,0 +1,80 @@
|
|
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.read_line(file)
|
15
|
+
line = file.gets
|
16
|
+
line = line.gsub("\n", "").split(' ').join(' ') unless line.nil?
|
17
|
+
line
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.write_feature(feature, output)
|
21
|
+
feature[:scenarios].each_with_index do |scenario, i|
|
22
|
+
output.puts "[#{i+1}. #{scenario[:name]}](#) "
|
23
|
+
end
|
24
|
+
output.puts ''
|
25
|
+
output.puts "# #{feature[:feature_name]} #"
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.read_content(features, output)
|
29
|
+
|
30
|
+
|
31
|
+
file = File.new("features/"+filename, "r")
|
32
|
+
output = File.new("aipim/markdown/"+filename+".md", "a")
|
33
|
+
|
34
|
+
is_screenshot = false; scenario_counter = 1; screenshot_counter = 0
|
35
|
+
screenshots = %x[\ls aipim/screenshots/#{filename}].split("\n")
|
36
|
+
|
37
|
+
output.puts ""
|
38
|
+
line = read_line(file)
|
39
|
+
while (line)
|
40
|
+
|
41
|
+
if !ParserHelper.is_comando?(line) && !(line.gsub(" ", "") == "")
|
42
|
+
output.puts " #{line} "
|
43
|
+
line = read_line(file)
|
44
|
+
|
45
|
+
elsif ParserHelper.is_marcacao?(line) && ParserHelper.is_screenshot?(line)
|
46
|
+
is_screenshot = true
|
47
|
+
line = read_line(file)
|
48
|
+
|
49
|
+
elsif ParserHelper.is_funcionalidade?(line)
|
50
|
+
output.puts "# #{ParserHelper.get_funcionalidade(line)} #"
|
51
|
+
line = read_line(file)
|
52
|
+
|
53
|
+
elsif ParserHelper.is_cenario?(line)
|
54
|
+
output.puts "> ## #{scenario_counter}. #{ParserHelper.get_cenario(line)} ##"
|
55
|
+
scenario_counter = scenario_counter+1
|
56
|
+
while ((line = read_line(file)) && !ParserHelper.is_comando?(line))
|
57
|
+
output.puts "> #{line} " if !(line.gsub(" ", "") == "")
|
58
|
+
end
|
59
|
+
if is_screenshot
|
60
|
+
output.puts '> [![Alt text](../screenshots/'+filename+'/'+screenshots[screenshot_counter].to_s+')](../screenshots/'+filename+'/'+screenshots[screenshot_counter].to_s+') '
|
61
|
+
screenshot_counter = screenshot_counter+1
|
62
|
+
is_screenshot = false
|
63
|
+
end
|
64
|
+
output.puts ''
|
65
|
+
|
66
|
+
elsif ParserHelper.is_contexto?(line)
|
67
|
+
output.puts "## Contexto : #{ParserHelper.get_contexto(line)} ##"
|
68
|
+
line = read_line(file)
|
69
|
+
|
70
|
+
else
|
71
|
+
line = read_line(file)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
file.close
|
75
|
+
output.close
|
76
|
+
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
data/lib/aipim-rails/parser.rb
CHANGED
@@ -3,83 +3,72 @@ require 'aipim-rails/parser_helper'
|
|
3
3
|
module Parser
|
4
4
|
|
5
5
|
def self.init(filename)
|
6
|
-
|
7
|
-
read_content(filename)
|
6
|
+
parser(filename)
|
8
7
|
end
|
9
8
|
|
10
9
|
def self.read_line(file)
|
11
10
|
line = file.gets
|
12
|
-
line = line.gsub("\n", "") unless line.nil?
|
11
|
+
line = line.gsub("\n", "").split(' ').join(' ') unless line.nil?
|
13
12
|
line
|
14
13
|
end
|
15
14
|
|
16
|
-
def self.
|
17
|
-
cenario_counter = 1
|
18
|
-
output = File.new("aipim/markdown/#{filename}.md", "w")
|
19
|
-
file = File.new("features/#{filename}", "r")
|
20
|
-
while(line = read_line(file))
|
21
|
-
if ParserHelper.is_cenario?(line)
|
22
|
-
output.puts "[#{cenario_counter}. #{ParserHelper.get_cenario(line)}](#) "
|
23
|
-
cenario_counter = cenario_counter+1
|
24
|
-
end
|
25
|
-
end
|
26
|
-
file.close
|
27
|
-
output.close
|
28
|
-
end
|
15
|
+
def self.parser(filename)
|
29
16
|
|
30
|
-
|
17
|
+
file = File.new("features/"+filename, "r")
|
31
18
|
|
32
|
-
|
33
|
-
output = File.new("aipim/markdown/#{filename}.md", "a")
|
19
|
+
screenshots = %x[\ls aipim/screenshots/#{filename}].split("\n")
|
34
20
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
21
|
+
is_screenshot = false; scenario_counter = 1; screenshot_counter = 0
|
22
|
+
feature = []; feature_name = nil; feature_description = []
|
23
|
+
context_name = nil; context_description = []
|
24
|
+
scenarios = []; scenario_name = nil; scenario_steps = []; screenshot = nil
|
39
25
|
|
40
|
-
output.puts ""
|
41
26
|
line = read_line(file)
|
42
27
|
while (line)
|
43
28
|
|
44
|
-
if
|
45
|
-
|
46
|
-
line = read_line(file)
|
47
|
-
|
48
|
-
elsif ParserHelper.is_marcacao?(line)
|
49
|
-
screenshot = true
|
29
|
+
if ParserHelper.is_marcacao?(line) && ParserHelper.is_screenshot?(line)
|
30
|
+
is_screenshot = true
|
50
31
|
line = read_line(file)
|
51
32
|
|
52
33
|
elsif ParserHelper.is_funcionalidade?(line)
|
53
|
-
|
54
|
-
line = read_line(file)
|
34
|
+
feature_name = ParserHelper.get_funcionalidade(line)
|
35
|
+
while ((line = read_line(file)) && !ParserHelper.is_comando?(line))
|
36
|
+
feature_description << line if !(line.gsub(" ", "") == "")
|
37
|
+
end
|
38
|
+
|
39
|
+
elsif ParserHelper.is_contexto?(line)
|
40
|
+
while ((line = read_line(file)) && !ParserHelper.is_comando?(line))
|
41
|
+
context_description << line if !(line.gsub(" ", "") == "")
|
42
|
+
end
|
55
43
|
|
56
44
|
elsif ParserHelper.is_cenario?(line)
|
57
|
-
|
58
|
-
cenario_counter = cenario_counter+1
|
45
|
+
scenario_name = ParserHelper.get_cenario(line)
|
59
46
|
while ((line = read_line(file)) && !ParserHelper.is_comando?(line))
|
60
|
-
if !(line.gsub(" ", "") == "")
|
61
|
-
output.puts "> #{line} "
|
62
|
-
end
|
47
|
+
scenario_steps << line if !(line.gsub(" ", "") == "")
|
63
48
|
end
|
64
|
-
if
|
65
|
-
|
66
|
-
|
67
|
-
|
49
|
+
if is_screenshot
|
50
|
+
screenshot = screenshots[screenshot_counter].to_s
|
51
|
+
screenshot_counter = screenshot_counter+1
|
52
|
+
is_screenshot = false
|
68
53
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
elsif ParserHelper.is_contexto?(line)
|
74
|
-
output.puts "## Contexto : #{ParserHelper.get_contexto(line)} ##"
|
75
|
-
line = read_line(file)
|
54
|
+
scenarios << {name: scenario_name, steps: scenario_steps, screenshot: screenshot}
|
55
|
+
scenario_steps = []
|
56
|
+
screenshot = nil
|
76
57
|
|
77
58
|
else
|
78
59
|
line = read_line(file)
|
79
60
|
end
|
80
61
|
end
|
81
62
|
file.close
|
82
|
-
|
63
|
+
|
64
|
+
feature = {
|
65
|
+
feature_name: feature_name,
|
66
|
+
feature_description: feature_description,
|
67
|
+
context_name: context_name,
|
68
|
+
context_description: context_description,
|
69
|
+
scenarios: scenarios,
|
70
|
+
filename: filename
|
71
|
+
}
|
83
72
|
|
84
73
|
|
85
74
|
end
|
@@ -9,7 +9,7 @@ module ParserHelper
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.get_funcionalidade(line)
|
12
|
-
line.gsub("Funcionalidade:
|
12
|
+
line.gsub("Funcionalidade:", '').split(' ').join(' ')
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.is_cenario?(line)
|
@@ -32,6 +32,10 @@ module ParserHelper
|
|
32
32
|
return true if line =~ /@.*/
|
33
33
|
end
|
34
34
|
|
35
|
+
def self.is_screenshot?(line)
|
36
|
+
return (line.include? "@screenshot") && (line.include? "@javascript")
|
37
|
+
end
|
38
|
+
|
35
39
|
def self.is_comentario?(line)
|
36
40
|
return true if line =~ /#.*/
|
37
41
|
end
|
File without changes
|
File without changes
|
@@ -12,7 +12,7 @@ Before do |scenario|
|
|
12
12
|
@ScenarioTags = scenario.source_tag_names
|
13
13
|
|
14
14
|
page.driver.browser.manage.window.maximize
|
15
|
-
page.driver.browser.manage.window.resize_to(
|
15
|
+
page.driver.browser.manage.window.resize_to(SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT)
|
16
16
|
end
|
17
17
|
|
18
18
|
After do
|
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.139
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facta TI
|
@@ -32,11 +32,12 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- lib/aipim-rails.rb
|
35
|
+
- lib/aipim-rails/markdown.rb
|
35
36
|
- lib/aipim-rails/parser.rb
|
36
37
|
- lib/aipim-rails/parser_helper.rb
|
37
|
-
- lib/screenshot.rb
|
38
|
-
- lib/bootstrap.min.css
|
39
|
-
- lib/jquery-1.9.1.js
|
38
|
+
- lib/webdriver/screenshot.rb
|
39
|
+
- lib/assets/bootstrap.min.css
|
40
|
+
- lib/assets/jquery-1.9.1.js
|
40
41
|
- lib/aipim-rails/convert_to_html.rb
|
41
42
|
- bin/aipim
|
42
43
|
homepage: http://rubygems.org/gems/aipim
|