Sha256: e5b1b29590338dc293eb89942b248bedf2dcafd95dbae31d10ab4b2f518f96a9
Contents?: true
Size: 979 Bytes
Versions: 1
Compression:
Stored size: 979 Bytes
Contents
module Shhh module App module PrivateKey class Detector < Struct.new(:opts) # :nodoc: @mapping = Hash.new class << self attr_reader :mapping def register(argument, proc) self.mapping[argument] = proc end end def key self.class.mapping.each_pair do |options_key, key_proc| return key_proc.call(self.opts[options_key]) if self.opts[options_key] end nil end end Detector.register :private_key, ->(key) { key } Detector.register :interactive, -> { Input::Handler.prompt('Private Key: ', :magenta) } Detector.register :keychain, ->(key_name) { KeyChain.new(key_name).find } Detector.register :keyfile, ->(file) { begin ::File.read(file) rescue Errno::ENOENT raise Shhh::Errors::FileNotFound.new("Encryption key file #{file} was not found.") end } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shhh-1.3.0 | lib/shhh/app/private_key/detector.rb |