equal
deleted
inserted
replaced
68 |
68 |
69 |
69 |
70 ### Returns +true+ if +address+ is a subscriber to this list. |
70 ### Returns +true+ if +address+ is a subscriber to this list. |
71 ### |
71 ### |
72 def include?( addr, section: nil ) |
72 def include?( addr, section: nil ) |
73 addr.downcase! |
73 addr = addr.downcase |
74 file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( addr ) |
74 file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( addr ) |
75 return false unless file.exist? |
75 return false unless file.exist? |
76 return file.read.scan( /T([^\0]+)\0/ ).flatten.include?( addr ) |
76 return file.read.scan( /T([^\0]+)\0/ ).flatten.include?( addr ) |
77 end |
77 end |
78 alias_method :is_subscriber?, :include? |
78 alias_method :is_subscriber?, :include? |
89 ### Subscribe +addr+ to the list within +section+. |
89 ### Subscribe +addr+ to the list within +section+. |
90 ### |
90 ### |
91 def subscribe( *addr, section: nil ) |
91 def subscribe( *addr, section: nil ) |
92 addr.each do |address| |
92 addr.each do |address| |
93 next unless address.index( '@' ) |
93 next unless address.index( '@' ) |
94 address.downcase! |
94 address = address.downcase |
95 |
95 |
96 file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( address ) |
96 file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( address ) |
97 self.with_safety do |
97 self.with_safety do |
98 if file.exist? |
98 if file.exist? |
99 addresses = file.read.scan( /T([^\0]+)\0/ ).flatten |
99 addresses = file.read.scan( /T([^\0]+)\0/ ).flatten |
115 |
115 |
116 ### Unsubscribe +addr+ from the list within +section+. |
116 ### Unsubscribe +addr+ from the list within +section+. |
117 ### |
117 ### |
118 def unsubscribe( *addr, section: nil ) |
118 def unsubscribe( *addr, section: nil ) |
119 addr.each do |address| |
119 addr.each do |address| |
120 address.downcase! |
120 address = address.downcase |
121 |
121 |
122 file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( address ) |
122 file = self.subscription_dir( section ) + Ezmlm::Hash.subscriber( address ) |
123 self.with_safety do |
123 self.with_safety do |
124 next unless file.exist? |
124 next unless file.exist? |
125 addresses = file.read.scan( /T([^\0]+)\0/ ).flatten |
125 addresses = file.read.scan( /T([^\0]+)\0/ ).flatten |