class Redmine::Commands::LeadTimes
Command
to calculate lead times for one or more tickets in Redmine
.
Public Class Methods
new(redmine:)
click to toggle source
# File lib/redmine/commands/lead_times.rb, line 11 def initialize(redmine:) @redmine = redmine end
Public Instance Methods
call(arguments)
click to toggle source
# File lib/redmine/commands/lead_times.rb, line 22 def call(arguments) case options[:format] when 'json' then generate_json(arguments) when 'csv' then generate_csv(arguments) when 'text' then generate_text(arguments) else raise ArgumentError, "Unknown format #{options[:format].inspect}" end end
Private Instance Methods
each_issue_lead_time(ids) { |id, issue.lead_time| ... }
click to toggle source
# File lib/redmine/commands/lead_times.rb, line 55 def each_issue_lead_time(ids) ids.each do |id| yield id, @redmine.issue(id).lead_time end end
generate_csv(arguments)
click to toggle source
# File lib/redmine/commands/lead_times.rb, line 40 def generate_csv(arguments) csv_output = CSV.generate do |csv| each_issue_lead_time(arguments) do |issue_id, lead_time| csv << [issue_id, lead_time] end end puts csv_output end
generate_json(arguments)
click to toggle source
# File lib/redmine/commands/lead_times.rb, line 33 def generate_json(arguments) lead_times = to_enum(:each_issue_lead_time, arguments).inject({}) do |output, (issue_id, lead_time)| output.merge issue_id => lead_time end puts JSON.dump(lead_times) end
generate_text()
click to toggle source
# File lib/redmine/commands/lead_times.rb, line 49 def generate_text each_issue_lead_time(arguments) do |issue_id, lead_time| puts "#{issue_id}\t#{lead_time}" end end