Class: VPOPMail::Domain

Inherits:
Object
  • Object
show all
Defined in:
lib/vpopmail/domain.rb

Overview


class: Domain {{{ ++ The Domain class represents a virtual domain in vpopmail

Constant Summary collapse

@@logger =

class attribute: logger {{{ ++

nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDomain


method: initialize {{{ ++ Creates a new Domain object



41
42
43
# File 'lib/vpopmail/domain.rb', line 41

def initialize
  @name = @path = ""
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



24
25
26
# File 'lib/vpopmail/domain.rb', line 24

def name
  @name
end

#pathObject

Returns the value of attribute path.



24
25
26
# File 'lib/vpopmail/domain.rb', line 24

def path
  @path
end

Class Method Details

.FindDomains(p_name = nil) ⇒ Object


class method: FindDomains {{{ ++ Finds all virtual domains that match the pattern p_name. If the pattern is not present, finds all virtual domains. Returns an array of Domain objects.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/vpopmail/domain.rb', line 51

def Domain.FindDomains(p_name = nil)
  cmdString = "#{VPOPMail::CFG['VPOP Bin']}/vdominfo -n -d"
  if !p_name.nil? and !p_name.empty? then
    raise ArgumentError unless p_name.kind_of?(String)
    cmdString = cmdString + " #{p_name}"
  end
  cmd = IO.popen(cmdString, "w+")
  cmd.close_write

  domains = Array.new
  domain  = Domain.new
  getName = true
  while line = cmd.gets do
    line = line.gsub(/[\r\n]*$/, "")
    next if line.empty?
    if getName then
      domain.name = line
    else
      domain.path = line
      domains << domain
      domain = Domain.new
    end
    getName = !getName
  end
  return domains
end

.loggerObject



31
# File 'lib/vpopmail/domain.rb', line 31

def self.logger ;            @@logger ; end

.logger=(p_object) ⇒ Object



32
# File 'lib/vpopmail/domain.rb', line 32

def self.logger=(p_object) ; @@logger = p_object ; end

Instance Method Details

#loggerObject



33
# File 'lib/vpopmail/domain.rb', line 33

def logger ;                 @@logger ; end

#logger=(p_object) ⇒ Object



34
# File 'lib/vpopmail/domain.rb', line 34

def logger=(p_object) ;      @@logger = p_object ; end

#postmaster(p_name = 'postmaster') ⇒ Object


method: postmaster {{{ ++ Calculates the default postmaster email address if the Domain. If p_name is present, it will be used instead of ‘postmaster’ Returns a RMail::Address object



84
85
86
# File 'lib/vpopmail/domain.rb', line 84

def postmaster(p_name = 'postmaster')
  return RMail::Address.parse("#{name}@#{@name}")[0]
end

#to_sObject


method: to_s {{{ ++ Returns the String representation of the Domain object



100
101
102
# File 'lib/vpopmail/domain.rb', line 100

def to_s
  return "Domain #{@name} stored in #{@path}"
end

#to_xmlObject


method: to_xml {{{ ++ Returns the REXML::Document that represents the Domain object



92
93
94
# File 'lib/vpopmail/domain.rb', line 92

def to_xml
  return REXML::Document.new("<Domain name=\"#{@name}\" path=\"#{@path}\" />")
end