Sha256: 93529594e6bc82501c38a24aa32914c4545ea5e97518512782a061bfbb2abcec

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

$root = File.expand_path("../..", __FILE__)
class BashDebug
  class << self
    def get_functions
      functions << ctn.scan(function_regexp)
    end

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

    def get_shortcuts
      ctn.scan(shortcut_regexp)
    end

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

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

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

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

    def check
      get_ctn
      get_functions
      get_shortcuts
      check_repeat
    end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ro_commands-0.0.3 lib/bash_debug.rb
ro_commands-0.0.2 lib/bash_debug.rb
ro_commands-0.0.1 lib/bash_debug.rb