Class: Scatter::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/scatter/node.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote, name, username, hostname) ⇒ Node

Returns a new instance of Node.



5
6
7
# File 'lib/scatter/node.rb', line 5

def initialize(remote, name, username, hostname)
  @remote, @name, @username, @hostname = remote, name, username, hostname
end

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



3
4
5
# File 'lib/scatter/node.rb', line 3

def hostname
  @hostname
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/scatter/node.rb', line 3

def name
  @name
end

#remoteObject (readonly)

Returns the value of attribute remote.



3
4
5
# File 'lib/scatter/node.rb', line 3

def remote
  @remote
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/scatter/node.rb', line 3

def username
  @username
end

Class Method Details

.decode_from_config(remote, name, config) ⇒ Object



23
24
25
# File 'lib/scatter/node.rb', line 23

def self.decode_from_config(remote, name, config)
  new(remote, name, config['username'], config['hostname'])
end

Instance Method Details

#encode_for_configObject



27
28
29
30
31
32
# File 'lib/scatter/node.rb', line 27

def encode_for_config
  {
    'username' => @username,
    'hostname' => @hostname
  }
end

#full_nameObject



9
10
11
# File 'lib/scatter/node.rb', line 9

def full_name
  [remote.name, name].join('/')
end

#listObject



13
14
15
# File 'lib/scatter/node.rb', line 13

def list
  Scatter::Gemlist.parse(Scatter::Shell.capture("ssh #{@username}@#{@hostname} gem list"))
end

#push(gemfile) ⇒ Object



17
18
19
20
21
# File 'lib/scatter/node.rb', line 17

def push(gemfile)
  Scatter::Shell.execute "scp #{gemfile} #{@username}@#{@hostname}:/tmp"
  Scatter::Shell.execute "ssh #{@username}@#{@hostname} sudo gem install /tmp/#{File.basename(gemfile)} --no-ri --no-rdoc"
  Scatter::Shell.execute "ssh #{@username}@#{@hostname} scatter receive /tmp/#{File.basename(gemfile)}"
end