Sha256: 03589574c459935ac649e1f6b3d69afb3fb9fccd585af965c1ce0cfbe633cd3c

Contents?: true

Size: 729 Bytes

Versions: 2

Compression:

Stored size: 729 Bytes

Contents

require_dependency "cogy/application_controller"

module Cogy
  class CogyController < ApplicationController
    # GET <mount_path>/cmd/:cmd/:user
    def command
      cmd = params[:cmd]
      args = request.query_parameters.select { |k,_| k !~ /\Acog_opt_/ }.values
      opts = request.query_parameters.select { |k,_| k =~ /\Acog_opt_/ }
        .transform_keys { |k| k.sub("cog_opt_", "") }
      user = params[:user]

      begin
        render text: Cogy.commands[cmd].run!(args, opts, user)
      rescue => e
        @user = user
        @cmd = cmd
        @exception = e
        render "cogy/error"
      end
    end

    # GET /inventory
    def inventory
      render text: Cogy.bundle_config.to_yaml
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cogy-0.0.3 app/controllers/cogy/cogy_controller.rb
cogy-0.0.2 app/controllers/cogy/cogy_controller.rb