Class: AbideDevUtils::Jira::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/abide_dev_utils/jira/finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Finder

Returns a new instance of Finder.



8
9
10
# File 'lib/abide_dev_utils/jira/finder.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#issue(id) ⇒ Object

Parameters:

  • id (String)

    The issue key or summary



24
25
26
27
28
29
30
31
32
33
# File 'lib/abide_dev_utils/jira/finder.rb', line 24

def issue(id)
  return id if id.is_a?(client.Issue.target_class)

  client.Issue.find(id)
rescue URI::InvalidURIError
  iss = client.Issue.all.find { |i| i.summary == id }
  raise AbideDevUtils::Errors::Jira::FindIssueError, id if iss.nil?

  iss
end

#issues_by_jql(jql) ⇒ Array<JIRA::Resource::Issue>

Parameters:

  • jql (String)

    The JQL query

Returns:

  • (Array<JIRA::Resource::Issue>)


37
38
39
# File 'lib/abide_dev_utils/jira/finder.rb', line 37

def issues_by_jql(jql)
  client.Issue.jql(jql, max_results: 1000)
end

#issuetype(id) ⇒ Object

Parameters:

  • id (String)

    The issuetype ID or name



42
43
44
45
46
47
48
49
50
# File 'lib/abide_dev_utils/jira/finder.rb', line 42

def issuetype(id)
  return id if id.is_a?(client.Issuetype.target_class)

  if id.match?(%r{^\d+$})
    client.Issuetype.find(id)
  else
    client.Issuetype.all.find { |i| i.name == id }
  end
end

#myselfObject



12
13
14
# File 'lib/abide_dev_utils/jira/finder.rb', line 12

def myself
  client.User.myself
end

#priority(id) ⇒ Object

Parameters:

  • id (String)

    The priority ID or name



53
54
55
56
57
58
59
60
61
# File 'lib/abide_dev_utils/jira/finder.rb', line 53

def priority(id)
  return id if id.is_a?(client.Priority.target_class)

  if id.match?(%r{^\d+$})
    client.Priority.find(id)
  else
    client.Priority.all.find { |i| i.name == id }
  end
end

#project(id) ⇒ Object

Parameters:

  • id (String)

    The project key or ID



17
18
19
20
21
# File 'lib/abide_dev_utils/jira/finder.rb', line 17

def project(id)
  return id if id.is_a?(client.Project.target_class)

  client.Project.find(id)
end