Module: Qcmd

Extended by:
Plaintext
Defined in:
lib/qcmd.rb,
lib/qcmd/cli.rb,
lib/qcmd/parser.rb,
lib/qcmd/aliases.rb,
lib/qcmd/context.rb,
lib/qcmd/handler.rb,
lib/qcmd/history.rb,
lib/qcmd/machine.rb,
lib/qcmd/network.rb,
lib/qcmd/version.rb,
lib/qcmd/commands.rb,
lib/qcmd/qlab/cue.rb,
lib/qcmd/plaintext.rb,
lib/qcmd/qlab/reply.rb,
lib/qcmd/configuration.rb,
lib/qcmd/qlab/cue_list.rb,
lib/qcmd/actions/action.rb,
lib/qcmd/qlab/workspace.rb,
lib/qcmd/input_completer.rb,
lib/qcmd/actions/cue_action.rb,
lib/qcmd/actions/base_action.rb

Defined Under Namespace

Modules: Commands, InputCompleter, Parser, Plaintext, QLab Classes: Action, Aliases, BaseAction, CLI, Configuration, Context, CueAction, Handler, History, Machine, Network

Constant Summary collapse

LEVELS =
%w(debug info warning error none)
VERSION =
"0.1.13"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Plaintext

ascii_qlab, centered_text, columns, joined_wrapped, log, pluralize, print, print_wrapped, right_text, set_columns, split_text, table, word_wrap, wrapped_text

Class Attribute Details

.context ⇒ Object

Returns the value of attribute context.



40
41
42
# File 'lib/qcmd.rb', line 40

def context
  @context
end

.debug_mode ⇒ Object

Returns the value of attribute debug_mode.



39
40
41
# File 'lib/qcmd.rb', line 39

def debug_mode
  @debug_mode
end

Class Method Details

.connected? ⇒ Boolean

Returns:

  • (Boolean)


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

def connected?
  !!context && !!context.machine && !context.machine.nil?
end

.debug(message) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/qcmd.rb', line 87

def debug message
  # always write to log

  Qcmd::Configuration.log.puts "[%s] %s" % [Time.now.strftime('%T'), message]

  log(:debug, message)
end

.debug? ⇒ Boolean

Returns:

  • (Boolean)


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

def debug?
  !!debug_mode
end

.log_level ⇒ Object



44
45
46
# File 'lib/qcmd.rb', line 44

def log_level
  @log_level ||= :info
end

.log_level=(value) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/qcmd.rb', line 48

def log_level=(value)
  if LEVELS.include?(value.to_s)
    @log_level = value
  else
    raise "Invalid log_level value: #{ value.to_s }"
  end
end

.log_level_acheived?(level) ⇒ Boolean

Returns:

  • (Boolean)


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

def log_level_acheived? level
  LEVELS.index(level.to_s) >= LEVELS.index(log_level.to_s)
end

.quiet! ⇒ Object



60
61
62
# File 'lib/qcmd.rb', line 60

def quiet!
  self.log_level = :warning
end

.quiet? ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/qcmd.rb', line 72

def quiet?
  self.log_level == :warning
end

.silent! ⇒ Object



64
65
66
# File 'lib/qcmd.rb', line 64

def silent!
  self.log_level = :none
end

.silent? ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/qcmd.rb', line 68

def silent?
  self.log_level == :none
end

.verbose! ⇒ Object



56
57
58
# File 'lib/qcmd.rb', line 56

def verbose!
  self.log_level = :debug
end

.while_quiet ⇒ Object



76
77
78
79
80
81
# File 'lib/qcmd.rb', line 76

def while_quiet
  previous_level = self.log_level
  self.log_level = :warning
  yield
  self.log_level = previous_level
end