Sha256: bc88a6903eb0e581c37006f0b16bc5ed72233fb4ad6d8c8e95659538bd0c7bf7

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 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(&:count)
          .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

2 entries across 2 versions & 1 rubygems

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