Class: Inspec::Resources::Group
- Inherits:
-
Object
- Object
- Inspec::Resources::Group
- Defined in:
- lib/resources/group.rb
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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/resources/group.rb', line 27 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
46 47 48 49 |
# File 'lib/resources/group.rb', line 46 def exists? # ensure that we found one group !group_info.nil? && group_info.size > 0 end |
#gid ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/resources/group.rb', line 51 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
62 63 64 |
# File 'lib/resources/group.rb', line 62 def has_gid?(compare_gid) gid == compare_gid end |
#local ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/resources/group.rb', line 66 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
76 77 78 |
# File 'lib/resources/group.rb', line 76 def to_s "Group #{@group}" end |