jefferies_tube 1.5.4 → 1.6.0

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: 8ddb970be7c5d3d44e2df2171455ce27685435dd61330cb692002097271496d1
4
- data.tar.gz: 6b8a796088c566761a11a8b1f2ec5214884eed1d9c51159d0aca7f11a55b872d
3
+ metadata.gz: 716c0ff79c3d49dc0a798f652893f52f2da6b8db643b21b84c76dbe1e56c765f
4
+ data.tar.gz: 79f241ab6a97ebfc27fa2c4fbf070927fb4a2f960317532e11fbf80b1128e350
5
5
  SHA512:
6
- metadata.gz: fa431cb07c4d1abf50390ac2e65879c1e6a8cb57dfa711bc02f46ba389d7e7d58631faebb217c5ca919db5136d63e0ba0ae0ff115f90760ae46cc4f0c0243fb4
7
- data.tar.gz: 313293998aaaecaf4e0d94f0c1437ae50f3369ee8a3db6d2220a8cc7c0aeb80040bf38bf5aeb055e5530ea5fa2ba2b40443b399138671238f5161da6d039cd20
6
+ metadata.gz: 84f5131653cd0887fe715cdd4d9f113468aa3c4da74b37b3b3bd127ad56b34dbb88ebd09421034cbc3f066578dbdbdc14af9c9a9646418b79fdf45e8d1162611
7
+ data.tar.gz: 103babd618aa140b2f6dfd1c7e21f30e42ea4b9613d5dc2d9db4f4d693b0e4e15a501c0cb742a57e45ae07d9b8aa4596406efc501c5320b4535a1ea56c1940a9
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.0
1
+ 3.1.1
data/CHANGELOG.md CHANGED
@@ -6,6 +6,8 @@ This project attempts to follow [semantic versioning](https://semver.org/)
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 1.6.0
10
+ Default rake task that runs rspec with simlecov and rubocop!
9
11
  ## 1.5.4
10
12
  Fix a bug in the prompt if Pry is present.
11
13
  ## 1.5.3
data/README.md CHANGED
@@ -26,7 +26,7 @@ Or install it yourself as:
26
26
 
27
27
  JefferiesTube by default installs a catchall route that will render 404 for you and supress the rollbar error. This also allows you to create super easy custom error pages.
28
28
 
29
- Simple put a template in the parent app in `app/views/errors/404.haml` (or html or erb, etc) and it will be rendered instead of the default Jefferies tube error.
29
+ Simple put a template in the parent app in `app/views/errors/404.haml` (or html or erb, etc) and it will be rendered instead of the default JefferiesTube error.
30
30
 
31
31
  #### 500 handling
32
32
 
@@ -182,6 +182,47 @@ JefferiesTube.configure do |config|
182
182
  end
183
183
  ```
184
184
 
185
+ ### Default Rake Tasks
186
+ JefferiesTube sets up the default rake task to run rspec with simplecov, then rubocop. Everything should be configued to the default automatically. All you need to do is run `rake`!
187
+
188
+ ### Simplecov
189
+ JefferiesTube configures Simplecov to check for coverage based solely on groups, not on the overall project. This is to ensure that important/easy files are covered and unimportant files can be untested without causing the total percentage to go down. If you override the required test coverage, warnings will show if you do not match the JefferiesTube default. The default required test coverage is as follows:
190
+
191
+ ```
192
+ 'Controllers' => 10,
193
+ 'API Controllers' => 100,
194
+ 'Models' => 100,
195
+ 'Services' => 100,
196
+ 'Helpers' => 10,
197
+ 'Policies' => 100,
198
+ 'Jobs' => 100,
199
+ 'Mailers' => 0,
200
+ 'Libraries' => 0,
201
+ 'Plugins' => 0,
202
+ 'Ungrouped' => 10
203
+ ```
204
+
205
+ and can be overrided by setting `JefferiesTube::Coverage.required_coverage` in an initializer.
206
+
207
+ ```
208
+ JefferiesTube::Coverage.required_coverage = {
209
+ 'Controllers' => 0,
210
+ 'API Controllers' => 0,
211
+ 'Models' => 0,
212
+ 'Services' => 0,
213
+ 'Helpers' => 0,
214
+ 'Policies' => 0,
215
+ 'Jobs' => 0,
216
+ 'Mailers' => 0,
217
+ 'Libraries' => 0,
218
+ 'Plugins' => 0,
219
+ 'Ungrouped' => 0
220
+ }
221
+ ```
222
+
223
+ ## Rubocop
224
+ Our Rubocop rules are built from the ground up to ensure the rules are all "actually good"! The first time you run `rake` JT will create a .rubocop.yml configuration file that inherits all the rules from JT. You can add/modify that file if you need to customize the rules for your project.
225
+
185
226
  ## Contributing
186
227
 
187
228
  1. Fork it ( http://github.com/<my-github-username>/jefferies_tube/fork )
data/default.yml ADDED
@@ -0,0 +1,5 @@
1
+ AllCops:
2
+ DisabledByDefault: true
3
+ SuggestExtensions: false
4
+ Layout/LineLength:
5
+ Max: 200
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency "bundler-audit", '~> 0.9.0'
28
28
  spec.add_dependency "pry", '~> 0.13'
29
+ spec.add_dependency 'rubocop', '~> 1.26'
30
+ spec.add_dependency 'simplecov'
29
31
  end
@@ -0,0 +1,3 @@
1
+ inherit_gem:
2
+ jefferies_tube:
3
+ - default.yml
@@ -0,0 +1,68 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter '/test/'
4
+ add_filter '/config/'
5
+
6
+ add_group 'Controllers' do |src_file|
7
+ src_file.filename.include?('app/controllers') && !src_file.filename.include?('api')
8
+ end
9
+ add_group 'API Controllers' do |src_file|
10
+ src_file.filename.include?('app/controllers') && src_file.filename.include?('api')
11
+ end
12
+ add_group 'Models', 'app/models'
13
+ add_group 'Services', 'app/services'
14
+ add_group 'Helpers', 'app/helpers'
15
+ add_group 'Policies', 'app/policies'
16
+ add_group 'Jobs', 'app/jobs'
17
+ add_group 'Mailers', 'app/mailers'
18
+ add_group 'Libraries', 'lib'
19
+ add_group 'Plugins', 'vendor/plugins'
20
+ end
21
+ SimpleCov.at_exit do
22
+ ideal_coverage = {
23
+ 'Controllers' => 10,
24
+ 'API Controllers' => 100,
25
+ 'Models' => 100,
26
+ 'Services' => 100,
27
+ 'Helpers' => 10,
28
+ 'Policies' => 100,
29
+ 'Jobs' => 100,
30
+ 'Mailers' => 0,
31
+ 'Libraries' => 0,
32
+ 'Plugins' => 0,
33
+ 'Ungrouped' => 10
34
+ }
35
+ required_coverage = JefferiesTube::Coverage.required_coverage
36
+ overall_failed = false
37
+ output = "=====================Test Coverage=====================\n"
38
+ output << "Group Files Current / Required (Ideal)\n"
39
+ SimpleCov.result.groups.each do |name, group|
40
+ next if group.size.zero?
41
+ failed = false
42
+ warning = false
43
+ if group.covered_percent.round(2) < ideal_coverage[name]
44
+ warning = true
45
+ end
46
+ if group.covered_percent.round(2) < required_coverage[name]
47
+ warning = false
48
+ failed = true
49
+ overall_failed = true
50
+ end
51
+ color = if failed
52
+ "\e[31m"
53
+ elsif warning
54
+ "\e[33m"
55
+ else
56
+ "\e[32m"
57
+ end
58
+ files = "Files: #{group.size}".ljust(11)
59
+ current = "#{group.covered_percent.round(2)}%".ljust(7)
60
+ required = "#{required_coverage[name]}%".ljust(8)
61
+ output << "#{color}#{name.ljust(16)} #{files} #{current} / #{required} (#{ideal_coverage[name]}%)\e[0m\n"
62
+ end
63
+ output += "\n"
64
+ puts output
65
+ if overall_failed
66
+ exit(SimpleCov::ExitCodes::MINIMUM_COVERAGE)
67
+ end
68
+ end
@@ -0,0 +1,25 @@
1
+ module JefferiesTube::Coverage
2
+ def self.default_converage
3
+ {
4
+ 'Controllers' => 10,
5
+ 'API Controllers' => 100,
6
+ 'Models' => 100,
7
+ 'Services' => 100,
8
+ 'Helpers' => 10,
9
+ 'Policies' => 100,
10
+ 'Jobs' => 100,
11
+ 'Mailers' => 0,
12
+ 'Libraries' => 0,
13
+ 'Plugins' => 0,
14
+ 'Ungrouped' => 10
15
+ }
16
+ end
17
+
18
+ def self.required_coverage=(hash)
19
+ @required_coverage = hash
20
+ end
21
+
22
+ def self.required_coverage
23
+ self.default_converage.merge(@required_coverage || {})
24
+ end
25
+ end
@@ -1,5 +1,6 @@
1
1
  require 'jefferies_tube'
2
2
  require 'jefferies_tube/console'
3
+ require 'jefferies_tube/coverage'
3
4
  require 'rails'
4
5
 
5
6
  module JefferiesTube
@@ -67,5 +68,29 @@ module JefferiesTube
67
68
  end
68
69
  end
69
70
  end
71
+
72
+ initializer "create default rubocop config if missing" do |config|
73
+ default_rubocop = File.join(File.dirname(__FILE__), "config", "rubocop_default.yml")
74
+ rubocop_path = ::Rails.root.join ".rubocop.yml"
75
+ if !File.file?(rubocop_path)
76
+ FileUtils::cp(default_rubocop, rubocop_path)
77
+ end
78
+ end
79
+
80
+ initializer 'load simplecov for tests' do |config|
81
+ if ::Rails.env.test?
82
+ simplecov_config = 'config/simplecov.rb'
83
+ require_relative simplecov_config
84
+ end
85
+ end
86
+
87
+ rake_tasks do
88
+ Rake.application['default'].clear
89
+ task default: :spec
90
+ require 'rubocop/rake_task'
91
+
92
+ RuboCop::RakeTask.new(:rubocop)
93
+ task default: :rubocop
94
+ end
70
95
  end
71
96
  end
@@ -1,7 +1,7 @@
1
1
  require 'open-uri'
2
2
 
3
3
  module JefferiesTube
4
- VERSION = "1.5.4"
4
+ VERSION = "1.6.0"
5
5
 
6
6
  def self.latest_rubygems_version
7
7
  JSON.parse(URI.parse("https://rubygems.org/api/v1/versions/jefferies_tube/latest.json").read)["version"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jefferies_tube
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Samson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-11 00:00:00.000000000 Z
11
+ date: 2022-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.13'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.26'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.26'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  description: Useful tools for Rails.
112
140
  email:
113
141
  - brian@tenforwardconsulting.com
@@ -132,6 +160,7 @@ files:
132
160
  - app/views/errors/404.json.jbuilder
133
161
  - app/views/errors/404.xml
134
162
  - app/views/errors/500.haml
163
+ - default.yml
135
164
  - jefferies_tube.gemspec
136
165
  - lib/jefferies_tube.rb
137
166
  - lib/jefferies_tube/access_token.rb
@@ -143,7 +172,10 @@ files:
143
172
  - lib/jefferies_tube/capistrano/rails.rb
144
173
  - lib/jefferies_tube/capistrano/s3_assets.rb
145
174
  - lib/jefferies_tube/capistrano/ssh.rb
175
+ - lib/jefferies_tube/config/rubocop_default.yml
176
+ - lib/jefferies_tube/config/simplecov.rb
146
177
  - lib/jefferies_tube/console.rb
178
+ - lib/jefferies_tube/coverage.rb
147
179
  - lib/jefferies_tube/custom_prompts.irbrc.rb
148
180
  - lib/jefferies_tube/database_backup.rb
149
181
  - lib/jefferies_tube/database_backup_adapter.rb
@@ -176,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
208
  - !ruby/object:Gem::Version
177
209
  version: '0'
178
210
  requirements: []
179
- rubygems_version: 3.3.3
211
+ rubygems_version: 3.3.11
180
212
  signing_key:
181
213
  specification_version: 4
182
214
  summary: Ten Forward Consulting useful tools.