Class: AocCli::EventController

Inherits:
ApplicationController show all
Defined in:
lib/aoc_cli/controllers/event_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

#attachObject



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

def attach
  return render_error!("Event does not exist") if queried_event.nil?

  @source = queried_event.location.path

  @target = Processors::ResourceAttacher.run!(
    resource: queried_event,
    path: params[:dir] || current_path
  ).path
end

#initObject



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

def init
  return unless ensure_not_in_aoc_dir!

  @event = Processors::EventInitialiser.run!(
    year: target_id,
    dir: params[:dir] || current_path
  )
end

#progressObject



23
24
25
26
27
# File 'lib/aoc_cli/controllers/event_controller.rb', line 23

def progress
  return unless ensure_in_aoc_dir!

  Components::ProgressTable.new(event: current_event || raise).render
end