Class: Jira::Core

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

Class Method Summary collapse

Class Method Details

.auth_pathString

Returns path to .jira-auth file.

Returns:

  • (String)

    path to .jira-auth file



73
74
75
# File 'lib/jira/core.rb', line 73

def auth_path
  @auth_path ||= self.root_path + "/.jira-auth"
end

.passwordString

Returns JIRA password.

Returns:



32
33
34
# File 'lib/jira/core.rb', line 32

def password
  @password ||= self.auth.last
end

.root_pathString

Returns path of root git directory.

Returns:

  • (String)

    path of root git directory

Raises:



80
81
82
83
84
# File 'lib/jira/core.rb', line 80

def root_path
  return @root_path if !@root_path.nil?
  raise GitException.new if !system('git rev-parse 2> /dev/null')
  @root_path ||= `git rev-parse --show-toplevel`.strip
end

.setupObject

Memoizes url, username, and password



8
9
10
11
# File 'lib/jira/core.rb', line 8

def setup
  self.url
  self.auth
end

.ticketString

Returns default ticket is the current branch.

Returns:

  • (String)

    default ticket is the current branch



39
40
41
# File 'lib/jira/core.rb', line 39

def ticket
  `git rev-parse --abbrev-ref HEAD`.strip
end

.ticket?(ticket, verbose = true) ⇒ Boolean

Determines whether or not the input ticket matches the expected JIRA ticketing syntax. Outputs a warning that the input ticket isn’t a valid ticket.

Parameters:

  • ticket (String)

    input ticket name

  • verbose (Boolean) (defaults to: true)

    verbose output of the ticket warning

Returns:

  • (Boolean)

    whether input string matches JIRA ticket syntax



53
54
55
56
57
58
59
# File 'lib/jira/core.rb', line 53

def ticket?(ticket, verbose=true)
  !!ticket.to_s[/^[a-zA-Z]+-[0-9]+$/] and return true
  if verbose
    puts "#{Jira::Format.ticket(ticket)} is not a valid JIRA ticket."
  end
  return false
end

.urlString

Returns JIRA project endpoint.

Returns:

  • (String)

    JIRA project endpoint



18
19
20
# File 'lib/jira/core.rb', line 18

def url
  @url ||= self.read(self.url_path)
end

.url_pathString

Returns path to .jira-url file.

Returns:

  • (String)

    path to .jira-url file



66
67
68
# File 'lib/jira/core.rb', line 66

def url_path
  @url_path ||= self.root_path + "/.jira-url"
end

.usernameString

Returns JIRA username.

Returns:



25
26
27
# File 'lib/jira/core.rb', line 25

def username
  @username ||= self.auth.first
end