Class: PolishGeeks::DevTools::Commands::AllowedExtensions
- Defined in:
- lib/polish_geeks/dev_tools/commands/allowed_extensions.rb
Overview
Checking config directory that all files are allowed
Constant Summary collapse
- ALLOWED_EXTENSIONS =
List of allowed extensions of files
%w( rb yml rb.example yml.example ).freeze
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#error_message ⇒ String
Error message that will be displayed if something goes wrong.
-
#execute ⇒ Array
Executes this command not allowed files in config directory.
-
#label ⇒ String
Label with this validator description.
-
#valid? ⇒ Boolean
have correct extension.
Methods inherited from Base
Instance Method Details
#error_message ⇒ String
Returns error message that will be displayed if something goes wrong.
40 41 42 43 44 45 |
# File 'lib/polish_geeks/dev_tools/commands/allowed_extensions.rb', line 40 def err = 'Following files are not allowed in config directory:' err << "\n\n" err << @output.join("\n") err << "\n" end |
#execute ⇒ Array
Executes this command not allowed files in config directory
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/polish_geeks/dev_tools/commands/allowed_extensions.rb', line 19 def execute results = Dir[config_path] @output = results .flatten .map { |line| line.gsub!(PolishGeeks::DevTools.app_root + '/config/', '') } .uniq @output.delete_if do |line| ALLOWED_EXTENSIONS.any? { |allow| line =~ /^.*\.#{allow}$/i } end @output end |
#label ⇒ String
Returns label with this validator description.
34 35 36 |
# File 'lib/polish_geeks/dev_tools/commands/allowed_extensions.rb', line 34 def label 'Allowed Extensions' end |
#valid? ⇒ Boolean
have correct extension
49 50 51 |
# File 'lib/polish_geeks/dev_tools/commands/allowed_extensions.rb', line 49 def valid? @output.empty? end |