Class: Git::Whistles::Youtrack::Ticket

Inherits:
Object
  • Object
show all
Defined in:
lib/git-whistles/youtrack/ticket.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



57
58
59
# File 'lib/git-whistles/youtrack/ticket.rb', line 57

def description
  @description
end

#idObject

Returns the value of attribute id.



55
56
57
# File 'lib/git-whistles/youtrack/ticket.rb', line 55

def id
  @id
end

#projectObject

Returns the value of attribute project.



56
57
58
# File 'lib/git-whistles/youtrack/ticket.rb', line 56

def project
  @project
end

#titleObject

Returns the value of attribute title.



54
55
56
# File 'lib/git-whistles/youtrack/ticket.rb', line 54

def title
  @title
end

Class Method Details

.build_from_remote(ticket_hash) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/git-whistles/youtrack/ticket.rb', line 5

def build_from_remote(ticket_hash)
  return nil if ticket_hash.nil?
  return nil if issue_not_found? ticket_hash

  self.new.tap do |ticket|
    ticket.title = title_from ticket_hash
    ticket.id = id_from ticket_hash
    ticket.project = project_from ticket_hash
    ticket.description = description_from ticket_hash
  end
end

.description_from(ticket_hash) ⇒ Object



38
39
40
41
42
43
# File 'lib/git-whistles/youtrack/ticket.rb', line 38

def description_from(ticket_hash)
  ticket_hash
    .dig('issue', 'field')
    .select { |f| f['name'] == 'description' }
    .first.dig('value')
end

.id_from(ticket_hash) ⇒ Object



24
25
26
27
28
29
# File 'lib/git-whistles/youtrack/ticket.rb', line 24

def id_from(ticket_hash)
  ticket_hash
    .dig('issue', 'field')
    .select { |f| f['name'] == 'numberInProject' }
    .first.dig('value').to_i
end

.issue_not_found?(ticket_hash) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
# File 'lib/git-whistles/youtrack/ticket.rb', line 45

def issue_not_found?(ticket_hash)
  if ticket_hash["error"]
    true
  else
    false
  end
end

.project_from(ticket_hash) ⇒ Object



31
32
33
34
35
36
# File 'lib/git-whistles/youtrack/ticket.rb', line 31

def project_from(ticket_hash)
  ticket_hash
    .dig('issue', 'field')
    .select { |f| f['name'] == 'projectShortName' }
    .first.dig('value')
end

.title_from(ticket_hash) ⇒ Object



17
18
19
20
21
22
# File 'lib/git-whistles/youtrack/ticket.rb', line 17

def title_from(ticket_hash)
  ticket_hash
    .dig('issue', 'field')
    .select { |f| f['name'] == 'summary' }
    .first.dig('value')
end