rosette-proj/rosette-core

View on GitHub
lib/rosette/core/validators/commits_validator.rb

Summary

Maintainability
A
0 mins
Test Coverage
# encoding: UTF-8

module Rosette
  module Core
    module Validators

      # Validates the existence of an array of commits.
      #
      # @example
      #   v = CommitsValidator.new
      #   v.valid?(['73cd130a42017d794ffa86ef0d255541d518a7b3'], 'my_repo', config)
      #   # => true
      #
      #   v.valid?(['non-existent-ref'], 'my_repo', config)
      #   # => false
      #
      #   v.messages  # => ["Unable to find commit 'non-existent-ref'."]
      class CommitsValidator < CommitValidator
        def valid?(commit_strs, repo_name, configuration)
          if commit_strs
            commit_strs.all? do |commit_str|
              super(commit_str, repo_name, configuration)
            end
          else
            false
          end
        end
      end

    end
  end
end