Class WEBrick::HTTPAuth::Htgroup
In: lib/webrick/httpauth/htgroup.rb
Parent: Object

Methods

add   flush   members   new   reload  

Public Class methods

[Source]

    # File lib/webrick/httpauth/htgroup.rb, line 15
15:       def initialize(path)
16:         @path = path
17:         @mtime = Time.at(0)
18:         @group = Hash.new
19:         open(@path,"a").close unless File::exist?(@path)
20:         reload
21:       end

Public Instance methods

[Source]

    # File lib/webrick/httpauth/htgroup.rb, line 56
56:       def add(group, members)
57:         @group[group] = members(group) | members
58:       end

[Source]

    # File lib/webrick/httpauth/htgroup.rb, line 37
37:       def flush(output=nil)
38:         output ||= @path
39:         tmp = Tempfile.new("htgroup", File::dirname(output))
40:         begin
41:           @group.keys.sort.each{|group|
42:             tmp.puts(format("%s: %s", group, self.members(group).join(" ")))
43:           }
44:           tmp.close
45:           File::rename(tmp.path, output)
46:         rescue
47:           tmp.close(true)
48:         end
49:       end

[Source]

    # File lib/webrick/httpauth/htgroup.rb, line 51
51:       def members(group)
52:         reload
53:         @group[group] || []
54:       end

[Source]

    # File lib/webrick/httpauth/htgroup.rb, line 23
23:       def reload
24:         if (mtime = File::mtime(@path)) > @mtime
25:           @group.clear
26:           open(@path){|io|
27:             while line = io.gets
28:               line.chomp!
29:               group, members = line.split(/:\s*/)
30:               @group[group] = members.split(/\s+/)
31:             end
32:           }
33:           @mtime = mtime
34:         end
35:       end

[Validate]