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.
6 7 8 |
# File 'lib/pechkin/auth.rb', line 6 def initialize(htpasswd) @htpasswd = htpasswd end |
Instance Attribute Details
#htpasswd ⇒ Object (readonly)
Returns the value of attribute htpasswd.
5 6 7 |
# File 'lib/pechkin/auth.rb', line 5 def htpasswd @htpasswd end |
Instance Method Details
#add(user, password) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/pechkin/auth.rb', line 10 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 |