Class: Jekyll::RpLogs::Skype12Parser
- Defined in:
- lib/jekyll/rp_logs/parse_skype_12hour.rb
Overview
This is for the date format [6/12/2015 7:01:45 PM]
Constant Summary collapse
- FORMAT_STR =
Add this class to the parsing dictionary
"Skype12"- NICK =
/(?<nick>[\w\-\\\[\]{}\^`|\s')(]+)/- DATE_REGEXP =
/(?<timestamp>\[\d?\d\/\d?\d\/\d\d\d\d\s\d?\d\:\d\d\:\d\d\s(AM|PM)\])/- TIMESTAMP_FORMAT =
"[%m/%d/%Y %I:%M:%S %p]"- MSG =
/(?<msg>[^\n]*)/- BAD_STUFF =
/[^a-zA-Z\-\_]/- EMOTE =
/^#{FLAGS}#{DATE_REGEXP}\s#{NICK}:\s\k<nick>#{MSG}$/- TEXT =
/^#{FLAGS}#{DATE_REGEXP}\s#{NICK}:\s#{MSG}$/
Constants inherited from Parser
Class Method Summary collapse
Class Method Details
.parse_line(line, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jekyll/rp_logs/parse_skype_12hour.rb', line 18 def self.parse_line(line, = {}) case line when EMOTE type = :rp when TEXT type = :ooc else # Only put text and emotes in the log return nil end # Preserve all the matches before the gsub date = DateTime.strptime($LAST_MATCH_INFO[:timestamp], TIMESTAMP_FORMAT) contents = $LAST_MATCH_INFO[:msg] flags = $LAST_MATCH_INFO[:flags] sendername = $LAST_MATCH_INFO[:nick].tr(" ", "-").gsub(BAD_STUFF, "") LogLine.new( date, , sender: sendername, contents: contents, flags: flags, type: type ) end |