Class: Jira::Core
- Inherits:
-
Object
- Object
- Jira::Core
- Defined in:
- lib/jira/core.rb
Class Method Summary collapse
-
.cli_path ⇒ String
Path to .jira-cli file.
-
.password ⇒ String
JIRA password.
-
.root_path ⇒ String
Path of root git directory.
-
.setup ⇒ Object
Memoizes url, username, and password.
-
.ticket ⇒ String
Default ticket is the current branch.
-
.ticket?(ticket, verbose = true) ⇒ Boolean
Determines whether or not the input ticket matches the expected JIRA ticketing syntax.
-
.url ⇒ String
JIRA project endpoint.
-
.username ⇒ String
JIRA username.
Class Method Details
.cli_path ⇒ String
Returns path to .jira-cli file.
65 66 67 |
# File 'lib/jira/core.rb', line 65 def cli_path @cli_path ||= self.root_path + "/.jira-cli" end |
.password ⇒ String
Returns JIRA password.
31 32 33 |
# File 'lib/jira/core.rb', line 31 def password @password ||= ENV['JIRA_PASSWORD'] || self.read(self.cli_path)[:global]['password'] end |
.root_path ⇒ String
Returns path of root git directory.
72 73 74 75 76 |
# File 'lib/jira/core.rb', line 72 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 |
.setup ⇒ Object
Memoizes url, username, and password
8 9 10 |
# File 'lib/jira/core.rb', line 8 def setup self.url end |
.ticket ⇒ String
Returns default ticket is the current branch.
38 39 40 |
# File 'lib/jira/core.rb', line 38 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.
52 53 54 55 56 57 58 |
# File 'lib/jira/core.rb', line 52 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 |
.url ⇒ String
Returns JIRA project endpoint.
17 18 19 |
# File 'lib/jira/core.rb', line 17 def url @url ||= ENV['JIRA_URL'] || self.read(self.cli_path)[:global]['url'] end |
.username ⇒ String
Returns JIRA username.
24 25 26 |
# File 'lib/jira/core.rb', line 24 def username @username ||= ENV['JIRA_USERNAME'] || self.read(self.cli_path)[:global]['username'] end |