slather 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmQ4NmM0NmNjYWQ3Yjc0NjgzN2Q5ODA0NzVhYmM2M2QxMTMzZGQ1ZA==
4
+ Yjg1ZGQzZjg5N2UxYzFlYjcwZTlhODU1MTdjZmJhOTFlZWM1MDQ2MA==
5
5
  data.tar.gz: !binary |-
6
- OTQwNTNlMTM3MjFhMjBiMzI3ZDQxZjUyODRiYWM4ZDU3MGVjMTBjYg==
6
+ ODBhZWIyMjZiOTA0YjllZDk2NWU5ZTYyNWU4MTgzN2U1NTM2NGZmZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjRhYzYyNGVkMDgwMDliYmJhMDVlNWEyNTUyYTg5YWQ0OTFiMTA2OGJiMDQ1
10
- YzYxYmMyODE1MDEyNGQ0MzY1ZGUzOTdjNWU0NjQ1MTM5OTBiZThmODg2MjVi
11
- MzU3M2JlZTQ1M2Y4NTFhYmQ5MGI0MGU1NWM0YTg0YjYxMjViN2U=
9
+ NDAzNjAyOTMwMTk2N2VmZjdiMmE1YWIyZjhjNGJlMzIyOThhZTMzOTI5YWM2
10
+ MzMyMzk5N2E2NDdkN2NiMDYwY2ZlYTNlOTQyYzkyNjRhMDU3NzllZjVjZDc4
11
+ ZDUxMDE2ZTM2NjJjYTJlMTQ1MGNjNTZhMTQ5NjlkM2JjMmZiYTk=
12
12
  data.tar.gz: !binary |-
13
- NDRlMGE4ZWM2YjZkNWE3YzBkMGZlZWMxMmE4OTAyN2E4MTE2NTE1YjQyMTVh
14
- NTRmZmNmMWFiNWRmZmVjMDY3NTQ3NmNjZjc3OTU2NmVhZWY1NThhYjYzMTc4
15
- NDY2ZDM2MWFiMWFhYTQ0M2E3YzE3ZWU4MzFkMzQzNmZmMzg1ZWI=
13
+ Y2ViZTAzNjViOWYyNjFhMDlmOGQ0NWQwYTU4YzNiZTcwZmYwZGVhNjJhMWM1
14
+ YTA2ZjYzMmU5OTIzN2NlMzYyYjc0ZWRhNTA1MTA0Y2Y1NzBlNWQ1ZDVmZjYz
15
+ MjM0ZDhlYjU3YjZiYjM4OWY5ZjBlNzdiZDhhZDk1ZDNiNDQzNTY=
data/bin/slather CHANGED
@@ -15,6 +15,7 @@ Clamp do
15
15
 
16
16
  option ["--coveralls", "-c"], :flag, "Post coverage results to coveralls"
17
17
  option ["--simple-output", "-s"], :flag, "Output coverage results to the terminal"
18
+ option ["--gutter-json", "-g"], :flag, "Output coverage results as Gutter JSON format"
18
19
 
19
20
  option ["--build-directory", "-b"], "BUILD_DIRECTORY", "The directory where gcno files will be written to. Defaults to derived data."
20
21
  option ["--source-directory"], "SOURCE_DIRECTORY", "The directory where your source files are located."
@@ -72,6 +73,8 @@ Clamp do
72
73
  project.coverage_service = :coveralls
73
74
  elsif simple_output?
74
75
  project.coverage_service = :terminal
76
+ elsif gutter_json?
77
+ project.coverage_service = :gutter_json
75
78
  end
76
79
  end
77
80
 
