Class: BashDebug

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

Class Method Summary collapse

Class Method Details

.checkObject



38
39
40
41
42
43
# File 'lib/bash_debug.rb', line 38

def check
  get_ctn
  get_functions
  get_shortcuts
  check_repeat
end

.check_repeatObject



20
21
22
23
24
25
# File 'lib/bash_debug.rb', line 20

def check_repeat
  repeat = shortcuts - (shortcuts - functions)
  unless repeat.empty?
    puts repeat
  end
end

.ctnObject



50
51
52
53
# File 'lib/bash_debug.rb', line 50

def ctn
  @ctn.uniq! if @ctn.respond_to?(:uniq!)
  @ctn ||= ''
end

.function_regexpObject



8
9
10
# File 'lib/bash_debug.rb', line 8

def function_regexp
  %r{^(?<function>(_|\w)+)\s\(\)\s}
end

.functionsObject



27
28
29
30
31
# File 'lib/bash_debug.rb', line 27

def functions
  @funcitons.flatten! if @funcitons.respond_to?(:flatten!)
  @funcitons.uniq! if @funcitons.respond_to?(:uniq!)
  @funcitons ||= []
end

.get_ctnObject



45
46
47
48
# File 'lib/bash_debug.rb', line 45

def get_ctn
  path = File.join($root, 'ro_commands.sh')
  @ctn = File.read(path)
end

.get_functionsObject



4
5
6
# File 'lib/bash_debug.rb', line 4

def get_functions
  functions << ctn.scan(function_regexp)
end

.get_shortcutsObject



12
13
14
# File 'lib/bash_debug.rb', line 12

def get_shortcuts
  ctn.scan(shortcut_regexp)
end

.shortcut_regexpObject



16
17
18
# File 'lib/bash_debug.rb', line 16

def shortcut_regexp
  %r{alias (?<shortcut>)}
end

.shortcutsObject



33
34
35
36
# File 'lib/bash_debug.rb', line 33

def shortcuts
  @shortcuts.uniq! if @shortcuts.respond_to?(:uniq!)
  @shortcuts ||= []
end