Class: HubLink::Api::Issue

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/hub_link/api/issue.rb

Direct Known Subclasses

PullRequest

Constant Summary collapse

EXPORT_COLUMNS =
%i(
  id
  title
  number
  created_at
  updated_at
  closed_at
  submitter
  labels
  repo
  html_url
  state
)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.list(repo:, page:, **options) ⇒ Object



21
22
23
24
25
26
# File 'lib/hub_link/api/issue.rb', line 21

def self.list(repo:, page:, **options)
  Octokit.list_issues(repo, options.merge(page: page, sort: "updated", direction: "asc", state: "all")).map do |item|
    item.repo = repo
    new_from_api(item)
  end
end

.new_from_api(item) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/hub_link/api/issue.rb', line 28

def self.new_from_api(item)
  if item.respond_to?(:pull_request)
    PullRequest.new(item)
  else
    Issue.new(item)
  end
end

Instance Method Details

#labelsObject



44
45
46
# File 'lib/hub_link/api/issue.rb', line 44

def labels
  super.map(&:name).join(", ")
end

#pull_request?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/hub_link/api/issue.rb', line 36

def pull_request?
  false
end

#submitterObject



40
41
42
# File 'lib/hub_link/api/issue.rb', line 40

def submitter
  user.
end

#to_hObject



48
49
50
# File 'lib/hub_link/api/issue.rb', line 48

def to_h
  Slicer.new(self, columns: export_columns).to_h
end