Method: Mac::Group#group_get

Defined in:
lib/beaker/host/mac/group.rb

#group_get(name, &block) {|String| ... } ⇒ String

Gets the group information in /etc/group format

Parameters:

  • name (String)

    Name of the group you want

  • block (Proc)

    Additional actions or insertions

Yields:

  • (String)

    The actual mac dscacheutil output

Returns:

  • (String)

    Group information in /etc/group format

Raises:

  • (FailTest)

    Raises an Assertion failure if it can’t find the name queried for in the returned block



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/beaker/host/mac/group.rb', line 31

def group_get(name, &block)
  execute("dscacheutil -q group -a name #{name}") do |result|
    fail_test "failed to get group #{name}" unless result.stdout =~ /^name: #{name}/
    gi = Hash.new  # group info
    result.stdout.each_line { |line|
      pieces = line.split(': ')
      gi[pieces[0].to_sym] = pieces[1].strip if pieces[1] != nil
    }
    answer = "#{gi[:name]}:#{gi[:password]}:#{gi[:gid]}"

    yield answer if block_given?
  end
end