simplecov 0.11.1 → 0.13.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4af948b77b779812e38aae3eaa154f6a280c910
4
- data.tar.gz: 80705587d23aeabb4a70eeb6a6e1ec0d1a8b7163
3
+ metadata.gz: 15fa4589e25ee4710bdbcec7485a4d8ec7be7abb
4
+ data.tar.gz: a1627cf287ce3c70ba2d60e0943f28f90fcdef79
5
5
  SHA512:
6
- metadata.gz: 86e09f20723efd9b0cd2574b6bc0191c5f7f0483a4bd50d0d7d3b77d227239bda9db764e53b3254c7497a95ab052810786895f0fbb1ea1892bfaf505a56254aa
7
- data.tar.gz: 1e2286d2c6bb0c683315b6ef74f80262a90610b58fde1465b6a21511075f37554a6ca17a0fa4219fed196da673d67685c85fa9441b91edd2cd6a4a258fa078fd
6
+ metadata.gz: 03a052dcae5923fe19e56f6f20fbd390505f03dca386d51eaca4b525252054856ce492e783e6923ad3b89a46719b89556747b8bbac295513b1d245fba3232e79
7
+ data.tar.gz: e2cd84b984e35dfa0c048f375ed2555f08d4df239d616d7c70289b086b1904394b1344f177ad5d7dd08cfb695fe2c22d5375af8e07da5d773500b034d87d4b1c
data/.rubocop.yml CHANGED
@@ -4,6 +4,9 @@ AllCops:
4
4
  - 'tmp/**/*'
5
5
  - 'vendor/bundle/**/*'
6
6
 
7
+ Bundler/OrderedGems:
8
+ Enabled: false
9
+
7
10
  Lint/AmbiguousRegexpLiteral:
8
11
  Exclude:
9
12
  - 'features/**/*_steps.rb'
@@ -13,6 +16,10 @@ Lint/AmbiguousRegexpLiteral:
13
16
  Metrics/AbcSize:
14
17
  Max: 25 # TODO: Lower to 15
15
18
 
19
+ Metrics/BlockLength:
20
+ Exclude:
21
+ - 'spec/**/*.rb'
22
+
16
23
  Metrics/BlockNesting:
17
24
  Max: 2
18
25
 
@@ -66,5 +73,12 @@ Style/FileName:
66
73
  Exclude:
67
74
  - 'spec/fixtures/utf-8.rb'
68
75
 
69
- Style/TrailingComma:
70
- EnforcedStyleForMultiline: 'comma'
76
+ Style/TrailingCommaInLiteral:
77
+ EnforcedStyleForMultiline: comma
78
+
79
+ Style/GuardClause:
80
+ Enabled: false
81
+
82
+ Style/MutableConstant:
83
+ Exclude:
84
+ - 'lib/simplecov/version.rb' # required for older versions of rubygems
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
 
3
3
  before_install:
4
+ - gem update --system
4
5
  - gem install bundler
5
6
 
6
7
  bundler_args: --without development --jobs=3 --retry=3
@@ -13,15 +14,19 @@ rvm:
13
14
  - 1.8.7
14
15
  - 1.9.3
15
16
  - 2.0.0
16
- - 2.1
17
- - 2.2
17
+ - 2.1.10
18
+ - 2.2.6
19
+ - 2.3.3
20
+ - 2.4.0
18
21
  - ruby-head
19
- - jruby
22
+ - jruby-head
23
+ - jruby-9.1.7.0
20
24
  - rbx-2
21
25
 
22
26
  matrix:
23
27
  allow_failures:
24
28
  - rvm: ruby-head
25
- - rvm: jruby
29
+ - rvm: jruby-head
30
+ - rvm: jruby-9.1.7.0
26
31
  - rvm: rbx-2
27
32
  fast_finish: true
