Sha256: 585745ca5e4101be5b4c7fbcabe737e54f26723893ffdf7c0f72b9b4e0bf0227

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

class Pathname
  def descendant_files
    out = children.select { |p| p.html? && !p.hidden? }
    children.select { |p| p.directory? && !p.hidden? }.each do |p|
      out += p.descendant_files
    end
    out
  end

  def html?
    file? && %w(.html).include?(extname)
  end

  def hidden?
    basename.to_s[0..0] == "."
  end

  def update_ext(extension)
    return self if extname == extension
    Pathname.new("#{to_s}#{extension}")
  end

  def write(content, options = {})
    preserve_mtime = options.delete(:preserve_mtime)
    _atime, _mtime = atime, mtime if preserve_mtime

    open("w", options) { |file| file << content }

    utime(_atime, _mtime) if preserve_mtime
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
storys-0.1.0 lib/storys/core_ext/pathname.rb
storys-0.0.6 lib/storys/core_ext/pathname.rb