@@ -0,0 +1,50 @@
1
+ module Slather
2
+ module CoverageService
3
+ module GutterJsonOutput
4
+
5
+ def coverage_file_class
6
+ Slather::CoverageFile
7
+ end
8
+ private :coverage_file_class
9
+
10
+ def post
11
+ output = { 'meta' => { 'timestamp' => DateTime.now.strftime('%Y-%m-%d %H:%M:%S.%6N') } }
12
+ symbols = {}
13
+
14
+ coverage_files.each do |coverage_file|
15
+ next unless coverage_file.gcov_data
16
+
17
+ filename = coverage_file.source_file_pathname.to_s
18
+ filename = filename.sub(Pathname.pwd.to_s, '')[1..-1]
19
+
20
+ coverage_file.gcov_data.split("\n").each do |line|
21
+ data = line.split(':')
22
+
23
+ line_number = data[1].to_i
24
+ next unless line_number > 0
25
+
26
+ coverage = data[0].strip
27
+
28
+ symbol = { 'line' => line_number,
29
+ 'long_text' => '',
30
+ 'short_text' => coverage }
31
+
32
+ if coverage != '-'
33
+ symbol['background_color'] = coverage.to_i > 0 ? '0x35CC4B' : '0xFC635E'
34
+ end
35
+
36
+ if symbols.has_key?(filename)
37
+ symbols[filename] << symbol
38
+ else
39
+ symbols[filename] = [ symbol ]
40
+ end
41
+ end
42
+ end
43
+
44
+ output['symbols_by_file'] = symbols
45
+ File.open('.gutter.json', 'w') { |file| file.write(output.to_json) }
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -104,6 +104,8 @@ module Slather
104
104
  extend(Slather::CoverageService::Coveralls)
105
105
  elsif service == :terminal
106
106
  extend(Slather::CoverageService::SimpleOutput)
107
+ elsif service == :gutter_json
108
+ extend(Slather::CoverageService::GutterJsonOutput)
107
109
  else
108
110
  raise ArgumentError, "`#{coverage_service}` is not a valid coverage service. Try `terminal` or `coveralls`"
109
111
  end
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
data/lib/slather.rb CHANGED
@@ -3,6 +3,7 @@ require 'slather/project'
3
3
  require 'slather/coverage_file'
4
4
  require 'slather/coveralls_coverage_file'
5
5
  require 'slather/coverage_service/coveralls'
6
+ require 'slather/coverage_service/gutter_json_output'
6
7
  require 'slather/coverage_service/simple_output'
7
8
 
8
9
  module Slather
@@ -0,0 +1 @@
1
+ {"meta":{"timestamp":"2014-09-19 11:21:36.112110"},"symbols_by_file":{"spec/fixtures/fixtures/fixtures.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":16,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"-"},{"line":20,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":21,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"}],"spec/fixtures/fixtures/more_files/peekaview.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":16,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":19,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":20,"long_text":"","short_text":"#####","background_color":"0xFC635E"},{"line":21,"long_text":"","short_text":"-"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"-"},{"line":27,"long_text":"","short_text":"-"},{"line":28,"long_text":"","short_text":"-"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"-"}],"spec/fixtures/fixturesTests/fixturesTests.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"-"},{"line":16,"long_text":"","short_text":"-"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"-"},{"line":20,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":21,"long_text":"","short_text":"-"},{"line":22,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"-"},{"line":27,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":28,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"-"},{"line":32,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":33,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":34,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":35,"long_text":"","short_text":"-"},{"line":36,"long_text":"","short_text":"-"}],"spec/fixtures/fixturesTests/peekaviewTests.m":[{"line":1,"long_text":"","short_text":"-"},{"line":2,"long_text":"","short_text":"-"},{"line":3,"long_text":"","short_text":"-"},{"line":4,"long_text":"","short_text":"-"},{"line":5,"long_text":"","short_text":"-"},{"line":6,"long_text":"","short_text":"-"},{"line":7,"long_text":"","short_text":"-"},{"line":8,"long_text":"","short_text":"-"},{"line":9,"long_text":"","short_text":"-"},{"line":10,"long_text":"","short_text":"-"},{"line":11,"long_text":"","short_text":"-"},{"line":12,"long_text":"","short_text":"-"},{"line":13,"long_text":"","short_text":"-"},{"line":14,"long_text":"","short_text":"-"},{"line":15,"long_text":"","short_text":"-"},{"line":16,"long_text":"","short_text":"-"},{"line":17,"long_text":"","short_text":"-"},{"line":18,"long_text":"","short_text":"-"},{"line":19,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":20,"long_text":"","short_text":"-"},{"line":21,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":22,"long_text":"","short_text":"-"},{"line":23,"long_text":"","short_text":"-"},{"line":24,"long_text":"","short_text":"-"},{"line":25,"long_text":"","short_text":"-"},{"line":26,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":27,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":28,"long_text":"","short_text":"-"},{"line":29,"long_text":"","short_text":"-"},{"line":30,"long_text":"","short_text":"-"},{"line":31,"long_text":"","short_text":"2","background_color":"0x35CC4B"},{"line":32,"long_text":"","short_text":"1","background_color":"0x35CC4B"},{"line":33,"long_text":"","short_text":"-"},{"line":34,"long_text":"","short_text":"-"}]}}
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+ require 'json'
3
+
4
+ describe Slather::CoverageService::GutterJsonOutput do
5
+
6
+ let(:fixtures_project) do
7
+ proj = Slather::Project.open(FIXTURES_PROJECT_PATH)
8
+ proj.extend(Slather::CoverageService::GutterJsonOutput)
9
+ end
10
+
11
+ describe '#coverage_file_class' do
12
+ it "should return CoverageFile" do
13
+ expect(fixtures_project.send(:coverage_file_class)).to eq(Slather::CoverageFile)
14
+ end
15
+ end
16
+
17
+ describe '#post' do
18
+ it "should print out the coverage for each file, and then total coverage" do
19
+ fixtures_project.post
20
+
21
+ fixture_json = JSON.parse(File.read(FIXTURES_JSON_PATH))
22
+ fixture_json['meta']['timestamp'] = ''
23
+
24
+ current_json = JSON.parse(File.read('.gutter.json'))
25
+ current_json['meta']['timestamp'] = ''
26
+
27
+ expect(current_json).to eq(fixture_json)
28
+ File.unlink('.gutter.json')
29
+ end
30
+ end
31
+ end
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,7 @@ require 'coveralls'
7
7
 
