simplecov-text 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simplecov-text.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 BJ Neilsen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Simplecov::Text
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'simplecov-text'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install simplecov-text
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:spec) do |t|
6
+ t.libs << "libs"
7
+ t.test_files = FileList['spec/*_spec.rb']
8
+ end
@@ -0,0 +1,43 @@
1
+ require "simplecov-text/version"
2
+
3
+ module SimpleCov
4
+ module Formatter
5
+ class TextFormatter
6
+
7
+ def format(result)
8
+ output = ""
9
+ output << sprintf("%0.2f", result.covered_percent) << "\n"
10
+ output << "%d of %d lines covered (%0.2f hits per line)" % [
11
+ result.covered_lines,
12
+ result.total_lines,
13
+ result.covered_strength
14
+ ]
15
+
16
+ result.groups.each do |name, files|
17
+ output << "Group: #{name}" << "\n"
18
+ output << "="*40 << "\n"
19
+ files.each do |file|
20
+ output << "%s (coverage: %0.2f%%)\n" % [
21
+ file.filename,
22
+ file.covered_percent
23
+ ]
24
+ end
25
+ output << "\n"
26
+ end
27
+
28
+ write_result(output)
29
+ end
30
+
31
+ def write_result(result)
32
+ File.open(path, 'w') do |f|
33
+ f.write(result)
34
+ end
35
+ end
36
+
37
+ def path
38
+ File.join(SimpleCov.coverage_path, 'result.txt')
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,7 @@
1
+ module SimpleCov
2
+ module Formatter
3
+ class TextFormatter
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/simplecov-text/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["BJ Neilsen"]
6
+ gem.email = ["bj.neilsen@gmail.com"]
7
+ gem.description = %q{SimpleCov Text Formatter}
8
+ gem.summary = gem.description
9
+ gem.homepage = "http://www.rand9.com"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "simplecov-text"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = SimpleCov::Formatter::TextFormatter::VERSION
17
+
18
+ gem.add_runtime_dependency 'simplecov'
19
+
20
+ gem.add_development_dependency 'rspec'
21
+ gem.add_development_dependency 'fakefs'
22
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleCov::Formatter::TextFormatter do
4
+
5
+ subject { SimpleCov::Formatter::TextFormatter.new }
6
+
7
+ def read_coverage_file(file)
8
+ File.read(file)
9
+ end
10
+
11
+ describe '#format' do
12
+ let(:result) {
13
+ double('simplecov result', {
14
+ :covered_percent => 75.0,
15
+ :covered_lines => 75,
16
+ :total_lines => 100,
17
+ :covered_strength => 1.0,
18
+ :groups => [group]
19
+ })
20
+ }
21
+
22
+ let(:group) {
23
+ double('group', {
24
+ :name => 'My Test Group',
25
+ :files => [file]
26
+ })
27
+ }
28
+
29
+ let(:file) {
30
+ double('file', {
31
+ :filename => 'my_test_file.rb',
32
+ :covered_percent => 75.0
33
+ })
34
+ }
35
+
36
+ it 'responds to #format method' do
37
+ subject.should respond_to(:format)
38
+ end
39
+
40
+ it 'writes the covered percentage to the text file' do
41
+ result.stub_chain(:groups, :each).and_yield(group.name, group.files)
42
+ subject.format(result)
43
+ read_coverage_file(subject.path).should =~ /75.00/
44
+ end
45
+ end
46
+
47
+ describe '#write_result' do
48
+ it 'writes the given line to the coverage file' do
49
+ subject.write_result('Hello, World')
50
+ read_coverage_file(subject.path).should =~ /Hello, World/
51
+ end
52
+ end
53
+
54
+ describe '#path' do
55
+ it 'provides the coverage output file path' do
56
+ subject.path.should eq(File.join(SimpleCov.coverage_path, 'result.txt'))
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec'
4
+ require 'fakefs/safe'
5
+ require 'simplecov'
6
+
7
+ $: << File.expand_path('../../lib', __FILE__)
8
+ require 'simplecov-text'
9
+
10
+ RSpec.configure do |config|
11
+ config.before(:suite) do
12
+ FakeFS.activate!
13
+ end
14
+
15
+ config.after(:suite) do
16
+ FakeFS.deactivate!
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-text
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - BJ Neilsen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: simplecov
16
+ requirement: &2156917480 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2156917480
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &2156916880 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2156916880
36
+ - !ruby/object:Gem::Dependency
37
+ name: fakefs
38
+ requirement: &2156916300 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2156916300
47
+ description: SimpleCov Text Formatter
48
+ email:
49
+ - bj.neilsen@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - lib/simplecov-text.rb
60
+ - lib/simplecov-text/version.rb
61
+ - simplecov-text.gemspec
62
+ - spec/simplecov-text_spec.rb
63
+ - spec/spec_helper.rb
64
+ homepage: http://www.rand9.com
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.15
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: SimpleCov Text Formatter
88
+ test_files:
89
+ - spec/simplecov-text_spec.rb
90
+ - spec/spec_helper.rb
91
+ has_rdoc: