polishgeeks-dev-tools 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +3 -0
  4. data/Gemfile.lock +27 -30
  5. data/Rakefile +1 -1
  6. data/lib/polishgeeks-dev-tools.rb +26 -20
  7. data/lib/polishgeeks/dev-tools/{command → commands}/allowed_extensions.rb +1 -1
  8. data/lib/polishgeeks/dev-tools/{command → commands}/base.rb +15 -25
  9. data/lib/polishgeeks/dev-tools/{command → commands}/brakeman.rb +4 -2
  10. data/lib/polishgeeks/dev-tools/{command → commands}/empty_method.rb +1 -1
  11. data/lib/polishgeeks/dev-tools/{command → commands}/empty_method/file_parser.rb +1 -1
  12. data/lib/polishgeeks/dev-tools/{command → commands}/empty_method/string_refinements.rb +1 -1
  13. data/lib/polishgeeks/dev-tools/{command → commands}/examples_comparator.rb +1 -1
  14. data/lib/polishgeeks/dev-tools/{command → commands}/expires_in.rb +1 -1
  15. data/lib/polishgeeks/dev-tools/{command → commands}/final_blank_line.rb +1 -1
  16. data/lib/polishgeeks/dev-tools/{command → commands}/haml_lint.rb +1 -1
  17. data/lib/polishgeeks/dev-tools/{command → commands}/readme.rb +1 -1
  18. data/lib/polishgeeks/dev-tools/{command → commands}/rspec.rb +1 -1
  19. data/lib/polishgeeks/dev-tools/{command → commands}/rspec_files_names.rb +1 -1
  20. data/lib/polishgeeks/dev-tools/{command → commands}/rspec_files_structure.rb +1 -1
  21. data/lib/polishgeeks/dev-tools/{command → commands}/rubocop.rb +1 -1
  22. data/lib/polishgeeks/dev-tools/{command → commands}/rubycritic.rb +1 -1
  23. data/lib/polishgeeks/dev-tools/{command/coverage.rb → commands/simplecov.rb} +22 -9
  24. data/lib/polishgeeks/dev-tools/{command → commands}/tasks_files_names.rb +1 -1
  25. data/lib/polishgeeks/dev-tools/{command → commands}/yard.rb +1 -1
  26. data/lib/polishgeeks/dev-tools/{command → commands}/yml_parser.rb +1 -1
  27. data/lib/polishgeeks/dev-tools/config.rb +0 -16
  28. data/lib/polishgeeks/dev-tools/errors.rb +25 -0
  29. data/lib/polishgeeks/dev-tools/logger.rb +7 -12
  30. data/lib/polishgeeks/dev-tools/runner.rb +2 -1
  31. data/lib/polishgeeks/dev-tools/validators/base.rb +26 -0
  32. data/lib/polishgeeks/dev-tools/validators/rails.rb +12 -0
  33. data/lib/polishgeeks/dev-tools/validators/simplecov.rb +20 -0
  34. data/lib/polishgeeks/dev-tools/version.rb +1 -1
  35. data/polishgeeks_dev_tools.gemspec +1 -1
  36. data/spec/lib/polishgeeks/dev-tools/{command → commands}/allowed_extensions_spec.rb +1 -1
  37. data/spec/lib/polishgeeks/dev-tools/commands/base_spec.rb +55 -0
  38. data/spec/lib/polishgeeks/dev-tools/{command → commands}/brakeman_spec.rb +10 -9
  39. data/spec/lib/polishgeeks/dev-tools/{command → commands}/empty_method/file_parser_spec.rb +1 -1
  40. data/spec/lib/polishgeeks/dev-tools/{command → commands}/empty_method/string_refinements_spec.rb +1 -1
  41. data/spec/lib/polishgeeks/dev-tools/{command → commands}/empty_method_spec.rb +1 -1
  42. data/spec/lib/polishgeeks/dev-tools/{command → commands}/examples_comparator_spec.rb +1 -1
  43. data/spec/lib/polishgeeks/dev-tools/{command → commands}/expires_in_spec.rb +1 -1
  44. data/spec/lib/polishgeeks/dev-tools/{command → commands}/final_blank_line_spec.rb +1 -1
  45. data/spec/lib/polishgeeks/dev-tools/{command → commands}/haml_lint_spec.rb +1 -1
  46. data/spec/lib/polishgeeks/dev-tools/{command → commands}/readme_spec.rb +1 -1
  47. data/spec/lib/polishgeeks/dev-tools/{command → commands}/rspec_files_names_spec.rb +1 -1
  48. data/spec/lib/polishgeeks/dev-tools/{command → commands}/rspec_files_structure_spec.rb +1 -1
  49. data/spec/lib/polishgeeks/dev-tools/{command → commands}/rspec_spec.rb +1 -1
  50. data/spec/lib/polishgeeks/dev-tools/{command → commands}/rubocop_spec.rb +1 -1
  51. data/spec/lib/polishgeeks/dev-tools/{command → commands}/rubycritic_spec.rb +1 -1
  52. data/spec/lib/polishgeeks/dev-tools/{command/coverage_spec.rb → commands/simplecov_spec.rb} +28 -15
  53. data/spec/lib/polishgeeks/dev-tools/{command → commands}/tasks_files_names_spec.rb +1 -1
  54. data/spec/lib/polishgeeks/dev-tools/{command → commands}/yard_spec.rb +1 -1
  55. data/spec/lib/polishgeeks/dev-tools/{command → commands}/yml_parser_spec.rb +1 -1
  56. data/spec/lib/polishgeeks/dev-tools/config_spec.rb +0 -18
  57. data/spec/lib/polishgeeks/dev-tools/errors_spec.rb +15 -0
  58. data/spec/lib/polishgeeks/dev-tools/logger_spec.rb +3 -3
  59. data/spec/lib/polishgeeks/dev-tools/runner_spec.rb +4 -1
  60. data/spec/lib/polishgeeks/dev-tools/validators/base_spec.rb +34 -0
  61. data/spec/lib/polishgeeks/dev-tools/validators/rails_spec.rb +21 -0
  62. data/spec/lib/polishgeeks/dev-tools/validators/simplecov_spec.rb +34 -0
  63. metadata +78 -69
  64. data/lib/polishgeeks/dev-tools/command/simplecov.rb +0 -32
  65. data/spec/lib/polishgeeks/dev-tools/command/base_spec.rb +0 -127
  66. data/spec/lib/polishgeeks/dev-tools/command/simplecov_spec.rb +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2cbe8369c08f481d0060a493bca52c0b1223c6f
