Class: Diogenes::Cli::Validate
- Inherits:
-
Object
- Object
- Diogenes::Cli::Validate
- Defined in:
- lib/diogenes/cli/validate.rb
Constant Summary collapse
- DIOGENES_DIR =
: String
".diogenes"
Class Method Summary collapse
-
.run(argv:, cwd:, out:, err:, **_opts) ⇒ Object
: (argv: Array, cwd: String, out: IO, err: IO, **untyped) -> Integer.
Instance Method Summary collapse
-
#initialize(argv:, cwd:, out:, err:) ⇒ Validate
constructor
: (argv: Array, cwd: String, out: IO, err: IO) -> void.
-
#run ⇒ Object
: () -> Integer.
Constructor Details
Class Method Details
.run(argv:, cwd:, out:, err:, **_opts) ⇒ Object
: (argv: Array, cwd: String, out: IO, err: IO, **untyped) -> Integer
10 11 12 |
# File 'lib/diogenes/cli/validate.rb', line 10 def self.run(argv:, cwd:, out:, err:, **_opts) new(argv:, cwd:, out:, err:).run end |
Instance Method Details
#run ⇒ Object
: () -> Integer
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/diogenes/cli/validate.rb', line 23 def run diogenes_dir = File.join(@cwd, DIOGENES_DIR) unless Dir.exist?(diogenes_dir) @err.puts "No #{DIOGENES_DIR}/ found. Run `diogenes init` first." return 1 end @out.puts "Validating #{DIOGENES_DIR}/ sources..." @out.puts issues = Diogenes::Validate::Runner.new(diogenes_dir).run errors = issues.select(&:error?) warnings = issues.select(&:warning?) if errors.empty? && warnings.empty? @out.puts "✓ All sources valid. Ready to build." return 0 end issues.each { |issue| @out.puts issue.to_s } @out.puts if errors.empty? @out.puts "#{warnings.size} warning#{"s" unless warnings.size == 1} found." 0 else parts = ["#{errors.size} error#{"s" unless errors.size == 1}"] parts << "#{warnings.size} warning#{"s" unless warnings.size == 1}" if warnings.any? @out.puts "#{parts.join(", ")} found." 1 end end |