Sha256: ff16c137fd920859cd8a97f8eef89ebe6e7160f930a3a86d0647afd73fa21f8e

Contents?: true

Size: 921 Bytes

Versions: 2

Compression:

Stored size: 921 Bytes

Contents

require "cp8_cli/github/api"
require "cp8_cli/github/parsed_url"
require "cp8_cli/story"

module Cp8Cli
  module Github
    class Issue < Story
      include Api::Client

      def initialize(number:, repo:, **attributes)
        @number = number
        @repo = repo
        @attributes = attributes
      end

      def self.find_by_url(url)
        url = ParsedUrl.new(url)
        issue = client.issue(url.repo, url.number).to_h
        new(**issue.merge(number: url.number, repo: url.repo))
      end

      def title
        attributes[:title]
      end

      def summary
        "Closes #{short_link}"
      end

      private

        attr_reader :number, :repo, :attributes

        def assign
          client.add_assignees repo, number, [user.github_login]
        end

        def user
          CurrentUser.new
        end

        def short_link
          "#{repo}##{number}"
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cp8_cli-9.1.1 lib/cp8_cli/github/issue.rb
cp8_cli-9.1.0 lib/cp8_cli/github/issue.rb