Class: AocCli::PuzzleController

Inherits:
ApplicationController show all
Defined in:
lib/aoc_cli/controllers/puzzle_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#execute

Methods included from Helpers::ViewHelper

#heading, #main_header, #success_tag, #table_for, #wrap_text

Methods included from Concerns::LocationConcern

#current_event, #current_location, #current_path, #current_puzzle, #ensure_in_aoc_dir!, #ensure_in_event_dir!, #ensure_in_puzzle_dir!, #ensure_not_in_aoc_dir!

Methods included from Concerns::ErrorConcern

#render_error!, #render_model_errors!

Instance Method Details

#attemptsObject



33
34
35
36
37
# File 'lib/aoc_cli/controllers/puzzle_controller.rb', line 33

def attempts
  return unless ensure_in_puzzle_dir!

  Components::AttemptsTable.new(puzzle: current_puzzle || raise).render
end

#initObject



3
4
5
6
7
8
9
10
# File 'lib/aoc_cli/controllers/puzzle_controller.rb', line 3

def init
  return unless ensure_in_event_dir!

  @puzzle = Processors::PuzzleInitialiser.run!(
    event: current_event,
    day: target_id
  )
end

#solveObject



12
13
14
15
16
17
18
19
# File 'lib/aoc_cli/controllers/puzzle_controller.rb', line 12

def solve
  return unless ensure_in_puzzle_dir!

  @attempt = Processors::SolutionPoster.run!(
    puzzle: current_puzzle,
    answer: params[:answer]
  )
end

#syncObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/aoc_cli/controllers/puzzle_controller.rb', line 21

def sync
  return unless ensure_in_puzzle_dir!

  @sync_log = Processors::PuzzleDirSynchroniser.run!(
    puzzle: current_puzzle,
    location: current_location,
    skip_cache: params[:skip_cache] || false
  )

  Components::PuzzleSyncComponent.new(log: @sync_log).render
end