class PrelandsRails::CreateSimpleSource::ValidateZipContent::ValidateIncomingFiles::ZipArchive
Attributes
errors[R]
Public Class Methods
new(incoming_files)
click to toggle source
@param [Array<{ftype, name}>] incoming_files
# File lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb, line 11 def initialize(incoming_files) @errors = [] @incoming_files = incoming_files end
Public Instance Methods
valid?()
click to toggle source
# File lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb, line 16 def valid? @errors = [ check_app_js, check_app_css, check_favicon, check_svg_absence ].compact @errors.none? end
Protected Instance Methods
check(pattern, name, absent_error, wrong_place_error)
click to toggle source
# File lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb, line 55 def check(pattern, name, absent_error, wrong_place_error) error = absent_error @incoming_files.each do |file| if file.name[pattern] error = nil unless file.name.index(name)&.zero? error = wrong_place_error % file.name end break end end error end
checka(pattern, present_error)
click to toggle source
check absence
# File lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb, line 72 def checka(pattern, present_error) error = nil @incoming_files.each do |file| if file.name[pattern] error = present_error break end end error end
Private Instance Methods
check_app_css()
click to toggle source
# File lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb, line 37 def check_app_css check 'index.css', 'index.css', 'The «index.css» STYLES file is not found in the zip-archive', 'The «index.css» STYLES file is not in root of the zip-archive: expected «index.css», got «%s»' end
check_app_js()
click to toggle source
@return [nil] Если ‘index.js` находится в корне zip-архива. @return [String] Иначе - вернёт сообщение об ошибке
# File lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb, line 31 def check_app_js check 'index.js', 'index.js', 'The «index.js» JAVASCRIPT file is not found in the zip-archive', 'The «index.js» JAVASCRIPT file is not in root of the zip-archive: expected «index.js», got «%s»' end
check_favicon()
click to toggle source
# File lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb, line 43 def check_favicon check 'icon.ico', /icon\.ico/, 'favicon file is not found in the zip-archive', 'favicon file is not in root of the zip-archive: got «%s»' end
check_svg_absence()
click to toggle source
# File lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb, line 49 def check_svg_absence checka /\.svg/, 'svg files detected, move inside css' end