#!/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 = [] ls = %x[ls features].split("\n") ls.each do |f| f = f.split("/") f.delete_at(0) if f[0] == "features" f = f[0] files << f if !(f =~ /.feature\z/).nil? 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') # resolucao padrĂ£o width = "1366" height = "768" screenshot = true # 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 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] # 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 Html.index(features) # geara o html das features Html.features(features) end