8
8
  Coveralls.wear!
9
9
 
10
+ FIXTURES_JSON_PATH = File.join(File.dirname(__FILE__), 'fixtures/gutter.json')
10
11
  FIXTURES_PROJECT_PATH = File.join(File.dirname(__FILE__), 'fixtures/fixtures.xcodeproj')
11
12
 
12
13
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slather
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,6 +128,7 @@ files:
128
128
  - lib/slather.rb
129
129
  - lib/slather/coverage_file.rb
130
130
  - lib/slather/coverage_service/coveralls.rb
131
+ - lib/slather/coverage_service/gutter_json_output.rb
131
132
  - lib/slather/coverage_service/simple_output.rb
132
133
  - lib/slather/coveralls_coverage_file.rb
133
134
  - lib/slather/project.rb
@@ -145,8 +146,10 @@ files:
145
146
  - spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist
146
147
  - spec/fixtures/fixturesTests/fixturesTests.m
147
148
  - spec/fixtures/fixturesTests/peekaviewTests.m
149
+ - spec/fixtures/gutter.json
148
150
  - spec/slather/coverage_file_spec.rb
149
151
  - spec/slather/coverage_service/coveralls_spec.rb
152
+ - spec/slather/coverage_service/gutter_json_spec.rb
150
153
  - spec/slather/coverage_service/simple_output_spec.rb
151
154
  - spec/slather/fixtures.gcno
152
155
  - spec/slather/project_spec.rb
@@ -189,8 +192,10 @@ test_files:
189
192
  - spec/fixtures/fixturesTests/Supporting Files/fixturesTests-Info.plist
190
193
  - spec/fixtures/fixturesTests/fixturesTests.m
191
194
  - spec/fixtures/fixturesTests/peekaviewTests.m
195
+ - spec/fixtures/gutter.json
192
196
  - spec/slather/coverage_file_spec.rb
193
197
  - spec/slather/coverage_service/coveralls_spec.rb
198
+ - spec/slather/coverage_service/gutter_json_spec.rb
194
199
  - spec/slather/coverage_service/simple_output_spec.rb
195
200
  - spec/slather/fixtures.gcno
196
201
  - spec/slather/project_spec.rb