No commit activity in last 3 years
No release in over 3 years
Extends Ruby File objects with some rich instance attributes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Richfile¶ ↑

A simple gem which adds some additional methods to File objects.

Install¶ ↑

gem install tsalzer-richfile --source http://gems.github.com

What is Richfile?¶ ↑

Richfile extends the Ruby built-in File instances with some sometimes useful attributes.

  • size attribute to cache the file size in a File object

  • OpenSSL digest attributes like md5 and sha1 (for all available digests)

Note that there is no built-in magic to keep the once-fetched attributes in sync with the effective attributes of the real files.

Usage¶ ↑

You simple require richfile:

require 'richfile'

Now, every new File object has a list of additional attributes. Whenever you access the attributes the first time, the data is pulled from the file system and cached in the File object.

If you need to refresh the data, either call refresh!, which updates every attribute you used before, or refresh_all!, which updates each of the cached attributes. When you are just interested in a single attribute, call the attribute with an added bang (like size!).

Building a new Gem¶ ↑

To create a new gem, you need to install the jeweler gem (see github.com/technicalpickles/jeweler/tree/master). If this is done, you can easily build a new gemspec with

rake gemspec
gem build richfile.gemspec

This would create a new richfile-x.y.z.gem, which can easily be installed via

gem install richfile-x.y.z.gem

License¶ ↑

The richfile gem comes to you under the MIT License. You should find the license text in the file MIT-LICENSE in the gem folder.