aboutsummaryrefslogtreecommitdiff
path: root/lib/hosts.rb
blob: 1a0fc27c3c8e51150675a388b33734c7f0434269 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module SSHConfig
  class Hosts
    attr_reader :hosts

    def initialize(&block)
      @hosts = []
      self.instance_eval(&block)
    end

    def merge(morehosts)
      @hosts += morehosts.hosts
    end

    def host(name)
      @hosts << Host.new(name, &Proc.new)
    end

    def to_s
      @hosts.map(&:to_s).join("\n")
    end
  end
end