#!/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') #Copia o arquivo de configuracao system('cp -n '+path+'config/aipim.yml config') # resolucao padrĂ£o width = "1366" height = "768" # 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] end end end # 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 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) elsif ARGV[0] == '--screenshot' config = YAML.load_file("config/aipim.yml") config['screenshot'] = true File.open("config/aipim.yml", 'w') {|file| file.write config.to_yaml } #Store elsif ARGV[0] == '--no-screenshot' config = YAML.load_file("config/aipim.yml") config['screenshot'] = false File.open("config/aipim.yml", 'w') {|file| file.write config.to_yaml } #Store end