data-writer - A gem to write to DATA
As most of you probably know in Ruby you can tell the interpreter the source file with the line: __END__
Anything you put below that line will be available as a file object in the DATA constant.
This can be very useful but by can only read from DATA and not write to it. But with data-writer you can!
For example you can do this:
require 'data-writer'
DATAWriter.file("w+") do |w|
w.write("this will be put in the source file after __END__")
end
__END__
So you could for example persist simple information about a script in the source file itself without using a secondary storage file.
To install do gem install data-writer and for documentation check out the github page at https://github.com/kl/data-writer
Anything you put below that line will be available as a file object in the DATA constant.
This can be very useful but by can only read from DATA and not write to it. But with data-writer you can!
For example you can do this:
require 'data-writer'
DATAWriter.file("w+") do |w|
w.write("this will be put in the source file after __END__")
end
__END__
So you could for example persist simple information about a script in the source file itself without using a secondary storage file.
To install do gem install data-writer and for documentation check out the github page at https://github.com/kl/data-writer

Comments