gcov2x 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 588bb5cafb28471b6d28b7eb6fc64380335f0d58
4
- data.tar.gz: 3ef57412184fec9d67c56f6e9431f4d6b082fe9e
3
+ metadata.gz: 50fa0a8dd61420208012101bda3b0af01c7938d4
4
+ data.tar.gz: f69ce2235ed8de8a7033f4a8127cb8928e401ae2
5
5
  SHA512:
6
- metadata.gz: 2784a4e1d6ff1ea7a9d1a56fdf43fbb70da5980b08cf16c46d3a8cb5116b676af09bfd30724ea0d0702f3ce8d09724707528404f7ac1a06585e6239bc5e24ae2
7
- data.tar.gz: 46285473496aacf00fe326b131d0ecf3c89a13b82ce3d27c01a61390dc6229c737f00c69936cb6cb779c61c3b7a56798f0cbcdc6166c0890f7ebbc7e3789dad6
6
+ metadata.gz: 27f6b3d1b9d6061dedf03a394befb2eaa679ede1965bc332f069be3a5b8335fe448b30245290a0917bc9517955c6e4085c0064fb7f1c23ad420f814259106459
7
+ data.tar.gz: dd9335ac6eb775306d23e513d7600c53c9fdb807a647c2edde217a28e34dccacc0b81bd39ff2b594f18fb2363440573204c7710dca4c4b7c24fbe3d77dd8b3c7
data/bin/gcov2x CHANGED
@@ -6,6 +6,7 @@ require_relative '../lib/gcov2x'
6
6
  require_relative '../lib/ansii_formatter'
7
7
  require_relative '../lib/xml_formatter'
8
8
  require_relative '../lib/html_formatter'
9
+ require_relative '../lib/json_formatter'
9
10
 
10
11
  class Util
11
12
  def Util.opt_wrap(s, width=61)
@@ -91,7 +92,8 @@ when :xml then
91
92
  formatter = GCOV::XMLFormatter.new( proj, :xsl => cli.config[:xsl] )
92
93
  formatter.print
93
94
  when :json then
94
- fail "json export not implemented yet"
95
+ formatter = GCOV::JSONFormatter.new proj
96
+ formatter.print
95
97
  else
96
98
  fail "Invalid format"
97
99
  end
@@ -0,0 +1,43 @@
1
+
2
+ require_relative './project'
3
+ require_relative './file'
4
+ require_relative './line'
5
+
6
+ require 'json'
7
+
8
+ module GCOV
9
+
10
+ class JSONFormatter
11
+
12
+ def initialize project, va={}
13
+ @project = project
14
+
15
+ @json = {
16
+ 'files' => []
17
+ }
18
+
19
+ @project.files.each do |file|
20
+ @json['files'] << {
21
+ 'name' => file.name,
22
+ 'meta' => file.meta,
23
+ 'stats' => file.stats,
24
+ 'lines' => []
25
+ }
26
+
27
+ file.lines.select{|line| line.number > 0}.each do |line|
28
+ @json['files'][-1]['lines'] << {
29
+ 'number' => line.number,
30
+ 'count' => line.count,
31
+ 'text' => line.text
32
+ }
33
+ end # each line
34
+ end # each file
35
+ end # initialize
36
+
37
+ def print
38
+ puts @json.to_json
39
+ end # JSONFormatter#print
40
+
41
+ end # JSONFormatter
42
+
43
+ end # GCOV
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GCOV
2
- VERSION = '0.2.4'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -1,4 +1,4 @@
1
- require_relative './spec_helper'
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe GCOV::File do
4
4
 
@@ -1,4 +1,4 @@
1
- require_relative './spec_helper'
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe GCOV::Line do
4
4
  describe "#number" do
@@ -1,4 +1,4 @@
1
- require_relative './spec_helper'
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe GCOV::Project do
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcov2x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattias Bergbom
@@ -32,17 +32,18 @@ files:
32
32
  - lib/gcov2x.rb
33
33
  - lib/html_formatter.rb
34
34
  - lib/html_view.html.erb
35
+ - lib/json_formatter.rb
35
36
  - lib/line.rb
36
37
  - lib/project.rb
37
38
  - lib/version.rb
38
39
  - lib/xml_formatter.rb
39
- - spec/data/data2/test3.cpp.gcov
40
- - spec/data/test.cpp.gcov
41
- - spec/data/test1.cpp.gcov
42
- - spec/data/test2.cpp.gcov
43
- - spec/file_spec.rb
44
- - spec/line_spec.rb
45
- - spec/project_spec.rb
40
+ - spec/gcov2x/data/data2/test3.cpp.gcov
41
+ - spec/gcov2x/data/test.cpp.gcov
42
+ - spec/gcov2x/data/test1.cpp.gcov
43
+ - spec/gcov2x/data/test2.cpp.gcov
44
+ - spec/gcov2x/file_spec.rb
45
+ - spec/gcov2x/line_spec.rb
46
+ - spec/gcov2x/project_spec.rb
46
47
  - spec/spec_helper.rb
47
48
  - src/Makefile
48
49
  - src/test.cpp
File without changes
File without changes
File without changes
File without changes