Class: ProtoCov::GenericFile

Inherits:
Object
  • Object
show all
Defined in:
lib/protocov/base.rb

Overview

Parent class of SourceFile and TestFile. Defines common methods.

Direct Known Subclasses

SourceFile, TestFile

Instance Method Summary collapse

Instance Method Details

#annotate!Object



43
44
45
46
47
48
49
# File 'lib/protocov/base.rb', line 43

def annotate!
  puts "== #{filename.bold} =="
  puts "Methods:\n#{defined_methods.map { |m| "- #{m}\n" }}" unless defined_methods.empty?
  puts "Modules:\n#{modules.map { |m| "- #{m}\n" }}" unless modules.empty?
  puts "Classes:\n#{classes.map { |m| "- #{m}\n" }}" unless classes.empty?
  puts ""
end

#bodyObject



19
20
21
# File 'lib/protocov/base.rb', line 19

def body
  @body ||= File.read(path)
end

#classesObject



35
36
37
# File 'lib/protocov/base.rb', line 35

def classes
  @classes ||= body.parse_for(:classes)
end

#defined_methodsObject



27
28
29
# File 'lib/protocov/base.rb', line 27

def defined_methods
  @defined_methods ||= body.parse_for(:method_definitions)
end

#invoked_methodsObject



31
32
33
# File 'lib/protocov/base.rb', line 31

def invoked_methods
  @invoked_methods ||= body.parse_for(:method_invocations)
end

#linesObject



23
24
25
# File 'lib/protocov/base.rb', line 23

def lines
  @lines ||= body.split(/\n/)
end

#modulesObject



39
40
41
# File 'lib/protocov/base.rb', line 39

def modules
  @modules ||= body.parse_for(:modules)
end

#pathObject



15
16
17
# File 'lib/protocov/base.rb', line 15

def path
  File.expand_path(File.join(path_prefix, filename))
end