Class: Pechkin::Auth::Manager
- Inherits:
-
Object
- Object
- Pechkin::Auth::Manager
- Defined in:
- lib/pechkin/auth.rb
Overview
Utility class for altering htpasswd files
Instance Attribute Summary collapse
-
#htpasswd ⇒ Object
readonly
Returns the value of attribute htpasswd.
Instance Method Summary collapse
- #add(user, password) ⇒ Object
-
#initialize(htpasswd) ⇒ Manager
constructor
A new instance of Manager.
Constructor Details
#initialize(htpasswd) ⇒ Manager
Returns a new instance of Manager.
9 10 11 |
# File 'lib/pechkin/auth.rb', line 9 def initialize(htpasswd) @htpasswd = htpasswd end |
Instance Attribute Details
#htpasswd ⇒ Object (readonly)
Returns the value of attribute htpasswd.
7 8 9 |
# File 'lib/pechkin/auth.rb', line 7 def htpasswd @htpasswd end |
Instance Method Details
#add(user, password) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/pechkin/auth.rb', line 13 def add(user, password) m = File.exist?(htpasswd) ? HTAuth::File::ALTER : HTAuth::File::CREATE HTAuth::PasswdFile.open(htpasswd, m) do |f| f.add_or_update(user, password, 'md5') end end |