Project

DATA.save

0.0
No commit activity in last 3 years
No release in over 3 years
Store shit in your script's DATA segment
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.2
 Project Readme

DATA.save

Stored shit in your script's data segment.

Install

$ gem install DATA.save

Example

A program that records how many times it's been run:

require 'DATA.save'

run_count = DATA.load.to_i
run_count += 1
DATA.save run_count

puts "Run count: #{run_count}"

__END__
0

When we invoke it, it increments the counter, which it stores in its DATA segment.

# run it 3 times
$ ruby count_runs.rb
Run count: 1

$ ruby count_runs.rb
Run count: 2

$ ruby count_runs.rb
Run count: 3

# now check out the file
$ cat count_runs.rb
require 'DATA.save'

run_count = DATA.load.to_i
run_count += 1
DATA.save run_count

puts "Run count: #{run_count}"

__END__
3

License

Just do what the fuck you want to.

http://www.wtfpl.net/about/