Module: Packwerk::Validator Abstract
- Extended by:
- ActiveSupport::Autoload
- Included in:
- Packwerk::Validators::DependencyValidator
- Defined in:
- lib/packwerk/validator.rb,
lib/packwerk/validator/result.rb
Overview
This module is abstract.
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Instance Method Summary collapse
- #call(package_set, configuration) ⇒ Object abstract
- #merge_results(results, separator: "\n", before_errors: "", after_errors: "") ⇒ Object
- #package_glob(configuration) ⇒ Object
- #package_manifests(configuration, glob_pattern = nil) ⇒ Object
- #package_manifests_settings_for(configuration, setting) ⇒ Object
- #permitted_keys ⇒ Object abstract
- #relative_path(configuration, path) ⇒ Object
Class Method Details
.all ⇒ Object
22 23 24 25 |
# File 'lib/packwerk/validator.rb', line 22 def all load_defaults validators.map(&:new) #: as Array[Validator] end |
.included(base) ⇒ Object
17 18 19 |
# File 'lib/packwerk/validator.rb', line 17 def included(base) validators << base end |
Instance Method Details
#call(package_set, configuration) ⇒ Object
This method is abstract.
46 |
# File 'lib/packwerk/validator.rb', line 46 def call(package_set, configuration) = raise NotImplementedError, "Abstract method called" |
#merge_results(results, separator: "\n", before_errors: "", after_errors: "") ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/packwerk/validator.rb', line 71 def merge_results(results, separator: "\n", before_errors: "", after_errors: "") results.reject!(&:ok?) if results.empty? Validator::Result.new(ok: true) else Validator::Result.new( ok: false, error_value: [ before_errors, separator.lstrip, results.map(&:error_value).join(separator), after_errors, ].join, ) end end |
#package_glob(configuration) ⇒ Object
61 62 63 |
# File 'lib/packwerk/validator.rb', line 61 def package_glob(configuration) configuration.package_paths end |
#package_manifests(configuration, glob_pattern = nil) ⇒ Object
54 55 56 57 58 |
# File 'lib/packwerk/validator.rb', line 54 def package_manifests(configuration, glob_pattern = nil) glob_pattern ||= package_glob(configuration) PackageSet.package_paths(configuration.root_path, glob_pattern, configuration.exclude) .map { |f| File.realpath(f) } end |
#package_manifests_settings_for(configuration, setting) ⇒ Object
49 50 51 |
# File 'lib/packwerk/validator.rb', line 49 def package_manifests_settings_for(configuration, setting) package_manifests(configuration).map { |f| [f, (YAML.load_file(File.join(f)) || {})[setting]] } end |
#permitted_keys ⇒ Object
This method is abstract.
42 |
# File 'lib/packwerk/validator.rb', line 42 def permitted_keys = raise NotImplementedError, "Abstract method called" |
#relative_path(configuration, path) ⇒ Object
90 91 92 |
# File 'lib/packwerk/validator.rb', line 90 def relative_path(configuration, path) Pathname.new(path).relative_path_from(configuration.root_path) end |