4
- data.tar.gz: 19384f5f7b3c94e6e588d610b1b6aeb2b1d90791
3
+ metadata.gz: 720e29e14953ef13e7c94a269d5c089ff3783d38
4
+ data.tar.gz: 56b9bf6b831f5cff118daf838c74a0f311a99977
5
5
  SHA512:
6
- metadata.gz: 9bf268c0e62ed3029f2bebb6872705304c3ec7abd97c26bfc14278a4b565ccff02f035610c94f36173748480fcabb471abc18b2ddfc82d741e1d5b9c9b93177f
7
- data.tar.gz: 9ec402bf09e3ec5f4258b2a15c014f71707c3dee74d4559d78c92aca56c7341a0b6b7a59d87c3d326bce8ed9d6a191892b3c997aa236e3e5653d3196e999b592
6
+ metadata.gz: 73fab8df5c40ec3f30c51a7b29b48c153d9131b559544adbe8cf8d651633bc25d86e9cbf1db09b03ea6a02bbc279e81620d25a827798c5bde288c24ce833bb80
7
+ data.tar.gz: 50a39d960da6ca93fabf46fe6e443569552fbd04e151d8633e1524db1193b77faa332bb1482382059c990619b3cbb039cff217c6aa135dfd59fab3094ef21501
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ .DS_Store
@@ -1,5 +1,8 @@
1
1
  # PolishGeeks Dev Tools Changelog
2
2
 
3
+ ## 1.2.1
4
+ - Extracted all errors to PolishGeeks::DevTools::Errors namespace
5
+
3
6
  ## 1.2.0
4
7
  - Added EmptyMethod command which checks if some files have empty methods
5
8
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polishgeeks-dev-tools (1.2.0)
4
+ polishgeeks-dev-tools (1.2.1)
5
5
  brakeman
6
6
  faker
7
7
  haml-lint
@@ -9,7 +9,7 @@ PATH
9
9
  pry
10
10
  rspec
11
11
  rubocop
12
- rubycritic (= 1.2.1)
12
+ rubycritic
13
13
  shoulda
14
14
  simplecov
15
15
  timecop
@@ -38,7 +38,7 @@ GEM
38
38
  descendants_tracker (~> 0.0.4)
39
39
  ice_nine (~> 0.11.0)
40
40
  thread_safe (~> 0.3, >= 0.3.1)
