Class: Lazylead::Jira
- Inherits:
-
Object
- Object
- Lazylead::Jira
- Defined in:
- lib/lazylead/system/jira.rb
Overview
Jira system for manipulation with issues.
- 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.
40 41 42 43 44 45 46 47 |
# File 'lib/lazylead/system/jira.rb', line 40 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’
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/lazylead/system/jira.rb', line 54 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.
73 74 75 76 |
# File 'lib/lazylead/system/jira.rb', line 73 def raw raise "ll-009: No block given to method" unless block_given? yield client end |