Class: Group
- Inherits:
- 
      Object
      
        - Object
- Group
 
- Defined in:
- lib/resources/group.rb
Overview
Usage: describe group(‘root’) do
it { should exist }
its('gid') { should eq 0 }
end
deprecated has matcher describe group(‘root’) do
it { should have_gid 0 }
end
Instance Method Summary collapse
- 
  
    
      #exists?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    verifies if a group exists. 
- #gid ⇒ Object
- 
  
    
      #has_gid?(compare_gid)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    implements rspec has matcher, to be compatible with serverspec. 
- 
  
    
      #initialize(groupname, domain = nil)  ⇒ Group 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Group. 
- #local ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(groupname, domain = nil) ⇒ Group
Returns a new instance of Group.
| 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # File 'lib/resources/group.rb', line 26 def initialize(groupname, domain = nil) @group = groupname.downcase @domain = domain @domain = @domain.downcase unless @domain.nil? @cache = nil # select group manager @group_provider = nil if inspec.os.unix? @group_provider = UnixGroup.new(inspec) elsif inspec.os.windows? @group_provider = WindowsGroup.new(inspec) else return skip_resource 'The `group` resource is not supported on your OS yet.' end end | 
Instance Method Details
#exists? ⇒ Boolean
verifies if a group exists
| 45 46 47 48 | # File 'lib/resources/group.rb', line 45 def exists? # ensure that we found one group !group_info.nil? && group_info.size > 0 end | 
#gid ⇒ Object
| 50 51 52 53 54 55 56 57 58 | # File 'lib/resources/group.rb', line 50 def gid return nil if group_info.nil? || group_info.size == 0 # the default case should be one group return group_info[0][:gid] if group_info.size == 1 # return array if we got multiple gids group_info.map { |grp| grp[:gid] } end | 
#has_gid?(compare_gid) ⇒ Boolean
implements rspec has matcher, to be compatible with serverspec
| 61 62 63 | # File 'lib/resources/group.rb', line 61 def has_gid?(compare_gid) gid == compare_gid end | 
#local ⇒ Object
| 65 66 67 68 69 70 71 72 73 | # File 'lib/resources/group.rb', line 65 def local return nil if group_info.nil? || group_info.size == 0 # the default case should be one group return group_info[0][:local] if group_info.size == 1 # return array if we got multiple gids group_info.map { |grp| grp[:local] } end | 
#to_s ⇒ Object
| 75 76 77 | # File 'lib/resources/group.rb', line 75 def to_s "Group #{@group}" end |