bin/aipim in aipim-rails-0.0.157 vs bin/aipim in aipim-rails-0.0.159
- old
+ new
@@ -1,11 +1,13 @@
#!/usr/bin/env ruby
require 'aipim-rails'
+# root do aipim
path = File.expand_path(File.dirname(__FILE__))+"/../"
+# pegar o nome dos arquivos das features
def get_files
files = []
ARGV.delete_at(0)
ARGV.each do |arg|
ls = %x[ls #{arg}].split("\n")
@@ -18,60 +20,80 @@
end
files
end
if ARGV[0] == 'generate'
+ # Cria a pasta do aipim
system('mkdir -p aipim')
+ # Cria pasta screenshot
system('mkdir -p aipim/screenshots')
+ # Cria um arquivo em branco para o github nao encher o saco
system('touch aipim/screenshots/empty')
+ # Cria a pasta das paginas html geradas pelo aipim
system('mkdir -p aipim/html')
+ # Cria a pasta costum do HTML
system('mkdir -p aipim/html/costum')
+ system('cp -n '+path+'lib/assets/costum.css aipim/html/costum')
+ system('cp -n '+path+'lib/assets/costum.js aipim/html/costum')
+ # Bootstrap
system('cp '+path+'lib/assets/bootstrap.min.css aipim/html')
+ # jQuery
system('cp '+path+'lib/assets/jquery-1.9.1.js aipim/html')
- system('cp '+path+'lib/assets/costum.css aipim/html/costum')
- system('cp '+path+'lib/assets/costum.js aipim/html/costum')
-
- width = "1366"
+ # resolucao padrão
+ width = "1366"
height = "768"
+ screenshot = true
- unless ARGV[1].nil?
- width = ARGV[1].split("x")[0]
- height = ARGV[1].split("x")[1]
+ # argumentos
+ ARGV.each_with_index do |arg, i|
+ if i > 0
+ # argumento da resolucao
+ if ARGV[i] == '--resolution'
+ width = ARGV[i+1].split("x")[0]
+ height = ARGV[i+1].split("x")[1]
+ # argumento do screenshot
+ elsif ARGV[i] == '--no-screenshot'
+ screenshot = false
+ end
+ end
end
- f = File.open(path+'lib/webdriver/screenshot.rb', "r")
- f_str = ""
- f.each_line {|line| f_str = f_str + line}
- f_str = f_str.gsub("SCREENSHOT_HEIGHT", height).gsub("SCREENSHOT_WIDTH", width)
- f.close
- f = File.open("features/support/screenshot.rb", "w")
- f.puts f_str
- f.close
+ if screenshot
+ # le o arquivo de configuracao do screenshot
+ f = File.open(path+'lib/webdriver/screenshot.rb', "r")
+ # salva tudo numa string
+ f_str = ""
+ f.each_line {|line| f_str = f_str + line}
+ # substitui os valores da resolucao
+ f_str = f_str.gsub("SCREENSHOT_HEIGHT", height).gsub("SCREENSHOT_WIDTH", width)
+ f.close
+ # abre o arquivo de configuracao do screenshot na pasta do cucumber
+ f = File.open("features/support/screenshot.rb", "w")
+ # coloca a string nesse arquivo
+ f.puts f_str
+ f.close
+ else
+ system('rm -f features/support/screenshot.rb')
+ end
elsif ARGV[0] == 'html'
+ # remove os htmls antigos
%x[rm -f aipim/html/*.feature.html]
- features = []
+ # pega o nome das features
files = get_files
+ # recebe o features master
+ features = []
files.each do |f|
features << Parser.init(f)
end
+ # gera a index do relatorio
ConvertToHtml.index(features)
- ConvertToHtml.init(features)
+ # geara o html das features
+ ConvertToHtml.features(features)
-elsif ARGV[0] == 'markdown' || ARGV[0] == 'md'
- %x[rm -rf aipim/markdown]
- %x[mkdir -p aipim/markdown]
- features = []
- files = get_files
- files.each do |f|
- features << Parser.init(f)
- end
- Markdown.init(features)
-
+# nao serve para nada!! é śó de DEBUG!!
elsif ARGV[0] == 'parser'
- %x[rm -rf aipim/markdown]
- %x[mkdir -p aipim/markdown]
files = get_files
files.each do |f|
puts "Tentando abrir arquivo #{f}"
feature = Parser.init(f)
puts "Feature name: #{feature[:feature_name]}"