Module: Sia
- Extended by:
- Configurable
- Defined in:
- lib/sia.rb,
lib/sia/lock.rb,
lib/sia/safe.rb,
lib/sia/error.rb,
lib/sia/version.rb,
lib/sia/persisted_config.rb
Overview
Encrypt files with digital safes
Defined Under Namespace
Modules: Configurable Classes: Error, Lock, PersistedConfig, Safe
Constant Summary collapse
- VERSION =
"0.1.0"
Constants included from Configurable
Class Method Summary collapse
-
.config(**opt) ⇒ Hash
Configure Sia, returning the final options.
-
.persist! ⇒ Object
Persist the current Sia-wide options.
-
.set_default_options!(*specifics, source: :persisted) ⇒ Hash
Reset the options to default and return the options.
Methods included from Configurable
Class Method Details
.config(**opt) ⇒ Hash
Configure Sia, returning the final options
Sia.config(
root_dir: '/path/to/the/safes/',
index_name: 'my_index',
buffer_bytes: 2048,
)
# => {:root_dir=>"/path/to/the/safes/", :index_name=>"my_index", ...}
Allows partial or piecemeal configuration.
Sia.
# => {:root_dir=>"~/.sia_safes"", :index_name=>".sia_index", ...}
Sia.config(root_dir: '/new_dir')
# => {:root_dir=>"/new_dir", :index_name=>".sia_index", ...}
Sia.config(index_name: 'my_index')
# => {:root_dir=>"/new_dir", :index_name=>"my_index", ...}
See Sia::Configurable::DEFAULTS for all available options.
46 47 48 49 |
# File 'lib/sia.rb', line 46 def config(**opt) @options.merge!((opt)) end |
.persist! ⇒ Object
Persist the current Sia-wide options
The next time Sia is loaded it will use the current config values. Consequently, all new safes will use the current configuration as defaults.
57 58 59 |
# File 'lib/sia.rb', line 57 def persist! PersistedConfig.new.persist() end |
.set_default_options!(*specifics, source: :persisted) ⇒ Hash
This change is not persisted.
Reset the options to default and return the options
Sia.config(root_dir: '/hi', index_name: 'there')
# => {:root_dir=>'/hi', :index_name=>'there', ...}
Sia.
# => {:root_dir=>"~/.sia_safes", :index_name=>".sia_index", ...}
With arguments, resets only the option(s) provided
Sia.config(root_dir: '/hi', index_name: 'there')
# => {:root_dir=>'/hi', :index_name=>'there', ...}
Sia.(:index_name)
# => {:root_dir=>'/hi', :index_name=>".sia_index", ...}
Optionally takes a :source
keyword argument that determines whether the
default values should be taken from the gem or from the persisted config.
Values should be either :persisted
or :gem
. Default is :persisted
.
If there is no persisted config the gem defaults are used.
87 88 89 90 91 92 |
# File 'lib/sia.rb', line 87 def (*specifics, source: :persisted) specifics = DEFAULTS.keys if specifics.empty? keepers = (@options || {}).slice(*DEFAULTS.keys - specifics) @options = defaults(source).merge(keepers) end |