
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
user_config is a library to manage configuration files in user's home directory for ruby libraries or applications. The format of a configuration file is yaml.
The class UserConfig manages values of configuration, which is handled as a set of hashes and is saved to yaml files in specified directory under user's home directory.
uconf = UserConfig.new(".some_config")
The directory ~/.some_config is created in the directory ENV['HOME']. To set the value "world" for the key "hello" of ~/.some_config/file.yaml,
uconf["file.yaml"]["hello"] = "world"
The value is not saved to the file. To do that,
uconf["file.yaml"].save
If we want to create initial files with default values, we use the method UserConfig#default.
UserConfig.default('conf.yaml', { 'key1' => 'val1', 'key2' => 'val2' })
uconf = UserConfig.new('.some_config')
uconf.create('conf.yaml')
The file ~/.some_config'/confi.yaml is created. To create another file 'conf2.yaml',
UserConfig.default('conf2.yaml', { 'hello' => 'world'})
uconf.create('conf2.yaml')
We load files in the above example as the following code.
uconf = UserConfig.new('.some_config')
yaml = uconf['conf.yaml']
p yaml['key1']
p yaml['key2']
UserConfig#save_all save all yaml files.
uconf = UserConfig.new('.some_config')
yaml = uconf['conf.yaml']
yaml['key1'] = 'modified_val1'
yaml['key3'] = 'val3'
yaml.save
If we modify some files, we can save all files by UserConfig#save_all.
yaml2 = uconf['conf2.yaml']
yaml2['new_key'] = 'ABCDE'
uconf.save_all
In internal of UserConfig::YAMLFile, the methods of Hash is called except for some methods.
uconf = UserConfig.new('.some_config')
yaml = uconf['conf.yaml']
yaml.each do |key, val|
...
end
yaml.empty?
Copyright (c) 2011 Takayuki YAMAGUCHI. See LICENSE.txt for further details.
FAQs
Unknown package
We found that user_config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.