simplecov-rcov-text 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ coverage
2
+ doc
3
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ group :test, :development do
4
+ gem 'simplecov'
5
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,12 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ simplecov (0.4.2)
5
+ simplecov-html (~> 0.4.4)
6
+ simplecov-html (0.4.4)
7
+
8
+ PLATFORMS
9
+ ruby
10
+
11
+ DEPENDENCIES
12
+ simplecov
data/README.rdoc ADDED
@@ -0,0 +1,58 @@
1
+ = Simplecov Rcov Formatter Text
2
+
3
+ The target of this formatter is to cheat on *metric_fu* so it's possible to use simplecov instead rcov.
4
+
5
+ = Install
6
+ gem install simplecov-rcov-text
7
+
8
+ = Usage
9
+
10
+ Add the gem to the Gemfile preferably in the group test:
11
+ gem 'simplecov', :require => false
12
+ gem 'simplecov-rcov-text', :require => false
13
+
14
+ Create a .metrics file in the root of project with the code:
15
+ MetricFu::Configuration.run do |config|
16
+ config.rcov[:external] = 'coverage/rcov/rcov.txt'
17
+ end
18
+
19
+
20
+ And follow the instructions of Simplecov[https://github.com/colszowka/simplecov] and metric_fu[https://github.com/jscruggs/metric_fu] or metrical[https://github.com/iain/metrical].
21
+
22
+ == Simplest way
23
+ require 'simplecov'
24
+ require 'simplecov-rcov-text'
25
+ SimpleCov.formatter = SimpleCov::Formatter::RcovTextFormatter
26
+
27
+ == Using with HTML Format
28
+ require 'simplecov'
29
+ require 'simplecov-rcov-text'
30
+ class SimpleCov::Formatter::MergedFormatter
31
+ def format(result)
32
+ SimpleCov::Formatter::HTMLFormatter.new.format(result)
33
+ SimpleCov::Formatter::RcovTextFormatter.new.format(result)
34
+ end
35
+ end
36
+ SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
37
+
38
+ == Running metric_fu/metrical
39
+ Be sure that you configured simplecov and simplecov-rcov-text.
40
+
41
+ Run your test framework, example:
42
+ rspec spec
43
+
44
+ After that you can run the metric_fu/metrical command.
45
+
46
+ <b>Don't forget to configure .metrics file!</b>
47
+ -----
48
+ = Example of generated file
49
+ metric_fu shift the first line
50
+ class SomeClass
51
+ def method_1
52
+ 1+1
53
+ end
54
+
55
+ def method_2 ( value )
56
+ !! value * value
57
+ end
58
+ end
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.pattern = "test/test_*.rb"
8
+ end
@@ -0,0 +1,48 @@
1
+ require 'bundler'
2
+ Bundler.setup(:default)
3
+ require 'cgi'
4
+ require 'fileutils'
5
+ require 'time'
6
+
7
+ unless defined?(SimpleCov)
8
+ raise RuntimeError, "simplecov-rcov-text is a formatter for simplecov. Please update your test helper and gemfile to require 'simplecov'!"
9
+ end
10
+
11
+
12
+ class SimpleCov::Formatter::RcovTextFormatter
13
+ def format( result )
14
+ FileUtils.mkdir_p(SimpleCov::Formatter::RcovTextFormatter.output_path)
15
+
16
+ File.open(File.join(SimpleCov::Formatter::RcovTextFormatter.output_path, SimpleCov::Formatter::RcovTextFormatter.file_name), "w+") do |rcov|
17
+ rcov << create_content(result)
18
+ end
19
+ end
20
+
21
+ def create_content(result)
22
+ content = "metric_fu shift the first line\n"
23
+ result.source_files.each do |source_file|
24
+ content << "=" * 80
25
+ content << "\n #{simple_file_name(source_file)}\n"
26
+ content << "=" * 80
27
+ content << "\n"
28
+ source_file.lines.each do |line|
29
+ content << (line.missed? ? '!!' : ' ')
30
+ content << " #{line.src.chomp}\n"
31
+ end
32
+ content << "\n"
33
+ end
34
+ content
35
+ end
36
+
37
+ def simple_file_name(source_file)
38
+ source_file.filename.gsub(SimpleCov.root, '.')
39
+ end
40
+
41
+ def self.file_name
42
+ "rcov.txt"
43
+ end
44
+
45
+ def self.output_path
46
+ File.join( SimpleCov.coverage_path, "/rcov" )
47
+ end
48
+ end
@@ -0,0 +1,8 @@
1
+ module SimpleCov
2
+ module Formatter
3
+ class RcovTextFormatter
4
+ VERSION = "0.0.2"
5
+ UPSTREAM_URL = "https://github.com/kina/simplecov-rcov-text"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "simplecov-rcov-text/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "simplecov-rcov-text"
7
+ s.version = SimpleCov::Formatter::RcovTextFormatter::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["William 'Kina'"]
10
+ s.email = ["thekina@gmail.com"]
11
+ s.homepage = "https://github.com/kina/simplecov-rcov-text"
12
+ s.summary = %q{A Simplecov Formatter}
13
+ s.description = %q{Just a Simplecov Formatter to cheat metric_fu.
14
+ Generate a rcov.txt file.}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+
19
+ s.rubyforge_project = "simplecov-rcov-text"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,9 @@
1
+ class SomeClass
2
+ def method_1
3
+ 1+1
4
+ end
5
+
6
+ def method_2 ( value )
7
+ value * value
8
+ end
9
+ end
@@ -0,0 +1,37 @@
1
+ require 'minitest/unit'
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+
5
+ require 'simplecov-rcov-text'
6
+
7
+ class TestSimpleCovFormatterRcovTextFormatter < MiniTest::Unit::TestCase
8
+ def setup
9
+ @rcov_file = File.join( SimpleCov::Formatter::RcovTextFormatter.output_path, SimpleCov::Formatter::RcovTextFormatter.file_name)
10
+ @result = SimpleCov::Result.new(
11
+ {
12
+ File.expand_path( File.join( File.dirname( __FILE__ ), 'fixtures', 'some_class.rb' ) ) =>
13
+ [1,1,1,1,nil,1,0,1,1]
14
+ }
15
+ )
16
+
17
+
18
+ end
19
+ def test_format
20
+ if File.exists?( @rcov_file )
21
+ File.delete( @rcov_file )
22
+ end
23
+
24
+ SimpleCov::Formatter::RcovTextFormatter.new.format( @result )
25
+
26
+ assert File.exists?( @rcov_file )
27
+
28
+ end
29
+ def test_create_content
30
+ content = SimpleCov::Formatter::RcovTextFormatter.new.create_content( @result )
31
+ test = "\="*80
32
+ assert_match /#{test}/,content
33
+
34
+ assert_match /!! value \* value/,content
35
+
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-rcov-text
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - William 'Kina'
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-28 00:00:00 -03:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: |-
18
+ Just a Simplecov Formatter to cheat metric_fu.
19
+ Generate a rcov.txt file.
20
+ email:
21
+ - thekina@gmail.com
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files:
27
+ - README.rdoc
28
+ files:
29
+ - .gitignore
30
+ - Gemfile
31
+ - Gemfile.lock
32
+ - README.rdoc
33
+ - Rakefile
34
+ - lib/simplecov-rcov-text.rb
35
+ - lib/simplecov-rcov-text/version.rb
36
+ - simplecov-rcov-text.gemspec
37
+ - test/fixtures/some_class.rb
38
+ - test/test_simplecov-rcov-text.rb
39
+ has_rdoc: true
40
+ homepage: https://github.com/kina/simplecov-rcov-text
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project: simplecov-rcov-text
63
+ rubygems_version: 1.6.2
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: A Simplecov Formatter
67
+ test_files:
68
+ - test/fixtures/some_class.rb
69
+ - test/test_simplecov-rcov-text.rb