Module: CredStash
- Defined in:
- lib/cred_stash.rb,
lib/cred_stash/error.rb,
lib/cred_stash/config.rb,
lib/cred_stash/version.rb
Defined Under Namespace
Classes: Cipher, CipherKey, Config, Error, ItemNotFound, Repository, Secret
Constant Summary
collapse
- VERSION =
"0.4.0"
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
7
8
9
|
# File 'lib/cred_stash/config.rb', line 7
def config
@config ||= Config.new
end
|
3
4
5
|
# File 'lib/cred_stash/config.rb', line 3
def configure
yield config
end
|
.delete(name) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/cred_stash.rb', line 28
def delete(name)
repository = Repository.new
item = repository.select(name).first
repository.delete(item)
end
|
.get(name) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/cred_stash.rb', line 5
def get(name)
secret = Secret.find(name)
if secret.falsified?
raise "Invalid secret. #{name} has falsified"
end
secret.decrypted_value
rescue CredStash::ItemNotFound
nil
end
|
.list ⇒ Object
24
25
26
|
# File 'lib/cred_stash.rb', line 24
def list
Repository.new.list.inject({}) {|h, item| h[item.name] = item.version; h }
end
|
.put(name, value) ⇒ Object
18
19
20
21
22
|
# File 'lib/cred_stash.rb', line 18
def put(name, value)
secret = Secret.new(name: name, value: value)
secret.encrypt!
secret.save
end
|