data/CHANGELOG.md CHANGED
@@ -1,10 +1,44 @@
1
- Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.11.0...master))
1
+ 0.13.0 2016-01-25 ([changes](https://github.com/colszowka/simplecov/compare/v0.12.0...v0.13.0))
2
+ ==========
3
+
4
+ ## Enhancements
5
+
6
+ * Faster run times when a very large number of files is loaded into SimpleCov. See [#520](https://github.com/colszowka/simplecov/pull/520) (thanks @alyssais)
7
+ * Only read in source code files that are actually used (faster when files are ignored etc.). See [#540](https://github.com/colszowka/simplecov/pull/540) (tahks @yui-knk)
8
+
9
+ ## Bugfixes
10
+
11
+ * Fix merging of resultsets if a file is missing on one side. See [#513](https://github.com/colszowka/simplecov/pull/513) (thanks @hanazuki)
12
+ * Fix Ruby 2.4 deprecation warnings by using Integer instead of Fixnum. See [#523](https://github.com/colszowka/simplecov/pull/523) (thanks @nobu)
13
+ * Force Ruby 2 to json 2. See [dc7417d50](https://github.com/colszowka/simplecov/commit/dc7417d5049b1809cea214314c15dd93a5dd964f) (thanks @amatsuda)
14
+ * Various other gem dependency fixes for different gems on different ruby versions. (thanks @amatsuda)
15
+
16
+ 0.12.0 2016-07-02 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.2...v0.12.0))
2
17
  =================
3
18
 
4
19
  ## Enhancements
5
20
 
21
+ * Add support for JSON versions 2.x
22
+
6
23
  ## Bugfixes
7
24
 
25
+ * Fix coverage rate of the parallel_tests. See [#441](https://github.com/colszowka/simplecov/pull/441) (thanks @sinsoku)
26
+ * Fix a regression on old rubies that failed to work with the recently introduced frozen VERSION string. See [#461](https://github.com/colszowka/simplecov/pull/461) (thanks @leafle)
27
+
28
+ 0.11.2 2016-02-03 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.1...v0.11.2))
29
+ =================
30
+
31
+ ## Enhancements
32
+
33
+ * Do not globally pollute Array and Hash with `merge_resultset` utility methods. See [#449](https://github.com/colszowka/simplecov/pull/449) (thanks @amatsuda)
34
+ * Do not `mkdir_p` the `coverage_path` on every access of the method (See [#453](https://github.com/colszowka/simplecov/pull/453) (thanks @paddor)
35
+ * Fixes a Ruby warning related to the `track_files` configuration. See [#447](https://github.com/colszowka/simplecov/pull/447) (thanks @craiglittle)
36
+ * Add a group for background jobs to default Rails profile. See [#442](https://github.com/colszowka/simplecov/pull/442) (thanks @stve)
37
+
38
+ ## Bugfixes
39
+
40
+ * Fix root_filter evaluates SimpleCov.root before initialization. See [#437](https://github.com/colszowka/simplecov/pull/437) (thanks @tmtm)
41
+
8
42
  0.11.1 2015-12-01 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.0...v0.11.1))
9
43
  =================
10
44
 
@@ -20,7 +54,7 @@ Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.11.0...m
20
54
  ## Enhancements
21
55
 
22
56
  * Added `SimpleCov.minimum_coverage_by_file` for per-file coverage thresholds. See [#392](https://github.com/colszowka/simplecov/pull/392) (thanks @ptashman)
23
- * Added `track_files` configuration option to specify a glob to always include in coverage results, whether or not those files are required. See [#422](https://github.com/colszowka/simplecov/pull/422) (thanks @hugopeixoto)
57
+ * Added `track_files` configuration option to specify a glob to always include in coverage results, whether or not those files are required. By default, this is enabled in the Rails profile for common Rails directories. See [#422](https://github.com/colszowka/simplecov/pull/422) (thanks @hugopeixoto)
24
58
  * Speed up `root_filter` by an order of magnitude. See [#396](https://github.com/colszowka/simplecov/pull/396) (thanks @raszi)
25
59
 
26
60
  ## Bugfixes
data/Gemfile CHANGED
@@ -6,29 +6,33 @@ source "https://rubygems.org"
6
6
  # Uncomment this to use development version of html formatter from github
7
7
  # gem 'simplecov-html', :github => 'colszowka/simplecov-html'
8
8
 
9
- gem "rake", ">= 10.3"
9
+ gem "rake", Gem::Version.new(RUBY_VERSION) < Gem::Version.new("1.9.3") ? "~>10.3" : ">= 10.3"
10
10
 
11
11
  group :test do
12
12
  gem "rspec", ">= 3.2"
13
13
  # Older versions of some gems required for Ruby 1.8.7 support
14
- platform :ruby_18 do
14
+ platforms :ruby_18 do
15
15
  gem "activesupport", "~> 3.2.21"
16
16
  gem "i18n", "~> 0.6.11"
17
17
  end
18
- platform :jruby, :ruby_19, :ruby_20, :ruby_21, :ruby_22 do
18
+ platforms :ruby_18, :ruby_19 do
19
+ gem "mime-types", "~> 1.25"
20
+ gem "addressable", "~> 2.3.0"
21
+ end
22
+ platforms :ruby_18, :ruby_19, :ruby_20, :ruby_21 do
23
+ gem "rack", "~> 1.6"
24
+ end
25
+ platforms :jruby, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25 do
19
26
  gem "aruba", "~> 0.7.4"
20
- gem "capybara", "~> 2.4"
21
-
22
- # Hack until Capybara fixes its gemspec. 3.0 removed 1.9 support.
23
- # See https://github.com/jnicklas/capybara/issues/1615
24
- gem "mime-types", "~> 2.0.0"
25
-
26
- gem "cucumber", "~> 2.0"
27
+ gem "capybara"
28
+ gem "nokogiri", RUBY_VERSION < "2.1" ? "~> 1.6.0" : ">= 1.7"
29
+ gem "cucumber"
27
30
  gem "phantomjs", "~> 1.9"
28
- gem "poltergeist", "~> 1.1"
29
- gem "rubocop", ">= 0.30"
30
- gem "test-unit", "~> 3.0"
31
+ gem "poltergeist"
32
+ gem "rubocop" unless RUBY_VERSION.start_with?("1.")
33
+ gem "test-unit"
31
34
  end
35
+ gem "json", RUBY_VERSION.start_with?("1.") ? "~> 1.8" : "~> 2.0"
32
36
  end
33
37
 
34
38
  gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)][Continuous Integration] [![Dependency Status](https://gemnasium.com/colszowka/simplecov.png)][Dependencies] [![Code Climate](https://codeclimate.com/github/colszowka/simplecov.png)](https://codeclimate.com/github/colszowka/simplecov) [![Inline docs](http://inch-ci.org/github/colszowka/simplecov.png)](http://inch-ci.org/github/colszowka/simplecov)
1
+ SimpleCov [![Build Status](https://travis-ci.org/colszowka/simplecov.svg)][Continuous Integration] [![Dependency Status](https://gemnasium.com/colszowka/simplecov.svg)][Dependencies] [![Code Climate](https://codeclimate.com/github/colszowka/simplecov.svg)](https://codeclimate.com/github/colszowka/simplecov) [![Inline docs](http://inch-ci.org/github/colszowka/simplecov.svg)](http://inch-ci.org/github/colszowka/simplecov)
2
2
  =========
3
3
  **Code coverage for Ruby**
4
4
 
@@ -6,11 +6,8 @@ SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)
6
6
  * [API documentation]
7
7
  * [Changelog]
8
8
  * [Rubygem]
9
- * [Mailing List]
10
9
  * [Continuous Integration]
11
10
 
12
- **Important Notice: There is a bug that affects exit code handling on the 0.8 line of SimpleCov, see [#281](https://github.com/colszowka/simplecov/issues/281). Please use versions `>= 0.9` to avoid this.**
13
-
14
11
  [Coverage]: http://www.ruby-doc.org/stdlib-2.1.0/libdoc/coverage/rdoc/Coverage.html "API doc for Ruby's Coverage library"
15
12
  [Source Code]: https://github.com/colszowka/simplecov "Source Code @ GitHub"
16
13
  [API documentation]: http://rubydoc.info/gems/simplecov/frames "RDoc API Documentation at Rubydoc.info"
@@ -20,10 +17,6 @@ SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)
20
17
  [Continuous Integration]: http://travis-ci.org/colszowka/simplecov "SimpleCov is built around the clock by travis-ci.org"
21
18
  [Dependencies]: https://gemnasium.com/colszowka/simplecov "SimpleCov dependencies on Gemnasium"
22
19
  [simplecov-html]: https://github.com/colszowka/simplecov-html "SimpleCov HTML Formatter Source Code @ GitHub"
23
- [Mailing List]: https://groups.google.com/forum/#!forum/simplecov "Open mailing list for discussion and announcements on Google Groups"
24
- [Pledgie]: http://www.pledgie.com/campaigns/18379
25
-
26
- [![You can support the development of SimpleCov via Pledgie - thanks for your help](https://pledgie.com/campaigns/18379.png?skin_name=chrome)][Pledgie]
27
20
 
28
21
  SimpleCov is a code coverage analysis tool for Ruby. It uses [Ruby's built-in Coverage][Coverage] library to gather code
29
22
  coverage data, but makes processing its results much easier by providing a clean API to filter, group, merge, format,
@@ -108,12 +101,12 @@ Getting started
108
101
 
109
102
  **Coverage results report, fully browsable locally with sorting and much more:**
110
103
 
111
- ![SimpleCov coverage report](http://colszowka.github.com/simplecov/devise_result-0.5.3.png)
104
+ ![SimpleCov coverage report](https://cloud.githubusercontent.com/assets/137793/17071162/db6f253e-502d-11e6-9d84-e40c3d75f333.png)
112
105
 
113
106
 
114
107
  **Source file coverage details view:**
115
108
 
116
- ![SimpleCov source file detail view](http://colszowka.github.com/simplecov/devise_source_file-0.5.3.png)
109
+ ![SimpleCov source file detail view](https://cloud.githubusercontent.com/assets/137793/17071163/db6f9f0a-502d-11e6-816c-edb2c66fad8d.png)
117
110
 
118
111
  ## Use it with any framework!
119
112
 
@@ -153,19 +146,6 @@ to use SimpleCov with them. Here's an overview of the known ones:
153
146
  <a href="https://github.com/colszowka/simplecov/pull/185">#185</a>
154
147
  </td>
155
148
  </tr>
156
- <tr>
157
- <th>
158
- Riot
159
- </th>
160
- <td>
161
- A user has reported problems with the coverage report using the riot
162
- framework. If you experience similar trouble please follow up on the
163
- related GitHub issue.
164
- </td>
165
- <td>
166
- <a href="https://github.com/colszowka/simplecov/issues/80">#80</a>
167
- </td>
168
- </tr>
169
149
  <tr>
170
150
  <th>
171
151
  RubyMine
data/Rakefile CHANGED
@@ -27,10 +27,15 @@ rescue LoadError
27
27
  end
28
28
 
29
29
  # Cucumber integration test suite is for impls that work with simplecov only - a.k.a. 1.9+
30
- if RUBY_VERSION >= "1.9"
30
+ if RUBY_VERSION.start_with? "1.8"
31
+ task :default => [:spec]
32
+ else
31
33
  require "cucumber/rake/task"
32
34
  Cucumber::Rake::Task.new
33
- task :default => [:spec, :cucumber, :rubocop]
34
- else
35
- task :default => [:spec]
35
+
36
+ if RUBY_VERSION.start_with? "1.9"
37
+ task :default => [:spec, :cucumber]
38
+ else
39
+ task :default => [:spec, :cucumber, :rubocop]
40
+ end
36
41
  end
@@ -11,7 +11,7 @@ Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
11
11
  when /Cucumber/i
12
12
  "features/support"
13
13
  else
14
- fail ArgumentError, "Could not identify test framework #{framework}!"
14
+ raise ArgumentError, "Could not identify test framework #{framework}!"
15
15
  end
16
16
  end
17
17
 
@@ -45,6 +45,6 @@ end
45
45
  # Workaround for https://github.com/cucumber/aruba/pull/125
46
46
  Aruba.configure do |config|
47
47
  config.before_cmd do
48
- set_env("JRUBY_OPTS", "-X-C --1.9")
48
+ set_env("JRUBY_OPTS", "--dev --debug")
49
49
  end
50
50
  end
@@ -28,6 +28,7 @@ module SimpleCov
28
28
  #
29
29
  def coverage_dir(dir = nil)
30
30
  return @coverage_dir if defined?(@coverage_dir) && dir.nil?
31
+ @coverage_path = nil # invalidate cache
31
32
  @coverage_dir = (dir || "coverage")
32
33
  end
33
34
 
@@ -37,9 +38,11 @@ module SimpleCov
37
38
  # values. Will create the directory if it's missing
38
39
  #
39
40
  def coverage_path
40
- coverage_path = File.expand_path(coverage_dir, root)
41
- FileUtils.mkdir_p coverage_path
42
- coverage_path
41
+ @coverage_path ||= begin
42
+ coverage_path = File.expand_path(coverage_dir, root)
43
+ FileUtils.mkdir_p coverage_path
44
+ coverage_path
45
+ end
43
46
  end
44
47
 
45
48
  #
@@ -47,8 +50,9 @@ module SimpleCov
47
50
  # or not they were explicitly required. Without this, un-required files
48
51
  # will not be present in the final report.
49
52
  #
50
- def track_files(glob)
51
- @track_files_glob = glob
53
+ def track_files(glob = nil)
54
+ return @track_files if defined?(@track_files) && glob.nil?
55
+ @track_files = glob
52
56
  end
53
57
 
54
58
  #
@@ -81,7 +85,7 @@ module SimpleCov
81
85
  def formatter(formatter = nil)
82
86
  return @formatter if defined?(@formatter) && formatter.nil?
83
87
  @formatter = formatter
84
- fail "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
88
+ raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
85
89
  @formatter
86
90
  end
87
91
 
@@ -114,7 +118,7 @@ module SimpleCov
114
118
  return @nocov_token if defined?(@nocov_token) && nocov_token.nil?
115
119
  @nocov_token = (nocov_token || "nocov")
116
120
  end
117
- alias_method :skip_token, :nocov_token
121
+ alias skip_token nocov_token
118
122
 
119
123
  #
120
124
  # Returns the configured groups. Add groups using SimpleCov.add_group
@@ -188,7 +192,7 @@ module SimpleCov
188
192
  end
189
193
 
190
194
  #
191
- # Defines them maximum age (in seconds) of a resultset to still be included in merged results.
195
+ # Defines the maximum age (in seconds) of a resultset to still be included in merged results.
192
196
  # i.e. If you run cucumber features, then later rake test, if the stored cucumber resultset is
193
197
  # more seconds ago than specified here, it won't be taken into account when merging (and is also
194
198
  # purged from the resultset cache)
@@ -200,7 +204,7 @@ module SimpleCov
200
204
  # Configure with SimpleCov.merge_timeout(3600) # 1hr
201
205
  #
202
206
  def merge_timeout(seconds = nil)
203
- @merge_timeout = seconds if seconds.is_a?(Fixnum)
207
+ @merge_timeout = seconds if seconds.is_a?(Integer)
204
208
  @merge_timeout ||= 600
205
209
  end
206
210
 
@@ -285,7 +289,7 @@ module SimpleCov
285
289
  elsif filter_argument.is_a?(Array)
286
290
  SimpleCov::ArrayFilter.new(filter_argument)
287
291
  else
288
- fail ArgumentError, "Please specify either a string or a block to filter with"
292
+ raise ArgumentError, "Please specify either a string or a block to filter with"
289
293
  end
290
294
  end
291
295
  end
@@ -4,8 +4,9 @@ require "pathname"
4
4
 
5
5
  SimpleCov.profiles.define "root_filter" do
6
6
  # Exclude all files outside of simplecov root
7
- root_filter = /\A#{Regexp.escape(SimpleCov.root)}/io
7
+ root_filter = nil
8
8
  add_filter do |src|
9
+ root_filter ||= /\A#{Regexp.escape(SimpleCov.root)}/io
9
10
  !(src.filename =~ root_filter)
10
11
  end
11
12
  end
@@ -31,6 +32,7 @@ SimpleCov.profiles.define "rails" do
31
32
  add_group "Models", "app/models"
32
33
  add_group "Mailers", "app/mailers"
33
34
  add_group "Helpers", "app/helpers"
35
+ add_group "Jobs", %w(app/jobs app/workers)
34
36
  add_group "Libraries", "lib"
35
37
 
36
38
  track_files "{app,lib}/**/*.rb"
@@ -47,19 +49,20 @@ end
47
49
  # Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
48
50
  SimpleCov::CommandGuesser.original_run_command = "#{$PROGRAM_NAME} #{ARGV.join(' ')}"
49
51
 
50
- at_exit do
52
+ at_exit do # rubocop:disable Metrics/BlockLength
51
53
  # If we are in a different process than called start, don't interfere.
52
54
  next if SimpleCov.pid != Process.pid
53
55
 
54
- if $! # was an exception thrown?
55
- # if it was a SystemExit, use the accompanying status
56
- # otherwise set a non-zero status representing termination by some other exception
57
- # (see github issue 41)
58
- @exit_status = $!.is_a?(SystemExit) ? $!.status : SimpleCov::ExitCodes::EXCEPTION
59
- else
60
- # Store the exit status of the test run since it goes away after calling the at_exit proc...
61
- @exit_status = SimpleCov::ExitCodes::SUCCESS
62
- end
56
+ @exit_status = if $! # was an exception thrown?
57
+ # if it was a SystemExit, use the accompanying status
58
+ # otherwise set a non-zero status representing termination by
59
+ # some other exception (see github issue 41)
60
+ $!.is_a?(SystemExit) ? $!.status : SimpleCov::ExitCodes::EXCEPTION
61
+ else
62
+ # Store the exit status of the test run since it goes away
63
+ # after calling the at_exit proc...
64
+ SimpleCov::ExitCodes::SUCCESS
65
+ end
63
66
 
64
67
  SimpleCov.at_exit.call
65
68
 
@@ -17,7 +17,7 @@ module SimpleCov
17
17
  end
18
18
 
19
19
  def matches?(_)
20
- fail "The base filter class is not intended for direct use"
20
+ raise "The base filter class is not intended for direct use"
21
21
  end
22
22
 
23
23
  def passes?(source_file)
@@ -11,7 +11,7 @@ if defined?(JRUBY_VERSION) && JRUBY_VERSION.to_f < 1.7
11
11
  # This monkey patches Coverage to address those issues
12
12
  module Coverage
13
13
  class << self
14
- alias_method :__broken_result__, :result
14
+ alias __broken_result__ result
15
15
 
16
16
  def result # rubocop:disable Metrics/MethodLength
17
17
  fixed = {}
@@ -4,13 +4,12 @@ module SimpleCov
4
4
  def merge_resultset(array)
5
5
  new_array = dup
6
6
  array.each_with_index do |element, i|
7
- if element.nil? && new_array[i].nil?
8
- new_array[i] = nil
9
- else
10
- local_value = element || 0
11
- other_value = new_array[i] || 0
12
- new_array[i] = local_value + other_value
13
- end
7
+ pair = [element, new_array[i]]
8
+ new_array[i] = if pair.any?(&:nil?) && pair.map(&:to_i).all?(&:zero?)
9
+ nil
10
+ else
11
+ element.to_i + new_array[i].to_i
12
+ end
14
13
  end
15
14
  new_array
16
15
  end
@@ -23,16 +22,16 @@ module SimpleCov
23
22
  def merge_resultset(hash)
24
23
  new_resultset = {}
25
24
  (keys + hash.keys).each do |filename|
26
- new_resultset[filename] = []
25
+ new_resultset[filename] = nil
27
26
  end
28
27
 
29
28
  new_resultset.each_key do |filename|
30
- new_resultset[filename] = (self[filename] || []).merge_resultset(hash[filename] || [])
29
+ result1 = self[filename]
30
+ result2 = hash[filename]
31
+ new_resultset[filename] =
32
+ result1 && result2 ? result1.extend(ArrayMergeHelper).merge_resultset(result2) : (result1 || result2).dup
31
33
  end
32
34
  new_resultset
33
35
  end
34
36
  end
35
37
  end
36
-
37
- Array.send :include, SimpleCov::ArrayMergeHelper
38
- Hash.send :include, SimpleCov::HashMergeHelper
@@ -15,7 +15,7 @@ module SimpleCov
15
15
  #
16
16
  def define(name, &blk)
17
17
  name = name.to_sym
18
- fail "SimpleCov Profile '#{name}' is already defined" unless self[name].nil?
18
+ raise "SimpleCov Profile '#{name}' is already defined" unless self[name].nil?
19
19
  self[name] = blk
20
20
  end
21
21
 
@@ -24,7 +24,7 @@ module SimpleCov
24
24
  #
25
25
  def load(name)
26
26
  name = name.to_sym
27
- fail "Could not find SimpleCov Profile called '#{name}'" unless key?(name)
27
+ raise "Could not find SimpleCov Profile called '#{name}'" unless key?(name)
28
28
  SimpleCov.configure(&self[name])
29
29
  end
30
30
  end
@@ -12,7 +12,7 @@ module SimpleCov
12
12
  attr_reader :original_result
13
13
  # Returns all files that are applicable to this result (sans filters!) as instances of SimpleCov::SourceFile. Aliased as :source_files
14
14
  attr_reader :files
15
- alias_method :source_files, :files
15
+ alias source_files files
16
16
  # Explicitly set the Time this result has been created
17
17
  attr_writer :created_at
18
18
  # Explicitly set the command name that was used for this coverage result. Defaults to SimpleCov.command_name
@@ -24,6 +24,7 @@ module SimpleCov
24
24
  # Initialize a new SimpleCov::Result from given Coverage.result (a Hash of filenames each containing an array of
25
25
  # coverage data)
26
26
  def initialize(original_result)
27
+ original_result = original_result.dup.extend(SimpleCov::HashMergeHelper) unless original_result.is_a? SimpleCov::HashMergeHelper
27
28
  @original_result = original_result.freeze
28
29
  @files = SimpleCov::FileList.new(original_result.map do |filename, coverage|
29
30
  SimpleCov::SourceFile.new(filename, coverage) if File.file?(filename)
@@ -59,7 +60,7 @@ module SimpleCov
59
60
 
60
61
  # Returns a hash representation of this Result that can be used for marshalling it into JSON
61
62
  def to_hash
62
- {command_name => {"coverage" => original_result.reject { |filename, _| !filenames.include?(filename) }, "timestamp" => created_at.to_i}}
63
+ {command_name => {"coverage" => coverage, "timestamp" => created_at.to_i}}
63
64
  end
64
65
 
65
66
  # Loads a SimpleCov::Result#to_hash dump
@@ -73,6 +74,11 @@ module SimpleCov
73
74
 
74
75
  private
75
76
 
77
+ def coverage
78
+ keys = original_result.keys & filenames
79
+ Hash[keys.zip(original_result.values_at(*keys))]
80
+ end
81
+
76
82
  # Applies all configured SimpleCov filters on this result's source files
77
83
  def filter!
78
84
  @files = SimpleCov.filtered(files)
@@ -20,14 +20,14 @@ module SimpleCov
20
20
  attr_reader :skipped
21
21
 
22
22
  # Lets grab some fancy aliases, shall we?
23
- alias_method :source, :src
24
- alias_method :line, :line_number
25
- alias_method :number, :line_number
23
+ alias source src
24
+ alias line line_number
25
+ alias number line_number
26
26
 
27
27
  def initialize(src, line_number, coverage)
28
- fail ArgumentError, "Only String accepted for source" unless src.is_a?(String)
29
- fail ArgumentError, "Only Fixnum accepted for line_number" unless line_number.is_a?(Fixnum)
30
- fail ArgumentError, "Only Fixnum and nil accepted for coverage" unless coverage.is_a?(Fixnum) || coverage.nil?
28
+ raise ArgumentError, "Only String accepted for source" unless src.is_a?(String)
29
+ raise ArgumentError, "Only Integer accepted for line_number" unless line_number.is_a?(Integer)
30
+ raise ArgumentError, "Only Integer and nil accepted for coverage" unless coverage.is_a?(Integer) || coverage.nil?
31
31
  @src = src
32
32
  @line_number = line_number
33
33
  @coverage = coverage
@@ -74,16 +74,20 @@ module SimpleCov
74
74
  attr_reader :filename
75
75
  # The array of coverage data received from the Coverage.result
76
76
  attr_reader :coverage
77
- # The source code for this file. Aliased as :source
78
- attr_reader :src
79
- alias_method :source, :src
80
77
 
81
78
  def initialize(filename, coverage)
82
79
  @filename = filename
83
80
  @coverage = coverage
84
- File.open(filename, "rb") { |f| @src = f.readlines }
85
81
  end
86
82
 
83
+ # The source code for this file. Aliased as :source
84
+ def src
85
+ # We intentionally read source code lazily to
86
+ # suppress reading unused source code.
87
+ @src ||= File.open(filename, "rb", &:readlines)
88
+ end
89
+ alias source src
90
+
87
91
  # Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
88
92
  # and thus including coverage data. Aliased as :source_lines
89
93
  def lines
@@ -102,7 +106,7 @@ module SimpleCov
102
106
  process_skipped_lines!
103
107
  @lines
104
108
  end
105
- alias_method :source_lines, :lines
109
+ alias source_lines lines
106
110
 
107
111
  # Access SimpleCov::SourceFile::Line source lines by line number
108
112
  def line(number)
@@ -116,7 +120,7 @@ module SimpleCov
116
120
  if relevant_lines.zero?
117
121
  0.0
118
122
  else
119
- Float((covered_lines.count) * 100.0 / relevant_lines.to_f)
123
+ Float(covered_lines.count * 100.0 / relevant_lines.to_f)
120
124
  end
121
125
  end
122
126
 
@@ -172,8 +176,8 @@ module SimpleCov
172
176
  lines.each do |line|
173
177
  if line.src =~ /^([\s]*)#([\s]*)(\:#{SimpleCov.nocov_token}\:)/
174
178
  skipping = !skipping
175
- else
176
- line.skipped! if skipping
179
+ elsif skipping
180
+ line.skipped!
177
181
  end
178
182
  end
179
183
  end
@@ -1,22 +1,25 @@
1
1
  module SimpleCov
2
- VERSION = "0.11.1"
3
- def VERSION.to_a
2
+ version = "0.13.0"
3
+
4
+ def version.to_a
4
5
  split(".").map(&:to_i)
5
6
  end
6
7
 
7
- def VERSION.major
8
+ def version.major
8
9
  to_a[0]
9
10
  end
10
11
 
11
- def VERSION.minor
12
+ def version.minor
12
13
  to_a[1]
13
14
  end
14
15
 
15
- def VERSION.patch
16
+ def version.patch
16
17
  to_a[2]
17
18
  end
18
19
 
19
- def VERSION.pre
20
+ def version.pre
20
21
  to_a[3]
21
22
  end
23
+
24
+ VERSION = version
22
25
  end