Sha256: 900b97917983c3af45c8eae8bc5c7598a19826e2272940050e732e4447cf398a

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module Lita
  module GithubPrList
    class Status
      attr_accessor :comment, :status,
                    :pass_regex, :review_regex, :fail_regex, :fixed_regex

      PASS_REGEX = /:elephant: :elephant: :elephant:/
      REVIEW_REGEX = /:book:/
      FAIL_REGEX = /:poop:|:hankey:/
      FIXED_REGEX = /:wave:/

      PASS_EMOJI = "(elephant)(elephant)(elephant)"
      REVIEW_EMOJI = "(book)"
      FAIL_EMOJI = "(hankey)"
      FIXED_EMOJI = "(wave)"

      def initialize(params = {})
        self.comment = params.fetch(:comment, nil)
        self.status = params.fetch(:status, {})

        raise "invalid params in #{self.class.name}" if comment.nil?
      end

      def comment_status
        case self.comment
          when PASS_REGEX
            status[:emoji] = PASS_EMOJI
            status[:status] = "Passed"
          when REVIEW_REGEX
            status[:emoji] = REVIEW_EMOJI
            status[:status] = "In Review"
          when FAIL_REGEX
            status[:emoji] = FAIL_EMOJI
            status[:status] = "Failed"
          when FIXED_REGEX
            status[:emoji] = FIXED_EMOJI
            status[:status] = "Fixed"
        end

        status
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-github_pr_list-0.0.13 lib/lita/github_pr_list/status.rb