simplecov-multi 0.0.1

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.
@@ -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-multi.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.
@@ -0,0 +1,36 @@
1
+ # SimpleCov Multi
2
+
3
+ Provide a simple formatter which contains multiple formatters. Similar to the explanation on the SimpleCov README file about using multiple formatters.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'simplecov-multi'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install simplecov-multi
18
+
19
+ ## Usage
20
+
21
+ In your `spec_helper`, be sure to set the SimpleCov formatter as the Multi wrapper:
22
+
23
+ ```ruby
24
+ require 'simplecov'
25
+ require 'simplecov-multi'
26
+ multi = SimpleCov::Formatter::MultiFormatter.new
27
+ multi << SimpleCov::Formatter::HTMLFormatter.new
28
+ multi << SimpleCov::Formatter::SomeOtherFormatter.new
29
+ # ... etc
30
+ SimpleCov.formatter = multi
31
+ SimpleCov.start
32
+ ```
33
+
34
+ ## Author
35
+
36
+ This formatter was created by [BJ Neilsen](http://twitter.com/localshred). Hopefully it's useful to you.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs.push "lib"
7
+ t.test_files = FileList['spec/*_spec.rb']
8
+ end
@@ -0,0 +1,25 @@
1
+ require "simplecov-multi/version"
2
+
3
+ class SimpleCov::Formatter::MultiFormatter
4
+ attr_reader :formatters
5
+
6
+ def initialize
7
+ @formatters = []
8
+ end
9
+
10
+ # Iterate through supplied formatters calling
11
+ # their format methods and supplying the given result
12
+ def format(result)
13
+ @formatters.each do |formatter|
14
+ formatter.format(result)
15
+ end
16
+ end
17
+
18
+ # Append a new formatter
19
+ def <<(formatter)
20
+ unless formatter.respond_to?(:format)
21
+ raise 'Formatter does not respond to `format` method'
22
+ end
23
+ @formatters << formatter
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ module SimpleCov
2
+ module Formatter
3
+ class MultiFormatter
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/simplecov-multi/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{Provide a simple formatter which contains multiple formatters. Similar to the explanation on the SimpleCov README file about using multiple formatters.}
8
+ gem.summary = %q{SimpleCov Multi Formatter}
9
+ gem.homepage = "http://github.com/localshred/simplecov-multi"
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-multi"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = SimpleCov::Formatter::MultiFormatter::VERSION
17
+ end
@@ -0,0 +1,70 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'simplecov-multi'
4
+
5
+ class BaseFormatter
6
+ def format(result)
7
+ result << '%s#format' % [self.class.name]
8
+ end
9
+ end
10
+ class FormatterOne < BaseFormatter; end
11
+ class FormatterTwo < BaseFormatter; end
12
+ class FormatterThree < BaseFormatter; end
13
+
14
+ describe SimpleCov::Formatter::MultiFormatter do
15
+ describe '.new' do
16
+ it 'creates an empty formatter list' do
17
+ multi = SimpleCov::Formatter::MultiFormatter.new
18
+ multi.formatters.must_be_instance_of(Array)
19
+ multi.formatters.must_be_empty
20
+ end
21
+ end
22
+
23
+ describe '#format' do
24
+ it 'responds to #format' do
25
+ SimpleCov::Formatter::MultiFormatter.new.must_respond_to(:format)
26
+ end
27
+
28
+ it 'calls #format on each appended formatter' do
29
+ one = FormatterOne.new
30
+ two = FormatterTwo.new
31
+ three = FormatterThree.new
32
+
33
+ multi = SimpleCov::Formatter::MultiFormatter.new
34
+ multi << one
35
+ multi << two
36
+ multi << three
37
+
38
+ result = ["result obj"]
39
+ multi.format(result)
40
+ result.must_equal([
41
+ "result obj",
42
+ 'FormatterOne#format',
43
+ 'FormatterTwo#format',
44
+ 'FormatterThree#format',
45
+ ])
46
+ end
47
+ end
48
+
49
+ describe '#<<' do
50
+ it 'appends given formatter onto formatters list' do
51
+ one = FormatterOne.new
52
+ two = FormatterTwo.new
53
+ three = FormatterThree.new
54
+
55
+ multi = SimpleCov::Formatter::MultiFormatter.new
56
+ multi.formatters.must_be_empty
57
+ multi << one
58
+ multi << two
59
+ multi << three
60
+ multi.formatters.count.must_equal(3)
61
+ end
62
+
63
+ it 'raises an error if the formatter does not respond to #format' do
64
+ class BogusFormatter; end
65
+ multi = SimpleCov::Formatter::MultiFormatter.new
66
+ puts *(lambda {}.methods.grep(/must_/))
67
+ lambda { multi << BogusFormatter }.must_raise(/Formatter does not respond to `format` method/)
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-multi
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-14 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Provide a simple formatter which contains multiple formatters. Similar
15
+ to the explanation on the SimpleCov README file about using multiple formatters.
16
+ email:
17
+ - bj.neilsen@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - lib/simplecov-multi.rb
28
+ - lib/simplecov-multi/version.rb
29
+ - simplecov-multi.gemspec
30
+ - spec/simplecov-multi_spec.rb
31
+ homepage: http://github.com/localshred/simplecov-multi
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.15
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: SimpleCov Multi Formatter
55
+ test_files:
56
+ - spec/simplecov-multi_spec.rb
57
+ has_rdoc: