condition_coverage 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8fbd7cd27ab04963d5c91539a6accc52d6f178eef85858b48e6b553dd51f39de
4
+ data.tar.gz: 59cebe77670d20308973d24f96712368a204adfb32ac90a7e0497f78aabf9331
5
+ SHA512:
6
+ metadata.gz: ff8f96409d90bb54be22e3755e461849c2f9dfaf5a0ca0fbf5bb685b64c2066a22385e5cf7bfec2bcebd12ddf8687555d56112e107f5c242a33e7a5156977ce5
7
+ data.tar.gz: 86324f587f50156ff2ae9049f7d019fd1eb17b984f4ac0b45a2e0ecbccd114b1d849d9e8cdde4dd824d7e5e047e153f7e9d622474f811e9bcaeb471b38159179
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2026, [CyberDojo Foundation](http://blog.cyber-dojo.org/2015/08/cyber-dojo-foundation.html)
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # condition_coverage
2
+
3
+ Status: an outline of the idea. No working code is published yet.
4
+
5
+ Condition coverage for Ruby, to run alongside SimpleCov's line and branch
6
+ coverage.
7
+
8
+ ## The gap it fills
9
+
10
+ Ruby's built-in `Coverage` (which SimpleCov reads) tracks branches, not the
11
+ conditions inside them:
12
+
13
+ ```ruby
14
+ if a || b || c
15
+ ```
16
+
17
+ is two branches. Tests that reach both can still leave `b` never true and `c`
18
+ never evaluated, and branch coverage reports 100%.
19
+
20
+ ## How it works
21
+
22
+ At load time, each file under the covered root is parsed with Prism and each
23
+ `&&` / `||` operand is wrapped in a recorder call, before compilation:
24
+
25
+ ```ruby
26
+ if __cc(7, 0, a) || __cc(7, 1, b) || __cc(7, 2, c)
27
+ ```
28
+
29
+ The recorder notes whether the operand was truthy or falsy and returns it
30
+ unchanged, so short-circuiting and the value of the expression are preserved.
31
+ The rewrite happens in memory only; no file on disk changes.
32
+
33
+ A static manifest of every site (file, line, column, operand count) is built
34
+ by scanning the covered files, so an operand that never ran, or a file never
35
+ loaded, is reported as missed rather than silently absent.
36
+
37
+ ## Beyond and/or
38
+
39
+ The same hook can record decisions hidden inside calls, each with its own
40
+ outcome classes:
41
+
42
+ - `any?` / `all?` / `none?`: empty, decided by the first item, decided later,
43
+ never decided
44
+ - `find` / `detect`: found vs nil
45
+ - `fetch(k, default)`, `dig`, `Hash#[]` with a default: present vs default
46
+ - `x || default` in value context, `&.` safe navigation: nil vs not nil
47
+ - ternaries, `unless`, modifier `if`, `case`/`when` and `in` patterns
48
+ - regex matches: nil vs MatchData
49
+
50
+ ## Reporting
51
+
52
+ Gaps only, in the style of a Missing column. Each site shows its source line
53
+ with a caret under each operand that was never true, never false, or never
54
+ evaluated, plus a JSON form of the same data. An HTML view underlines each
55
+ operand in its own colour.
56
+
57
+ ## Intended use
58
+
59
+ ```ruby
60
+ # test coverage config, before any application code is required
61
+ require 'simplecov'
62
+ require 'condition_coverage'
63
+ SimpleCov.start do
64
+ # ...
65
+ end
66
+ ConditionCoverage.start(root: APP_DIR, cover: 'source/**/*.rb')
67
+ ```
68
+
69
+ The figure is gathered and reported, not gated.
70
+
71
+ ## Constraints
72
+
73
+ - CRuby only: the hook is `RubyVM::InstructionSequence.load_iseq`.
74
+ - That hook has a single slot, which Bootsnap also uses, so the two cannot
75
+ both be active in one process.
@@ -0,0 +1,3 @@
1
+ module ConditionCoverage
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: condition_coverage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jon Jagger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: prism
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: Placeholder release outlining the idea; see the README.
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE.md
34
+ - README.md
35
+ - lib/condition_coverage.rb
36
+ homepage: https://github.com/cyber-dojo/condition_coverage
37
+ licenses:
38
+ - BSD-2-Clause
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.0.3.1
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Condition coverage for Ruby, alongside SimpleCov branch coverage
59
+ test_files: []