preferences / 0.3
| Short description: | Persistent preferences for applications | |||||
|---|---|---|---|---|---|---|
| Category: | Library/Development | |||||
| Status: | beta | |||||
| Created: | 2004-12-06 18:43:30 GMT | |||||
| Last update: | 2006-05-29 21:50:57 GMT | |||||
| Owner: | Joel VanderWerf (Projects of this owner) | |||||
| Homepage: | http://redshift.sourceforge.net/preferences | |||||
| Download: | http://redshift.sourceforge.net/preferences | |||||
| License: | Ruby's | |||||
| Dependency: |
|
|||||
| Description: | PreferencesThe Preferences class is an easy way to make variables in an application persist in a file. The file is human readable, through the magic of YAML. Preferences vary from user to user, so typically the file used for persistence will be chosen based on the user’s environment as well as the name of the app. Any pair of methods that look like a reader/writer pair can be persisted, so existing variables can be stored with little additional fuss and bother. Synopsis
require 'preferences'
PREFS = Preferences.new("/tmp/prefs")
class Window
attr_accessor :x, :y, :z
def initialize
PREFS.register "my app/window" do |entry|
entry.var "x", "y" => "default_y"
entry.var "z"
end
end
def run
@x = 7 # emulate user's interaction
end
end
Window.new.run
PREFS.save
After executing this code, /tmp/prefs contains:
my app:
window:
x: 7
y: default_y
z:
When the program is run again, these saved preferences will be loaded into the variables when the PREFS.register method is called. New in preferences 0.3
|
|||||
| Versions: | [0.3 (2006-05-29)] [0.2 (2005-01-05)] [0.1 (2004-12-06)] | |||||