Sha256: 8ba68c28b30b0e6c340a6a853ad37b059c2095ed2b6265f5031dfe3875cbefe9

Contents?: true

Size: 810 Bytes

Versions: 5

Compression:

Stored size: 810 Bytes

Contents

require 'uri'
require 'etc'
require 'forwardable'

require 'chake/backend'

module Chake

  class Node

    extend Forwardable

    attr_reader :hostname
    attr_reader :username
    attr_reader :path
    attr_reader :data

    def initialize(hostname, data = {})
      uri = URI.parse(hostname)
      if !uri.scheme && !uri.host && uri.path
        uri = URI.parse("ssh://#{hostname}")
      end
      if uri.path.empty?
        uri.path = nil
      end

      @backend_name = uri.scheme

      @hostname = uri.hostname
      @username = uri.user || Etc.getpwuid.name
      @path = uri.path || "/tmp/chef.#{username}"
      @data = data
    end

    def backend
      @backend ||= Chake::Backend.get(@backend_name).new(self)
    end

    def_delegators :backend, :run, :run_as_root, :rsync_dest

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chake-0.1.4 lib/chake/node.rb
chake-0.1.3 lib/chake/node.rb
chake-0.1.2 lib/chake/node.rb
chake-0.1.1 lib/chake/node.rb
chake-0.1.0 lib/chake/node.rb