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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f25b31823c9434d9542ec3b7e49232710328078c
4
- data.tar.gz: 2b58a29e80cc8c65f93842659d21f0b9c86bcdf9
3
+ metadata.gz: 66cc36bbb83ffc547d9b6ac6c823141c6206cec1
4
+ data.tar.gz: 7788f2f905779cb197ccd152175430c4b905f8c1
5
5
  SHA512:
6
- metadata.gz: eb94643d94ec7378c7a338d0510b33567879e4b7207127a5fb7c337b76a347dbf02894c372925009ba34c5f664227b7e8e62780a73b2d5f5205d62dff26f36ca
7
- data.tar.gz: e2c5fc42631e661b1fae18519c036140e0a74089406aba95604f2deada1e69072b7801dc4c46a9b208a97ee6d6e6c60513c29b661b00536c82ee1c414ef231f6
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
- if ARGV[0] == 'generate'
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.join('/')
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.each { |f| Parser.init(f) }
26
- files.each { |f| ConvertToHtml.init(f) }
27
- system('cp '+path+'lib/bootstrap.min.css aipim/html')
28
- system('cp '+path+'lib/jquery-1.9.1.js aipim/html')
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
- files = []
34
- ARGV.delete_at(0)
35
- ARGV.each do |arg|
36
- ls = %x[ls #{arg}].split("\n")
37
- ls.each do |f|
38
- f = f.split('/')
39
- f.delete_at(0)
40
- f = f.join('/')
41
- files << f if !(f =~ /.feature\z/).nil?
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
- files.each { |f| Parser.init(f) }
84
+
45
85
  end
@@ -1,2 +1,3 @@
1
1
  require 'aipim-rails/parser'
2
- require 'aipim-rails/convert_to_html'
2
+ require 'aipim-rails/convert_to_html'
3
+ require 'aipim-rails/markdown'
@@ -1,50 +1,88 @@
1
- require 'redcarpet'
1
+ require 'aipim-rails/parser_helper'
2
2
 
3
3
  module ConvertToHtml
4
4
 
5
- def self.md_to_html(filename)
6
- markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
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.init(filename)
11
- system("mkdir -p aipim/html")
12
- output = File.open("aipim/html/"+filename+".html", "w")
13
- output.puts '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
14
- output.puts '<html>'
15
- output.puts ' <head>'
16
- output.puts ' <META http-equiv="Content-Type" content="text/html; charset=utf-8">'
17
- output.puts ' <link href="bootstrap.min.css" rel="stylesheet">'
18
- output.puts ' <script src="jquery-1.9.1.js"></script>'
19
- output.puts ' <script type="text/javascript">'
20
- output.puts ' $(document).ready(function(){'
21
- output.puts ' $(\'a\').click(function(){'
22
- output.puts ' var titulo = $(this).html();'
23
- output.puts ' $(\'html, body\').animate({'
24
- output.puts ' scrollTop: $(\'h2\').filter(\':contains("\'+titulo+\'")\').offset().top'
25
- output.puts ' }, 1000);'
26
- output.puts ' });'
27
- output.puts ' });'
28
- output.puts ' </script>'
29
- output.puts ' <style>'
30
- output.puts ' img {'
31
- output.puts ' width: 100%;'
32
- output.puts ' }'
33
- output.puts ' blockquote p {'
34
- output.puts ' text-align: center;'
35
- output.puts ' }'
36
- output.puts ' body {'
37
- output.puts ' padding-left:25%;'
38
- output.puts ' padding-right:25%;'
39
- output.puts ' align:center'
40
- output.puts ' }'
41
- output.puts ' </style>'
42
- output.puts '</head>'
43
- output.puts '<body>'
44
- output.puts md_to_html(filename)
45
- output.puts '</body>'
46
- output.puts '</html>'
47
- output.close
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
@@ -3,83 +3,72 @@ require 'aipim-rails/parser_helper'
3
3
  module Parser
4
4
 
5
5
  def self.init(filename)
6
- read_links(filename)
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.read_links(filename)
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
- def self.read_content(filename)
17
+ file = File.new("features/"+filename, "r")
31
18
 
32
- file = File.new("features/#{filename}", "r")
33
- output = File.new("aipim/markdown/#{filename}.md", "a")
19
+ screenshots = %x[\ls aipim/screenshots/#{filename}].split("\n")
34
20
 
35
- screenshot = false
36
- cenario_counter = 1
37
- result = %x[ls aipim/screenshots/#{filename}].split("\n")
38
- counter_screenshot = 0
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 !ParserHelper.is_comando?(line) && !(line.gsub(" ", "") == "")
45
- output.puts "#{line} "
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
- output.puts "# #{ParserHelper.get_funcionalidade(line)} #"
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
- output.puts "> ## #{cenario_counter}. #{ParserHelper.get_cenario(line)} ##"
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 screenshot
65
- output.puts '> [![Alt text](../screenshots/'+filename+'/'+result[counter_screenshot].to_s+')](../screenshots/'+filename+'/'+result[counter_screenshot].to_s+') '
66
- counter_screenshot = counter_screenshot+1
67
- screenshot = false
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
- output.puts ''
70
- output.puts '<!-- -->'
71
- output.puts ''
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
- output.close
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: ", '').split(' ').join(' ')
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
@@ -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(1024, 768)
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.41
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