Class: JiraDependencyVisualizer::Jira

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

Overview

Creates a Jira client and exposes functions to get Jira issues

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Jira

Returns a new instance of Jira.

Parameters:

  • opts (Hash) (defaults to: {})

    the options to create a Jira client

Options Hash (opts):

  • :context_path (String)

    The Jira application’s context path

  • :password (String)

    The Jira user’s password

  • :proxy_address (String)

    The proxy address

  • :proxy_port (Integer)

    The proxy port

  • :read_timeout (Integer)

    Number of seconds to wait for data to be read

  • :rest_base_path (String)

    The Jira rest API base path

  • :site (String)

    URL for Jira

  • :use_ssl (Boolean)

    Whether to use SSL

  • :username (String)

    The Jira user’s username



19
20
21
22
# File 'lib/jira_dependency_visualizer/jira.rb', line 19

def initialize(opts = {})
  @options = opts
  client
end

Instance Method Details

#base_urlString

Returns the base Jira URL without a trailing slash.

Returns:

  • (String)

    the base Jira URL without a trailing slash



39
40
41
42
43
44
45
46
47
# File 'lib/jira_dependency_visualizer/jira.rb', line 39

def base_url
  site         = @options[:site].dup
  context_path = @options[:context_path].dup

  site.chop! if site.ends_with?('/')
  context_path.chop! if context_path.ends_with?('/')

  URI.join(site, context_path).to_s
end

#get_issue(issue, client = @client) ⇒ JIRA::Issue

Returns the matched Jira issue object.

Parameters:

  • issue (String)

    the Jira issue ID

  • client (JIRA::Client) (defaults to: @client)

    a Jira client instance

Returns:

  • (JIRA::Issue)

    the matched Jira issue object



27
28
29
# File 'lib/jira_dependency_visualizer/jira.rb', line 27

def get_issue(issue, client = @client)
  client.Issue.find(issue)
end

#query(query, client = @client) ⇒ Array[JIRA::Issue]

Returns list of matching Jira issue objects.

Parameters:

  • query (String)

    a Jira JQL query string

  • client (JIRA::Client) (defaults to: @client)

    a Jira client instance

Returns:

  • (Array[JIRA::Issue])

    list of matching Jira issue objects



34
35
36
# File 'lib/jira_dependency_visualizer/jira.rb', line 34

def query(query, client = @client)
  client.Issue.jql(query)
end