Top Level Namespace
Defined Under Namespace
Modules: Jira
Classes: APIClient
Instance Method Summary
collapse
Instance Method Details
116
117
118
119
120
121
|
# File 'lib/jira/worklog/cli.rb', line 116
def formatted_duration(total_seconds)
hours = total_seconds / (60 * 60)
minutes = (total_seconds / 60) % 60
seconds = total_seconds % 60
'%2d:%02d:%02d' % [hours, minutes, seconds]
end
|
#get_credentials(options) ⇒ Object
123
124
125
126
127
128
129
|
# File 'lib/jira/worklog/cli.rb', line 123
def get_credentials(options)
user = options.user || ask('JIRA user: ')
password = options.password || ask('JIRA password: ') { |q| q.echo = '*' }
url_base = options.url_base
raise('--url_base is mandatory option') if url_base.nil? || url_base.empty?
[url_base, user, password]
end
|
#load_from_xlsx(filename) ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/jira/worklog/cli.rb', line 98
def load_from_xlsx(filename)
doc = SimpleXlsxReader.open(filename)
doc.sheets
sheet = doc.sheets.first
puts "Loading from sheet: #{sheet.name}"
worklogs = []
sheet.rows.each.with_index do |row, idx|
issue, date, duration, = row[0], row[1], row[2], row[3]
duration = Float(duration) rescue 0
if issue && !issue.nil? && !issue.empty? && date.is_a?(Date) && duration > 0 && && !.nil? && !.empty?
worklogs << ({issue: issue, date: date, duration: duration * 3600, comment: })
else
puts "Skipping row ##{idx + 1}: #{row.inspect}"
end
end
worklogs
end
|