Class: GCOV::JSONFormatter
- Inherits:
-
Object
- Object
- GCOV::JSONFormatter
- Defined in:
- lib/json_formatter.rb
Instance Method Summary collapse
-
#initialize(project, va = {}) ⇒ JSONFormatter
constructor
A new instance of JSONFormatter.
-
#print ⇒ Object
initialize.
Constructor Details
#initialize(project, va = {}) ⇒ JSONFormatter
Returns a new instance of JSONFormatter.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/json_formatter.rb', line 12 def initialize project, va={} @project = project @json = { 'files' => [] } @project.files.each do |file| @json['files'] << { 'name' => file.name, 'meta' => file., 'stats' => file.stats, 'lines' => [] } file.lines.select{|line| line.number > 0}.each do |line| @json['files'][-1]['lines'] << { 'number' => line.number, 'count' => line.count, 'text' => line.text } end # each line end # each file end |
Instance Method Details
#print ⇒ Object
initialize
37 38 39 |
# File 'lib/json_formatter.rb', line 37 def print puts @json.to_json end |