Sha256: 2a72defd2a7f26fdc4fc8b457239403af6782f2a2cfb64ae141daff0db05c2b4

Contents?: true

Size: 918 Bytes

Versions: 9

Compression:

Stored size: 918 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

9 entries across 9 versions & 1 rubygems

Version Path
cp8_cli-9.0.3 lib/cp8_cli/github/issue.rb
cp8_cli-9.0.2 lib/cp8_cli/github/issue.rb
cp8_cli-9.0.1 lib/cp8_cli/github/issue.rb
cp8_cli-9.0.0 lib/cp8_cli/github/issue.rb
cp8_cli-8.2.1 lib/cp8_cli/github/issue.rb
cp8_cli-8.2.0 lib/cp8_cli/github/issue.rb
cp8_cli-8.1.0 lib/cp8_cli/github/issue.rb
cp8_cli-8.0.1 lib/cp8_cli/github/issue.rb
cp8_cli-8.0.0 lib/cp8_cli/github/issue.rb