Class: BBMB::Util::PopMission
- Inherits:
-
Object
- Object
- BBMB::Util::PopMission
- Defined in:
- lib/bbmb/util/polling_manager.rb
Constant Summary collapse
- @@ptrn =
/name=(?:(?:(?<quote>['"])(?:=\?.+?\?[QB]\?)?(?<file>.*?)(\?=)?(?<!\\)\k<quote>)|(?:(?<file>.+?)(?:;|$)))/i
Instance Attribute Summary collapse
-
#delete ⇒ Object
Returns the value of attribute delete.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
Instance Attribute Details
#delete ⇒ Object
Returns the value of attribute delete.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def delete @delete end |
#host ⇒ Object
Returns the value of attribute host.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def host @host end |
#pass ⇒ Object
Returns the value of attribute pass.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def pass @pass end |
#port ⇒ Object
Returns the value of attribute port.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def port @port end |
#user ⇒ Object
Returns the value of attribute user.
47 48 49 |
# File 'lib/bbmb/util/polling_manager.rb', line 47 def user @user end |
Instance Method Details
#poll(&block) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/bbmb/util/polling_manager.rb', line 49 def poll(&block) Net::POP3.start(@host, @port || 110, @user, @pass) { |pop| pop.each_mail { |mail| poll_mail(mail, &block) } } end |
#poll_mail(mail, &block) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/bbmb/util/polling_manager.rb', line 56 def poll_mail(mail, &block) source = mail.pop ## work around a bug in RMail::Parser that cannot deal with ## RFC-2822-compliant CRLF.. source.gsub!(/\r\n/, "\n") (RMail::Parser.read(source), &block) mail.delete if(@delete) rescue StandardError => err BBMB::Util::Mail.notify_error(err) end |
#poll_message(message, &block) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/bbmb/util/polling_manager.rb', line 66 def (, &block) if(.multipart?) .each_part { |part| (part, &block) } elsif(match = @@ptrn.match(.header["Content-Type"])) block.call(match["file"], .decode) end end |