Class: CodeownerValidator::Validator
- Inherits:
-
Tasks::Base
- Object
- Tasks::Base
- CodeownerValidator::Validator
- Includes:
- Group
- Defined in:
- lib/codeowner_validator/validator.rb
Overview
Public: The validator is utilized for execution of the tasks associated to the code owner validation tasks. It has the option to either execute a validation and automatically output the stdout or return an [Array] of comments for the consumer to do as they please. The CLI execution will route all comments to stdout.
Instance Method Summary collapse
-
#comments ⇒ Object
Public: Performs the execution of all tasks and returns the comments to be interpreted.
-
#initialize(tasks: [], **options) ⇒ Validator
constructor
Public: Creates an instance of the executor with provided tasks.
-
#summary ⇒ Array
Public: Returns an array of summaries associated to all tasks that are to be executed.
-
#validate ⇒ Object
Public: Performs the execution of all tasks.
Methods inherited from Tasks::Base
Methods included from UtilityHelper
Methods included from Command
Methods included from Logging
#log_command, #log_error, #log_info, #log_stderr, #log_verbose, #log_warn, #logger, #program_name
Constructor Details
#initialize(tasks: [], **options) ⇒ Validator
Public: Creates an instance of the executor with provided tasks
18 19 20 21 22 23 24 |
# File 'lib/codeowner_validator/validator.rb', line 18 def initialize(tasks: [], **) super @options = # allow defining what tasks the merger should execute @tasks = tasks.map { |task_class| task_class.new(**@options) } unless tasks.empty? end |
Instance Method Details
#comments ⇒ Object
Public: Performs the execution of all tasks and returns the comments to be interpreted
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/codeowner_validator/validator.rb', line 45 def comments comments = [] in_repo_folder do tasks&.each do |task| parent = Comment.build( comment: task.summary, type: Comment::TYPE_VERBOSE ) task.comments.each do |comment| comment.parent = parent comments << comment end end end comments.group_by(&:parent) end |
#summary ⇒ Array
Public: Returns an array of summaries associated to all tasks that are to be executed
29 30 31 |
# File 'lib/codeowner_validator/validator.rb', line 29 def summary tasks.map { |t| " * #{t.summary}" } end |
#validate ⇒ Object
Public: Performs the execution of all tasks
34 35 36 37 38 39 40 41 42 |
# File 'lib/codeowner_validator/validator.rb', line 34 def validate log_verbose(%w[Started:] + summary) in_repo_folder do tasks&.each(&:execute) end log_info 'VALIDATION complete! 🌟' end |