Class: Dev::Jira
- Defined in:
- lib/firespring_dev_commands/jira.rb,
lib/firespring_dev_commands/jira/user.rb,
lib/firespring_dev_commands/jira/issue.rb,
lib/firespring_dev_commands/jira/parent.rb,
lib/firespring_dev_commands/jira/history.rb,
lib/firespring_dev_commands/jira/project.rb,
lib/firespring_dev_commands/jira/histories.rb,
lib/firespring_dev_commands/jira/user/type.rb
Overview
Class which contains methods to conenct to jira and query issues
Defined Under Namespace
Classes: Config, Histories, History, Issue, Parent, Project, User
Constant Summary collapse
- CONFIG_FILE =
The config file to try to load credentials from
"#{Dir.home}/.env.jira".freeze
- JIRA_USERNAME =
The text of the username variable key
'JIRA_USERNAME'.freeze
- JIRA_TOKEN =
The text of the token variable key
'JIRA_TOKEN'.freeze
- JIRA_URL =
The text of the url variable key
'JIRA_URL'.freeze
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#client ⇒ Object
Returns the value of attribute client.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.config {|@config| ... } ⇒ Object
(also: configure)
Instantiates a new top level config object if one hasn’t already been created Yields that config object to any given block Returns the resulting config object.
Instance Method Summary collapse
-
#initialize(username: self.class.config.username, token: self.class.config.token, url: self.class.config.url) ⇒ Jira
constructor
Initialize a new jira client using the given inputs.
-
#issues(jql) ⇒ Object
Query jira using the given jql and yield each matching result.
Constructor Details
#initialize(username: self.class.config.username, token: self.class.config.token, url: self.class.config.url) ⇒ Jira
Initialize a new jira client using the given inputs
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/firespring_dev_commands/jira.rb', line 56 def initialize(username: self.class.config.username, token: self.class.config.token, url: self.class.config.url) raise 'username is required' if username.to_s.strip.empty? raise 'token is required' if token.to_s.strip.empty? raise 'url is required' if url.to_s.strip.empty? @username = username @token = token @url = url @auth = Base64.strict_encode64("#{@username}:#{@token}") = { auth_type: :basic, site: @url, default_headers: {Authorization: "Basic #{@auth}"}, context_path: '', read_timeout: self.class.config.read_timeout, use_ssl: true, ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER, http_debug: self.class.config.http_debug } @client = JIRA::Client.new() end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
53 54 55 |
# File 'lib/firespring_dev_commands/jira.rb', line 53 def auth @auth end |
#client ⇒ Object
Returns the value of attribute client.
53 54 55 |
# File 'lib/firespring_dev_commands/jira.rb', line 53 def client @client end |
#token ⇒ Object
Returns the value of attribute token.
53 54 55 |
# File 'lib/firespring_dev_commands/jira.rb', line 53 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
53 54 55 |
# File 'lib/firespring_dev_commands/jira.rb', line 53 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
53 54 55 |
# File 'lib/firespring_dev_commands/jira.rb', line 53 def username @username end |
Class Method Details
.config {|@config| ... } ⇒ Object Also known as: configure
Instantiates a new top level config object if one hasn’t already been created Yields that config object to any given block Returns the resulting config object
43 44 45 46 47 |
# File 'lib/firespring_dev_commands/jira.rb', line 43 def config @config ||= Config.new yield(@config) if block_given? @config end |
Instance Method Details
#issues(jql) ⇒ Object
Query jira using the given jql and yield each matching result
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/firespring_dev_commands/jira.rb', line 81 def issues(jql, &) start_at = 0 max_results = 100 = self.class.config. # Query Jira and yield all issues it returns issues = @client.Issue.jql(jql, start_at:, max_results:, expand:) issues.map { |data| Issue.new(data) }.each(&) # If we returned the max_results then there may be more - add the max results to where we start at and query again while issues.length >= max_results start_at += max_results issues = @client.Issue.jql(jql, start_at:, max_results:, expand:) issues.map { |data| Issue.new(data) }.each(&) end end |