lib/aipim-rails/parser.rb in aipim-rails-0.0.168 vs lib/aipim-rails/parser.rb in aipim-rails-0.0.169
- old
+ new
@@ -1,21 +1,17 @@
require 'aipim-rails/parser_helper'
module Parser
- # inicia o processo de parset
def self.init(filename)
- system("mkdir -p aipim/screenshots/#{filename}")
- parser(filename)
+ filename
end
def self.tag_screenshot(line,file,workset)
- if line && ParserHelper.is_tag?(line)
- if ParserHelper.is_screenshot?(line)
- workset[:screenshot] = true
- end
+ if line && ParserHelper.is_tag?(line) && ParserHelper.is_screenshot?(line)
+ workset[:screenshot] = true
line = ParserHelper::read_line(file)
end
return line, workset
end
@@ -46,17 +42,15 @@
scenario_name = ParserHelper.get_scenario(line)
scenario_steps = []
while ((line = ParserHelper::read_line(file)) && !ParserHelper.is_command?(line))
scenario_steps << line if !(line.gsub(" ", "") == "")
end
- screenshot = nil
if workset[:screenshot]
screenshot = workset[:screenshots][workset[:screenshot_counter]].to_s
workset[:screenshot_counter] += 1
workset[:screenshot] = false
end
- workset[:screenshot] = false
workset[:scenarios] << {name: scenario_name, steps: scenario_steps, screenshot: screenshot}
end
return line, workset
end
@@ -68,37 +62,32 @@
line = ParserHelper::read_line(file) unless ParserHelper.is_command?(line)
return line, workset
end
def self.parser(filename)
-
# Read input
file = read_file(filename)
# Get screenshot files
screenshots = get_screenshot_files(filename)
- # variaveis de trabalho
workset = {
screenshot: false,
screenshot_counter: 0,
screenshots: screenshots,
- feature_name: "",
+ feature_name: nil,
feature_description: [],
context_name: nil,
context_description: [],
scenarios: []
}
- # esse codigo é q faz a magica
line = ParserHelper::read_line(file)
while (line)
line, workset = process_tags(line,file,workset)
end
file.close
- # no final o workset vai estar com tudo que precisamos
- # montar a feature com o qu eu tenho do workset
feature = {
feature_name: workset[:feature_name],
feature_description: workset[:feature_description],
context_name: workset[:context_name],
context_description: workset[:context_description],