Class: GmVault::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/gmvault/config.rb

Overview

Wrapper around GmVault configuration

Constant Summary

BASE_DIR =

Default location

ENV['HOME'] + '/.gmvault'
DEF_DB =

Default maildb location

ENV['HOME'] + '/Mail/gmvault-db'

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Config) initialize(path = BASE_DIR)

Constructor

Parameters:

  • path (String) (defaults to: BASE_DIR)

    path to the base directory for configuration



28
29
30
# File 'lib/gmvault/config.rb', line 28

def initialize(path = BASE_DIR)
  @path = path
end

Instance Attribute Details

- (Object) path (readonly)

Returns the value of attribute path



19
20
21
# File 'lib/gmvault/config.rb', line 19

def path
  @path
end

Class Method Details

+ (Array) list(path = BASE_DIR)

Class method equiv. to #list

Returns:

  • (Array)

    list of different email addresses



52
53
54
# File 'lib/gmvault/config.rb', line 52

def self.list(path = BASE_DIR)
  self.new(path).list
end

Instance Method Details

- (Array) find_addrs

Looks at all configured email addresses

Returns:

  • (Array)

    list of different email addresses



34
35
36
37
38
39
40
41
42
# File 'lib/gmvault/config.rb', line 34

def find_addrs
  @list = Array.new
  Dir.chdir(@path) do
    Dir['**.oauth'].each do |m|
      @list << m.split('.')[0..-2].join('.')
    end
  end
  @list
end

- (Array) list

Get all configured email addresses

Returns:

  • (Array)

    list of different email addresses



46
47
48
# File 'lib/gmvault/config.rb', line 46

def list
  @list || find_addrs()
end