Module: IconGenerator::Validator
- Included in:
- Builder, FaviconBuilder, TouchBuilder
- Defined in:
- lib/icon_generator/validator.rb
Overview
Module intended to be used as a convenient mixin.
Instance Method Summary collapse
-
#validate_arguments(source, destination) ⇒ Object
Validates the given source image file and the destination directory for correctness.
-
#validate_file_status(filename) ⇒ Object
Validates the existence of the given file.
Instance Method Details
#validate_arguments(source, destination) ⇒ Object
Validates the given source image file and the destination directory for correctness.
16 17 18 19 20 |
# File 'lib/icon_generator/validator.rb', line 16 def validate_arguments(source, destination) raise IconGenerator::Error, '1st argument must be a valid image' unless source.match /\.gif$|\.jpg$|\.png$/ raise IconGenerator::Error, '1st argument must be an existing file' unless File.exists? source raise IconGenerator::Error, '2nd argument must be an existing directory' unless Dir.exists? destination end |
#validate_file_status(filename) ⇒ Object
Validates the existence of the given file.
25 26 27 |
# File 'lib/icon_generator/validator.rb', line 25 def validate_file_status(filename) raise IconGenerator::Error unless File.exists? filename end |