Class: Group

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmo/group.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, accounts) ⇒ Group

Returns a new instance of Group.



2
3
4
5
# File 'lib/cosmo/group.rb', line 2

def initialize name, accounts
  @name = name
  @accounts = accounts
end

Instance Method Details

#accountsObject



27
28
29
# File 'lib/cosmo/group.rb', line 27

def accounts
  @accounts
end

#cp(options = {:files => [], :to => []}) ⇒ Object



43
44
45
46
47
# File 'lib/cosmo/group.rb', line 43

def cp options = {:files => [], :to => []} 
  @accounts.each do ||
    .cp options
  end
end

#dry_run(*commands) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/cosmo/group.rb', line 15

def dry_run *commands
  @accounts.each do ||
    commands.each do |command|
      .dry_run command
    end
  end
end

#localObject



31
32
33
34
35
# File 'lib/cosmo/group.rb', line 31

def local
  locals = []
  @accounts.each {|m| locals.push m if m.local?}
  locals.first
end

#machinesObject



23
24
25
# File 'lib/cosmo/group.rb', line 23

def machines
  @accounts.map {|a| a.machine}.uniq
end

#remotesObject



37
38
39
40
41
# File 'lib/cosmo/group.rb', line 37

def remotes
  remotes = []
  @accounts.each {|m| remotes.push m unless m.local?}
  remotes
end

#run(*commands) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/cosmo/group.rb', line 7

def run *commands
  @accounts.each do ||
    commands.each do |command|
      .run command
    end
  end
end