simplecov-sublime-ruby-coverage 1.0.0

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ Manifest
2
+ README.md
3
+ Rakefile
4
+ lib/simplecov-sublime-ruby-coverage.rb
5
+ simplecov-sublime-ruby-coverage.gemspec
6
+ test/fixtures/app/controllers/sample_controller.rb
7
+ test/fixtures/app/models/user.rb
8
+ test/fixtures/sample.rb
9
+ test/fixtures/test-fixtures-app-controllers-sample_controller_rb.csv
10
+ test/fixtures/test-fixtures-app-models-user_rb.csv
11
+ test/fixtures/test-fixtures-sample_rb.csv
12
+ test/helper.rb
13
+ test/simplecov-sublime-ruby-coverage_test.rb
@@ -0,0 +1,29 @@
1
+ SimpleCov Sublime Ruby Coverage Formatter gem
2
+ =============================================
3
+
4
+ Is a formatter for the ruby 1.9+ coverage gem: [SimpleCov](http://github.com/colszowka/simplecov) to work with the [Ruby Coverage Formatter](http://github.com/integrum/SublimeRubyCoverage) plugin for Sublime 2
5
+
6
+ Install
7
+ =======
8
+
9
+ $ [sudo] gem install simplecov-sublime-ruby-coverage
10
+
11
+ Usage
12
+ =====
13
+
14
+ require 'simplecov-sublime-ruby-coverage'
15
+ SimpleCov.formatter = SimpleCov::Formatter::SublimeRubyCoverageFormatter
16
+
17
+ TODO
18
+ ====
19
+
20
+ The actual version generates many simple text files, one for every source file.
21
+
22
+ Credits
23
+ =======
24
+
25
+ **Authors** Drew LeSueur, Jade Meskill and Roy van de Water: http://integrumtech.com
26
+ **Copyright** Copyright (c) 2012 Integrum Technologies, LLC
27
+ **License** Released under the MIT license.
28
+ **Originally Forked From** http://github.com/fguillen/simplecov-csv
29
+
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('simplecov-sublime-ruby-coverage', '1.0.0') do |p|
6
+ p.description = "Sublime Ruby Coverage formatter for SimpleCov"
7
+ p.url = "http://github.com/integrum/simplecov-sublime-ruby-coverage"
8
+ p.author = "Integrum Dudes http://integrumtech.com"
9
+ p.email = "everyone+github@integrumtech.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ p.runtime_dependencies = ['simplecov']
13
+ end
@@ -0,0 +1,45 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+
4
+ class SimpleCov::Formatter::SublimeRubyCoverageFormatter
5
+
6
+ def format(result)
7
+
8
+ @path_relativizer = Hash.new{|h,base|
9
+ h[base] = Pathname.new(base).cleanpath.to_s.gsub(%r{^\w:[/\\]}, "").gsub(/\./, "_").gsub(/[\\\/]/, "-") + ".csv"
10
+ }
11
+
12
+ FileUtils.mkdir_p output_path
13
+
14
+ result.files.each do |file|
15
+ data = []
16
+
17
+ file.lines.each do |line|
18
+ data << ((line.covered? || line.status == 'never') ? '1' : '0')
19
+ end
20
+
21
+ csv = data.join("\n")
22
+
23
+ result_file_path = File.join(output_path, relative_filename(shortened_filename(file)))
24
+ File.open(result_file_path, "w") do |file_result|
25
+ file_result.write csv
26
+ end
27
+ end
28
+
29
+ puts "Coverage report generated for #{result.command_name} to #{output_path}"
30
+ end
31
+
32
+ def output_path
33
+ File.join SimpleCov.coverage_path, 'sublime-ruby-coverage'
34
+ end
35
+
36
+ private
37
+
38
+ def relative_filename(path)
39
+ @path_relativizer[path]
40
+ end
41
+
42
+ def shortened_filename(source_file)
43
+ source_file.filename.gsub(SimpleCov.root, '.')
44
+ end
45
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "simplecov-sublime-ruby-coverage"
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Integrum Dudes http://integrumtech.com"]
9
+ s.date = "2012-09-24"
10
+ s.description = "Sublime Ruby Coverage formatter for SimpleCov"
11
+ s.email = "everyone+github@integrumtech.com"
12
+ s.extra_rdoc_files = ["README.md", "lib/simplecov-sublime-ruby-coverage.rb"]
13
+ s.files = ["README.md", "Rakefile", "lib/simplecov-sublime-ruby-coverage.rb", "simplecov-sublime-ruby-coverage.gemspec", "test/fixtures/app/controllers/sample_controller.rb", "test/fixtures/app/models/user.rb", "test/fixtures/sample.rb", "test/fixtures/test-fixtures-app-controllers-sample_controller_rb.csv", "test/fixtures/test-fixtures-app-models-user_rb.csv", "test/fixtures/test-fixtures-sample_rb.csv", "test/helper.rb", "test/simplecov-sublime-ruby-coverage_test.rb", "Manifest"]
14
+ s.homepage = "http://github.com/integrum/simplecov-sublime-ruby-coverage"
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Simplecov-sublime-ruby-coverage", "--main", "README.md"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = "simplecov-sublime-ruby-coverage"
18
+ s.rubygems_version = "1.8.24"
19
+ s.summary = "Sublime Ruby Coverage formatter for SimpleCov"
20
+ s.test_files = ["test/simplecov-sublime-ruby-coverage_test.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<simplecov>, [">= 0"])
27
+ else
28
+ s.add_dependency(%q<simplecov>, [">= 0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<simplecov>, [">= 0"])
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ # Foo class
2
+ class Foo
3
+ def initialize
4
+ @foo = 'baz'
5
+ end
6
+
7
+ def bar
8
+ @foo
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # Foo class
2
+ class Foo
3
+ def initialize
4
+ @foo = 'baz'
5
+ end
6
+
7
+ def bar
8
+ @foo
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # Foo class
2
+ class Foo
3
+ def initialize
4
+ @foo = 'baz'
5
+ end
6
+
7
+ def bar
8
+ @foo
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ 1
2
+ 1
3
+ 1
4
+ 1
5
+ 1
6
+ 1
7
+ 1
8
+ 1
9
+ 1
10
+ 1
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'mocha'
4
+ require 'simplecov'
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+ require 'simplecov-sublime-ruby-coverage'
9
+
10
+ class Test::Unit::TestCase
11
+ end
@@ -0,0 +1,26 @@
1
+ require "#{File.dirname(__FILE__)}/helper"
2
+
3
+ class SimplecovSublimeRubyCoverageFormatterTest < Test::Unit::TestCase
4
+ def test_format
5
+ SimpleCov.stubs(:coverage_path).returns("/tmp")
6
+
7
+ @original_result = {
8
+ File.join(fixtures_path, 'sample.rb') => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
9
+ File.join(fixtures_path, 'app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
10
+ File.join(fixtures_path, 'app/controllers/sample_controller.rb') => [nil, 1, 1, 1, nil, nil, 0, 0, nil, nil]
11
+ }
12
+
13
+ @result = SimpleCov::Result.new(@original_result)
14
+ formatter = SimpleCov::Formatter::SublimeRubyCoverageFormatter.new()
15
+ formatter.format(@result)
16
+
17
+ Dir[File.join(formatter.output_path, '*')].each do |output_file_path|
18
+ fixture_path = File.join fixtures_path, File.basename(output_file_path)
19
+ assert FileUtils.compare_file(fixture_path, output_file_path)
20
+ end
21
+ end
22
+
23
+ def fixtures_path
24
+ File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-sublime-ruby-coverage
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Integrum Dudes http://integrumtech.com
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: simplecov
16
+ requirement: !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: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Sublime Ruby Coverage formatter for SimpleCov
31
+ email: everyone+github@integrumtech.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files:
35
+ - README.md
36
+ - lib/simplecov-sublime-ruby-coverage.rb
37
+ files:
38
+ - README.md
39
+ - Rakefile
40
+ - lib/simplecov-sublime-ruby-coverage.rb
41
+ - simplecov-sublime-ruby-coverage.gemspec
42
+ - test/fixtures/app/controllers/sample_controller.rb
43
+ - test/fixtures/app/models/user.rb
44
+ - test/fixtures/sample.rb
45
+ - test/fixtures/test-fixtures-app-controllers-sample_controller_rb.csv
46
+ - test/fixtures/test-fixtures-app-models-user_rb.csv
47
+ - test/fixtures/test-fixtures-sample_rb.csv
48
+ - test/helper.rb
49
+ - test/simplecov-sublime-ruby-coverage_test.rb
50
+ - Manifest
51
+ homepage: http://github.com/integrum/simplecov-sublime-ruby-coverage
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --line-numbers
56
+ - --inline-source
57
+ - --title
58
+ - Simplecov-sublime-ruby-coverage
59
+ - --main
60
+ - README.md
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '1.2'
75
+ requirements: []
76
+ rubyforge_project: simplecov-sublime-ruby-coverage
77
+ rubygems_version: 1.8.24
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Sublime Ruby Coverage formatter for SimpleCov
81
+ test_files:
82
+ - test/simplecov-sublime-ruby-coverage_test.rb