Class: Lazylead::Jira
- Inherits:
-
Object
- Object
- Lazylead::Jira
- Defined in:
- lib/lazylead/system/jira.rb
Overview
Jira system for manipulation with issues.
Jira official documentation:
- https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/issue-getIssue
- https://developer.atlassian.com/server/jira/platform/rest-apis/
- Author
-
Yurii Dubinka ([email protected])
- Copyright
-
Copyright © 2019-2020 Yurii Dubinka
- License
-
MIT
Instance Method Summary collapse
-
#initialize(opts, salt = NoSalt.new, log = Log.new) ⇒ Jira
constructor
A new instance of Jira.
-
#issues(jql, opts = { max_results: 50, fields: nil, expand: nil }) ⇒ Object
Find the jira issues by ‘JQL’.
-
#raw {|client| ... } ⇒ Object
Execute request to the ticketing system using raw client.
Constructor Details
#initialize(opts, salt = NoSalt.new, log = Log.new) ⇒ Jira
TODO:
#57/DEV The debug method should be moved outside of ctor. This was moved here from ‘client’ method because Rubocop failed the build due to ‘Metrics/AbcSize’ violation.
Returns a new instance of Jira.
44 45 46 47 48 49 50 51 |
# File 'lib/lazylead/system/jira.rb', line 44 def initialize(opts, salt = NoSalt.new, log = Log.new) @opts = opts @salt = salt @log = log @log.debug "Initiate a Jira client using following opts: " \ "#{@opts.except 'password', :password} " \ " and salt #{@salt.id} (found=#{@salt.specified?})" end |
Instance Method Details
#issues(jql, opts = { max_results: 50, fields: nil, expand: nil }) ⇒ Object
Find the jira issues by ‘JQL’
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/lazylead/system/jira.rb', line 58 def issues(jql, opts = { max_results: 50, fields: nil, expand: nil }) raw do |jira| start = 0 tickets = [] total = jira.Issue.jql(jql, max_results: 0) @log.debug "Found #{total} ticket(s) in '#{jql}'" loop do tickets.concat(jira.Issue.jql(jql, opts.merge(start_at: start)) .map { |i| Lazylead::Issue.new(i, jira) }) @log.debug "Fetched #{tickets.size}" start += opts.fetch(:max_results, 50).to_i break if start > total end tickets end end |
#raw {|client| ... } ⇒ Object
Execute request to the ticketing system using raw client. For Jira the raw client is ‘jira-ruby’ gem.
77 78 79 80 |
# File 'lib/lazylead/system/jira.rb', line 77 def raw raise "ll-009: No block given to method" unless block_given? yield client end |