Sha256: 3aa173ec78eaf287f39fb4b155f20dbf405ca3e677c2c991f8024def659506c6

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 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:/
      FIXED_REGEX = /:wave:/

      PASS_EMOJI = "(elephant)(elephant)(elephant)"
      REVIEW_EMOJI = "(book)"
      FAIL_EMOJI = "(poop)"
      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

11 entries across 11 versions & 1 rubygems

Version Path
lita-github_pr_list-0.0.12 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.11 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.10 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.9 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.8 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.7 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.6 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.5 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.4 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.2 lib/lita/github_pr_list/status.rb
lita-github_pr_list-0.0.1 lib/lita/github_pr_list/status.rb