Sha256: f38df6494016add42a06b7796f6355e2edd20e69019bd5e8baa9eddb52d25d19

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

require_relative "check_input/check_haml_data"
require_relative "logger"

class CheckInput
  def check(filepath)
    @filepath = filepath
    # Check HAML file syntax
    exist = check_file_exist
    return false unless exist
    check_file_content
  end

  private

  def check_file_exist
    if @filepath.nil?
      Logger.error "CheckInput: Unknown filename"
      exit 1
    end
    unless File.exist? @filepath
      Logger.error "CheckInput: File not found! (#{@filepath})"
      exit 1
    end
    unless File.extname(@filepath) == ".haml"
      Logger.error "CheckInput: Check works with HAML files!"
      exit 1
    end
    true
  end

  def check_file_content
    data = CheckHamlData.new(@filepath)
    data.check
    data.show_errors if @verbose
    data.ok?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asker-tool-2.7.1 lib/asker/check_input.rb