Sha256: da12f622b7d47e60ff4a18b6d81a20f922bacb9268a6b6f25ddd003c2b8cd8dc

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

require 'pathname'
require 'yaml'
require 'fileutils'

module FeCoreExt::CoreExt
end

module FeCoreExt::CoreExt::Pathname
  def load_yaml
    return unless exist?
    YAML.load_file(self)
  end

  def glob(pattern, &block)
    Pathname.glob(join(pattern), &block)
  end

  def touch(options={})
    FileUtils.touch(@path, options)
  end

  def rm(options={})
    FileUtils.rm(self, options)
  end

  def mkdir_p
    mkpath
    self
  end

  def require_relative
    Kernel.require_relative(self)
  end

  def mktmpdir(prefix_suffix=nil, tmpdir=nil)
    if block_given?
      Dir.mktmpdir prefix_suffix, tmpdir do |dir|
        yield new(dir)
      end
    else
      new(Dir.mktmpdir(prefix_suffix, tmpdir))
    end
  end
end

module FeCoreExt::CoreExt::PathnameClassMethods
  def join(*args)
    new(File.join(*args))
  end
end

class Pathname
  extend FeCoreExt::CoreExt::PathnameClassMethods
  include FeCoreExt::CoreExt::Pathname
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fe_core_ext-0.11.0 lib/fe_core_ext/core_ext/pathname.rb