I have published the Ruby gems string_in_file and array_in_file. Think of them as the ultimate global variables.
string_in_file
is used for storing a string in a file. In addition to writing a
string value to a file and reading a string value from a file, you can
also:
1. Check to see if a particular string value is present in a file.
2. Replace every instance of a given string in a file with another string.
array_in_file is used for storing an array of strings in a file, with each string separated by a newline character.
I'm
using string_in_file and array_in_file in my bsf_scrape and dvi_scrape
gems, and I'm integrating them into my Bargain Stock Funds
(
http://www.bargainstockfunds.com) and Doppler Value Investing
(
http://www.dopplervalueinvesting.com) web sites as well. These gems are very simple, but they help me write cleaner code, as I don't have to keep rewriting the functions for every Ruby gem or Rails app.