Class: TempestTime::Commands::Submit

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

Instance Method Summary collapse

Methods inherited from TempestTime::Command

#command, #date_prompt, #execute, #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

Methods included from Helpers::TimeHelper

#beginning_of_week, #dates_in_range, #end_of_week, #formatted_date, #formatted_date_range, #formatted_time, #formatted_time_for_input, #formatted_time_long, #future_dates, #parsed_time, #past_dates, #past_week_selections, #week_beginnings, #week_dates

Constructor Details

#initialize(options) ⇒ Submit

Returns a new instance of Submit.



9
10
11
# File 'lib/tempest_time/commands/submit.rb', line 9

def initialize(options)
  @options = options
end

Instance Method Details

#execute!Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tempest_time/commands/submit.rb', line 13

def execute!
  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