Class: Scatter::Remote

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Remote

Returns a new instance of Remote.



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

def initialize(name)
  @name = name
  @nodes = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#nodesObject (readonly)

Returns the value of attribute nodes.



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

def nodes
  @nodes
end

Class Method Details

.decode_from_config(name, config) ⇒ Object



20
21
22
23
24
25
# File 'lib/scatter/remote.rb', line 20

def self.decode_from_config(name, config)
  remote = new(name)
  nodes = config['nodes'].collect { |nodename, config| Node.decode_from_config(remote, nodename, config) } rescue []
  remote.nodes.concat(nodes)
  remote
end

Instance Method Details

#encode_for_configObject



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

def encode_for_config
  {
    'nodes' => @nodes.inject({}) { |hash, node| hash[node.name] = node.encode_for_config; hash }
  }
end

#find_node(name) ⇒ Object



16
17
18
# File 'lib/scatter/remote.rb', line 16

def find_node(name)
  nodes.find { |node| node.name == name }
end

#push(gemfile) ⇒ Object



10
11
12
13
14
# File 'lib/scatter/remote.rb', line 10

def push(gemfile)
  @nodes.each do |node|
    node.push(gemfile)
  end
end