Sha256: 4add147fb0023048e90e00e33c591c7cebe67197826a288352d5e4a659fa7ef3

Contents?: true

Size: 586 Bytes

Versions: 5

Compression:

Stored size: 586 Bytes

Contents

require 'yaml'
require 'drbqs/config'

module DRbQS
  class SSHHost
    def initialize
      @dir = DRbQS::Config.get_host_file_directory
      @host_files = (Dir.glob("#{@dir}/*.yaml") + Dir.glob("#{@dir}/*.yml")).map { |s| File.basename(s) }
    end

    def get(name)
      if (name.size > 0) && (host = @host_files.find { |s| /^#{name}/ =~ s })
        return File.join(@dir, host)
      end
      return nil
    end
    private :get

    def get_options(name)
      if path = get(name)
        return [path, YAML.load_file(path)]
      end
      return [nil, {}]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
drbqs-0.0.13 lib/drbqs/ssh/host.rb
drbqs-0.0.12 lib/drbqs/ssh/host.rb
drbqs-0.0.11 lib/drbqs/ssh/host.rb
drbqs-0.0.10 lib/drbqs/ssh/host.rb
drbqs-0.0.9 lib/drbqs/ssh/host.rb