module Overcommit
  module Utils
    class << self
      include ConsoleMethods

      def hook_name
        File.basename($0).gsub('-', '_')
      end

      def load_hooks
        require File.expand_path("../hooks/#{hook_name}", __FILE__)
      rescue LoadError
        error "No hook definition found for #{hook_name}"
        exit 1
      end

      def script_path(script)
        File.join(File.expand_path('../../hooks/scripts', $0), script)
      end

      # Shamelessly stolen from:
      # http://stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby
      def underscorize(str)
        str.gsub(/::/, '/').
            gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
            gsub(/([a-z\d])([A-Z])/,'\1_\2').
            tr("-", "_").
            downcase
      end
    end
  end
end

module Overcommit
  module Utils
    class << self
      include ConsoleMethods

      def hook_name
        File.basename($0).tr('-', '_')
      end

      def load_hooks
        require File.expand_path("../hooks/#{hook_name}", __FILE__)
      rescue LoadError
        error "No hook definition found for #{hook_name}"
        exit 1
      end

      def script_path(script)
        File.join(File.expand_path('../../hooks/scripts', $0), script)
      end

      # Shamelessly stolen from:
      # http://stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby
      def underscorize(str)
        str.gsub(/::/, '/').
            gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
            gsub(/([a-z\d])([A-Z])/, '\1_\2').
            tr('-', '_').
            downcase
      end
    end
  end
end

Address style cleanups in Utils
Address style cleanups in Utils

As pointed out by Joe on
https://gerrit.causes.com/#/c/22332/2/lib/overcommit/utils.rb

Change-Id: I5cc01a344f2b9ca9098969b72ff21ad3c91eb430
Reviewed-on: https://gerrit.causes.com/22356
Reviewed-by: Aiden Scandella <1faf1e8390cdac9204f160c35828cc423b7acd7b@causes.com>
Tested-by: Aiden Scandella <1faf1e8390cdac9204f160c35828cc423b7acd7b@causes.com>
