Sha256: 9538a3a20fa58d8c455e4fe039d1e454325656f9c0e6c637767f5a47806d9ca0

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

module SshConfig
  # SshHost represents a single Host entry in an ssh_config(5)
  class Entry
    attr_reader :user

    def initialize(*names)
      @names = Array(names).flatten.map { |name| String(name) }
    end

    def distinct_names
      @distinct_names ||= begin
        no_ips = @names
          .sort_by(&:length)
          .reject { |name| name =~ /\A\d+\.\d+\.\d+\.\d+\Z/ }

        no_ips
          .reject do |name|
            parts = name.split('.')
            parts.count != 1 && no_ips.include?(parts.first)
          end
      end
    end

    def user=(val)
      @user = String(val)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ssh-host-lister-0.2.1 lib/ssh_config/entry.rb