Class: UserAttr

Inherits:
Object show all
Defined in:
lib/puppet/util/user_attr.rb

Class Method Summary collapse

Class Method Details

.get_attributes_by_name(name) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/puppet/util/user_attr.rb', line 2

def self.get_attributes_by_name(name)
  attributes = nil

  File.readlines('/etc/user_attr').each do |line|
    next if line =~ /^#/

    token = line.split(':')

    if token[0] == name
      attributes = {:name => name}
      token[4].split(';').each do |attr|
        key_value = attr.split('=')
        attributes[key_value[0].intern] = key_value[1].strip
      end
      break
    end
  end
  attributes
end