Class: Uncool::Analysis

Inherits:
Object
  • Object
show all
Defined in:
lib/uncool/analysis.rb

Instance Method Summary collapse

Constructor Details

#initialize(trace, options = {}) ⇒ Analysis

Returns a new instance of Analysis.



10
11
12
13
# File 'lib/uncool/analysis.rb', line 10

def initialize(trace, options={})
  @trace   = trace
  @private = options[:private]
end

Instance Method Details

#checklistObject

Returns a list of all possible coverage points.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/uncool/analysis.rb', line 50

def checklist
  coverage = []
  targets.each do |target|
    target.instance_methods(false).each do |meth|
      unit = Unit.new(target, meth)
      coverage << unit
    end

    target.methods(false).each do |meth|
      unit = Unit.new(target, meth, :function=>true)
      coverage << unit
    end

    if private?
      target.protected_instance_methods(false).each do |meth|
        unit = Unit.new(target, meth, :access=>:protected)
        coverage << unit
      end
      target.private_instance_methods(false).each do |meth|
        unit = Unit.new(target, meth, :access=>:private)
        coverage << unit
      end

      target.protected_methods(false).each do |meth|
        unit = Unit.new(target, meth, :access=>:protected, :function=>true)
        coverage << unit
      end
      target.private_methods(false).each do |meth|
        unit = Unit.new(target, meth, :access=>:private, :function=>true)
        coverage << unit
      end
    end
  end
  coverage
end

#coverageObject

Returns a list of postive and negative coverage.



33
34
35
# File 'lib/uncool/analysis.rb', line 33

def coverage
  covered | checklist
end

#coveredObject

Return a list of units that were covered.



38
39
40
41
42
43
44
45
46
47
# File 'lib/uncool/analysis.rb', line 38

def covered
  @coverage ||= (
    list = []
    log.each do |object, method|
      unit = Unit.new(object.class, method, :covered=>true)
      list << unit
    end
    list
  )
end

#logObject



16
17
18
# File 'lib/uncool/analysis.rb', line 16

def log
  @trace.log
end

#private?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/uncool/analysis.rb', line 28

def private?
  @private
end

#targetsObject



21
22
23
24
25
# File 'lib/uncool/analysis.rb', line 21

def targets
  @trace.targets.map do |t|
    eval(t, TOPLEVEL_BINDING)
  end
end