Sha256: 997e402ae42a34d0c55a814482a91879e21aa3e86c028fcf367476165840c5af

Contents?: true

Size: 1.89 KB

Versions: 3

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

module SmartTodo
  # This module contains all the methods accessible for SmartTodo comments.
  # It is meant to be reopened by the host application in order to define
  # its own events.
  #
  # An event needs to return a +String+ containing the message that will be
  # sent to the TODO assignee or +false+ in case the event hasn't been met.
  #
  # @example Adding a custom event
  #   module SmartTodo
  #     module Events
  #       def trello_card_close(card)
  #         ...
  #       end
  #     end
  #   end
  #
  #   TODO(on: trello_card_close(381), to: 'john@example.com')
  module Events
    extend self

    # Check if the +date+ is in the past
    #
    # @param date [String] a correctly formatted date
    # @return [false, String]
    def date(date)
      Date.met?(date)
    end

    # Check if a new version of +gem_name+ was released with the +requirements+ expected
    #
    # @param gem_name [String]
    # @param requirements [Array<String>] a list of version specifiers
    # @return [false, String]
    def gem_release(gem_name, *requirements)
      GemRelease.new(gem_name, requirements).met?
    end

    # Check if the issue +issue_number+ is closed
    #
    # @param organization [String] the GitHub organization name
    # @param repo [String] the GitHub repo name
    # @param issue_number [String, Integer]
    # @return [false, String]
    def issue_close(organization, repo, issue_number)
      IssueClose.new(organization, repo, issue_number, type: 'issues').met?
    end

    # Check if the pull request +pr_number+ is closed
    #
    # @param organization [String] the GitHub organization name
    # @param repo [String] the GitHub repo name
    # @param pr_number [String, Integer]
    # @return [false, String]
    def pull_request_close(organization, repo, pr_number)
      IssueClose.new(organization, repo, pr_number, type: 'pulls').met?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smart_todo-1.1.0 lib/smart_todo/events.rb
smart_todo-1.0.2 lib/smart_todo/events.rb
smart_todo-1.0.1 lib/smart_todo/events.rb