transmute-ruby 0.0.2
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 +7 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +55 -0
- data/README.md +49 -0
- data/Rakefile +3 -0
- data/lib/transmute/version.rb +5 -0
- data/lib/transmute.rb +62 -0
- data/transmute-ruby.gemspec +27 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c2d925eeaad2f63fbbdaaf50a2d6d4d0e506d4317c37f2c38748db47ce469cf0
|
4
|
+
data.tar.gz: 360c397ad5f2aefe61b71f108d1b8f4169f9794e66ed3e290536bb5f4a74e486
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f9a1dce7d9a0ff6546fef8e7c843d467dae00b253096573bb5546488c703ee823d269e5e3ec420a66c3df0a5d03a16d6aaf274fd58ffca4b344580415e24c2c
|
7
|
+
data.tar.gz: 5f956c6fb77591a61f22050207d40071ece404009af17dda4f3cda942208e4f998c570093df4d066e3d17d617ef96124d004ffe93ab01b442d92c2aebbcf3337
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
transmute (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
parallel (1.22.1)
|
12
|
+
parser (3.1.2.0)
|
13
|
+
ast (~> 2.4.1)
|
14
|
+
rainbow (3.1.1)
|
15
|
+
rake (13.0.6)
|
16
|
+
regexp_parser (2.3.0)
|
17
|
+
rexml (3.2.5)
|
18
|
+
rspec (3.11.0)
|
19
|
+
rspec-core (~> 3.11.0)
|
20
|
+
rspec-expectations (~> 3.11.0)
|
21
|
+
rspec-mocks (~> 3.11.0)
|
22
|
+
rspec-core (3.11.0)
|
23
|
+
rspec-support (~> 3.11.0)
|
24
|
+
rspec-expectations (3.11.0)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.11.0)
|
27
|
+
rspec-mocks (3.11.1)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.11.0)
|
30
|
+
rspec-support (3.11.0)
|
31
|
+
rubocop (0.93.1)
|
32
|
+
parallel (~> 1.10)
|
33
|
+
parser (>= 2.7.1.5)
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
35
|
+
regexp_parser (>= 1.8)
|
36
|
+
rexml
|
37
|
+
rubocop-ast (>= 0.6.0)
|
38
|
+
ruby-progressbar (~> 1.7)
|
39
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
40
|
+
rubocop-ast (1.17.0)
|
41
|
+
parser (>= 3.1.1.0)
|
42
|
+
ruby-progressbar (1.11.0)
|
43
|
+
unicode-display_width (1.8.0)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
x86_64-linux
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
rake (~> 13.0)
|
50
|
+
rspec (~> 3.0)
|
51
|
+
rubocop (~> 0.80)
|
52
|
+
transmute!
|
53
|
+
|
54
|
+
BUNDLED WITH
|
55
|
+
2.2.3
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Transmute
|
2
|
+
|
3
|
+
Ruby gem to help you to generate the reverse-coverage relationship between code and tests. The output is a `.transmute.json` file with key as source code + line and the value is an array with all specs that touch this particular line.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "transmute"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install transmute
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require "rspec"
|
25
|
+
require "transmute"
|
26
|
+
|
27
|
+
RSpec.configure do |config|
|
28
|
+
config.before(:suite) do
|
29
|
+
Transmute.instance.start
|
30
|
+
end
|
31
|
+
|
32
|
+
config.around do |example|
|
33
|
+
example.run
|
34
|
+
Transmute.instance.add_coverage(example)
|
35
|
+
end
|
36
|
+
|
37
|
+
config.after(:suite) do
|
38
|
+
Transmute.instance.store!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
## Test
|
44
|
+
|
45
|
+
We prioritize end-to-end tests, so you'll not see spec file here. In order to make sure that everything is working properly, you should add rust specs in the engine folder.
|
46
|
+
|
47
|
+
## License
|
48
|
+
|
49
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/lib/transmute.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'coverage'
|
4
|
+
require 'json'
|
5
|
+
require 'singleton'
|
6
|
+
|
7
|
+
Coverage.start
|
8
|
+
|
9
|
+
class Transmute
|
10
|
+
@instance = new
|
11
|
+
|
12
|
+
private_class_method :new
|
13
|
+
|
14
|
+
attr_reader :data, :previous_result
|
15
|
+
|
16
|
+
class << self
|
17
|
+
attr_reader :instance
|
18
|
+
end
|
19
|
+
|
20
|
+
def start
|
21
|
+
@data = {}
|
22
|
+
@previous_result = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_coverage(example)
|
26
|
+
result = select_project_files
|
27
|
+
test_path = example.metadata[:file_path]
|
28
|
+
process(test_path, result)
|
29
|
+
end
|
30
|
+
|
31
|
+
def process(test_path, result)
|
32
|
+
current_result = diff_result(result)
|
33
|
+
current_result.map do |file, lines|
|
34
|
+
lines.map.with_index do |value, line|
|
35
|
+
next if value.nil? || value.zero?
|
36
|
+
|
37
|
+
@data["#{file}:#{line + 1}"] ||= []
|
38
|
+
@data["#{file}:#{line + 1}"] << test_path
|
39
|
+
@data["#{file}:#{line + 1}"].uniq!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
@previous_result = current_result
|
43
|
+
end
|
44
|
+
|
45
|
+
def store!
|
46
|
+
File.write('transmute.json', JSON.dump(data))
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def select_project_files(result = Coverage.peek_result)
|
52
|
+
result.select do |file_path, _lines|
|
53
|
+
file_path.start_with?(Dir.pwd) && !file_path.start_with?(Dir.pwd + '/spec')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def diff_result(current_result)
|
58
|
+
previous_result.merge(current_result) do |_file_path, previous_line, current_line|
|
59
|
+
previous_line.zip(current_line).map { |values| values[0] == values[1] ? nil : values[1].to_i - values[0].to_i }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/transmute/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'transmute-ruby'
|
7
|
+
spec.version = Transmute::VERSION
|
8
|
+
spec.authors = ['Victor Antoniazzi']
|
9
|
+
spec.email = ['vgsantoniazzi@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Generate reverse relationsip between code and specs.'
|
12
|
+
spec.description = 'Ruby gem to help you to generate the reverse-coverage relationship between code and tests. The output is a `.transmute.json` file with key as source code + line and the value is an array with all specs that touch this particular line.'
|
13
|
+
spec.homepage = 'https://github.com/vgsantoniazzi/transmute'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/vgsantoniazzi/transmute'
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.require_paths = ['lib']
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: transmute-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Victor Antoniazzi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ruby gem to help you to generate the reverse-coverage relationship between
|
14
|
+
code and tests. The output is a `.transmute.json` file with key as source code +
|
15
|
+
line and the value is an array with all specs that touch this particular line.
|
16
|
+
email:
|
17
|
+
- vgsantoniazzi@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/transmute.rb
|
27
|
+
- lib/transmute/version.rb
|
28
|
+
- transmute-ruby.gemspec
|
29
|
+
homepage: https://github.com/vgsantoniazzi/transmute
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata:
|
33
|
+
homepage_uri: https://github.com/vgsantoniazzi/transmute
|
34
|
+
source_code_uri: https://github.com/vgsantoniazzi/transmute
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.4.0
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubygems_version: 3.2.3
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Generate reverse relationsip between code and specs.
|
54
|
+
test_files: []
|