Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Gem introduction

Katharina Sabel edited this page May 24, 2015 · 3 revisions

This document aims to describe how to get started while using reedb as a gem dependency

Add gem 'reedb', '~> 0.9.10' (or any later version) into your Gemfile and make sure reedb is installed on your system before going any further.

As I already hinted require 'reedb' is how it all gets started. Really make sure that you can import that module and it doesn't throw any errors before continuing :)

As you probably know from the Interface Overview, there are a couple of interface provided by Reedb. All of them are their own modules in the larger Reedb namespace.

So to access CORE you use Reedb::Core, to access VAULT you use Reedb::Vault etc. I won't go into all the details about all the functions here but rather show you how to set up your Reedb system to work.

There can only be one Reedb instance running per config. This means that the process doesn't block itself via PID but rather a lock in the master folder. That means that your application could use a completely separate instance of Reedb, provided you also use a different master folder for your configurations.

Please just be sure that you know what you are doing before doing it!

===

In the beginning we need to call Reedb::Core::init( ... ) and I left the parameters blank on purpose because you might want to create a hash to contain all your options. Here they are:

Option Meaning
:os Define the operating system you're working with. :linux, :osx, :win, :other are all applicable.
:pw_length Define the minimum password length that is required for reedb not to bitch at users. Default is 12.
:daemon Boolean to tell Reedb whether it's running as a daemon or not. You can overwrite this but it's usually better to let it handle things by itself.
:verbose Boolean to tell Reedb whether or not it should be verbosely logging things to the default log output
:no_token Boolean to tell Reedb not to use tokens (true ==> NO TOKENS, false ==> TOKENS)
:path Tell Reedb where to put it's master path. Use this to run your own Reedb in a different directory. Default is ~/.config/reedb (on *nix)
:cleanup Boolean to tell Reedb whether or not it should be house-keeping the config file and remove stale vaults.

Let's have a look at some examples and code snippets. For example this init procedure:

require 'reedb'

# These options should be set when using Reedb as a normal dependency
options = {
	:daemon => false, # !!! IMPORTANT !!!
	:os => :something, # Pick whichever one applies (:linux, :osx, :win, :other)
	:pw_length => 16, # Is mandatory anyways
	:no_token => true, # Important!
	:path => "/some/path/here" # !!! IMPORTANT !!!
}

Reedb::Core::init(options)

# ... more stuff down below ...

Other values can include :cleanup (boolean) and :verbose (boolean). The options hash defines the run parameters of the Reedb stacks. Explaining them one by one:

  • daemons => false : makes Reedb run as a gem dependency and doesn't use the HTTP interface.
  • os => :something : Tells Reedb on what operating system it's running. :other should be used for mobile.
  • pw_length => X : Tells Reedb what the minimum length of a passphrase should be. Can be overwritten by vaults though!
  • no_token => true . Tells Reedb to not use the token stack. This is currently not implemented but insures future compatibility with versions 0.13 and above!
  • path => "..." : Is probably the most important line. It makes Reedb move away from it's default operation route and allows you to specify your own. Very important if you want to have a different Reedb instance running next to an existing one OR if you're developing on a weird platform (like mobile).
# Make sure to properly shut down Reedb. It will get upset if you don't!
# Literally...it will lock itself up! :s
Reedb::Core::terminate("aliens")
Clone this wiki locally