require 'find'

module HamlLint
  # A miscellaneous set of utility functions.
  module Utils
    class << self
      def extract_files_from(list)
        files = []

        list.each do |file|
          begin
            Find.find(file) do |f|
              files << f if haml_file?(f)
            end
          rescue Errno::ENOENT
            # One of the paths specified does not exist; raise a more
            # descriptive exception so we know which one
            raise HamlLint::Exceptions::InvalidFilePath,
                  "File path '#{file}' does not exist"
          end
        end

        files.uniq
      end

    private

      def haml_file?(file)
        return false unless FileTest.file?(file)

        File.extname(file) == '.haml'
      end
    end
  end
end

require 'find'

module HamlLint
  # A miscellaneous set of utility functions.
  module Utils
    module_function

    def extract_files_from(list)
      files = []

      list.each do |file|
        begin
          Find.find(file) do |f|
            files << f if haml_file?(f)
          end
        rescue Errno::ENOENT
          # One of the paths specified does not exist; raise a more
          # descriptive exception so we know which one
          raise HamlLint::Exceptions::InvalidFilePath,
                "File path '#{file}' does not exist"
        end
      end

      files.uniq
    end

  private

    def haml_file?(file)
      return false unless FileTest.file?(file)

      File.extname(file) == '.haml'
    end
  end
end

Use module_function instead of class << self
Use module_function instead of class << self

The `Utils` module had an unnecessary extra level of indention due to
its use of `class << self` to make its helpers all class-level
functions.

Fix this by using the `module_function` helper, which accomplishes the
same thing.

Change-Id: I6194f394e111a6e7dac2672189472eb53ae62f04
Reviewed-on: http://gerrit.causes.com/42352
Tested-by: jenkins <d95b56ce41a2e1ac4cecdd398defd7414407cc08@causes.com>
Reviewed-by: Shane da Silva <67fb7bfe39f841b16a1f86d3928acc568d12c716@brigade.com>
