Class: TempestTime::Commands::Submit

Inherits:
TempestTime::Command show all
Includes:
Helpers::TimeHelper
Defined in:
lib/tempest_time/commands/submit.rb

Instance Method Summary collapse

Methods included from Helpers::TimeHelper

#beginning_of_week, #end_of_week, #formatted_date, #formatted_date_range, #formatted_time, #formatted_time_for_input, #formatted_time_long, #parsed_time, #past_date_selections, #past_week_selections, #week_beginnings, #week_dates

Methods inherited from TempestTime::Command

#command, #date_prompt, #pastel, #prompt, #spinner, #table, #week_prompt, #with_spinner, #with_success_fail_spinner

Methods included from Helpers::GitHelper

#automatic_issue

Methods included from Helpers::FormattingHelper

#braced, #with_percent_sign

Constructor Details

#initialize(options) ⇒ Submit

Returns a new instance of Submit.



12
13
14
# File 'lib/tempest_time/commands/submit.rb', line 12

def initialize(options)
  @options = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tempest_time/commands/submit.rb', line 16

def execute(input: $stdin, output: $stdout)
  reviewer = prompt.ask('Who should review this timesheet? (username)')
  dates = week_dates(week_prompt('Select a week to submit.'))

  message = 'Submit the selected timesheet to ' + pastel.green(reviewer) + '?'
  abort unless prompt.yes?(message)
  abort unless prompt.yes?('Are you sure? No edits can be made once submitted!')

  with_success_fail_spinner("Submitting your timesheet...") do
    TempoAPI::Requests::SubmitTimesheet.new(reviewer, dates).send_request
  end
end