Sha256: bdcfa9f6d29d30cfd9d219a9e245fcded4394adb0be297b4da608feaf83d3257

Contents?: true

Size: 553 Bytes

Versions: 4

Compression:

Stored size: 553 Bytes

Contents

module Hike
  module FileUtils
    extend self

    # Like `File.stat`. Returns nil if the file does not exist.
    def stat(path)
      if File.exist?(path)
        File.stat(path.to_s)
      else
        nil
      end
    end

    # A version of `Dir.entries` that filters out `.` files and `~` swap files.
    # Returns an empty `Array` if the directory does not exist.
    def entries(path)
      if File.directory?(path)
        Dir.entries(path).reject { |entry| entry =~ /^\.|~$|^\#.*\#$/ }.sort
      else
        []
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hike-2.1.3 lib/hike/fileutils.rb
hike-2.1.2 lib/hike/fileutils.rb
hike-2.1.1 lib/hike/fileutils.rb
hike-2.1.0 lib/hike/fileutils.rb