polishgeeks-dev-tools 1.2.1 → 1.3.0
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/.ruby-version +1 -1
- data/.travis.yml +3 -2
- data/CHANGELOG.md +69 -0
- data/Gemfile.lock +76 -81
- data/README.md +28 -22
- data/Rakefile +4 -3
- data/config/rubocop.yml +16 -16
- data/config/rubocop_todo.yml +14 -0
- data/lib/polish_geeks/dev_tools.rb +26 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/allowed_extensions.rb +4 -4
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/base.rb +18 -3
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/brakeman.rb +5 -2
- data/lib/polish_geeks/dev_tools/commands/bundler_audit.rb +23 -0
- data/lib/{polishgeeks/dev-tools/commands/empty_method.rb → polish_geeks/dev_tools/commands/empty_methods.rb} +3 -13
- data/lib/{polishgeeks/dev-tools/commands/empty_method → polish_geeks/dev_tools/commands/empty_methods}/file_parser.rb +1 -1
- data/lib/{polishgeeks/dev-tools/commands/empty_method → polish_geeks/dev_tools/commands/empty_methods}/string_refinements.rb +2 -2
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/examples_comparator.rb +13 -7
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/expires_in.rb +6 -6
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/final_blank_line.rb +1 -11
- data/lib/polish_geeks/dev_tools/commands/gemfile.rb +39 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/haml_lint.rb +0 -0
- data/lib/polish_geeks/dev_tools/commands/required_files.rb +38 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec.rb +24 -5
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_names.rb +1 -1
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_structure.rb +22 -9
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rubocop.rb +10 -8
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rubycritic.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/simplecov.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/tasks_files_names.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/yard.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/yml_parser.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/config.rb +24 -16
- data/lib/polish_geeks/dev_tools/config_manager.rb +68 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/errors.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/hash.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/logger.rb +3 -3
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/output_storer.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/runner.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/shell.rb +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/tasks/dev-tools.rake +0 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/base.rb +2 -2
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/rails.rb +0 -0
- data/lib/polish_geeks/dev_tools/validators/rubocop.rb +12 -0
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/simplecov.rb +1 -1
- data/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/version.rb +1 -1
- data/lib/polishgeeks-dev-tools.rb +6 -31
- data/polishgeeks_dev_tools.gemspec +6 -5
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/allowed_extensions_spec.rb +5 -17
- data/spec/lib/polish_geeks/dev_tools/commands/base_spec.rb +90 -0
- data/spec/lib/polish_geeks/dev_tools/commands/brakeman_spec.rb +99 -0
- data/spec/lib/polish_geeks/dev_tools/commands/bundler_audit_spec.rb +52 -0
- data/spec/lib/{polishgeeks/dev-tools/commands/empty_method → polish_geeks/dev_tools/commands/empty_methods}/file_parser_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools/commands/empty_method → polish_geeks/dev_tools/commands/empty_methods}/string_refinements_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools/commands/empty_method_spec.rb → polish_geeks/dev_tools/commands/empty_methods_spec.rb} +7 -54
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/examples_comparator_spec.rb +8 -8
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/expires_in_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/final_blank_line_spec.rb +2 -45
- data/spec/lib/polish_geeks/dev_tools/commands/gemfile_spec.rb +91 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/haml_lint_spec.rb +13 -21
- data/spec/lib/polish_geeks/dev_tools/commands/required_files_spec.rb +51 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_names_spec.rb +2 -2
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rspec_files_structure_spec.rb +19 -32
- data/spec/lib/polish_geeks/dev_tools/commands/rspec_spec.rb +106 -0
- data/spec/lib/polish_geeks/dev_tools/commands/rubocop_spec.rb +131 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/rubycritic_spec.rb +5 -3
- data/spec/lib/polish_geeks/dev_tools/commands/simplecov_spec.rb +136 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/tasks_files_names_spec.rb +8 -8
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/yard_spec.rb +10 -10
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/commands/yml_parser_spec.rb +2 -2
- data/spec/lib/polish_geeks/dev_tools/config_manager_spec.rb +124 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/config_spec.rb +3 -3
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/errors_spec.rb +0 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/hash_spec.rb +8 -8
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/logger_spec.rb +9 -9
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/output_storer_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/runner_spec.rb +0 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/shell_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/base_spec.rb +0 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/rails_spec.rb +0 -0
- data/spec/lib/polish_geeks/dev_tools/validators/rubocop_spec.rb +29 -0
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/validators/simplecov_spec.rb +1 -1
- data/spec/lib/{polishgeeks/dev-tools → polish_geeks/dev_tools}/version_spec.rb +0 -0
- data/spec/lib/{polishgeeks-dev-tools_spec.rb → polish_geeks/dev_tools_spec.rb} +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +141 -99
- data/lib/polishgeeks/dev-tools/commands/readme.rb +0 -32
- data/spec/lib/polishgeeks/dev-tools/commands/base_spec.rb +0 -55
- data/spec/lib/polishgeeks/dev-tools/commands/brakeman_spec.rb +0 -96
- data/spec/lib/polishgeeks/dev-tools/commands/readme_spec.rb +0 -38
- data/spec/lib/polishgeeks/dev-tools/commands/rspec_spec.rb +0 -63
- data/spec/lib/polishgeeks/dev-tools/commands/rubocop_spec.rb +0 -127
- data/spec/lib/polishgeeks/dev-tools/commands/simplecov_spec.rb +0 -134
data/config/rubocop.yml
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
AlignParameters:
|
|
2
|
-
Enabled: false
|
|
3
|
-
ClassLength:
|
|
4
|
-
CountComments: false
|
|
5
|
-
Max: 200
|
|
6
|
-
LineLength:
|
|
7
|
-
Max: 99
|
|
8
|
-
MethodLength:
|
|
9
|
-
CountComments: false
|
|
10
|
-
Max: 15
|
|
11
|
-
Metrics/AbcSize:
|
|
12
|
-
Max: 25
|
|
13
1
|
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.3
|
|
14
3
|
Exclude:
|
|
15
4
|
- bin/**/*
|
|
16
5
|
- db/**/*
|
|
@@ -23,13 +12,24 @@ AllCops:
|
|
|
23
12
|
- !ruby/regexp /polishgeeks-[^\/]{2,}\.rb/
|
|
24
13
|
Include:
|
|
25
14
|
- '**/Rakefile'
|
|
26
|
-
- config.ru
|
|
15
|
+
- '**/config.ru'
|
|
27
16
|
- lib/tasks/**/*.rake
|
|
28
17
|
- lib/tasks/**/*.rb
|
|
29
18
|
- lib/capistrano/**/*.rb
|
|
30
19
|
- lib/capistrano/**/*.cap
|
|
20
|
+
AlignParameters:
|
|
21
|
+
Enabled: false
|
|
22
|
+
ClassLength:
|
|
23
|
+
CountComments: false
|
|
24
|
+
Max: 200
|
|
25
|
+
LineLength:
|
|
26
|
+
Max: 99
|
|
27
|
+
MethodLength:
|
|
28
|
+
CountComments: false
|
|
29
|
+
Max: 15
|
|
30
|
+
Metrics/AbcSize:
|
|
31
|
+
Max: 25
|
|
31
32
|
Style/MultilineOperationIndentation:
|
|
32
33
|
EnforcedStyle: indented
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
- indented
|
|
34
|
+
|
|
35
|
+
inherit_from: rubocop_todo.yml
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2016-02-18 19:14:30 +0100 using RuboCop version 0.37.2.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 74
|
|
10
|
+
# Cop supports --auto-correct.
|
|
11
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
12
|
+
# SupportedStyles: when_needed, always
|
|
13
|
+
Style/FrozenStringLiteralComment:
|
|
14
|
+
Enabled: false
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module PolishGeeks
|
|
2
|
+
# Allows us to get config, gem_root, app_root and setup
|
|
3
|
+
module DevTools
|
|
4
|
+
# This is just an alias so we can use it from DevTools directly
|
|
5
|
+
# @return [PolishGeeks::DevTools::Config.config]
|
|
6
|
+
def self.config
|
|
7
|
+
Config.config
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# @return [String] root path of this gem
|
|
11
|
+
def self.gem_root
|
|
12
|
+
File.expand_path('../../..', __FILE__)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @return [String] app root path
|
|
16
|
+
def self.app_root
|
|
17
|
+
File.dirname(ENV['BUNDLE_GEMFILE'])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Sets up the whole configuration
|
|
21
|
+
# @param [Block] block
|
|
22
|
+
def self.setup(&block)
|
|
23
|
+
Config.setup(&block)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -11,7 +11,7 @@ module PolishGeeks
|
|
|
11
11
|
yml
|
|
12
12
|
rb.example
|
|
13
13
|
yml.example
|
|
14
|
-
)
|
|
14
|
+
).freeze
|
|
15
15
|
|
|
16
16
|
# Executes this command
|
|
17
17
|
# @return [Array] command output array with list of
|
|
@@ -20,9 +20,9 @@ module PolishGeeks
|
|
|
20
20
|
results = Dir[config_path]
|
|
21
21
|
|
|
22
22
|
@output = results
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
.flatten
|
|
24
|
+
.map { |line| line.gsub!(PolishGeeks::DevTools.app_root + '/config/', '') }
|
|
25
|
+
.uniq
|
|
26
26
|
@output.delete_if do |line|
|
|
27
27
|
ALLOWED_EXTENSIONS.any? { |allow| line =~ /^.*\.#{allow}$/i }
|
|
28
28
|
end
|
|
@@ -14,9 +14,12 @@ module PolishGeeks
|
|
|
14
14
|
# Available command types. We have validators that check something
|
|
15
15
|
# and that should have a 'valid?' method and that check for errors, etc
|
|
16
16
|
# and generators that are executed to generate some stats, docs, etc
|
|
17
|
-
TYPES = %i( validator generator )
|
|
17
|
+
TYPES = %i( validator generator ).freeze
|
|
18
18
|
|
|
19
19
|
class << self
|
|
20
|
+
# ConfigManager instance can be provided, which allows us to find a
|
|
21
|
+
# config file for a command
|
|
22
|
+
attr_accessor :config_manager
|
|
20
23
|
attr_accessor :type
|
|
21
24
|
attr_accessor :validators
|
|
22
25
|
|
|
@@ -30,14 +33,14 @@ module PolishGeeks
|
|
|
30
33
|
|
|
31
34
|
# @raise [NotImplementedError] this should be implemented in a subclass
|
|
32
35
|
def execute
|
|
33
|
-
|
|
36
|
+
raise Errors::NotImplementedError
|
|
34
37
|
end
|
|
35
38
|
|
|
36
39
|
# @raise [NotImplementedError] this should be implemented in a subclass
|
|
37
40
|
# if it is a validator type (or no implementation required when
|
|
38
41
|
# it is a validator)
|
|
39
42
|
def valid?
|
|
40
|
-
|
|
43
|
+
raise Errors::NotImplementedError
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
# @return [String] what message should be printed when error occures
|
|
@@ -57,6 +60,18 @@ module PolishGeeks
|
|
|
57
60
|
validator_class.new(stored_output).validate!
|
|
58
61
|
end
|
|
59
62
|
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
# @param [String] path from which we want take files
|
|
67
|
+
# @return [Array<String>] list of files in path with app prefix path
|
|
68
|
+
# @note if path is a file return array with file path with app prefix path
|
|
69
|
+
def files_from_path(path)
|
|
70
|
+
full_path = "#{::PolishGeeks::DevTools.app_root}/#{path}"
|
|
71
|
+
return [full_path] if File.file?(full_path)
|
|
72
|
+
|
|
73
|
+
Dir.glob(full_path).select { |f| File.file? f }
|
|
74
|
+
end
|
|
60
75
|
end
|
|
61
76
|
end
|
|
62
77
|
end
|
|
@@ -4,6 +4,7 @@ module PolishGeeks
|
|
|
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
|
+
self.config_manager = ConfigManager.new('brakeman.yml')
|
|
7
8
|
self.type = :validator
|
|
8
9
|
self.validators = [
|
|
9
10
|
Validators::Rails
|
|
@@ -16,12 +17,14 @@ module PolishGeeks
|
|
|
16
17
|
templates: /Template.* (\d+)/,
|
|
17
18
|
errors: /Error.* (\d+)/,
|
|
18
19
|
warnings: /Warning.* (\d+)/
|
|
19
|
-
}
|
|
20
|
+
}.freeze
|
|
20
21
|
|
|
21
22
|
# Executes this command
|
|
22
23
|
# @return [String] command output
|
|
23
24
|
def execute
|
|
24
|
-
|
|
25
|
+
cmd = ['bundle exec brakeman -q']
|
|
26
|
+
cmd << "-c #{self.class.config_manager.path}" if self.class.config_manager.present?
|
|
27
|
+
@output = Shell.new.execute(cmd.join(' '))
|
|
25
28
|
end
|
|
26
29
|
|
|
27
30
|
# @return [Boolean] true if we didn't have any vulnerabilities detected
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module PolishGeeks
|
|
2
|
+
module DevTools
|
|
3
|
+
module Commands
|
|
4
|
+
# Command wrapper for Bundler Audit
|
|
5
|
+
# Checks for vulnerable versions of gems in Gemfile.lock.
|
|
6
|
+
# @see https://github.com/rubysec/bundler-audit
|
|
7
|
+
class BundlerAudit < Base
|
|
8
|
+
self.type = :validator
|
|
9
|
+
|
|
10
|
+
# Executes this command
|
|
11
|
+
# @return [String] command output
|
|
12
|
+
def execute
|
|
13
|
+
@output = Shell.new.execute('bundle-audit update 2>&1 > /dev/null; bundle-audit check')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @return [Boolean] true if there were no vulnerabilities found
|
|
17
|
+
def valid?
|
|
18
|
+
@output.match(/Unpatched versions found/).nil?
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -2,7 +2,7 @@ module PolishGeeks
|
|
|
2
2
|
module DevTools
|
|
3
3
|
module Commands
|
|
4
4
|
# Validator used to check if all '.rb' files don't have empty methods
|
|
5
|
-
class
|
|
5
|
+
class EmptyMethods < Base
|
|
6
6
|
self.type = :validator
|
|
7
7
|
|
|
8
8
|
attr_reader :counter
|
|
@@ -17,7 +17,7 @@ module PolishGeeks
|
|
|
17
17
|
public
|
|
18
18
|
app/assets/images
|
|
19
19
|
app/assets/fonts
|
|
20
|
-
)
|
|
20
|
+
).freeze
|
|
21
21
|
|
|
22
22
|
# Executes this command and set output and counter variables
|
|
23
23
|
def execute
|
|
@@ -76,17 +76,7 @@ module PolishGeeks
|
|
|
76
76
|
|
|
77
77
|
# @return [Array<String>] list of excluded files/directories from config file
|
|
78
78
|
def config_excludes
|
|
79
|
-
DevTools.config.
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# @param [String] path from which we want take files
|
|
83
|
-
# @return [Array<String>] list of files in path with app prefix path
|
|
84
|
-
# @note if path is a file return array with file path with app prefix path
|
|
85
|
-
def files_from_path(path)
|
|
86
|
-
full_path = "#{::PolishGeeks::DevTools.app_root}/#{path}"
|
|
87
|
-
return [full_path] if File.file?(full_path)
|
|
88
|
-
|
|
89
|
-
Dir.glob(full_path).select { |f| File.file? f }
|
|
79
|
+
DevTools.config.empty_methods_ignored || []
|
|
90
80
|
end
|
|
91
81
|
|
|
92
82
|
# @param [String] file name that we want to sanitize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module PolishGeeks
|
|
2
2
|
module DevTools
|
|
3
3
|
module Commands
|
|
4
|
-
class
|
|
4
|
+
class EmptyMethods
|
|
5
5
|
# Adds ability to check strings on specific regex matching
|
|
6
6
|
module StringRefinements
|
|
7
7
|
# Regex to determine commented or empty string
|
|
@@ -13,7 +13,7 @@ module PolishGeeks
|
|
|
13
13
|
# Regex to determine end of method
|
|
14
14
|
END_REGEX = /^\s*end(\.\w+(\s+|$)|\s*#.+|\s+|$)\s*/
|
|
15
15
|
# Regex to determine begin of method definition through define_method
|
|
16
|
-
DEFINE_METHOD = '^\s*(define_method|define_singleton_method)'
|
|
16
|
+
DEFINE_METHOD = '^\s*(define_method|define_singleton_method)'.freeze
|
|
17
17
|
# Regex to determine definition of method with do-end block
|
|
18
18
|
DEFINE_METHOD_WITH_DO_END =
|
|
19
19
|
/#{DEFINE_METHOD}(\s+|\().*do(\s*(\s*|.*\|\s*))(\s*|#.*)$/
|
|
@@ -13,14 +13,8 @@ module PolishGeeks
|
|
|
13
13
|
|
|
14
14
|
Dir[config_path].each do |example_file|
|
|
15
15
|
dedicated_file = example_file.gsub('.example', '')
|
|
16
|
-
|
|
17
16
|
header = compare_header(example_file, dedicated_file)
|
|
18
|
-
|
|
19
|
-
if same_key_structure?(example_file, dedicated_file)
|
|
20
|
-
@output << successful_compare(header)
|
|
21
|
-
else
|
|
22
|
-
@output << failed_compare(header)
|
|
23
|
-
end
|
|
17
|
+
@output << compare_output(header, example_file, dedicated_file)
|
|
24
18
|
end
|
|
25
19
|
end
|
|
26
20
|
|
|
@@ -58,6 +52,18 @@ module PolishGeeks
|
|
|
58
52
|
"#{File.basename(example_file)} and #{File.basename(dedicated_file)}"
|
|
59
53
|
end
|
|
60
54
|
|
|
55
|
+
# @param [String] header output message
|
|
56
|
+
# @param [File] example_file which we compare with dedicated one
|
|
57
|
+
# @param [File] dedicated_file which is compared with example one
|
|
58
|
+
# @return [String] success/failure message for single file
|
|
59
|
+
def compare_output(header, example_file, dedicated_file)
|
|
60
|
+
if same_key_structure?(example_file, dedicated_file)
|
|
61
|
+
successful_compare(header)
|
|
62
|
+
else
|
|
63
|
+
failed_compare(header)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
61
67
|
# @param [String] compare_header output message
|
|
62
68
|
# @return [String] success message for single file
|
|
63
69
|
def successful_compare(compare_header)
|
|
@@ -9,11 +9,11 @@ module PolishGeeks
|
|
|
9
9
|
CHECKED_DIRS = %w(
|
|
10
10
|
app
|
|
11
11
|
lib
|
|
12
|
-
)
|
|
12
|
+
).freeze
|
|
13
13
|
|
|
14
14
|
# Regexp that we want to use to catch invalid things that occur
|
|
15
15
|
# instead of expires_in
|
|
16
|
-
CHECKED_REGEXP = 'expire_in\|expir_in'
|
|
16
|
+
CHECKED_REGEXP = 'expire_in\|expir_in'.freeze
|
|
17
17
|
|
|
18
18
|
# Executes this command
|
|
19
19
|
def execute
|
|
@@ -23,10 +23,10 @@ module PolishGeeks
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
@output = results
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
.flatten
|
|
27
|
+
.map { |line| line.split(':').first }
|
|
28
|
+
.map { |line| line.gsub!(PolishGeeks::DevTools.app_root, '') }
|
|
29
|
+
.uniq
|
|
30
30
|
|
|
31
31
|
@output.delete_if do |line|
|
|
32
32
|
excludes.any? { |exclude| line =~ /#{exclude}/ }
|
|
@@ -19,7 +19,7 @@ module PolishGeeks
|
|
|
19
19
|
app/assets/fonts
|
|
20
20
|
.DS_Store
|
|
21
21
|
.gem
|
|
22
|
-
)
|
|
22
|
+
).freeze
|
|
23
23
|
|
|
24
24
|
# Executes this command and set output and counter variables
|
|
25
25
|
def execute
|
|
@@ -80,16 +80,6 @@ module PolishGeeks
|
|
|
80
80
|
DevTools.config.final_blank_line_ignored || []
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
# @param [String] path from which we want take files
|
|
84
|
-
# @return [Array<String>] list of files in path with app prefix path
|
|
85
|
-
# @note if path is a file return array with file path with app prefix path
|
|
86
|
-
def files_from_path(path)
|
|
87
|
-
full_path = "#{::PolishGeeks::DevTools.app_root}/#{path}"
|
|
88
|
-
return [full_path] if File.file?(full_path)
|
|
89
|
-
|
|
90
|
-
Dir.glob(full_path).select { |f| File.file? f }
|
|
91
|
-
end
|
|
92
|
-
|
|
93
83
|
# @param [String] file name that we want to sanitize
|
|
94
84
|
# @return [String] sanitized file name
|
|
95
85
|
# @example
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module PolishGeeks
|
|
2
|
+
module DevTools
|
|
3
|
+
module Commands
|
|
4
|
+
# Checks if Gemfile contains local gems
|
|
5
|
+
class Gemfile < Base
|
|
6
|
+
self.type = :validator
|
|
7
|
+
|
|
8
|
+
# Regex which check if Gemfile has local gem
|
|
9
|
+
# ex:
|
|
10
|
+
# gem 'example_gem', path: '/Users/Projects/gems/example_gem'
|
|
11
|
+
# gem 'example_gem', :path => '/Users/Projects/gems/example_gem'
|
|
12
|
+
CHECKED_REGEXP = /^[^#]*((\bpath:)|(:path[ \t]*=>))/
|
|
13
|
+
|
|
14
|
+
# Executes this command
|
|
15
|
+
def execute
|
|
16
|
+
@output = []
|
|
17
|
+
gemfile = File.join(::PolishGeeks::DevTools.app_root, 'Gemfile')
|
|
18
|
+
return unless File.exist?(gemfile)
|
|
19
|
+
@output = IO.readlines(gemfile).select { |l| l.match(CHECKED_REGEXP) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [String] label with this validator description
|
|
23
|
+
def label
|
|
24
|
+
'Gemfile checking'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @return [String] message with local gems
|
|
28
|
+
def error_message
|
|
29
|
+
"Gemfile contains gems from local path: \n#{output.join('')}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @return [Boolean] true if output doesn't contain any local gems
|
|
33
|
+
def valid?
|
|
34
|
+
@output.empty?
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module PolishGeeks
|
|
2
|
+
module DevTools
|
|
3
|
+
module Commands
|
|
4
|
+
# Checks for required files
|
|
5
|
+
class RequiredFiles < Base
|
|
6
|
+
self.type = :validator
|
|
7
|
+
|
|
8
|
+
# Executes this command
|
|
9
|
+
# @return [String] command output
|
|
10
|
+
def execute
|
|
11
|
+
output = []
|
|
12
|
+
required_files = ['README.md']
|
|
13
|
+
required_files.concat(::PolishGeeks::DevTools.config.required_files_include || [])
|
|
14
|
+
required_files.each do |required_file|
|
|
15
|
+
file_path = File.join(::PolishGeeks::DevTools.app_root, required_file)
|
|
16
|
+
output << "#{file_path} not exist" unless File.exist?(file_path)
|
|
17
|
+
output << "#{file_path} is empty" if File.zero?(file_path)
|
|
18
|
+
end
|
|
19
|
+
@output = output
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [String] error message
|
|
23
|
+
def error_message
|
|
24
|
+
return if @output.nil?
|
|
25
|
+
err = 'Following files does not exist or are empty:'
|
|
26
|
+
err << "\n"
|
|
27
|
+
err << @output.join("\n")
|
|
28
|
+
err << "\n"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @return [Boolean] true if files exist and are not empty
|
|
32
|
+
def valid?
|
|
33
|
+
@output.empty?
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|