Class: Sym::App::PrivateKey::Detector

Inherits:
Struct
  • Object
show all
Defined in:
lib/sym/app/private_key/detector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Detector

Returns a new instance of Detector.



12
13
14
15
# File 'lib/sym/app/private_key/detector.rb', line 12

def initialize(*args)
  super(*args)
  read
end

Instance Attribute Details

#input_handlerObject

Returns the value of attribute input_handler

Returns:

  • (Object)

    the current value of input_handler



9
10
11
# File 'lib/sym/app/private_key/detector.rb', line 9

def input_handler
  @input_handler
end

#keyObject

Returns the value of attribute key.



10
11
12
# File 'lib/sym/app/private_key/detector.rb', line 10

def key
  @key
end

#key_sourceObject

Returns the value of attribute key_source.



10
11
12
# File 'lib/sym/app/private_key/detector.rb', line 10

def key_source
  @key_source
end

#optsObject

Returns the value of attribute opts

Returns:

  • (Object)

    the current value of opts



9
10
11
# File 'lib/sym/app/private_key/detector.rb', line 9

def opts
  @opts
end

#password_cacheObject

Returns the value of attribute password_cache

Returns:

  • (Object)

    the current value of password_cache



9
10
11
# File 'lib/sym/app/private_key/detector.rb', line 9

def password_cache
  @password_cache
end

Instance Method Details

#readObject



17
18
19
20
# File 'lib/sym/app/private_key/detector.rb', line 17

def read
  return key if key
  self.key, self.key_source = read!
end

#read!Object

Returns the first valid 32-bit key obtained by running the above procs on a given string.



24
25
26
27
28
29
30
31
32
33
# File 'lib/sym/app/private_key/detector.rb', line 24

def read!
  KeySourceCheck::CHECKS.each do |source_check|
    next unless result = source_check.detect(self) rescue nil
    if key_ = normalize_key(result.key)
      key_source_ = result.to_s
      return key_, key_source_
    end
  end
  nil
end