Class: User
- Inherits:
- 
      Object
      
        - Object
- User
 
- Defined in:
- lib/resources/user.rb
Instance Method Summary collapse
- #deprecated(name, alternative = nil) ⇒ Object
- #exists? ⇒ Boolean
- #gid ⇒ Object
- #group ⇒ Object
- #groups ⇒ Object
- #has_authorized_key?(_compare_key) ⇒ Boolean
- #has_home_directory?(compare_home) ⇒ Boolean
- #has_login_shell?(compare_shell) ⇒ Boolean
- 
  
    
      #has_uid?(compare_uid)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    implements rspec has matcher, to be compatible with serverspec @see: github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers/built_in/has.rb. 
- #home ⇒ Object
- 
  
    
      #initialize(user)  ⇒ User 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of User. 
- 
  
    
      #maxdays  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    returns the maximum days between password changes. 
- 
  
    
      #maximum_days_between_password_change  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    implement ‘maxdays’ method to be compatible with serverspec. 
- 
  
    
      #mindays  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    returns the minimum days between password changes. 
- 
  
    
      #minimum_days_between_password_change  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    implement ‘mindays’ method to be compatible with serverspec. 
- #shell ⇒ Object
- #to_s ⇒ Object
- #uid ⇒ Object
- 
  
    
      #warndays  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    returns the days for password change warning. 
Constructor Details
#initialize(user) ⇒ User
Returns a new instance of User.
| 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # File 'lib/resources/user.rb', line 51 def initialize(user) @user = user # select package manager @user_provider = nil case inspec.os[:family] when 'ubuntu', 'debian', 'redhat', 'fedora', 'centos', 'arch', 'opensuse', 'wrlinux' @user_provider = LinuxUser.new(inspec) when 'windows' @user_provider = WindowsUser.new(inspec) when 'darwin' @user_provider = DarwinUser.new(inspec) when 'freebsd' @user_provider = FreeBSDUser.new(inspec) when 'aix' @user_provider = AixUser.new(inspec) else return skip_resource 'The `user` resource is not supported on your OS yet.' end end | 
Instance Method Details
#deprecated(name, alternative = nil) ⇒ Object
| 149 150 151 | # File 'lib/resources/user.rb', line 149 def deprecated(name, alternative = nil) warn "[DEPRECATION] #{name} is deprecated. #{alternative}" end | 
#exists? ⇒ Boolean
| 72 73 74 | # File 'lib/resources/user.rb', line 72 def exists? !identiy.nil? && !identiy[:user].nil? end | 
#gid ⇒ Object
| 80 81 82 | # File 'lib/resources/user.rb', line 80 def gid identiy.nil? ? nil : identiy[:gid] end | 
#group ⇒ Object
| 84 85 86 | # File 'lib/resources/user.rb', line 84 def group identiy.nil? ? nil : identiy[:group] end | 
#groups ⇒ Object
| 88 89 90 | # File 'lib/resources/user.rb', line 88 def groups identiy.nil? ? nil : identiy[:groups] end | 
#has_authorized_key?(_compare_key) ⇒ Boolean
| 144 145 146 147 | # File 'lib/resources/user.rb', line 144 def (_compare_key) deprecated('has_authorized_key?') fail NotImplementedError end | 
#has_home_directory?(compare_home) ⇒ Boolean
| 134 135 136 137 | # File 'lib/resources/user.rb', line 134 def has_home_directory?(compare_home) deprecated('has_home_directory?', "Please use 'its(:home)'") home == compare_home end | 
#has_login_shell?(compare_shell) ⇒ Boolean
| 139 140 141 142 | # File 'lib/resources/user.rb', line 139 def has_login_shell?(compare_shell) deprecated('has_login_shell?', "Please use 'its(:shell)'") shell == compare_shell end | 
#has_uid?(compare_uid) ⇒ Boolean
implements rspec has matcher, to be compatible with serverspec @see: github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers/built_in/has.rb
| 129 130 131 132 | # File 'lib/resources/user.rb', line 129 def has_uid?(compare_uid) deprecated('has_uid?') uid == compare_uid end | 
#home ⇒ Object
| 92 93 94 | # File 'lib/resources/user.rb', line 92 def home .nil? ? nil : [:home] end | 
#maxdays ⇒ Object
returns the maximum days between password changes
| 106 107 108 | # File 'lib/resources/user.rb', line 106 def maxdays credentials.nil? ? nil : credentials[:maxdays] end | 
#maximum_days_between_password_change ⇒ Object
implement ‘maxdays’ method to be compatible with serverspec
| 122 123 124 125 | # File 'lib/resources/user.rb', line 122 def maximum_days_between_password_change deprecated('maximum_days_between_password_change', "Please use 'its(:maxdays)'") maxdays end | 
#mindays ⇒ Object
returns the minimum days between password changes
| 101 102 103 | # File 'lib/resources/user.rb', line 101 def mindays credentials.nil? ? nil : credentials[:mindays] end | 
#minimum_days_between_password_change ⇒ Object
implement ‘mindays’ method to be compatible with serverspec
| 116 117 118 119 | # File 'lib/resources/user.rb', line 116 def minimum_days_between_password_change deprecated('minimum_days_between_password_change', "Please use 'its(:mindays)'") mindays end | 
#shell ⇒ Object
| 96 97 98 | # File 'lib/resources/user.rb', line 96 def shell .nil? ? nil : [:shell] end | 
#to_s ⇒ Object
| 153 154 155 | # File 'lib/resources/user.rb', line 153 def to_s "User #{@user}" end | 
#uid ⇒ Object
| 76 77 78 | # File 'lib/resources/user.rb', line 76 def uid identiy.nil? ? nil : identiy[:uid] end | 
#warndays ⇒ Object
returns the days for password change warning
| 111 112 113 | # File 'lib/resources/user.rb', line 111 def warndays credentials.nil? ? nil : credentials[:warndays] end |