app/controllers/cogy/cogy_controller.rb in cogy-0.5.2 vs app/controllers/cogy/cogy_controller.rb in cogy-0.6.0
- old
+ new
@@ -9,11 +9,11 @@
# POST /<mount_path>/cmd/:cmd
#
# Executes the requested {Command} and returns the result.
def command
cmd = params[:cmd]
- args = params.select { |k, _| k.start_with?("COG_ARGV_") }
+ args = params.select { |k, _| k.start_with?("COG_ARGV_") }.to_unsafe_h
.sort_by { |k, _| k.match(/\d+\z/)[0] }.to_h.values
opts = params.select { |k, _| k.start_with?("COG_OPT_") }
.transform_keys { |k| k.sub("COG_OPT_", "").downcase }
user = params["COG_CHAT_HANDLE"]
cog_env = request.request_parameters
@@ -24,13 +24,13 @@
if result.is_a?(Hash)
result = "COG_TEMPLATE: #{command.template || command.name}\n" \
"JSON\n" \
"#{result.to_json}"
end
- render text: result
+ render plain: result
else
- render status: 404, text: "The command '#{cmd}' does not exist."
+ render status: 404, plain: "The command '#{cmd}' does not exist."
end
rescue => e
@user = user
@cmd = cmd
@exception = e
@@ -45,9 +45,9 @@
# GET /<mount_path>/inventory
#
# Returns the bundle config in YAML format, which is installable by Cog.
# It is typically hit by `cogy:install` (https://github.com/skroutz/cogy-bundle).
def inventory
- render text: Cogy.bundle_config.to_yaml, content_type: "application/x-yaml"
+ render body: Cogy.bundle_config.to_yaml, content_type: "application/x-yaml"
end
end
end