eat_your_vegetables 0.1.1 → 0.1.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 +4 -4
- data/Dockerfile +9 -0
- data/Gemfile +4 -0
- data/README.md +24 -6
- data/bin/eat_your_vegetables +3 -1
- data/docs/ADDING_ADAPTERS.md +31 -0
- data/docs/SUPPORTED_TOOLS.md +46 -0
- data/eat_your_vegetables.gemspec +2 -1
- data/lib/eat_your_vegetables.rb +12 -3
- data/lib/eat_your_vegetables/tools/base.rb +9 -15
- data/lib/eat_your_vegetables/tools/rubocop.rb +6 -2
- data/lib/eat_your_vegetables/tools/simplecov.rb +24 -0
- data/lib/eat_your_vegetables/version.rb +1 -1
- metadata +23 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7866981bdf47ceca5aceebd1333e265b27f63ee59a7d7dddf4d0b3c317326f2
|
|
4
|
+
data.tar.gz: 965d18fe6d1b29f07378761b8beca7c713adb63450f3cb7083c0e9e71493cb93
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 374cecbb22296387508a0f2c088d9727adb95a4d065a5ec62383cbebdf0d2de46adf16027d9d5561b023d14be323162a8c36820929aec639fdddb2f0cadd0a36
|
|
7
|
+
data.tar.gz: 999905d875acec18e496d611baea5951c60038719e33072f40623d0dd23261ab4f9a35544af1e420e7aa01604fd7eede9c7e645026df0441457363a958b8a618
|
data/Dockerfile
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
* [Email](mailto:cfeckardt@gmail.com)
|
|
4
4
|
|
|
5
|
-
_NOTE THIS IS A WORK IN PROGRESS. DOCUMENTATION AND SOFTWARE IS
|
|
5
|
+
_NOTE THIS IS A WORK IN PROGRESS. DOCUMENTATION AND SOFTWARE IS INCOMPLETE AND IS PROVIDED ON AS IS. PLEASE HELP MY CONTRIBUTING_
|
|
6
6
|
|
|
7
7
|
## Description
|
|
8
8
|
Eat Your Vegetables is a tool that aims to help you improve your codebase over
|
|
@@ -18,10 +18,10 @@ that number hasn't decreased.
|
|
|
18
18
|
|
|
19
19
|
## Features
|
|
20
20
|
Support for linters, coverage and test tools. For a full list of support tools
|
|
21
|
-
see SUPPORTED_TOOLS.md
|
|
21
|
+
see [SUPPORTED_TOOLS.md](docs/SUPPORTED_TOOLS.md)
|
|
22
22
|
|
|
23
23
|
This project is still in early days so _please_ add support for your framework
|
|
24
|
-
if it is missing. There is a simple guide here:
|
|
24
|
+
if it is missing. There is a simple guide here: [ADDING_ADAPTERS.md](docs/ADDING_ADAPTERS.md)
|
|
25
25
|
|
|
26
26
|
## Requirements
|
|
27
27
|
|
|
@@ -37,9 +37,12 @@ be executing your environment with git available.
|
|
|
37
37
|
Eat Your Vegetables is intended to be run with
|
|
38
38
|
|
|
39
39
|
### With docker
|
|
40
|
+
|
|
40
41
|
For all you hip kids out there, there's a Dockerfile!
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
```bash
|
|
44
|
+
$ docker run --mount type=bind,source=`pwd`,target=/data cfeckardt/eat_your_vegetables:latest
|
|
45
|
+
```
|
|
43
46
|
|
|
44
47
|
## Configuration
|
|
45
48
|
|
|
@@ -56,12 +59,27 @@ simplecov
|
|
|
56
59
|
|
|
57
60
|
### Setting up CI
|
|
58
61
|
|
|
59
|
-
####
|
|
62
|
+
#### Travis
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
---
|
|
66
|
+
language: ruby
|
|
67
|
+
before_script:
|
|
68
|
+
- gem install eat_your_vegetables
|
|
69
|
+
script:
|
|
70
|
+
- bundle exec eat_your_vegetables
|
|
60
71
|
|
|
61
|
-
|
|
72
|
+
```
|
|
62
73
|
|
|
63
74
|
#### Other
|
|
64
75
|
|
|
76
|
+
In order to run _eyv_ in your CI suite you need to:
|
|
77
|
+
|
|
78
|
+
1. Ensure git is installed
|
|
79
|
+
2. Ensure ruby is installed
|
|
80
|
+
3. Run `gem intall eat_your_vegetables`
|
|
81
|
+
4. Run `bundle exec eat_your_vegetables` or just `eat_your_vegetables`
|
|
82
|
+
|
|
65
83
|
Please contribute by adding set up instructions for other CIs.
|
|
66
84
|
|
|
67
85
|
## Contributing
|
data/bin/eat_your_vegetables
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Adding support for more adapters
|
|
2
|
+
|
|
3
|
+
Currently there is only support for a small number of tools, in ruby, but adding support for _any_ language is easy, and will only take a couple of minutes.
|
|
4
|
+
|
|
5
|
+
You may use the example below to implement your own adapter:
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
require_relative 'base'
|
|
9
|
+
|
|
10
|
+
module EatYourVegetables
|
|
11
|
+
module Tools # Create your tool in this namespace
|
|
12
|
+
class MyTool < Base # Inherit from the base tool
|
|
13
|
+
attr_writer :config_file # Add attr_writers for configurable values
|
|
14
|
+
protected
|
|
15
|
+
# Will get called when running the tool to determine
|
|
16
|
+
# the location of the config file (across branches)
|
|
17
|
+
def config_file # You need to implement this method
|
|
18
|
+
@config_file || '.mytoolignore.yml' # Default value
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Will get called with the contents of the config_file, for the valid branches.
|
|
22
|
+
# Should return an array of files excluded by the content
|
|
23
|
+
def excluded_files(content) # You need to implement this method
|
|
24
|
+
content.split("\n")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Supported Tools
|
|
2
|
+
|
|
3
|
+
Currently there is only support for a small number of tools, in ruby, but adding support for _any_ language is easy, and will only take a couple of minutes. See [ADDING_ADAPTERS.md](ADDING_ADAPTERS.md) for instructions.
|
|
4
|
+
|
|
5
|
+
## Ruby
|
|
6
|
+
|
|
7
|
+
### Rubocop
|
|
8
|
+
|
|
9
|
+
The rubocop adapter supports the following options:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
rubocop do
|
|
13
|
+
config_file ".rubocop.yml" # relative path to the config file, defaults to .rubocop.yml
|
|
14
|
+
end
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Any and all files matched under an `Exclude:` key are considered excluded by this adapter. This means that both `file1.rb` and `file2.rb` are matched.
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
AllCops:
|
|
21
|
+
Exclude:
|
|
22
|
+
- file1.rb
|
|
23
|
+
Style/Indentation:
|
|
24
|
+
Exclude:
|
|
25
|
+
- file2.rb
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Simplecov
|
|
29
|
+
|
|
30
|
+
The simplecov adapter supports the following options:
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
simplecov do
|
|
34
|
+
config_file 'spec/spec_helper.rb' # relative path of config file, defaults to spec/spec_helper.rb
|
|
35
|
+
end
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The simplecov adapter will look for _any_ lines in the provided file that includes the line `add_filter "some_file.rb"` and match on `some_file.rb`
|
|
39
|
+
|
|
40
|
+
Typically you will have something like:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
Simplecov.start do
|
|
44
|
+
add_filter "file1.rb"
|
|
45
|
+
end
|
|
46
|
+
```
|
data/eat_your_vegetables.gemspec
CHANGED
|
@@ -28,10 +28,11 @@ Force your team to incrementally improve your code base with every commit to mas
|
|
|
28
28
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
29
29
|
gem.require_paths = ['lib']
|
|
30
30
|
|
|
31
|
-
gem.add_dependency '
|
|
31
|
+
gem.add_dependency 'colorize', '~> 0.8'
|
|
32
32
|
|
|
33
33
|
gem.add_development_dependency 'bundler', '~> 1.10'
|
|
34
34
|
gem.add_development_dependency 'pry', '~> 0.12'
|
|
35
|
+
gem.add_development_dependency 'rake', '~> 12.3.2'
|
|
35
36
|
gem.add_development_dependency 'rspec', '~> 3.0'
|
|
36
37
|
gem.add_development_dependency 'rubocop', '~> 0.63'
|
|
37
38
|
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
data/lib/eat_your_vegetables.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'eat_your_vegetables/version'
|
|
2
2
|
require 'eat_your_vegetables/tools/rubocop'
|
|
3
3
|
|
|
4
|
+
require 'colorize'
|
|
5
|
+
|
|
4
6
|
module EatYourVegetables
|
|
5
7
|
class Runner
|
|
6
8
|
def initialize
|
|
@@ -17,14 +19,21 @@ module EatYourVegetables
|
|
|
17
19
|
|
|
18
20
|
if @tools.any? &:is_configed?
|
|
19
21
|
if step_difference == 0
|
|
20
|
-
puts "Sorry, I can't let you do that"
|
|
22
|
+
puts "Sorry, I can't let you do that".yellow
|
|
23
|
+
puts "Please, fix one of the ignored files and try again!".yellow
|
|
24
|
+
puts "For example:".yellow
|
|
25
|
+
|
|
26
|
+
@tools.flat_map(&:current_exclusions).flatten.sort.sample(10).each do |excluded_file|
|
|
27
|
+
puts excluded_file.red
|
|
28
|
+
end
|
|
29
|
+
|
|
21
30
|
exit 1
|
|
22
31
|
else
|
|
23
|
-
puts "Thanks, for eating your veggies."
|
|
32
|
+
puts "Thanks, for eating your veggies.".green
|
|
24
33
|
exit 0
|
|
25
34
|
end
|
|
26
35
|
else
|
|
27
|
-
puts 'It appears there are no vegetables to eat'
|
|
36
|
+
puts 'It appears there are no vegetables to eat'.blue
|
|
28
37
|
exit 0
|
|
29
38
|
end
|
|
30
39
|
end
|
|
@@ -6,30 +6,24 @@ module EatYourVegetables
|
|
|
6
6
|
class Base
|
|
7
7
|
def initialize(parent_branch:)
|
|
8
8
|
@parent_branch = parent_branch
|
|
9
|
-
@ambition_filter = []
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def filter(file)
|
|
13
|
-
if file.is_a? Array
|
|
14
|
-
file.each do |f|
|
|
15
|
-
filter f
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
@ambition_filter << file
|
|
20
9
|
end
|
|
21
10
|
|
|
22
11
|
def step_difference
|
|
23
12
|
return 0 unless is_configed?
|
|
24
13
|
|
|
25
|
-
parent_exclusions = excluded_files(parent_file_contents)
|
|
26
|
-
current_exclusions = excluded_files(current_file_contents)
|
|
27
|
-
|
|
28
14
|
(parent_exclusions - current_exclusions).count
|
|
29
15
|
end
|
|
30
16
|
|
|
17
|
+
def parent_exclusions
|
|
18
|
+
@parent_exclusions ||= excluded_files(parent_file_contents)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def current_exclusions
|
|
22
|
+
@current_exclusions ||= excluded_files(current_file_contents)
|
|
23
|
+
end
|
|
24
|
+
|
|
31
25
|
def parent_file_contents
|
|
32
|
-
cmdstr = "git show origin
|
|
26
|
+
cmdstr = "git show origin/#{@parent_branch}:#{config_file}"
|
|
33
27
|
stdout, stderr, status = Open3.capture3(cmdstr)
|
|
34
28
|
|
|
35
29
|
stdout
|
|
@@ -4,16 +4,20 @@ require_relative 'base'
|
|
|
4
4
|
module EatYourVegetables
|
|
5
5
|
module Tools
|
|
6
6
|
class Rubocop < Base
|
|
7
|
+
attr_writer :config_file
|
|
8
|
+
|
|
7
9
|
protected
|
|
8
10
|
|
|
9
11
|
def config_file
|
|
10
|
-
'.rubocop.yml'
|
|
12
|
+
@config_file || '.rubocop.yml'
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def excluded_files(content)
|
|
14
16
|
yaml = YAML.load(content)
|
|
15
17
|
|
|
16
|
-
yaml[
|
|
18
|
+
yaml.values.reduce([]) do |acc, hash|
|
|
19
|
+
acc << hash['Exclude']
|
|
20
|
+
end.compact.sort.uniq
|
|
17
21
|
end
|
|
18
22
|
end
|
|
19
23
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module EatYourVegetables
|
|
2
|
+
module Tools
|
|
3
|
+
# Simplecov provides integration with the Simplecov coverage framework
|
|
4
|
+
class Simplecov < Base
|
|
5
|
+
attr_writer :config_file
|
|
6
|
+
|
|
7
|
+
protected
|
|
8
|
+
|
|
9
|
+
def config_file
|
|
10
|
+
@config_file || 'spec/spec_helper.rb'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def excluded_files(content)
|
|
14
|
+
# Matches all add_filter in the file.
|
|
15
|
+
# It's imperfect but works for now.
|
|
16
|
+
content.split("\n").select do |line|
|
|
17
|
+
line.include? 'add_filter'
|
|
18
|
+
end.map do |line|
|
|
19
|
+
/[\"'](\S+)[\"']/.match(line.strip).to_s
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eat_your_vegetables
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fredrik Eckardt
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-02-
|
|
11
|
+
date: 2019-02-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: colorize
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: '0.8'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: '0.8'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0.12'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 12.3.2
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 12.3.2
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: rspec
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -124,17 +138,21 @@ files:
|
|
|
124
138
|
- ".travis.yml"
|
|
125
139
|
- ".yardopts"
|
|
126
140
|
- ChangeLog.md
|
|
141
|
+
- Dockerfile
|
|
127
142
|
- Gemfile
|
|
128
143
|
- LICENSE.txt
|
|
129
144
|
- README.md
|
|
130
145
|
- Rakefile
|
|
131
146
|
- Veggiefile
|
|
132
147
|
- bin/eat_your_vegetables
|
|
148
|
+
- docs/ADDING_ADAPTERS.md
|
|
149
|
+
- docs/SUPPORTED_TOOLS.md
|
|
133
150
|
- eat_your_vegetables.gemspec
|
|
134
151
|
- lib/eat_your_vegetables.rb
|
|
135
152
|
- lib/eat_your_vegetables/ambition.rb
|
|
136
153
|
- lib/eat_your_vegetables/tools/base.rb
|
|
137
154
|
- lib/eat_your_vegetables/tools/rubocop.rb
|
|
155
|
+
- lib/eat_your_vegetables/tools/simplecov.rb
|
|
138
156
|
- lib/eat_your_vegetables/version.rb
|
|
139
157
|
- spec/eat_your_vegetables_spec.rb
|
|
140
158
|
- spec/spec_helper.rb
|