Module: Lorca::Phrases

Defined in:
lib/lorca/expansions/phrases.rb

Overview

Built-in Phrases expansion. Adds all necessary dependencies to enable secure random phrases. Intended as a passphrase generator.

It exposes the following instance methods:

phrase

A phrase randomly generated suitable as a passphrase.

Defined Under Namespace

Modules: LorcaPlugin

Constant Summary collapse

MIN_WORDS =

Default minimum number of words a user can request per phrase.

8.freeze
MAX_WORDS =

Default maximum number of words a user can request per phrase.

53.freeze
DICE =

Default number of dice used for rolling a word id. Meant to fit the included vocabulary.

5.freeze
VOCABULARY =

The default vocabulary’s database path.

"#{__dir__}/phrases/eff_large_wordlist"

Class Method Summary collapse

Class Method Details

.configure(expansion, min_words: MIN_WORDS, max_words: MAX_WORDS, dice_to_toss: DICE, vocabulary: VOCABULARY) ⇒ Object

Configure the Lorca::Phrases expansion upon loading.

The following settings are configurable.

min_words

The minimum number of words a user can request per phrase.

max_words

The maximum number of words a user can request per phrase.

dice_to_toss

The number of dice to toss to generate a word id. It should only be changed when switching vocabulary.

vocabulary

The path to the SDBM compatible vocabulary database.



32
33
34
35
36
37
38
39
# File 'lib/lorca/expansions/phrases.rb', line 32

def self.configure expansion, min_words: MIN_WORDS, max_words: MAX_WORDS,
    dice_to_toss: DICE, vocabulary: VOCABULARY
  config = expansion.settings[:phrases] = {}
  config[:min_words] = min_words
  config[:max_words] = max_words
  config[:dice_to_toss] = dice_to_toss
  config[:vocabulary] = vocabulary
end