Class: SSH::Ident::Config
- Inherits:
-
Object
- Object
- SSH::Ident::Config
- Defined in:
- lib/ssh/ident/config.rb
Overview
ssh ident config
Class Method Summary collapse
Instance Method Summary collapse
- #get(param) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load ⇒ Object
- #set(param, value) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
18 19 20 |
# File 'lib/ssh/ident/config.rb', line 18 def initialize @values = load end |
Class Method Details
.defaults ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/ssh/ident/config.rb', line 8 def self.defaults { 'FILE_USER_CONFIG' => "#{ENV['HOME']}/.ssh-ident", 'DIR_IDENTITIES' => "#{ENV['HOME']}/.ssh/identities", 'DIR_AGENTS' => "#{ENV['HOME']}/.ssh/agents", 'DEFAULT_IDENTITY' => "#{ENV['USER']}", 'SSH_ADD_OPTIONS' => '-t 7200' } end |
Instance Method Details
#get(param) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/ssh/ident/config.rb', line 31 def get(param) result = ENV[param] result ||= @values[param] if @values result ||= Config.defaults[param] fail "failed to find parameter #{param}" if result.nil? return File.(result) if result.is_a?(String) && result.include?('~') result end |
#load ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/ssh/ident/config.rb', line 22 def load if respond_to?(:load_custom) return load_custom end path = get('FILE_USER_CONFIG') return {} unless File.exist?(path) YAML.load(File.read(path)) end |
#set(param, value) ⇒ Object
40 41 42 |
# File 'lib/ssh/ident/config.rb', line 40 def set(param, value) @values[param] = value end |