Simple library that allows organize distribution of files within hex based tree.
gem install file_distribution
require 'rubygems'
require 'file_distribution'
fd = FileDistribution.new("/tmp/storage")
# default extensions
database_id = 1
fd.hex_path(database_id)
fd.rename_from("/tmp/upload/file1.txt")
path = fd.get_path # saved file path
# set all extensions to .pdf
database_id = 256
fd.set_extension(".pdf")
fd.hex_path(database_id)
fd.rename_from("/tmp/upload/file2.txt")
path = fd.get_path # saved file path
Files should be stored in /tmp/storage/01.dat and /tmp/storage/01/00.pdf