Class: PolishGeeks::DevTools::Commands::Base Abstract
- Inherits:
-
Object
- Object
- PolishGeeks::DevTools::Commands::Base
- Defined in:
- lib/polish_geeks/dev_tools/commands/base.rb
Overview
Subclass and use
Base class for all the commands
Direct Known Subclasses
AllowedExtensions, Brakeman, BundlerAudit, EmptyMethods, ExamplesComparator, ExpiresIn, FinalBlankLine, Gemfile, HamlLint, RequiredFiles, Rspec, RspecFilesNames, RspecFilesStructure, Rubocop, Rubycritic, Simplecov, TasksFilesNames, Yard, YmlParser
Constant Summary collapse
- TYPES =
Available command types. We have validators that check something and that should have a ‘valid?’ method and that check for errors, etc and generators that are executed to generate some stats, docs, etc
%i(validator generator).freeze
Class Attribute Summary collapse
-
.config_manager ⇒ Object
ConfigManager instance can be provided, which allows us to find a config file for a command.
-
.type ⇒ Object
Returns the value of attribute type.
-
.validators ⇒ Object
Returns the value of attribute validators.
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Output string that we get after executing this command.
-
#stored_output ⇒ Object
stored_output [PolishGeeks::DevTools::OutputStorer] storer with results of previous commands (they might use output from previous/other commands).
Instance Method Summary collapse
-
#ensure_executable! ⇒ Object
Runs validators if any to check if all requirements of this command are met in order to execute it properly.
-
#error_message ⇒ String
What message should be printed when error occures.
- #execute ⇒ Object
- #valid? ⇒ Boolean
Class Attribute Details
.config_manager ⇒ Object
ConfigManager instance can be provided, which allows us to find a config file for a command
22 23 24 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 22 def config_manager @config_manager end |
.type ⇒ Object
Returns the value of attribute type.
23 24 25 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 23 def type @type end |
.validators ⇒ Object
Returns the value of attribute validators.
24 25 26 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 24 def validators @validators end |
Instance Attribute Details
#output ⇒ Object (readonly)
Output string that we get after executing this command
9 10 11 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 9 def output @output end |
#stored_output ⇒ Object
stored_output [PolishGeeks::DevTools::OutputStorer] storer with results of previous
commands (they might use output from previous/other commands)
12 13 14 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 12 def stored_output @stored_output end |
Instance Method Details
#ensure_executable! ⇒ Object
Runs validators if any to check if all requirements of this command are met in order to execute it properly
58 59 60 61 62 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 58 def ensure_executable! (self.class.validators || []).each do |validator_class| validator_class.new(stored_output).validate! end end |
#error_message ⇒ String
By default the whole output of an executed command will be printed
Returns what message should be printed when error occures.
48 49 50 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 48 def output end |
#execute ⇒ Object
35 36 37 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 35 def execute raise Errors::NotImplementedError end |
#valid? ⇒ Boolean
42 43 44 |
# File 'lib/polish_geeks/dev_tools/commands/base.rb', line 42 def valid? raise Errors::NotImplementedError end |