simplecov-teamcity-summary 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f34f987c80b2378d7677c873c11eb4a32891964e
4
+ data.tar.gz: a1a1ab8d83aa9b5cc5cd35a3a0100bfc49ca3458
5
+ SHA512:
6
+ metadata.gz: a8ab0d1f819851d352221bf6cc3b00427a98c199f37e0f4d83110b530548732c80474b2c66ee0d6e5522d0405cc8c7666442d9fcfffecb3f64cd0a436c749cdb
7
+ data.tar.gz: 77f15148363dab284946c72dbe339cd45a96524ba335e9ae0b6a8bf74b69c5271719d01258bc1125823162ef73cab737fa536ccf6413093f6008976bbc8d2358
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /coverage/
data/.simplecov ADDED
@@ -0,0 +1,5 @@
1
+ SimpleCov.profiles.define 'teamcity' do
2
+ at_exit do
3
+ Simplecov::Formatter::TeamcitySummaryFormatter.new.format(SimpleCov.result) if ENV['TEAMCITY_VERSION']
4
+ end
5
+ end
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simplecov-teamcity-summary (0.1.0)
5
+ simplecov
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.0)
11
+ diff-lcs (1.2.5)
12
+ docile (1.1.2)
13
+ method_source (0.8.2)
14
+ multi_json (1.8.4)
15
+ pry (0.9.12.6)
16
+ coderay (~> 1.0)
17
+ method_source (~> 0.8)
18
+ slop (~> 3.4)
19
+ rake (10.1.1)
20
+ rspec (2.14.1)
21
+ rspec-core (~> 2.14.0)
22
+ rspec-expectations (~> 2.14.0)
23
+ rspec-mocks (~> 2.14.0)
24
+ rspec-core (2.14.7)
25
+ rspec-expectations (2.14.4)
26
+ diff-lcs (>= 1.1.3, < 2.0)
27
+ rspec-mocks (2.14.4)
28
+ simplecov (0.8.2)
29
+ docile (~> 1.1.0)
30
+ multi_json
31
+ simplecov-html (~> 0.8.0)
32
+ simplecov-html (0.8.0)
33
+ slop (3.4.7)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ bundler (~> 1.3)
40
+ pry
41
+ rake
42
+ rspec
43
+ simplecov-teamcity-summary!
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (C) 2014 Ben Cochez
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Simplecov::TeamcitySummary
2
+
3
+ SimpleCov formatter to present coverage results to TeamCity.
4
+
5
+ ![See your coverage results in TeamCity](https://raw.github.com/benc/simplecov-teamcity-summary/master/img/coverage_results.png)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'simplecov-teamcity-summary'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install simplecov-teamcity-summary
20
+
21
+ ## Configuration
22
+
23
+ ### When starting Simplecov
24
+
25
+ ```ruby
26
+ require 'simplecov'
27
+ SimpleCov.start do
28
+ at_exit do
29
+ Simplecov::Formatter::TeamcitySummaryFormatter.new.format(SimpleCov.result) if ENV['TEAMCITY_VERSION']
30
+ end
31
+ end
32
+ ```
33
+
34
+ ### Using a Simplecov profile
35
+
36
+ Create or edit a .simplecov file and include:
37
+
38
+ ```ruby
39
+ SimpleCov.profiles.define 'teamcity' do
40
+ at_exit do
41
+ Simplecov::Formatter::TeamcitySummaryFormatter.new.format(SimpleCov.result) if ENV['TEAMCITY_VERSION']
42
+ end
43
+ end
44
+ ```
45
+
46
+ Then, start your Simplecov instance like this:
47
+
48
+ ```ruby
49
+ require 'simplecov'
50
+ SimpleCov.start 'teamcity'
51
+ ```
52
+
53
+ ## License
54
+
55
+ This is free software, and may be redistributed under the terms of MIT license.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rake'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Run RSpec'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
Binary file
@@ -0,0 +1 @@
1
+ require 'simplecov-teamcity-summary/formatter'
@@ -0,0 +1,20 @@
1
+ require 'simplecov'
2
+
3
+ module Simplecov::Formatter
4
+ class TeamcitySummaryFormatter
5
+ def format(simplecov_results)
6
+ puts format_teamcity(simplecov_results)
7
+ end
8
+
9
+ def format_teamcity(simplecov_results)
10
+ <<-eos
11
+
12
+ ##teamcity[blockOpened name='Code Coverage Summary']
13
+ ##teamcity[buildStatisticValue key='CodeCoverageL' value='#{simplecov_results.covered_percent}']
14
+ ##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='#{simplecov_results.covered_lines}']
15
+ ##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='#{simplecov_results.total_lines}']
16
+ ##teamcity[blockClosed name='Code Coverage Summary']
17
+ eos
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Simplecov
2
+ module TeamcitySummary
3
+ VERSION="0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simplecov-teamcity-summary/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "simplecov-teamcity-summary"
8
+ gem.version = Simplecov::TeamcitySummary::VERSION
9
+ gem.authors = ["Ben Cochez"]
10
+ gem.email = ["ben@cochezconsult.be"]
11
+ gem.description = "Simplecov formatter that prints coverage summary information to display in TeamCity."
12
+ gem.summary = gem.description
13
+ gem.homepage = "https://github.com/benc/simplecov-teamcity-summary"
14
+ gem.license = 'MIT'
15
+
16
+ gem.files = `git ls-files`.split($/).reject do |filename|
17
+ filename.match(/^vendor\/cache/) || filename.match(/^doc/) || filename.match(/^.yardoc/)
18
+ end
19
+ gem.test_files = gem.files.grep(%r{^(spec)/})
20
+ gem.require_paths = ["lib"]
21
+
22
+ gem.add_development_dependency 'bundler', '~> 1.3'
23
+ gem.add_development_dependency 'pry'
24
+ gem.add_development_dependency 'rake'
25
+ gem.add_development_dependency 'rspec'
26
+ gem.add_dependency 'simplecov'
27
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Simplecov::Formatter::TeamcitySummaryFormatter do
4
+ describe "#format" do
5
+ before do
6
+ expect_any_instance_of(described_class).to receive(:format_teamcity).with(:arg).and_return(:return_value)
7
+ expect_any_instance_of(described_class).to receive(:puts).with(:return_value)
8
+ end
9
+ subject { described_class.new.format(:arg) }
10
+ it { expect(subject).to be_nil }
11
+ end
12
+
13
+ describe "#format_teamcity" do
14
+ let(:simplecov_result) { OpenStruct.new({covered_percent: '12.34567', covered_lines: '1234', total_lines: '5678' })}
15
+ let(:open_block) { "##teamcity[blockOpened name='Code Coverage Summary']" }
16
+ let(:coverage_percent) { "##teamcity[buildStatisticValue key='CodeCoverageL' value='12.34567']" }
17
+ let(:covered_lines) { "##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='1234']" }
18
+ let(:total_lines) { "##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='5678']" }
19
+ let(:close_block) { "##teamcity[blockClosed name='Code Coverage Summary']" }
20
+
21
+ subject { described_class.new.format_teamcity(simplecov_result) }
22
+
23
+ it { expect(subject).to include(open_block) }
24
+ it { expect(subject).to include(coverage_percent) }
25
+ it { expect(subject).to include(covered_lines) }
26
+ it { expect(subject).to include(total_lines) }
27
+ it { expect(subject).to include(close_block) }
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ require 'simplecov'
2
+ SimpleCov.start 'teamcity'
3
+
4
+ require 'simplecov-teamcity-summary'
5
+ require 'pry'
6
+
7
+ support_path = File.expand_path("spec/support")
8
+ Dir["#{support_path}/**/*.rb"].each { |f| require f }
9
+
10
+ RSpec.configure do |config|
11
+ config.color_enabled = true
12
+ config.tty = true
13
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-teamcity-summary
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Cochez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Simplecov formatter that prints coverage summary information to display
84
+ in TeamCity.
85
+ email:
86
+ - ben@cochezconsult.be
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".simplecov"
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - img/coverage_results.png
99
+ - lib/simplecov-teamcity-summary.rb
100
+ - lib/simplecov-teamcity-summary/formatter.rb
101
+ - lib/simplecov-teamcity-summary/version.rb
102
+ - simplecov-teamcity-summary.gemspec
103
+ - spec/lib/formatter_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://github.com/benc/simplecov-teamcity-summary
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.2.0
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Simplecov formatter that prints coverage summary information to display in
129
+ TeamCity.
130
+ test_files:
131
+ - spec/lib/formatter_spec.rb
132
+ - spec/spec_helper.rb