Class: Piggly::Reporter::Base

Inherits:
Object
  • Object
show all
Includes:
HtmlDsl
Defined in:
lib/piggly/reporter/base.rb

Direct Known Subclasses

Index, Procedure

Constant Summary

Constants included from HtmlDsl

HtmlDsl::HTML_PATTERN, HtmlDsl::HTML_REPLACE

Instance Method Summary collapse

Methods included from HtmlDsl

#e, #html, #tag

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/piggly/reporter/base.rb', line 7

def initialize(config)
  @config = config
end

Instance Method Details

#install(*files) ⇒ Object

Copy each file to @config.report_root



12
13
14
15
16
17
18
19
# File 'lib/piggly/reporter/base.rb', line 12

def install(*files)
  files.each do |name|
    src = File.join(File.dirname(__FILE__), name)
    dst = report_path(name)

    File.open(dst, "w"){|io| io.write(File.read(src)) }
  end
end

#report_path(file = nil, ext = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/piggly/reporter/base.rb', line 21

def report_path(file=nil, ext=nil)
  unless file.nil?
    # Remove the original extension from +file+ and add given extension
    @config.mkpath(@config.report_root, ext ?
      File.basename(file, ".*") + ext :
      File.basename(file))
  else
    @config.mkpath(@config.report_root)
  end
end