Class: Cp8Cli::Github::Issue

Inherits:
Base
  • Object
show all
Defined in:
lib/cp8_cli/github/issue.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

configure

Constructor Details

#initialize(number:, repo:, attributes:) ⇒ Issue

Returns a new instance of Issue.



8
9
10
11
12
# File 'lib/cp8_cli/github/issue.rb', line 8

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

Class Method Details

.fieldsObject



14
15
16
# File 'lib/cp8_cli/github/issue.rb', line 14

def self.fields
  [:title]
end


24
25
26
27
28
# File 'lib/cp8_cli/github/issue.rb', line 24

def self.find_by_short_link(short_link)
  short_link = ParsedShortLink.new(short_link)
  issue = client.issue(short_link.repo, short_link.number)
  new number: short_link.number, repo: short_link.repo, attributes: issue
end

.find_by_url(url) ⇒ Object



18
19
20
21
22
# File 'lib/cp8_cli/github/issue.rb', line 18

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

Instance Method Details

#acceptObject



54
55
56
# File 'lib/cp8_cli/github/issue.rb', line 54

def accept
  # noop for now
end

#add_label(label) ⇒ Object



63
64
65
# File 'lib/cp8_cli/github/issue.rb', line 63

def add_label(label)
  self.class.request(:post, "cards/#{id}/idLabels", value: label.id)
end

#assign(user) ⇒ Object



58
59
60
61
# File 'lib/cp8_cli/github/issue.rb', line 58

def assign(user)
  # add_assignes not released as gem yet https://github.com/octokit/octokit.rb/pull/894
  client.post "#{Octokit::Repository.path repo}/issues/#{number}/assignees", assignees: [user.]
end

#attach(url:) ⇒ Object



67
68
69
# File 'lib/cp8_cli/github/issue.rb', line 67

def attach(url:)
  self.class.request(:post, "cards/#{id}/attachments", url: url)
end

#finishObject



50
51
52
# File 'lib/cp8_cli/github/issue.rb', line 50

def finish
  # noop for now
end

#pr_titleObject



34
35
36
# File 'lib/cp8_cli/github/issue.rb', line 34

def pr_title
  title
end


71
72
73
# File 'lib/cp8_cli/github/issue.rb', line 71

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

#short_urlObject



75
76
77
# File 'lib/cp8_cli/github/issue.rb', line 75

def short_url
  attributes[:shortUrl]
end

#startObject



46
47
48
# File 'lib/cp8_cli/github/issue.rb', line 46

def start
  # noop for now
end

#summaryObject



42
43
44
# File 'lib/cp8_cli/github/issue.rb', line 42

def summary
  "Closes #{short_link}"
end

#titleObject



30
31
32
# File 'lib/cp8_cli/github/issue.rb', line 30

def title
  attributes[:title]
end

#urlObject



38
39
40
# File 'lib/cp8_cli/github/issue.rb', line 38

def url
  attributes[:html_url]
end