41
- brakeman (3.1.0)
41
+ brakeman (3.1.2)
42
42
  erubis (~> 2.6)
43
43
  fastercsv (~> 1.5)
44
44
  haml (>= 3.0, < 5.0)
@@ -46,10 +46,11 @@ GEM
46
46
  multi_json (~> 1.2)
47
47
  ruby2ruby (>= 2.1.1, < 2.3.0)
48
48
  ruby_parser (~> 3.7.0)
49
+ safe_yaml
49
50
  sass (~> 3.0)
50
51
  slim (>= 1.3.6, < 4.0)
51
- terminal-table (~> 1.4.5)
52
- bson (3.2.4)
52
+ terminal-table (~> 1.4)
53
+ bson (3.2.6)
53
54
  builder (3.2.2)
54
55
  coderay (1.1.0)
55
56
  coercible (1.0.0)
@@ -57,7 +58,6 @@ GEM
57
58
  concord (0.1.5)
58
59
  adamantium (~> 0.2.0)
59
60
  equalizer (~> 0.0.9)
60
- connection_pool (2.2.0)
61
61
  descendants_tracker (0.0.4)
62
62
  thread_safe (~> 0.3, >= 0.3.1)
63
63
  diff-lcs (1.2.5)
@@ -79,41 +79,38 @@ GEM
79
79
  haml (~> 4.0)
80
80
  rubocop (>= 0.25.0)
81
81
  sysexits (~> 1.1)
82
- highline (1.7.3)
82
+ highline (1.7.8)
83
83
  i18n (0.7.0)
84
84
  ice_nine (0.11.1)
85
85
  json (1.8.3)
86
86
  memoizable (0.4.2)
87
87
  thread_safe (~> 0.3, >= 0.3.1)
88
88
  method_source (0.8.2)
89
- minitest (5.8.0)
90
- mongoid (4.0.2)
89
+ minitest (5.8.2)
90
+ mongo (2.1.2)
91
+ bson (~> 3.0)
92
+ mongoid (5.0.1)
91
93
  activemodel (~> 4.0)
92
- moped (~> 2.0.0)
94
+ mongo (~> 2.1)
93
95
  origin (~> 2.1)
94
96
  tzinfo (>= 0.3.37)
95
- mongoid-rspec (2.2.0)
96
- mongoid (~> 4.0.0)
97
+ mongoid-rspec (3.0.0)
98
+ mongoid (~> 5.0)
97
99
  rake
98
- rspec (~> 3.1)
99
- moped (2.0.7)
100
- bson (~> 3.0)
101
- connection_pool (~> 2.0)
102
- optionable (~> 0.2.0)
100
+ rspec (~> 3.3)
103
101
  multi_json (1.11.2)
104
- optionable (0.2.0)
105
102
  origin (2.1.1)
106
- parser (2.2.2.6)
103
+ parser (2.2.3.0)
107
104
  ast (>= 1.1, < 3.0)
108
105
  powerpack (0.1.1)
109
106
  procto (0.0.2)
110
- pry (0.10.1)
107
+ pry (0.10.3)
111
108
  coderay (~> 1.1.0)
112
109
  method_source (~> 0.8.1)
113
110
  slop (~> 3.4)
114
111
  rainbow (2.0.0)
115
112
  rake (10.4.2)
116
- reek (1.6.3)
113
+ reek (1.6.5)
117
114
  parser (~> 2.2.0.pre.7)
118
115
  rainbow (>= 1.99, < 3.0)
119
116
  unparser (~> 0.2.2)
@@ -130,26 +127,26 @@ GEM
130
127
  diff-lcs (>= 1.2.0, < 2.0)
131
128
  rspec-support (~> 3.3.0)
132
129
  rspec-support (3.3.0)
133
- rubocop (0.34.0)
130
+ rubocop (0.35.0)
134
131
  astrolabe (~> 1.3)
135
- parser (>= 2.2.2.5, < 3.0)
132
+ parser (>= 2.2.3.0, < 3.0)
136
133
  powerpack (~> 0.1)
137
134
  rainbow (>= 1.99.1, < 3.0)
138
- ruby-progressbar (~> 1.4)
135
+ ruby-progressbar (~> 1.7)
139
136
  ruby-progressbar (1.7.5)
140
137
  ruby2ruby (2.2.0)
141
138
  ruby_parser (~> 3.1)
142
139
  sexp_processor (~> 4.0)
143
- ruby_parser (3.7.1)
140
+ ruby_parser (3.7.2)
144
141
  sexp_processor (~> 4.1)
