Sha256: ff2af803323ee6d6e1432bf23255679b918e3d7f2d1ec045f7991b533f6bdd7a
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true module RakeUi class RakeTaskLogsController < ApplicationController RAKE_TASK_LOG_ATTRS = [:id, :name, :args, :environment, :rake_command, :rake_definition_file, :log_file_name, :log_file_full_path].freeze 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 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 private def rake_task_log_as_json(task) RAKE_TASK_LOG_ATTRS.each_with_object({}) do |param, obj| obj[param] = task.send(param) end end def rake_task_logs_as_json(tasks = []) tasks.map { |task| rake_task_log_as_json(task) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rake-ui-0.1.0 | app/controllers/rake_ui/rake_task_logs_controller.rb |
rake-ui-0.0.1 | app/controllers/rake_ui/rake_task_logs_controller.rb |