Sha256: 441ef251f3864bd8c189b929c00110d524a48d91cbc3df64f9871971894eb55c

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
# Copyright Freya Dorn <freya.siv.dorn@gmail.com>, 2013
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>

class File
  def self.save name, &blk
    name = File.expand_path(name)

    # make sure directory exists
    dir = File.dirname(name)
    FileUtils.mkdir_p dir if not Dir.exist? dir

    # now open it
    file = case name
           when /\.gz$/	; Zlib::GzipWriter.open(name, &blk)
           else        	; File.open(name, "w", &blk)
           end

    file
  end

  def self.load name
    name = File.expand_path(name)

    file = case name
           when /\.gz$/	; Zlib::GzipReader.open(name)
           else        	; File.open(name)
           end

    file
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
muflax-0.7.0 lib/muflax/file.rb