145
- rubycritic (1.2.1)
142
+ rubycritic (1.4.0)
146
143
  flay (= 2.4.0)
147
144
  flog (= 4.2.1)
148
145
  parser (>= 2.2.0, < 3.0)
149
- reek (= 1.6.3)
150
- ruby2ruby (>= 2.1.1, < 3.0)
146
+ reek (= 1.6.5)
151
147
  virtus (~> 1.0)
152
- sass (3.4.18)
148
+ safe_yaml (1.0.4)
149
+ sass (3.4.19)
153
150
  sexp_processor (4.6.0)
154
151
  shoulda (3.5.0)
155
152
  shoulda-context (~> 1.0, >= 1.0.1)
@@ -168,7 +165,7 @@ GEM
168
165
  slop (3.6.0)
169
166
  sysexits (1.2.0)
170
167
  temple (0.7.6)
171
- terminal-table (1.4.5)
168
+ terminal-table (1.5.2)
172
169
  thread_safe (0.3.5)
173
170
  tilt (2.0.1)
174
171
  timecop (0.8.0)
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ task :check do
8
8
  config.brakeman = false
9
9
  config.haml_lint = false
10
10
  config.expires_in_files_ignored = %w(
11
- lib/polishgeeks/dev-tools/command/expires_in.rb
11
+ lib/polishgeeks/dev-tools/commands/expires_in.rb
12
12
  )
