eat_your_vegetables 0.1.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: 0f8738ad0032c17b980daedaf010e6efcc474e2916123cc09d3259af219f9829
4
+ data.tar.gz: 5432ad196459817c96e02752657823d93198ea958b5af6b9ddc1b3eef38acdf1
5
+ SHA512:
6
+ metadata.gz: 6f3b84923f31277bb37c2e4918bdb259f144e7f9ebacd7db293b1c5414771890cb693a65143918404971532d65e928193a6dda3aef4427ed3007689dcffc39b0
7
+ data.tar.gz: 4195f71b37d18ec5a4542d4b8a6413c4281ba1da13155144e08a5ad30631d43b915910b128dee57170385710ffcdef8fc104b16196950b6e81aeabc9a66f9097
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.md
3
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /.bundle
2
+ /.yardoc/
3
+ /Gemfile.lock
4
+ /doc/
5
+ /pkg/
6
+ /vendor/cache/*.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,95 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'Gemfile'
4
+ - 'vendor/**/*'
5
+ - eat_your_vegetables.gemspec
6
+ - spec/spec_helper.rb
7
+ - lib/eat_your_vegetables/tools/base.rb
8
+ - lib/eat_your_vegetables/tools/rubocop.rb
9
+ - lib/eat_your_vegetables/ambition.rb
10
+ - lib/eat_your_vegetables.rb
11
+
12
+ Style/Documentation:
13
+ Enabled: true
14
+ Exclude:
15
+
16
+ Style/DocumentationMethod:
17
+ Enabled: true
18
+
19
+ Style/ClassAndModuleChildren:
20
+ Enabled: false
21
+
22
+ Style/StringLiterals:
23
+ Enabled: false
24
+
25
+ Style/SymbolArray:
26
+ Enabled: false
27
+
28
+ Style/NumericPredicate:
29
+ Enabled: false
30
+
31
+ Metrics/LineLength:
32
+ Max: 100
33
+
34
+ Metrics/MethodLength:
35
+ Max: 75
36
+
37
+ Metrics/ClassLength:
38
+ Max: 1000
39
+
40
+ Metrics/AbcSize:
41
+ Max: 100
42
+
43
+ Metrics/CyclomaticComplexity:
44
+ Max: 30
45
+
46
+ Metrics/PerceivedComplexity:
47
+ Max: 30
48
+
49
+ Metrics/ParameterLists:
50
+ Max: 10
51
+
52
+ StringLiterals:
53
+ EnforcedStyle: single_quotes
54
+
55
+ Style/DoubleNegation:
56
+ Enabled: false
57
+
58
+ Style/FrozenStringLiteralComment:
59
+ Enabled: false
60
+
61
+ Style/NegatedIf:
62
+ Enabled: false
63
+
64
+ Style/NegatedWhile:
65
+ Enabled: false
66
+
67
+ Style/GuardClause:
68
+ Enabled: false
69
+
70
+ Style/SignalException:
71
+ Enabled: false
72
+
73
+ Layout/MultilineOperationIndentation:
74
+ EnforcedStyle: indented
75
+
76
+ Layout/MultilineMethodCallIndentation:
77
+ EnforcedStyle: indented
78
+
79
+ Style/Next:
80
+ Enabled: false
81
+
82
+ Style/ClassVars:
83
+ Enabled: false
84
+
85
+ Metrics/BlockLength:
86
+ Exclude:
87
+ - "**/*_spec.rb"
88
+ - "**/*_factory.rb"
89
+ - "config/initializers/*.rb"
90
+
91
+ Layout/IndentHash:
92
+ EnforcedStyle: consistent
93
+
94
+ Style/MultilineBlockChain:
95
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ script:
3
+ - bundle exec rspec
4
+ - bundle exec rubocop
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title "eat_your_vegetables Documentation" --protected
data/ChangeLog.md ADDED
@@ -0,0 +1,4 @@
1
+ ### 0.1.0 / 2019-01-31
2
+
3
+ * Initial release:
4
+
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'kramdown'
7
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2019 Fredrik Eckardt
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Eat Your Vegetables
2
+
3
+ * [Email](mailto:cfeckardt@gmail.com)
4
+
5
+ _NOTE THIS IS A WORK IN PROGRESS. DOCUMENTATION AND SOFTWARE IS INCOMPLETE_
6
+
7
+ ## Description
8
+ Eat Your Vegetables is a tool that aims to help you improve your codebase over
9
+ time. You configure the ambition that you want to set, that is, which files do
10
+ you want to be covered by your test tools in an ideal world. Then, every time a
11
+ commit is made into your code base, Eat Your Vegetables will ensure that your
12
+ are one incremental step closer to that goal.
13
+
14
+ Run Eat Your Vegetables in your CI server, as part of your test suite. On every
15
+ test run it will then look at the previous state, count up the number of
16
+ excluded files from your linter/test framework/coverage and _fail_ your tests if
17
+ that number hasn't decreased.
18
+
19
+ ## Features
20
+ Support for linters, coverage and test tools. For a full list of support tools
21
+ see SUPPORTED_TOOLS.md
22
+
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: ADDING_FRAMEWORKS.md
25
+
26
+ ## Requirements
27
+
28
+ A newish version of git must be installed on the CI server. Your CI server must
29
+ be executing your environment with git available.
30
+
31
+ ## Install
32
+
33
+ $ gem install eat_your_vegetables
34
+
35
+ ## Running it
36
+
37
+ Eat Your Vegetables is intended to be run with
38
+
39
+ ### With docker
40
+ For all you hip kids out there, there's a Dockerfile!
41
+
42
+ `docker run eat_your_vegetables:latest`
43
+
44
+ ## Configuration
45
+
46
+ In the root of your project create a file named `Veggiefile`
47
+
48
+ ```ruby
49
+ ambition do
50
+ include '/'
51
+ end
52
+
53
+ rubocop
54
+ simplecov
55
+ ```
56
+
57
+ ### Setting up CI
58
+
59
+ #### Gitlab
60
+
61
+ #### Circle CI
62
+
63
+ #### Other
64
+
65
+ Please contribute by adding set up instructions for other CIs.
66
+
67
+ ## Contributing
68
+
69
+ Nothing special here! Contributions are welcome!
70
+
71
+ ## Copyright
72
+
73
+ Copyright (c) 2019 Fredrik Eckardt
74
+
75
+ See {file:LICENSE.txt} for details.
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError => e
6
+ abort e.message
7
+ end
8
+
9
+ require 'rake'
10
+
11
+ require 'rubygems/tasks'
12
+ Gem::Tasks.new
13
+
14
+ require 'rspec/core/rake_task'
15
+ RSpec::Core::RakeTask.new
16
+
17
+ task test: :spec
18
+ task default: :spec
19
+
20
+ require 'yard'
21
+ YARD::Rake::YardocTask.new
22
+ task doc: :yard
data/Veggiefile ADDED
@@ -0,0 +1,3 @@
1
+ rubocop
2
+
3
+ simplecov
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'eat_your_vegetables'
4
+
5
+ EatYourVegetables::Runner.new.run
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'eat_your_vegetables/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'eat_your_vegetables'
7
+ gem.version = EatYourVegetables::VERSION
8
+ gem.summary = 'Eat Your Vegetables lets you incrementally improve code quality over time'
9
+ gem.description = 'Use EYV to incrementally improve code quality in your project.
10
+ Force your team to incrementally improve your code base with every commit to master.'
11
+ gem.license = 'MIT'
12
+ gem.authors = ['Fredrik Eckardt']
13
+ gem.email = 'cfeckardt@gmail.com'
14
+ gem.homepage = 'https://github.com/cfeckardt/eat_your_vegetables'
15
+
16
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+
18
+ `git submodule --quiet foreach --recursive pwd`.split($INPUT_RECORD_SEPARATOR).each do |submodule|
19
+ submodule.sub!("#{Dir.pwd}/", '')
20
+
21
+ Dir.chdir(submodule) do
22
+ `git ls-files`.split($INPUT_RECORD_SEPARATOR).map do |subpath|
23
+ gem.files << File.join(submodule, subpath)
24
+ end
25
+ end
26
+ end
27
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
28
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
29
+ gem.require_paths = ['lib']
30
+
31
+ gem.add_dependency 'rake', '~> 12.3.2'
32
+
33
+ gem.add_development_dependency 'bundler', '~> 1.10'
34
+ gem.add_development_dependency 'pry', '~> 0.12'
35
+ gem.add_development_dependency 'rspec', '~> 3.0'
36
+ gem.add_development_dependency 'rubocop', '~> 0.63'
37
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
38
+ gem.add_development_dependency 'yard', '~> 0.9.11'
39
+ end
@@ -0,0 +1,11 @@
1
+ module EatYourVegetables
2
+ class Ambition
3
+ def initialize
4
+ yield if block_given?
5
+ end
6
+
7
+ def include; end
8
+
9
+ def exclude; end
10
+ end
11
+ end
@@ -0,0 +1,59 @@
1
+ require 'rake/file_list'
2
+ require 'open3'
3
+
4
+ module EatYourVegetables
5
+ module Tools
6
+ class Base
7
+ def initialize(parent_branch:)
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
+ end
21
+
22
+ def step_difference
23
+ return 0 unless is_configed?
24
+
25
+ parent_exclusions = excluded_files(parent_file_contents)
26
+ current_exclusions = excluded_files(current_file_contents)
27
+
28
+ (parent_exclusions - current_exclusions).count
29
+ end
30
+
31
+ def parent_file_contents
32
+ cmdstr = "git show origin/master:#{config_file}"
33
+ stdout, stderr, status = Open3.capture3(cmdstr)
34
+
35
+ stdout
36
+ end
37
+
38
+ def current_file_contents
39
+ File.read(config_file)
40
+ end
41
+
42
+ def is_configed?
43
+ File.file?(config_file) && !parent_file_contents.empty?
44
+ rescue Errno::ENOENT
45
+ false
46
+ end
47
+
48
+ protected
49
+
50
+ def config_file
51
+ raise NotImplementedError
52
+ end
53
+
54
+ def excluded_files(_content)
55
+ raise NotImplementedError
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,20 @@
1
+ require 'yaml'
2
+ require_relative 'base'
3
+
4
+ module EatYourVegetables
5
+ module Tools
6
+ class Rubocop < Base
7
+ protected
8
+
9
+ def config_file
10
+ '.rubocop.yml'
11
+ end
12
+
13
+ def excluded_files(content)
14
+ yaml = YAML.load(content)
15
+
16
+ yaml['AllCops']['Exclude']
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ module EatYourVegetables
2
+ # eat_your_vegetables version
3
+ VERSION = '0.1.1'.freeze
4
+ end
@@ -0,0 +1,46 @@
1
+ require 'eat_your_vegetables/version'
2
+ require 'eat_your_vegetables/tools/rubocop'
3
+
4
+ module EatYourVegetables
5
+ class Runner
6
+ def initialize
7
+ @tools = []
8
+ end
9
+
10
+ def run
11
+ veggies = File.read('Veggiefile')
12
+ instance_eval(veggies)
13
+
14
+ step_difference = @tools.reduce(0) do |acc, tool|
15
+ (acc + tool.step_difference)
16
+ end
17
+
18
+ if @tools.any? &:is_configed?
19
+ if step_difference == 0
20
+ puts "Sorry, I can't let you do that"
21
+ exit 1
22
+ else
23
+ puts "Thanks, for eating your veggies."
24
+ exit 0
25
+ end
26
+ else
27
+ puts 'It appears there are no vegetables to eat'
28
+ exit 0
29
+ end
30
+ end
31
+
32
+ def ambition
33
+ yield if block_given?
34
+ end
35
+
36
+ def rubocop
37
+ @tools << EatYourVegetables::Tools::Rubocop.new(parent_branch: 'master')
38
+ end
39
+
40
+ def simplecov; end
41
+
42
+ private
43
+
44
+ def step_difference; end
45
+ end
46
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'eat_your_vegetables'
3
+
4
+ describe EatYourVegetables do
5
+ it 'should have a VERSION constant' do
6
+ expect(subject.const_get('VERSION')).to_not be_empty
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ require 'rspec'
2
+ require 'eat_your_vegetables/version'
3
+
4
+ include EatYourVegetables
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eat_your_vegetables
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Fredrik Eckardt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 12.3.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 12.3.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.63'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.63'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubygems-tasks
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.11
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.11
111
+ description: |-
112
+ Use EYV to incrementally improve code quality in your project.
113
+ Force your team to incrementally improve your code base with every commit to master.
114
+ email: cfeckardt@gmail.com
115
+ executables:
116
+ - eat_your_vegetables
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".document"
121
+ - ".gitignore"
122
+ - ".rspec"
123
+ - ".rubocop.yml"
124
+ - ".travis.yml"
125
+ - ".yardopts"
126
+ - ChangeLog.md
127
+ - Gemfile
128
+ - LICENSE.txt
129
+ - README.md
130
+ - Rakefile
131
+ - Veggiefile
132
+ - bin/eat_your_vegetables
133
+ - eat_your_vegetables.gemspec
134
+ - lib/eat_your_vegetables.rb
135
+ - lib/eat_your_vegetables/ambition.rb
136
+ - lib/eat_your_vegetables/tools/base.rb
137
+ - lib/eat_your_vegetables/tools/rubocop.rb
138
+ - lib/eat_your_vegetables/version.rb
139
+ - spec/eat_your_vegetables_spec.rb
140
+ - spec/spec_helper.rb
141
+ homepage: https://github.com/cfeckardt/eat_your_vegetables
142
+ licenses:
143
+ - MIT
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.7.6
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Eat Your Vegetables lets you incrementally improve code quality over time
165
+ test_files:
166
+ - spec/eat_your_vegetables_spec.rb
167
+ - spec/spec_helper.rb