Class: Cuporter::ReportBase

Inherits:
Object
  • Object
show all
Defined in:
lib/cuporter/report/report_base.rb

Direct Known Subclasses

FeatureReport, TagReport, TreeReport

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ReportBase

Returns a new instance of ReportBase.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cuporter/report/report_base.rb', line 7

def initialize(options)
  @input_file_pattern = options[:input_file_pattern]
  @doc                = Cuporter::Document.new_xml
  @view               = options[:report]
  @root_dir           = options[:root_dir]
  @filter             = Filter.new(options[:filter_args])
  @title              = options[:title]
  @sort               = options[:sort]
  @total              = options[:total]
  @number             = options[:number]
  @leaves             = options[:leaves]
  @show_files         = options[:show_files]
  @show_tags          = options[:show_tags]
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



5
6
7
# File 'lib/cuporter/report/report_base.rb', line 5

def doc
  @doc
end

#filterObject (readonly)

Returns the value of attribute filter.



5
6
7
# File 'lib/cuporter/report/report_base.rb', line 5

def filter
  @filter
end

#root_dirObject (readonly)

Returns the value of attribute root_dir.



5
6
7
# File 'lib/cuporter/report/report_base.rb', line 5

def root_dir
  @root_dir
end

#viewObject (readonly)

Returns the value of attribute view.



5
6
7
# File 'lib/cuporter/report/report_base.rb', line 5

def view
  @view
end

Class Method Details

.create(options) ⇒ Object



50
51
52
53
# File 'lib/cuporter/report/report_base.rb', line 50

def self.create(options)
  klass = Cuporter.const_get("#{options[:report].downcase}Report".to_class_name)
  klass.new(options)
end

Instance Method Details

#buildObject



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cuporter/report/report_base.rb', line 55

def build
  report_node.sort_all_descendants!  if sort?
  report_node.number_all_descendants if number?
  report_node.total                  if total?
  report_node.defoliate!             if no_leaves?
  report_node.remove_files!          unless show_files?
  report_node.remove_tags!           unless show_tags?

  doc.add_filter_summary(@filter)
  doc.add_report report_node
  self
end

#filesObject



46
47
48
# File 'lib/cuporter/report/report_base.rb', line 46

def files
  Dir[@input_file_pattern].collect {|f| File.expand_path f}
end

#no_leaves?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/cuporter/report/report_base.rb', line 22

def no_leaves?
  !@leaves
end

#number?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/cuporter/report/report_base.rb', line 34

def number?
  @number
end

#show_files?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/cuporter/report/report_base.rb', line 38

def show_files?
  @show_files
end

#show_tags?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/cuporter/report/report_base.rb', line 42

def show_tags?
  @show_tags
end

#sort?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/cuporter/report/report_base.rb', line 26

def sort?
  @sort
end

#total?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/cuporter/report/report_base.rb', line 30

def total?
  @total
end