13
13
  config.empty_method_ignored = %w(
14
14
  empty_method_spec.rb
@@ -1,13 +1,29 @@
1
- require 'yaml'
2
- require 'yard'
3
- require 'pry'
4
- require 'fileutils'
5
- require 'timecop'
6
- require 'faker'
7
- require 'ostruct'
8
-
9
- base_path = File.dirname(__FILE__) + '/polishgeeks/dev-tools/*.rb'
10
- Dir[base_path].each { |file| require file }
1
+ %w(
2
+ yaml
3
+ yard
4
+ pry
5
+ fileutils
6
+ timecop
7
+ faker
8
+ ostruct
9
+ ).each { |lib| require lib }
10
+
11
+ %w(
12
+ validators/base
13
+ commands/base
14
+ commands/empty_method
15
+ commands/empty_method/string_refinements
16
+ ).each { |lib| require "polishgeeks/dev-tools/#{lib}" }
17
+
18
+ %w(
19
+ *.rb
20
+ validators/*.rb
21
+ commands/*.rb
22
+ commands/**/*.rb
23
+ ).each do |path|
24
+ base_path = File.dirname(__FILE__) + "/polishgeeks/dev-tools/#{path}"
25
+ Dir[base_path].each { |file| require file }
26
+ end
11
27
 
12
28
  module PolishGeeks
13
29
  module DevTools
@@ -35,14 +51,4 @@ module PolishGeeks
35
51
  end
36
52
  end
37
53
 
38
- require 'polishgeeks/dev-tools/command/base'
39
- require 'polishgeeks/dev-tools/command/empty_method'
40
- require 'polishgeeks/dev-tools/command/empty_method/string_refinements'
41
-
42
- commands_path = File.dirname(__FILE__) + '/polishgeeks/dev-tools/command/*.rb'
43
- Dir[commands_path].each { |file| require file }
44
-
45
- commands_path = File.dirname(__FILE__) + '/polishgeeks/dev-tools/command/**/*.rb'
46
- Dir[commands_path].each { |file| require file }
47
-
48
54
  load 'polishgeeks/dev-tools/tasks/dev-tools.rake'
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Checking config directory that all files are allowed
5
5
  class AllowedExtensions < Base
6
6
  self.type = :validator
@@ -1,14 +1,11 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
3
  # Module encapsulating all the commands that we use to check/verify code
4
- module Command
4
+ module Commands
5
5
  # Base class for all the commands
6
6
  # @abstract Subclass and use
7
7
  class Base
8
- # Raised when we specify a framework in which a given command can be executed
9
- # and it is not present (not detected)
10
- class MissingFramework < StandardError; end
11
-
8
+ # Output string that we get after executing this command
12
9
  attr_reader :output
13
10
  # stored_output [PolishGeeks::DevTools::OutputStorer] storer with results of previous
14
11
  # commands (they might use output from previous/other commands)
@@ -21,7 +18,7 @@ module PolishGeeks
21
18
 
22
19
  class << self
23
20
  attr_accessor :type
24
- attr_accessor :framework
21
+ attr_accessor :validators
25
22
 
26
23
  TYPES.each do |type|
27
24
  # @return [Boolean] if it is a given type command
@@ -31,23 +28,16 @@ module PolishGeeks
31
28
  end
32
29
  end
33
30
 
34
- # When we will try to use a given command, we need to check if it requires
35
- # a given framework (Rails, Sinatra), if so, then we need to check if it is
36
- # present, because without it a given command cannot run
37
- def initialize
38
- ensure_framework_if_required
39
- end
40
-
41
31
  # @raise [NotImplementedError] this should be implemented in a subclass
42
32
  def execute
43
- fail NotImplementedError
33
+ fail Errors::NotImplementedError
44
34
  end
45
35
 
46
36
  # @raise [NotImplementedError] this should be implemented in a subclass
47
37
  # if it is a validator type (or no implementation required when
48
38
  # it is a validator)
49
39
  def valid?
50
- fail NotImplementedError
40
+ fail Errors::NotImplementedError
51
41
  end
52
42
 
53
43
  # @return [String] what message should be printed when error occures
@@ -56,16 +46,16 @@ module PolishGeeks
56
46
  output
57
47
  end
58
48
 
59
- private
60
-
61
- # Checks if a framework is required for a given command, and if so, it wont
62
- # allow to execute this command if it is not present
63
- # @raise [PolishGeeks::DevTools::Command::Base::MissingFramework] if req framework missing
64
- def ensure_framework_if_required
65
- return unless self.class.framework
66
- return if PolishGeeks::DevTools.config.public_send(:"#{self.class.framework}?")
67
-
68
- fail MissingFramework, self.class.framework
49
+ # Runs validators if any to check if all requirements of this command
50
+ # are met in order to execute it properly
51
+ # @raise [PolishGeeks::DevTools::Errors::InvalidValidatorClassError] when invalid
52
+ # validator class name is defined
53
+ # @raise [PolishGeeks::DevTools::Errors::PreCommandValidationError] when validator
54
+ # conditions are not met
55
+ def ensure_executable!
56
+ (self.class.validators || []).each do |validator_class|
57
+ validator_class.new(stored_output).validate!
58
+ end
69
59
  end
70
60
  end
71
61
  end
@@ -1,11 +1,13 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # A static analysis security vulnerability scanner for Ruby on Rails applications
5
5
  # @see https://github.com/presidentbeef/brakeman
6
6
  class Brakeman < Base
7
7
  self.type = :validator
8
- self.framework = :rails
8
+ self.validators = [
9
+ Validators::Rails
10
+ ]
9
11
 
10
12
  # Regexps to get some stat info from brakeman output
11
13
  REGEXPS = {
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Validator used to check if all '.rb' files don't have empty methods
5
5
  class EmptyMethod < Base
6
6
  self.type = :validator
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  class EmptyMethod
5
5
  # Parse file and search whether it contain empty methods
6
6
  class FileParser
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  class EmptyMethod
5
5
  # Adds ability to check strings on specific regex matching
6
6
  module StringRefinements
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Command wrapper for ExamplesComparator rake task
5
5
  # It informs us if our .example files structure is the same as non-example once
6
6
  class ExamplesComparator < Base
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Checking Rails cache options especially expires_in
5
5
  class ExpiresIn < Base
6
6
  self.type = :validator
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Validator used to check if all files have final blank line
5
5
  class FinalBlankLine < Base
6
6
  self.type = :validator
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Command wrapper for Haml lint validation
5
5
  # It informs us if haml is formatted in a proper way
6
6
  # @see https://github.com/causes/haml-lint
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Checks README.rb exists
5
5
  class Readme < Base
6
6
  self.type = :validator
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Command wrapper for Rspec validation
5
5
  # It informs us if our specs are working in a proper way
6
6
  class Rspec < Base
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Validator used to check if all the rspec spec files have a proper
5
5
  # sufix (_spec.rb)
6
6
  class RspecFilesNames < Base
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Checks if there are are rb files that don't have corresponding rspec
5
5
  # spec files defined
6
6
  # This will validate that the names are the same (no typos, etc) and no
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Command wrapper for Rubocop validation
5
5
  # It informs us if code is formatted in a proper way
6
6
  class Rubocop < Base
@@ -1,6 +1,6 @@
1
1
  module PolishGeeks
2
2
  module DevTools
3
- module Command
3
+ module Commands
4
4
  # Command wrapper for RubyCritic statistics
5
5
  # It informs us if RubyCritic stats were generated
6
6
  class Rubycritic < Base