#!/usr/bin/env ruby require 'aipim-rails' path = File.expand_path(File.dirname(__FILE__))+"/../" def get_files files = [] ARGV.delete_at(0) ARGV.each do |arg| ls = %x[ls #{arg}].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 end files end if ARGV[0] == 'generate' system('mkdir -p aipim') system('mkdir -p aipim/screenshots') width = "1024" height = "768" unless ARGV[1].nil? width = ARGV[1].split("x")[0] height = ARGV[1].split("x")[1] 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 elsif ARGV[0] == 'html' %x[rm -rf aipim/html] %x[mkdir -p aipim/html] features = [] files = get_files files.each do |f| features << Parser.init(f) end ConvertToHtml.init(features) system('cp '+path+'lib/assets/bootstrap.min.css aipim/html') system('cp '+path+'lib/assets/jquery-1.9.1.js aipim/html') 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) 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]}" puts "Feature description: " feature[:feature_description].each {|t| puts t} puts "Context name: #{feature[:context_name]}" puts "Context description" feature[:context_description].each {|t| puts t} feature[:scenarios].each do |scenario| puts "----------------------------------------------" puts scenario[:name] scenario[:steps].each {|step| puts step} end end end