Class: Savvy::Cert::Config

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

Overview

The Savvy Cert gem Config

Author:

Since:

  • 0.2.0

Version:

  • 0.1

Constant Summary collapse

DEFAULT_CONFIG =

Returns the default configuration options

Since:

  • 0.2.0

{
  ssh_dir: File.join(ENV['HOME'], '.ssh', 'savvy'),
  ssh_key_size: 8192,
  signature_hash_algorithm: 'SHA256'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Savvy::Cert::Config

A new instance of Config

Options Hash (opts):

  • :ssh_dir (String)

    the Config ssh_dir

  • :ssh_key_size (Fixnum)

    the Config ssh_key_size

  • :signature_hash_algorithm (String)

    the Config signature_hash_algorithm

Since:

  • 0.2.0


48
49
50
51
52
# File 'lib/savvy/cert/config.rb', line 48

def initialize(opts = {})
  DEFAULT_CONFIG.each do |k, default|
    instance_variable_set("@#{k}", opts[k] || default)
  end
end

Instance Attribute Details

#signature_hash_algorithmString

Returns the hashing algorithm used for creating signatures

Since:

  • 0.2.0


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/savvy/cert/config.rb', line 32

class Config
  attr_accessor :ssh_dir, :ssh_key_size, :signature_hash_algorithm

  # @return [Hash{Symbol => String | Fixnum}] the default configuration options
  DEFAULT_CONFIG = {
    ssh_dir: File.join(ENV['HOME'], '.ssh', 'savvy'),
    ssh_key_size: 8192,
    signature_hash_algorithm: 'SHA256'
  }.freeze

  # A new instance of Config
  # @param opts [Hash] the options to initialize the Config instance with
  # @option opts [String] :ssh_dir the Config ssh_dir
  # @option opts [Fixnum] :ssh_key_size the Config ssh_key_size
  # @option opts [String] :signature_hash_algorithm the Config signature_hash_algorithm
  # @return [Savvy::Cert::Config] an instance of Config
  def initialize(opts = {})
    DEFAULT_CONFIG.each do |k, default|
      instance_variable_set("@#{k}", opts[k] || default)
    end
  end
end

#ssh_dirString

Returns the ssh directory to persist RSA keys in

Since:

  • 0.2.0


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/savvy/cert/config.rb', line 32

class Config
  attr_accessor :ssh_dir, :ssh_key_size, :signature_hash_algorithm

  # @return [Hash{Symbol => String | Fixnum}] the default configuration options
  DEFAULT_CONFIG = {
    ssh_dir: File.join(ENV['HOME'], '.ssh', 'savvy'),
    ssh_key_size: 8192,
    signature_hash_algorithm: 'SHA256'
  }.freeze

  # A new instance of Config
  # @param opts [Hash] the options to initialize the Config instance with
  # @option opts [String] :ssh_dir the Config ssh_dir
  # @option opts [Fixnum] :ssh_key_size the Config ssh_key_size
  # @option opts [String] :signature_hash_algorithm the Config signature_hash_algorithm
  # @return [Savvy::Cert::Config] an instance of Config
  def initialize(opts = {})
    DEFAULT_CONFIG.each do |k, default|
      instance_variable_set("@#{k}", opts[k] || default)
    end
  end
end

#ssh_key_sizeFixnum

Returns the ssh key size in bytes for new RSA keys

Since:

  • 0.2.0


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/savvy/cert/config.rb', line 32

class Config
  attr_accessor :ssh_dir, :ssh_key_size, :signature_hash_algorithm

  # @return [Hash{Symbol => String | Fixnum}] the default configuration options
  DEFAULT_CONFIG = {
    ssh_dir: File.join(ENV['HOME'], '.ssh', 'savvy'),
    ssh_key_size: 8192,
    signature_hash_algorithm: 'SHA256'
  }.freeze

  # A new instance of Config
  # @param opts [Hash] the options to initialize the Config instance with
  # @option opts [String] :ssh_dir the Config ssh_dir
  # @option opts [Fixnum] :ssh_key_size the Config ssh_key_size
  # @option opts [String] :signature_hash_algorithm the Config signature_hash_algorithm
  # @return [Savvy::Cert::Config] an instance of Config
  def initialize(opts = {})
    DEFAULT_CONFIG.each do |k, default|
      instance_variable_set("@#{k}", opts[k] || default)
    end
  end
end