Sha256: 428208d02f707c3be295e8b12c12fd4603960300fa3c675f10c56033c48499f8

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

module I18nFlow::Validator
  class Error
    attr_reader :key
    attr_reader :file
    attr_reader :line

    def initialize(key)
      @key = key
    end

    def ==(other)
      return false unless other.is_a?(self.class)
      data == other.data
    end

    def data
      [key]
    end

    def single?
      !!@single
    end

    def set_location(node)
      @file = node.file_path
      @line = node.start_line
      self
    end
  end

  class InvalidTypeError < Error
    def initialize(key, single: false)
      super(key)
      @single = single
    end
  end

  class MissingKeyError < Error
    def initialize(key, single: false)
      super(key)
      @single = single
    end
  end

  class ExtraKeyError < Error
    def initialize(key, single: false)
      super(key)
      @single = single
    end
  end

  class InvalidTodoError < Error
  end

  class TodoContentError < Error
    attr_reader :expect
    attr_reader :actual

    def initialize(key, expect:, actual:)
      super(key)
      @expect = expect
      @actual = actual
    end

    def data
      super + [expect, actual]
    end
  end

  class InvalidLocaleError < Error
    attr_reader :expect
    attr_reader :actual

    def initialize(key, expect:, actual:)
      super(key)
      @expect = expect
      @actual = actual
    end

    def data
      super + [expect, actual]
    end
  end

  class AsymmetricArgsError < Error
    attr_reader :expect
    attr_reader :actual

    def initialize(key, expect:, actual:)
      super(key)
      @expect = expect
      @actual = actual
    end

    def data
      super + [expect, actual]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i18n_flow-0.1.0 lib/i18n_flow/validator/errors.rb