covered 0.4.1 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b84eee5b7608c146ccec6a4feaf61935965cedf006c1e7ffb4b887700d2a864
4
- data.tar.gz: 6f853b88a9bc70c48bacd819d5e49d8cf643079f724138aa3b9fea2994c6bc1d
3
+ metadata.gz: 8ab7cb43335f9a1a56aefb96ceeca0258c84462ddf5657eeaed13e8662eb74e3
4
+ data.tar.gz: 68de7fc8c253d5237769e4b0a41383de404c37d6923a73d508401ace75c3f64a
5
5
  SHA512:
6
- metadata.gz: 516dfd68e9d8e74a76a2916edb4248d14c40f1174f801d74f21629495184123e120b83d332ae7bb895391f4f53122769d6f3a2486ebbec5ee94c0e58ffb7c643
7
- data.tar.gz: 9fbc9360d7c86b0d53859c5a46a4488c92a8141abe83f97e7e0790b6becbe807c561cbb25b1e86d08689eefa96da4e0b20e2e42c8514cf44e8dc1f64f2a64d2d
6
+ metadata.gz: 611f47e4457cbcf2e2b8ed0e3d29c9ef66168c4358c1fd2466278ed0663a222dcef15af62a8a28a0e36d802cdfccafc20ece100a78e6a7a2247e7f45105727f9
7
+ data.tar.gz: c1707dbc6141f38bc2782276237de511eb1750e7d5591382c15a8dad7a2cb381c1a45d4150f505f95d1abbb1c1bd113e9ebb805f817d4ebd1d219d99d30cbd53
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # Covered [![Build Status](https://travis-ci.com/ioquatix/covered.svg)](hhttps://travis-ci.com/ioquatix/covered)
1
+ # Covered [![Build Status](https://travis-ci.com/ioquatix/covered.svg)](https://travis-ci.com/ioquatix/covered)
2
2
 
3
- Covered uses modern Ruby features to generate comprehensive coverage, including support for templates which are compiled into Ruby. **This only works with Ruby 2.6 and it's experimental support for RubyVM::AST**
3
+ Covered uses modern Ruby features to generate comprehensive coverage, including support for templates which are compiled into Ruby. **This only works with Ruby 2.6 and its experimental support for RubyVM::AbstractSyntaxTree**
4
4
 
5
5
  ![Screenshot](media/example.png)
6
6
 
7
7
  ## Motivation
8
8
 
9
- Existing Ruby coverage tools are unable to handle `eval`ed code. This is because the `coverage` module built into Ruby doesn't expose the necessary hooks to capture it. With Ruby 2.6, `RubyVM::AST.parse(source)` came in to existance, which gives us a fine grained tool for computing initial source coverage (i.e. what lines are executable), and thus making it possible to compute coverage for "templates".
9
+ Existing Ruby coverage tools are unable to handle `eval`ed code. This is because the `coverage` module built into Ruby doesn't expose the necessary hooks to capture it. With Ruby 2.6, `RubyVM::AST.parse(source)` came into existence, which gives us a fine grained tool for computing initial source coverage (i.e. what lines are executable), and thus making it possible to compute coverage for "templates".
10
10
 
11
11
  It's still tricky to do it correctly, but it is feasible now to compute coverage of web application "views" by using this technique. This gem is an exploration to see what is possible.
12
12
 
data/covered.gemspec CHANGED
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = '~> 2.6.a'
21
+ spec.required_ruby_version = '~> 2.6.0.rc1'
22
22
 
23
23
  spec.add_dependency "rainbow"
24
24
 
25
25
  spec.add_development_dependency "trenni", "~> 3.6"
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
  end
@@ -26,14 +26,14 @@ require 'thread'
26
26
  module Covered
27
27
  # The source map, loads the source file, parses the AST to generate which lines contain executable code.
28
28
  class Source < Wrapper
29
- EXECUTABLE = /NODE_(.?CALL|.VAR|.ASGN|DEFN)/.freeze
29
+ EXECUTABLE = /(.?CALL|.VAR|.ASGN|DEFN)/.freeze
30
30
 
31
31
  # Deviate from the standard policy above, because all the files are already loaded, so we skip NODE_FCALL.
32
- DOGFOOD = /NODE_([V]?CALL|.VAR|.ASGN|DEFN)/.freeze
32
+ DOGFOOD = /([V]?CALL|.VAR|.ASGN|DEFN)/.freeze
33
33
 
34
34
  # Ruby trace points don't trigger for argument execution.
35
35
  # Constants are loaded when the file loads, so they are less interesting.
36
- IGNORE = /NODE_(ARGS|CDECL)/.freeze
36
+ IGNORE = /(ARGS|CDECL)/.freeze
37
37
 
38
38
  def initialize(output, executable: EXECUTABLE, ignore: IGNORE)
39
39
  super(output)
@@ -69,12 +69,12 @@ module Covered
69
69
  end
70
70
 
71
71
  def executable?(node)
72
- node.type =~ @executable
72
+ node.type.to_s =~ @executable
73
73
  end
74
74
 
75
75
  def ignore?(node)
76
76
  # NODE_ARGS Ruby doesn't report execution of arguments in :line tracepoint.
77
- node.type =~ @ignore
77
+ node.nil? or node.type.to_s =~ @ignore
78
78
  end
79
79
 
80
80
  def expand(node, counts)
@@ -82,8 +82,11 @@ module Covered
82
82
 
83
83
  counts[node.first_lineno] ||= 0 if executable?(node)
84
84
 
85
+ # puts "#{node.inspect} #{node.to_s} -> #{node.children.inspect}"
85
86
  node.children.each do |child|
86
- next if child.nil? or ignore?(child)
87
+ next unless child.is_a? RubyVM::AbstractSyntaxTree::Node
88
+
89
+ next if ignore?(child)
87
90
 
88
91
  expand(child, counts)
89
92
  end
@@ -93,9 +96,9 @@ module Covered
93
96
  # puts "Parse #{path}"
94
97
 
95
98
  if source = @paths[path]
96
- RubyVM::AST.parse(source)
99
+ RubyVM::AbstractSyntaxTree.parse(source)
97
100
  elsif File.exist?(path)
98
- RubyVM::AST.parse_file(path)
101
+ RubyVM::AbstractSyntaxTree.parse_file(path)
99
102
  else
100
103
  warn "Couldn't parse #{path}, file doesn't exist?"
101
104
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Covered
22
- VERSION = "0.4.1"
22
+ VERSION = "0.5.1"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: covered
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-09 00:00:00.000000000 Z
11
+ date: 2018-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.16'
47
+ version: '2.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.16'
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -118,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
- version: 2.6.a
121
+ version: 2.6.0.rc1
122
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
124
  - - ">="
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.7.6
129
+ rubygems_version: 2.7.8
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: A modern approach to code coverage.