Class: Dude::Gitlab::AddSpendTime
- Inherits:
-
Base
- Object
- Base
- Dude::Gitlab::AddSpendTime
show all
- Defined in:
- lib/dude/gitlab/add_spend_time.rb
Constant Summary
Constants included
from Settings
Settings::CONFIG_FILE
Instance Attribute Summary
Attributes included from Service
#options
Instance Method Summary
collapse
Methods inherited from Base
#check_input_data, #configure_gitlab, #initialize, #issue_exists?, #project_id, #throw_error
Methods included from Settings
#file, #read, #settings
Methods included from Service
included, #initialize
Instance Method Details
#add_spend_time ⇒ Object
13
14
15
16
17
|
# File 'lib/dude/gitlab/add_spend_time.rb', line 13
def add_spend_time
::Gitlab.add_time_spent_on_issue(
project_id, options[:issue_id], "#{options[:duration]}s"
)
end
|
#call ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'lib/dude/gitlab/add_spend_time.rb', line 4
def call
if duration_exists?
add_spend_time
print_success_message
else
print_error_message
end
end
|
#duration_exists? ⇒ Boolean
19
20
21
|
# File 'lib/dude/gitlab/add_spend_time.rb', line 19
def duration_exists?
options[:duration] > 0
end
|
31
32
33
|
# File 'lib/dude/gitlab/add_spend_time.rb', line 31
def formatted_time
Time.at(options[:duration]).utc.strftime('%H:%M:%S').to_s.colorize(:green)
end
|
#print_error_message ⇒ Object
27
28
29
|
# File 'lib/dude/gitlab/add_spend_time.rb', line 27
def print_error_message
puts "Nothing to add".colorize(:yellow)
end
|
#print_success_message ⇒ Object
23
24
25
|
# File 'lib/dude/gitlab/add_spend_time.rb', line 23
def print_success_message
puts "Added #{formatted_time} to spent time"
end
|