Class: EnvironmentInformation::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/environment_information/base/base.rb

Constant Summary collapse

TRY_TO_USE_HTML_COLOURS =
#

TRY_TO_USE_HTML_COLOURS

If true then we will try to use the konsole-colours, when possible.

These are part of the colours gem, so this adds a dependency on the colours gem.

#
true

Instance Method Summary collapse

Instance Method Details

#be_silentObject Also known as: be_quiet

#

be_silent

#


499
500
501
# File 'lib/environment_information/base/base.rb', line 499

def be_silent
  @internal_hash[:be_verbose] = false
end

#be_silent?Boolean

#

be_silent?

#

Returns:

  • (Boolean)


513
514
515
# File 'lib/environment_information/base/base.rb', line 513

def be_silent?
  !be_verbose?
end

#be_verbose?Boolean

#

be_verbose?

#

Returns:

  • (Boolean)


492
493
494
# File 'lib/environment_information/base/base.rb', line 492

def be_verbose?
  @internal_hash[:be_verbose]
end

#blue(i = '', use_colours = use_colours? ) ⇒ Object

#

blue

#


299
300
301
302
303
304
305
# File 'lib/environment_information/base/base.rb', line 299

def blue(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.blue(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#cd(i) ⇒ Object

#

cd (cd tag)

A shorter variant for the change-directory action.

#


105
106
107
# File 'lib/environment_information/base/base.rb', line 105

def cd(i)
  ::EnvironmentInformation.cd(i)
end

#col1Object

#

col1

The “first” colour to be used.

#


466
467
468
469
# File 'lib/environment_information/base/base.rb', line 466

def col1
  return Colours::BOLD_BLUE if use_colours?
  return ''
end

#commandline_arguments?Boolean

#

commandline_arguments?

#

Returns:

  • (Boolean)


79
80
81
# File 'lib/environment_information/base/base.rb', line 79

def commandline_arguments?
  @commandline_arguments
end

#crimson(i = '', use_colours = use_colours? ) ⇒ Object

#

crimson

#


310
311
312
313
314
315
316
# File 'lib/environment_information/base/base.rb', line 310

def crimson(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.crimson(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#cyan(i = '', use_colours = use_colours? ) ⇒ Object

#

cyan

#


203
204
205
206
207
208
209
# File 'lib/environment_information/base/base.rb', line 203

def cyan(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.cyan(i) if use_colours and TRY_TO_USE_HTML_COLOURS
  return i
end

#darkgreen(i = '', use_colours = use_colours? ) ⇒ Object

#

darkgreen

#


453
454
455
456
457
458
459
# File 'lib/environment_information/base/base.rb', line 453

def darkgreen(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.darkgreen(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#darkolivegreen(i = '', use_colours = use_colours? ) ⇒ Object

#

darkolivegreen

#


365
366
367
368
369
370
371
# File 'lib/environment_information/base/base.rb', line 365

def darkolivegreen(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.darkolivegreen(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#dimgray(i = '', use_colours = use_colours? ) ⇒ Object

#

dimgray

#


442
443
444
445
446
447
448
# File 'lib/environment_information/base/base.rb', line 442

def dimgray(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.dimgray(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#disable_coloursObject Also known as: no_colours

#

disable_colours

#


261
262
263
# File 'lib/environment_information/base/base.rb', line 261

def disable_colours
  set_use_colours(false)
end

#e(i = '') ⇒ Object

#

e (e tag)

#


119
120
121
# File 'lib/environment_information/base/base.rb', line 119

def e(i = '')
  puts i
end

#enable_coloursObject

#

enable_colours

#


254
255
256
# File 'lib/environment_information/base/base.rb', line 254

def enable_colours
  set_use_colours(true)
end

#esystem(i) ⇒ Object

#

esystem

#


126
127
128
129
# File 'lib/environment_information/base/base.rb', line 126

def esystem(i)
  e i
  system i
end

#first_argument?Boolean Also known as: first?

#

first_argument?

#

Returns:

  • (Boolean)


86
87
88
# File 'lib/environment_information/base/base.rb', line 86

def first_argument?
  @commandline_arguments.first
end

#gold(i = '') ⇒ Object

#

gold

#


182
183
184
# File 'lib/environment_information/base/base.rb', line 182

def gold(i = '')
  return ::Colours::HtmlColoursMethods.gold(i)
end

#is_on_roebe?Boolean

#

is_on_roebe?

#

Returns:

  • (Boolean)


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

def is_on_roebe?
  ::EnvironmentInformation.is_on_roebe?
end

#is_rbt_available?Boolean

#

is_rbt_available? (rbt tag)

Query whether the user has the necessary code from the RBT project installed.

#

Returns:

  • (Boolean)


96
97
98
# File 'lib/environment_information/base/base.rb', line 96

def is_rbt_available?
  Object.const_defined? :RBT
end

#lightblue(i = '') ⇒ Object

#

lightblue

#


196
197
198
# File 'lib/environment_information/base/base.rb', line 196

def lightblue(i = '')
  return ::Colours::HtmlColoursMethods.lightblue(i)
end

#lightgreen(i = '', use_colours = use_colours? ) ⇒ Object

#

lightgreen

#


354
355
356
357
358
359
360
# File 'lib/environment_information/base/base.rb', line 354

def lightgreen(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.lightgreen(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#lightseagreen(i = '', use_colours = use_colours? ) ⇒ Object

#

lightseagreen

#


277
278
279
280
281
282
283
# File 'lib/environment_information/base/base.rb', line 277

def lightseagreen(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.lightseagreen(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#limegreen(i = '', use_colours = use_colours? ) ⇒ Object

#

limegreen

#


376
377
378
379
380
381
382
# File 'lib/environment_information/base/base.rb', line 376

def limegreen(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.limegreen(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#load_dataset_from_this_file(i) ⇒ Object Also known as: try_to_load_dataset_from_this_file, try_to_read_content_from_this_file

#

load_dataset_from_this_file

This method can be used to read which programs will be displayed from a local file, rather than rely on the pre-set default.

#


539
540
541
542
543
544
545
546
547
# File 'lib/environment_information/base/base.rb', line 539

def load_dataset_from_this_file(i)
  if File.exist? i
    File.readlines(i).map {|entry|
      entry.delete('-').strip # ← Clean up the input a little bit.
    }
  else
    opne "No file exists at `#{sfile(i)}`."
  end
end

#log_dir?Boolean Also known as: log_directory?, temp_dir?, temp_directory?

#

log_dir?

#

Returns:

  • (Boolean)


527
528
529
# File 'lib/environment_information/base/base.rb', line 527

def log_dir?
  ::EnvironmentInformation.temp_directory?
end

#mediumaquamarine(i = '') ⇒ Object

#

mediumaquamarine

#


189
190
191
# File 'lib/environment_information/base/base.rb', line 189

def mediumaquamarine(i = '')
  return ::Colours::HtmlColoursMethods.mediumaquamarine(i)
end

#mediumpurple(i = '', use_colours = use_colours? ) ⇒ Object

#

mediumpurple

#


321
322
323
324
325
326
327
# File 'lib/environment_information/base/base.rb', line 321

def mediumpurple(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.mediumpurple(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#olive(i = '', use_colours = use_colours? ) ⇒ Object

#

olive

#


387
388
389
390
391
392
393
# File 'lib/environment_information/base/base.rb', line 387

def olive(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.olive(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#olivedrab(i = '', use_colours = use_colours? ) ⇒ Object

#

olivedrab

#


398
399
400
401
402
403
404
# File 'lib/environment_information/base/base.rb', line 398

def olivedrab(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.olivedrab(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#opne(i = '') ⇒ Object Also known as: opnne

#

opne

#


520
521
522
# File 'lib/environment_information/base/base.rb', line 520

def opne(i = '')
  opnn; e i
end

#orange(i = '', use_colours = use_colours? ) ⇒ Object

#

orange

#


343
344
345
346
347
348
349
# File 'lib/environment_information/base/base.rb', line 343

def orange(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.orange(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#register_sigintObject

#

register_sigint

#


233
234
235
# File 'lib/environment_information/base/base.rb', line 233

def register_sigint
  Signal.trap('SIGINT') { e; exit }
end

#resetObject

#

reset

#


30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/environment_information/base/base.rb', line 30

def reset
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  @internal_hash = {}
  # ======================================================================= #
  # === :use_colours
  # ======================================================================= #
  set_use_colours(TRY_TO_USE_HTML_COLOURS)
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  set_be_verbose
end

#return_very_silent_system_output_from(use_this_query) ⇒ Object Also known as: default_query, silent_sys_command, silent_query, swift_query

#

return_very_silent_system_output_from (query tag)

#


134
135
136
137
138
139
140
# File 'lib/environment_information/base/base.rb', line 134

def return_very_silent_system_output_from(
    use_this_query
  )
  return ::EnvironmentInformation.return_very_silent_system_output_from(
    use_this_query
  )
end

#rev(use_colours = use_colours? ) ⇒ Object

#

rev (rev tag)

#


268
269
270
271
272
# File 'lib/environment_information/base/base.rb', line 268

def rev(
    use_colours = use_colours?
  )
  return ::EnvironmentInformation.rev(use_colours)
end

#royalblue(i = '', use_colours = use_colours? ) ⇒ Object

#

royalblue

#


431
432
433
434
435
436
437
# File 'lib/environment_information/base/base.rb', line 431

def royalblue(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.royalblue(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#sanitize_this_version_string(i) ⇒ Object

#

sanitize_this_version_string

#


148
149
150
151
152
# File 'lib/environment_information/base/base.rb', line 148

def sanitize_this_version_string(
    i
  )
  return ::EnvironmentInformation.sanitize_this_version_string(i)
end

#seagreen(i = '', use_colours = use_colours? ) ⇒ Object

#

seagreen

#


288
289
290
291
292
293
294
# File 'lib/environment_information/base/base.rb', line 288

def seagreen(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.seagreen(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#set_be_silent(i = true) ⇒ Object

#

set_be_silent

#


506
507
508
# File 'lib/environment_information/base/base.rb', line 506

def set_be_silent(i = true)
  @internal_hash[:be_verbose] = !i
end

#set_be_verbose(i = true) ⇒ Object

#

set_be_verbose

#


48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/environment_information/base/base.rb', line 48

def set_be_verbose(
    i = true
  )
  case i
  # ======================================================================== #
  # === :be_quiet
  # ======================================================================== #
  when :be_quiet
    i = false
  end
  @internal_hash[:be_verbose] = i
end

#set_commandline_arguments(i = '') ⇒ Object

#

set_commandline_arguments

#


71
72
73
74
# File 'lib/environment_information/base/base.rb', line 71

def set_commandline_arguments(i = '')
  i = [i].flatten.compact
  @commandline_arguments = i
end

#set_use_colours(i = true) ⇒ Object

#

set_use_colours

#


247
248
249
# File 'lib/environment_information/base/base.rb', line 247

def set_use_colours(i = true)
  @use_colours = i
end

#sfancy(i = '', use_colours = use_colours? ) ⇒ Object

#

sfancy

#


474
475
476
477
478
479
480
# File 'lib/environment_information/base/base.rb', line 474

def sfancy(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours.sfancy(i) if use_colours
  return i
end

#sfile(i = '', use_colours = use_colours? ) ⇒ Object

#

sfile

#


157
158
159
160
161
162
163
# File 'lib/environment_information/base/base.rb', line 157

def sfile(
    i           = '',
    use_colours = use_colours?
  )
  return ::EnvironmentInformation.sfile(i, use_colours) if use_colours
  return i
end

#simp(i, use_colours = use_colours? ) ⇒ Object

#

simp

#


222
223
224
225
226
227
228
# File 'lib/environment_information/base/base.rb', line 222

def simp(
    i,
    use_colours = use_colours?
  )
  return ::Colours.simp(i) if use_colours
  return i
end

#slateblue(i = '', use_colours = use_colours? ) ⇒ Object

#

slateblue

#


420
421
422
423
424
425
426
# File 'lib/environment_information/base/base.rb', line 420

def slateblue(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.slateblue(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#steelblue(i = '', use_colours = use_colours? ) ⇒ Object

#

steelblue

#


409
410
411
412
413
414
415
# File 'lib/environment_information/base/base.rb', line 409

def steelblue(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.steelblue(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#teal(i = '', use_colours = use_colours? ) ⇒ Object

#

teal

#


332
333
334
335
336
337
338
# File 'lib/environment_information/base/base.rb', line 332

def teal(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours::HtmlColoursMethods.teal(i) if use_colours? and TRY_TO_USE_HTML_COLOURS
  return i
end

#tomato(i = '') ⇒ Object

#

tomato

#


175
176
177
# File 'lib/environment_information/base/base.rb', line 175

def tomato(i = '')
  return ::Colours::HtmlColoursMethods.tomato(i)
end

#tracked_programs?Boolean

#

tracked_programs?

#

Returns:

  • (Boolean)


240
241
242
# File 'lib/environment_information/base/base.rb', line 240

def tracked_programs?
  ARRAY_TRACKED_PROGRAMS
end

#true_revObject

#

true_rev

#


214
215
216
217
# File 'lib/environment_information/base/base.rb', line 214

def true_rev
  return Colours.rev if use_colours?
  return ''
end

#use_colours?Boolean

#

use_colours?

#

Returns:

  • (Boolean)


168
169
170
# File 'lib/environment_information/base/base.rb', line 168

def use_colours?
  @use_colours
end

#write_what_into(what, into) ⇒ Object

#

write_what_into

#


485
486
487
# File 'lib/environment_information/base/base.rb', line 485

def write_what_into(what, into)
  ::EnvironmentInformation.write_what_into(what, into)
end