Class: GHX::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/ghx/issue.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner:, repo:, **args) ⇒ Issue

Returns a new instance of Issue.



21
22
23
24
25
# File 'lib/ghx/issue.rb', line 21

def initialize(owner:, repo:, **args)
  @owner = owner
  @repo = repo
  update_attributes(args)
end

Instance Attribute Details

#assigneesObject

Returns the value of attribute assignees.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def assignees
  @assignees
end

#authorObject

Returns the value of attribute author.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def author
  @author
end

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def body
  @body
end

#closed_atObject

Returns the value of attribute closed_at.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def closed_at
  @closed_at
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def created_at
  @created_at
end

#labelsObject

Returns the value of attribute labels.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def labels
  @labels
end

#milestoneObject

Returns the value of attribute milestone.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def milestone
  @milestone
end

#numberObject

Returns the value of attribute number.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def number
  @number
end

#ownerObject

Returns the value of attribute owner.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def owner
  @owner
end

#repoObject

Returns the value of attribute repo.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def repo
  @repo
end

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def state
  @state
end

#state_reasonObject

Returns the value of attribute state_reason.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def state_reason
  @state_reason
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def title
  @title
end

#updated_atObject

Returns the value of attribute updated_at.



3
4
5
# File 'lib/ghx/issue.rb', line 3

def updated_at
  @updated_at
end

Class Method Details

.find(owner:, repo:, number:) ⇒ Object



16
17
18
19
# File 'lib/ghx/issue.rb', line 16

def self.find(owner:, repo:, number:)
  response_data = GHX.rest_client.get("repos/#{owner}/#{repo}/issues/#{number}")
  new(owner: owner, repo: repo, **response_data)
end

.search(owner:, repo:, query:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/ghx/issue.rb', line 5

def self.search(owner:, repo:, query:)
  data = GHX.rest_client.get("search/issues?q=#{URI.encode_www_form_component(query)}+is:issue+repo:#{owner}/#{repo}")
  data.fetch("items").to_a.map do |issue_data|
    new(owner: owner, repo: repo, **issue_data)
  end
rescue => e
  GHX.logger.error "Error searching for issues with query: #{e.message}"
  GHX.logger.error "Received data: #{data}"
  []
end

Instance Method Details

#saveObject



27
28
29
# File 'lib/ghx/issue.rb', line 27

def save
  @number.nil? ? create : update
end