Class: Omnivault::AbstractVault

Inherits:
Object
  • Object
show all
Defined in:
lib/omnivault/abstract_vault.rb

Direct Known Subclasses

AppleKeychain, PWS

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_name = 'default') ⇒ AbstractVault

Returns a new instance of AbstractVault.

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/omnivault/abstract_vault.rb', line 42

def initialize(_name = 'default')
  raise NotImplementedError, 'Must invoke from subclass'
end

Class Method Details

.for_platform(name = 'default') ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/omnivault/abstract_vault.rb', line 12

def self.for_platform(name = 'default')
  if (/darwin/ =~ RUBY_PLATFORM).nil?
    PWS.new(name)
  else
    AppleKeychain.new(name)
  end
rescue LoadError => e
  puts e.message
  puts e.backtrace
  PWS.new(name)
end

.from_env(name = 'default') ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/omnivault/abstract_vault.rb', line 3

def self.from_env(name = 'default')
  case ENV['VAULT']
  when 'apple', 'keychain', 'AppleKeychain'
    AppleKeychain.new(name)
  when 'pws', 'PWS'
    PWS.new(name)
  end
end

Instance Method Details

#configure_aws!Object

Either aws-sdk and/or aws-sdk-v1 must be required BEFORE calling Omnivault::AbstractVault#configure_aws!



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/omnivault/abstract_vault.rb', line 26

def configure_aws!
  if defined?(Aws)
    require_relative 'v2_credential_provider'

    provider = V2CredentialProvider.new(self)
    Aws.config[:credentials] = provider
  end

  if defined?(AWS)
    require_relative 'v1_credential_provider'

    provider = V1CredentialProvider.new(self)
    AWS.config(credential_provider: provider)
  end
end

#entriesObject

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/omnivault/abstract_vault.rb', line 46

def entries
  raise NotImplementedError, 'Must invoke from subclass'
end

#fetch(key) ⇒ Object



50
51
52
# File 'lib/omnivault/abstract_vault.rb', line 50

def fetch(key)
  entries[key]
end

#remove(_key) ⇒ Object

Raises:

  • (NotImplementedError)


58
59
60
# File 'lib/omnivault/abstract_vault.rb', line 58

def remove(_key)
  raise NotImplementedError, 'Must invoke from subclass'
end

#store(_key, _value) ⇒ Object

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/omnivault/abstract_vault.rb', line 54

def store(_key, _value)
  raise NotImplementedError, 'Must invoke from subclass'
end