class JobsFeed < Feed require 'PP' def initialize( link, token=nil, regex=nil ) super( link, token, "^Jobs:(.*)" ) end def buildFeed( date ) # setup Iconv to translate most everything to UTF8 trans = Iconv.new('UTF-8//IGNORE', 'LATIN1' ) @rss = RSS::Maker.make( version ) do |m| m.channel.title = title m.channel.link = link m.channel.description = description m.items.do_sort = true end changes = $p4.run_jobs( "-e modifieddate>" + date + " " + match[1] ) changes.each do |c| next if( !isValidJob?( c ) ) i = RSS::Rss::Channel::Item.new( ) i.title = c["Job"] + ": " + truncate_cleanly( trans.iconv(c["Description"]) ) i.link = @link + c["Job"] + "?ac=111" i.date = Time.parse( c["ModifiedDate"] ) i.description = "" + c["Status"] + " " + c["Subsystem"] + " " + c["Severity"] + " " + c["Type"] + " modified by " + c["ModifiedBy"] + "

" # + "

" + c["Description"].gsub(/[\a\b\e]/, "") + "
" # add some diffs begin pd = i.date - 30 fd = i.date + 30 fpd = pd.strftime("%Y/%m/%d:%H:%M:%S") ffd = fd.strftime("%Y/%m/%d:%H:%M:%S") diff = $p4.run_diff2( "//spec/job/" + c["Job"] + "@" + fpd, "//spec/job/" + c["Job"] + "@" + ffd ) if( diff[0]["status"] == "content" ) # turn off tagged output $p4.tagged = false # run diff diff = $p4.run_diff2( "-dv", "//spec/job/" + c["Job"] + "@" + fpd, "//spec/job/" + c["Job"] + "@" + ffd ) i.description += "

Diffs:" diff.shift i.description += "

" 
                    diff.each do |d|
                        trans.iconv(d).gsub(/[\a\b\e]/, "").each_line do |l|
                            if( l.start_with?( "#" ) )
                                next
                            end
                            i.description += l
                        end
                    end
                    i.description += "
" # turn on tagged output $p4.tagged = true else i.description += "
" + trans.iconv(c["Description"]).gsub(/[\a\b\e]/, "") + "
" # add in the blog field if( c["P4Blog"] && c["P4Blog"].length > 0 ) i.description += "

P4Blog:" i.description += "

" + trans.iconv(c["P4Blog"]).gsub(/[\a\b\e]/, "") + "
" end # add in the callnumbers field if( c["CallNumbers"] && c["CallNumbers"].length > 0 ) i.description += "

Call Numbers:" i.description += "

" 
                    
                         c["CallNumbers"].gsub(/[\a\b\e]/, "").each_line("\n") {|l|
                             i.description += "" + l + ""
                         }
                    
                        i.description += "
" end # add in the customers field if( c["Customers"] && c["Customers"].length > 0 ) i.description += "

Customers:" i.description += "

" + trans.iconv(c["Customers"]).gsub(/[\a\b\e]/, "") + "
" end end rescue end @rss.items << i end end def isValidJob?( job ) result = false if( true ) result = true end result end def title if( match != nil ) "Jobs matching " + match[1] else @title end end def description if( match != nil ) "Jobs matching " + match[1] else @description end end end begin $ids["Jobs:"] = JobsFeed.method( 'new' ) end