Sha256: 6add08e518859cc56797fe15cfca3a625f1efdf0ba5e305b11c4fdb277dc8d69
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true module RakeUi class RakeTasksController < RakeUi::ApplicationController RAKE_TASK_ATTRS = [:id, :name, :name_with_args, :arg_description, :full_comment, :locations, :is_internal_task, :sources].freeze def index @rake_tasks = RakeUi::RakeTask.all unless params[:show_all] @rake_tasks = @rake_tasks.select(&:internal_task?) end respond_to do |format| format.html format.json do render json: { rake_tasks: rake_tasks_as_json(@rake_tasks) } end end end def show @rake_task = RakeUi::RakeTask.find_by_id(params[:id]) respond_to do |format| format.html format.json do render json: { rake_task: rake_task_as_json(@rake_task) } end end end def execute @rake_task = RakeUi::RakeTask.find_by_id(params[:id]) rake_task_log = @rake_task.call(args: params[:args], environment: params[:environment]) redirect_to rake_task_log_path rake_task_log.id end private def rake_task_as_json(task) RAKE_TASK_ATTRS.each_with_object({}) do |param, obj| obj[param] = task.send(param) end end def rake_tasks_as_json(tasks) tasks.map { |task| rake_task_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_tasks_controller.rb |
rake-ui-0.0.1 | app/controllers/rake_ui/rake_tasks_controller.rb |