Class: RakeUi::RakeTaskLogsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rake_ui/rake_task_logs_controller.rb

Constant Summary collapse

RAKE_TASK_LOG_ATTRS =
[:id,
:name,
:args,
:environment,
:rake_command,
:rake_definition_file,
:log_file_name,
:log_file_full_path].freeze

Instance Method Summary collapse

Instance Method Details

#indexObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/rake_ui/rake_task_logs_controller.rb', line 14

def index
  @rake_task_logs = RakeUi::RakeTaskLog.all.sort_by(&:id)

  respond_to do |format|
    format.html
    format.json do
      render json: {
        rake_task_logs: rake_task_logs_as_json(@rake_task_logs)
      }
    end
  end
end

#showObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/rake_ui/rake_task_logs_controller.rb', line 27

def show
  @rake_task_log = RakeUi::RakeTaskLog.find_by_id(params[:id])

  @rake_task_log_content = @rake_task_log.file_contents.gsub("\n", "<br />")
  @rake_task_log_content_url = rake_task_log_path(@rake_task_log.id, format: :json)
  @is_rake_task_log_finished = @rake_task_log.finished?

  respond_to do |format|
    format.html
    format.json do
      render json: {
        rake_task_log: rake_task_log_as_json(@rake_task_log),
        rake_task_log_content: @rake_task_log_content,
        rake_task_log_content_url: @rake_task_log_content_url,
        is_rake_task_log_finished: @is_rake_task_log_finished
      }
    end
  end
end