Module: Sia

Extended by:
Configurable
Defined in:
lib/sia.rb,
lib/sia/info.rb,
lib/sia/lock.rb,
lib/sia/safe.rb,
lib/sia/error.rb

Overview

Encrypt files with digital safes

Defined Under Namespace

Classes: Error, Lock, Safe

Constant Summary collapse

VERSION =
"0.1.0"
HOMEPAGE =

TODO: Put your gem's website or public repo URL here.

"http://www.example.com/"

Class Method Summary collapse

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.options
# => {: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.

Parameters:

  • opt (Hash)

Returns:

  • (Hash)

See Also:

  • Configurable::DEFAULTS

45
46
47
48
# File 'lib/sia.rb', line 45

def config(**opt)
  @options.merge!(clean_options(opt))
  options
end

.set_default_options!(*specifics) ⇒ Hash

Reset the options to default and return the options

Sia.config(root_dir: '/hi', index_name: 'there')
# => {:root_dir=>'/hi', :index_name=>'there', ...}
Sia.set_default_options!
# => {: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.set_default_options!(:index_name)
# => {:root_dir=>'/hi', :index_name=>".sia_index", ...}

Returns:

  • (Hash)

66
67
68
69
70
71
# File 'lib/sia.rb', line 66

def set_default_options!(*specifics)
  specifics = DEFAULTS.keys if specifics.empty?
  keepers = (@options || {}).slice(*DEFAULTS.keys - specifics)
  @options = defaults.merge(keepers)
  options
end