Module: Aruba::Reporting

Defined in:
lib/aruba/reporting.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reportsObject



19
20
21
22
23
# File 'lib/aruba/reporting.rb', line 19

def reports
  @reports ||= Hash.new do |hash, feature|
    hash[feature] = []
  end
end

Instance Method Details

#again(erb, erbout, file) ⇒ Object



76
77
78
# File 'lib/aruba/reporting.rb', line 76

def again(erb, erbout, file)
  erbout.concat(erb.result(binding))
end

#children(dir) ⇒ Object



80
81
82
# File 'lib/aruba/reporting.rb', line 80

def children(dir)
  Dir["#{dir}/*"].sort
end

#commandsObject



51
52
53
# File 'lib/aruba/reporting.rb', line 51

def commands
  @commands || []
end

#depthObject



88
89
90
# File 'lib/aruba/reporting.rb', line 88

def depth
  File.dirname(@scenario.feature.file).split('/').length
end

#descriptionObject



45
46
47
48
49
# File 'lib/aruba/reporting.rb', line 45

def description
  unescaped_description = @scenario.description.gsub(/^(\s*)\\/, '\1')
  markdown = RDiscount.new(unescaped_description)
  markdown.to_html
end

#filesObject



70
71
72
73
74
# File 'lib/aruba/reporting.rb', line 70

def files
  erb = ERB.new(template('files.erb'), nil, '-')
  file = current_directory
  erb.result(binding)
end

#indexObject



92
93
94
95
# File 'lib/aruba/reporting.rb', line 92

def index
  erb = ERB.new(template('index.erb'), nil, '-')
  erb.result(binding)
end

#index_titleObject



97
98
99
# File 'lib/aruba/reporting.rb', line 97

def index_title
  "Examples"
end

#outputObject



55
56
57
58
59
60
61
62
63
# File 'lib/aruba/reporting.rb', line 55

def output
  aruba.config.keep_ansi = true # We want the output coloured!
  escaped_stdout = CGI.escapeHTML(all_stdout)
  html = Bcat::ANSI.new(escaped_stdout).to_html
  Bcat::ANSI::STYLES.each do |name, style|
    html.gsub!(/style='#{style}'/, %{class="xterm_#{name}"})
  end
  html
end

#pygmentize(file) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/aruba/reporting.rb', line 26

def pygmentize(file)
  pygmentize = Processes::SpawnProcess.new(%{pygmentize -f html -O encoding=utf-8 "#{file}"}, 3, 0.5, Dir.getwd)
  pygmentize.run! do |p|
    exit_status = p.stop(false)
    if(exit_status == 0)
      p.stdout(false)
    elsif(p.stderr(false) =~ /no lexer/) # Pygment's didn't recognize it
      IO.read(file)
    else
      STDERR.puts "\e[31m#{p.stderr} - is pygments installed?\e[0m"
      exit $CHILD_STATUS.exitstatus
    end
  end
end

#reportObject



65
66
67
68
# File 'lib/aruba/reporting.rb', line 65

def report
  erb = ERB.new(template('main.erb'), nil, '-')
  erb.result(binding)
end

#template(path) ⇒ Object



84
85
86
# File 'lib/aruba/reporting.rb', line 84

def template(path)
  IO.read(File.join(ENV['ARUBA_REPORT_TEMPLATES'], path))
end

#titleObject



41
42
43
# File 'lib/aruba/reporting.rb', line 41

def title
  @scenario.title
end