Class: DoctorService
- Inherits:
-
Object
- Object
- DoctorService
- Extended by:
- Forwardable
- Defined in:
- lib/core/doctor_service.rb
Instance Method Summary collapse
-
#initialize(command) ⇒ DoctorService
constructor
A new instance of DoctorService.
-
#run_validations(validations, silent_if_passing: false) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #validate_config ⇒ Object
- #validate_templates ⇒ Object
Constructor Details
#initialize(command) ⇒ DoctorService
Returns a new instance of DoctorService.
10 11 12 |
# File 'lib/core/doctor_service.rb', line 10 def initialize(command) @command = command end |
Instance Method Details
#run_validations(validations, silent_if_passing: false) ⇒ Object
rubocop:disable Metrics/MethodLength
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/core/doctor_service.rb', line 14 def run_validations(validations, silent_if_passing: false) # rubocop:disable Metrics/MethodLength @any_failed_validation = false validations.each do |validation| case validation when "config" validate_config when "templates" validate_templates else raise ValidationError, Shell.color("ERROR: Invalid validation '#{validation}'.", :red) end progress.puts("#{Shell.color('[PASS]', :green)} #{validation}") unless silent_if_passing rescue ValidationError => e @any_failed_validation = true progress.puts("#{Shell.color('[FAIL]', :red)} #{validation}\n\n#{e.}\n\n") end exit(ExitCode::ERROR_DEFAULT) if @any_failed_validation end |
#validate_config ⇒ Object
37 38 39 |
# File 'lib/core/doctor_service.rb', line 37 def validate_config check_for_app_names_contained_in_others end |
#validate_templates ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/core/doctor_service.rb', line 41 def validate_templates @template_parser = TemplateParser.new(@command) filenames = Dir.glob("#{@template_parser.template_dir}/*.yml") templates = @template_parser.parse(filenames) check_for_duplicate_templates(templates) warn_deprecated_template_variables end |