Prepare auditor to print a present role

This commit is contained in:
Tobias Bühlmann
2023-03-09 19:35:30 +01:00
parent 901484d75d
commit 6b11303230
3 changed files with 28 additions and 5 deletions

View File

@@ -1,6 +1,13 @@
require "active_support/core_ext/time/conversions"
class Mrsk::Commands::Auditor < Mrsk::Commands::Base
attr_reader :role
def initialize(config, role: nil)
super(config)
@role = role
end
# Runs remotely
def record(line)
append \
@@ -25,11 +32,15 @@ class Mrsk::Commands::Auditor < Mrsk::Commands::Base
end
def tagged_record_line(line)
"'#{recorded_at_tag} #{performer_tag} #{line}'"
quote [recorded_at_tag, performer_tag, role_tag, line].compact.join(" ")
end
def tagged_broadcast_line(line)
"'#{performer_tag} #{line}'"
quote [performer_tag, role_tag, line].compact.join(" ")
end
def role_tag
"[#{role}]" if role
end
def performer_tag
@@ -39,4 +50,8 @@ class Mrsk::Commands::Auditor < Mrsk::Commands::Base
def recorded_at_tag
"[#{Time.now.to_fs(:db)}]"
end
def quote(tagged_line)
"'#{tagged_line}'"
end
end