Class: Expressir::Commands::ValidateAscii
- Defined in:
- lib/expressir/commands/validate_ascii.rb
Overview
ValidateAscii command for checking EXPRESS files for non-ASCII characters
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#run(express_file_path) ⇒ Object
rubocop:disable Metrics/AbcSize.
Methods inherited from Base
#exit_with_error, #initialize, #say
Constructor Details
This class inherits a constructor from Expressir::Commands::Base
Instance Method Details
#run(express_file_path) ⇒ Object
rubocop:disable Metrics/AbcSize
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
# File 'lib/expressir/commands/validate_ascii.rb', line 520 def run(express_file_path) # rubocop:disable Metrics/AbcSize # Check if input is a manifest file if File.file?(express_file_path) && File.extname(express_file_path) == ".yaml" validate_from_manifest(express_file_path) return end # Original file/directory validation logic if File.file?(express_file_path) unless File.exist?(express_file_path) raise Errno::ENOENT, "Specified EXPRESS file " \ "`#{express_file_path}` not found." end if File.extname(express_file_path) != ".exp" raise ArgumentError, "Specified file `#{express_file_path}` is " \ "not an EXPRESS file." end exp_files = [express_file_path] elsif [:recursive] # Support the relative path with glob pattern base_path = File.(express_file_path) exp_files = Dir.glob("#{base_path}/**/*.exp") else # Non-recursive option base_path = File.(express_file_path) exp_files = Dir.glob("#{base_path}/*.exp") end if exp_files.empty? raise Errno::ENOENT, "No EXPRESS files found in " \ "`#{express_file_path}`." end process_files(exp_files) end |