Sha256: e01bb024a52346ef44d1d94a990d95d79c00e4b7b0c4840d6195220898718861

Contents?: true

Size: 773 Bytes

Versions: 6

Compression:

Stored size: 773 Bytes

Contents

module Furoshiki
  class Validator
    def initialize(config)
      @config = config
      @errors = []
    end

    attr_reader :config

    def valid?
      reset_and_validate
      return errors.empty?
    end

    def reset_and_validate
      @errors.clear
      validate if respond_to? :validate
    end

    def errors
      @errors.dup
    end

    def error_message_list
      @errors.map {|m| "  - #{m}"}.join("\n")
    end

    def working_dir
      @config.working_dir
    end

    private
    def add_error(message)
      @errors << message
    end

    def add_missing_file_error(value, description)
      message = "#{description} configured as '#{value}', but couldn't find file at #{working_dir.join(value.to_s)}"
      add_error(message)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
furoshiki-0.6.1 lib/furoshiki/validator.rb
furoshiki-0.6.0 lib/furoshiki/validator.rb
furoshiki-0.5.0 lib/furoshiki/validator.rb
furoshiki-0.4.0 lib/furoshiki/validator.rb
furoshiki-0.3.1 lib/furoshiki/validator.rb
furoshiki-0.3.0 lib/furoshiki/validator.rb