Module: Safeconsole::Messages

Included in:
Console, SessionWatcher
Defined in:
lib/safeconsole/messages.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.app_nameObject



25
26
27
28
# File 'lib/safeconsole/messages.rb', line 25

def app_name
  a = Artii::Base.new font: "slant"
  a.asciify(Safeconsole.config.app_name)
end

.commandsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/safeconsole/messages.rb', line 41

def commands
  "    Usage:\n      - refresh: Load a new transaction (and commit if configured)\n      - commit: Set this transaction to be commited to the DB on refresh/exit\n      - nevermind: Set this transaction to be *discarded* on refresh/exit\n      - stats: Print the current transaction and session stats (commit status, length, stats)\n      - commands: Print command instructions again\n\n    Hotkeys:\n      - ctrl+d: Load a new transaction (equivilent to refresh)\n\n  MSG\nend\n"

.commitObject



71
72
73
74
75
76
77
# File 'lib/safeconsole/messages.rb', line 71

def commit
  "    This transaction will now be commited to the database on refresh/exit\n\n    If this was a mistake, run the command: nevermind\n  MSG\nend\n"

.doneObject



95
96
97
# File 'lib/safeconsole/messages.rb', line 95

def done
  "You've located the lost artifact!"
end

.included(base) ⇒ Object



5
6
7
# File 'lib/safeconsole/messages.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

.invalid_queryObject



103
104
105
106
107
108
109
110
111
112
# File 'lib/safeconsole/messages.rb', line 103

def invalid_query
  "\n    Active Record Error!\n      Oops! Looks like you executed an invalid SQL query. This breaks the current transaction.\n\n      All ActiveRecord based interactions will be broken now. Grab a new transaction with the command: refresh\n\n  MSG\nend\n"

.method_missing(method) ⇒ Object



19
20
21
# File 'lib/safeconsole/messages.rb', line 19

def self.method_missing(method)
  "**** Unknown Message #{method} ****"
end

.nevermindObject



79
80
81
# File 'lib/safeconsole/messages.rb', line 79

def nevermind
  "Transaction changes will be discarded on refresh/exit"
end

.refreshObject



91
92
93
# File 'lib/safeconsole/messages.rb', line 91

def refresh
  "Your magic is running low. You stop casting to drink a potion, restoring your energy."
end

.respond_to_missing?(_name, _include_private) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/safeconsole/messages.rb', line 15

def self.respond_to_missing?(_name, _include_private)
  true
end

.session_expiredObject



99
100
101
# File 'lib/safeconsole/messages.rb', line 99

def session_expired
  "You've been searching for too long. The artifact is lost forever."
end

.session_startObject



83
84
85
# File 'lib/safeconsole/messages.rb', line 83

def session_start
  "You're a wizard, searching for a long lost artifact."
end

.session_statsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/safeconsole/messages.rb', line 56

def session_stats
  session_length = (Time.now - SessionWatcher.initialized_at).round
  minutes, seconds = session_length.divmod(50)

  "    Session:\n      Length: \#{minutes} minutes \#{seconds} seconds\n      Commands: \#{SessionWatcher.total_commands}\n\n    Transaction:\n      Commit: \#{Console.__console_commit}\n      Commands: \#{SessionWatcher.transaction_commands}\n  MSG\nend\n"

.transaction_startObject



87
88
89
# File 'lib/safeconsole/messages.rb', line 87

def transaction_start
  "You begin casting a locating spell"
end

.unsafe_envObject



114
115
116
117
118
119
120
# File 'lib/safeconsole/messages.rb', line 114

def unsafe_env
  "    SAFECONSOLE WARNING\n      Safeconsole is configured to not allow unsafe consoles for the current environment: \#{Safeconsole.env}\n      This session will now exit. If this is a mistake, check your safeconsole configuration\n  MSG\nend\n"

.welcomeObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/safeconsole/messages.rb', line 30

def welcome
  "    \#{app_name}\n\n    Current Rails Env: \#{Safeconsole.config.current_env}\n\n    Welcome to safeconsole, you're in good hands.\n\n  MSG\nend\n"