class Stepdown::Analyzer

Public Class Methods

new(steps_dir, feature_dir, reporter) click to toggle source
# File lib/stepdown/analyzer.rb, line 5
def initialize(steps_dir, feature_dir, reporter)
  @feature_dir = feature_dir
  @steps_dir = steps_dir
  @reporter = reporter
end

Public Instance Methods

analyze() click to toggle source
# File lib/stepdown/analyzer.rb, line 11
def analyze
  scenarios = collect_scenarios

  stats = Statistics.new(scenarios, instance.step_collection)
  stats.generate

  reporter = reporter(@reporter, stats)
  reporter.output_overview

  Stepdown::YamlWriter.write(stats)
  Stepdown::FlotGraph.create_graph
end
collect_scenarios() click to toggle source
# File lib/stepdown/analyzer.rb, line 24
def collect_scenarios
  puts "Parsing feature files..." unless Stepdown.quiet
  process_feature_files(feature_files)
end
instance() click to toggle source
# File lib/stepdown/analyzer.rb, line 52
def instance
  @instance ||= begin
    new_inst = Stepdown::StepInstance.new

    Dir.glob(step_files).each do |file_name|
      new_inst.instance_eval File.read(file_name)
    end
    new_inst
  end
end
process_feature_files(feature_files) click to toggle source
# File lib/stepdown/analyzer.rb, line 29
def process_feature_files(feature_files)
  listener = Stepdown::FeatureParser.new(instance)

  parser = Gherkin::Parser::Parser.new(listener, true, 'root')

  feature_files.each do |feature_file|
    parser.parse(File.read(feature_file), feature_file, 0)
  end
  listener.scenarios
end
reporter(type, stats) click to toggle source
# File lib/stepdown/analyzer.rb, line 40
def reporter(type, stats)
  case type
    when "html"
      Stepdown::HTMLReporter.new(stats)
    when "text"
      Stepdown::TextReporter.new(stats)
    when "quiet"
      Stepdown::Reporter.new(stats)
  end
end

Private Instance Methods

feature_files() click to toggle source
# File lib/stepdown/analyzer.rb, line 64
def feature_files
  return @feature_files if @feature_files
  @feature_files = Dir.glob(@feature_dir + '/**/*.feature')
end
step_files() click to toggle source
# File lib/stepdown/analyzer.rb, line 69
def step_files
  return @step_files if @step_files
  @step_files = Dir.glob(@steps_dir + '/**/*.rb')
end