Change how ruby executes commands

This commit is contained in:
spengreb 2019-10-08 22:35:26 +02:00
parent 2981d737a9
commit e8fb72653d
2 changed files with 93 additions and 1 deletions

View file

@ -5,7 +5,7 @@ class VouchersController < ApplicationController
# GET /vouchers
def index
@vouchers = Voucher.all
whitelist = %x[mcrcon -c -H mine.vereto.net -p #{ENV["MC_RCON_PASS"]} 'whitelist list' | sed 's/There are*.*whitelisted players: //g'].gsub("\n", "").split(", ")
whitelist = %x{mcrcon -c -H mine.vereto.net -p #{ENV["MC_RCON_PASS"]} 'whitelist list' | sed 's/There are*.*whitelisted players: //g'}.gsub("\n", "")
render json: { :vouchers => @vouchers, :whitelist => whitelist }.to_json
end

View file

@ -2374,3 +2374,95 @@ Processing by VouchersController#index as */*
Completed 200 OK in 122ms (Views: 0.2ms | ActiveRecord: 1.4ms | Allocations: 6017)
Started GET "/vouchers" for ::1 at 2019-10-08 22:24:13 +0200
 (0.2ms) SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
 (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
Processing by VouchersController#index as */*
Completed 500 Internal Server Error in 127ms (ActiveRecord: 0.0ms | Allocations: 782)
NoMethodError (undefined method `gsub' for true:TrueClass):
app/controllers/vouchers_controller.rb:9:in `index'
Started GET "/vouchers" for ::1 at 2019-10-08 22:24:29 +0200
Processing by VouchersController#index as */*
Voucher Load (0.5ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:11:in `index'
Completed 200 OK in 129ms (Views: 0.2ms | ActiveRecord: 2.1ms | Allocations: 5932)
Started GET "/vouchers" for ::1 at 2019-10-08 22:24:54 +0200
Processing by VouchersController#index as */*
Voucher Load (0.4ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:11:in `index'
Completed 200 OK in 130ms (Views: 0.2ms | ActiveRecord: 2.0ms | Allocations: 5405)
Started GET "/vouchers" for ::1 at 2019-10-08 22:25:26 +0200
Processing by VouchersController#index as */*
Started GET "/vouchers" for ::1 at 2019-10-08 22:25:38 +0200
 (0.3ms) SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
 (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
Processing by VouchersController#index as */*
Started GET "/vouchers" for ::1 at 2019-10-08 22:28:12 +0200
 (0.5ms) SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
 (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
SyntaxError (/media/Linux-Shared/dev/gitlab.com/vereto-api/app/controllers/vouchers_controller.rb:8: syntax error, unexpected unary-, expecting do or '{' or '('
...hitelist = IO.popen(mcrcon -c -H mine.vereto.net -p #{ENV["M...
... ^):
app/controllers/vouchers_controller.rb:8: syntax error, unexpected unary-, expecting do or '{' or '('
app/controllers/vouchers_controller.rb:8: syntax error, unexpected unary-, expecting do or '{' or '('
Started GET "/vouchers" for ::1 at 2019-10-08 22:30:10 +0200
Processing by VouchersController#index as */*
Voucher Load (0.3ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:10:in `index'
Completed 200 OK in 10ms (Views: 0.1ms | ActiveRecord: 1.5ms | Allocations: 5989)
Started GET "/vouchers" for ::1 at 2019-10-08 22:33:42 +0200
Processing by VouchersController#index as */*
Voucher Load (0.3ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:10:in `index'
Completed 200 OK in 11ms (Views: 0.1ms | ActiveRecord: 1.1ms | Allocations: 5408)
Started GET "/vouchers" for ::1 at 2019-10-08 22:33:54 +0200
Processing by VouchersController#index as */*
Voucher Load (0.4ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:10:in `index'
Completed 200 OK in 20ms (Views: 0.2ms | ActiveRecord: 0.4ms | Allocations: 1153)
Started GET "/vouchers" for ::1 at 2019-10-08 22:34:22 +0200
Processing by VouchersController#index as */*
Voucher Load (0.3ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:10:in `index'
Completed 200 OK in 19ms (Views: 0.2ms | ActiveRecord: 1.7ms | Allocations: 5429)
Started GET "/vouchers" for ::1 at 2019-10-08 22:34:36 +0200
 (0.2ms) SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
 (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
Processing by VouchersController#index as */*
Voucher Load (0.3ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:10:in `index'
Completed 200 OK in 12ms (Views: 0.1ms | ActiveRecord: 1.0ms | Allocations: 5970)
Started GET "/vouchers" for ::1 at 2019-10-08 22:35:04 +0200
Processing by VouchersController#index as */*
Voucher Load (0.3ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:10:in `index'
Completed 200 OK in 130ms (Views: 0.1ms | ActiveRecord: 1.0ms | Allocations: 5408)
Started GET "/vouchers" for ::1 at 2019-10-08 22:35:20 +0200
Processing by VouchersController#index as */*
Voucher Load (0.4ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:10:in `index'
Completed 200 OK in 122ms (Views: 0.2ms | ActiveRecord: 1.7ms | Allocations: 5452)