Sha256: c4f4376e79117ee5779be02f191504c04354cfeb3c4e4085429f1dc234400bde

Contents?: true

Size: 1.34 KB

Versions: 15

Compression:

Stored size: 1.34 KB

Contents

=begin
Copyright <%= copyright %>

See the file LICENSE for copying permission.
=end

require 'pre-commit/error_list'
require 'pre-commit/checks/plugin'

# :nodoc:
module PreCommit
  # :nodoc:
  module Checks

    #
    # <%= description %>
    #
    class <%= name.capitalize %> < Plugin

      #
      # description of the plugin
      #
      def self.description
        "<%= description %>"
      end

      #
      # Finds files and verify them
      #
      # @param staged_files [Array<String>] list of files to check
      #
      # @return [nil|Array<PreCommit::ErrorList>] nil when no errors,
      #                                           list of errors otherwise
      def call(staged_files)
        errors = staged_files.map { |file| run_check(file) }.compact
        return if errors.empty?

        errors
      end

    private

      #
      # <%= description %>
      #
      # @param file [String] path to file to verify
      #
      # @return [nil|PreCommit::ErrorList] nil when file verified,
      #                                    ErrorList when verification failed
      #
      def run_check(file)
        if
          true # add a check here to verify files
        then
          nil
        else
          PreCommit::ErrorList.new(PreCommit::Line.new("Describe why verification failed", file))
        end
      end

    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pre-commit-0.40.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.39.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.38.1 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.38.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.37.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.36.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.35.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.34.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.33.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.32.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.31.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.30.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.29.0 templates/gem/lib/plugins/pre_commit/checks/PLUGIN_NAME.rb
pre-commit-0.28.0 templates/gem/lib/plugins/pre_commit/checks/<%= name %>.rb
pre-commit-0.27.0 templates/gem/lib/plugins/pre_commit/checks/<%= name %>.rb