Sha256: c0fc988fed7b82ef3456cc471746e0e0070cdc51fff435faf1fbf98f0d0bf565

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'wukong/script'

class Logline < Struct.new(
  :ip, :date, :time, :http_method, :protocol, :path, :response_code, :duration, :referer, :ua, :tz)

  def page_type
    case
    when path =~ /\.(css|js)$/                  then :asset
    when path =~ /\.(png|gif|ico)$/             then :image
    when path =~ /\.(pl|s?html?|asp|jsp|cgi)$/  then :page
    else                                             :other
    end
  end

  def is_page?
    page_type == :page
  end
end

class PageFilter < Wukong::Streamer::StructStreamer
  def process visit, *args
    yield visit.ua if visit.
  end
end
Wukong.run(PageFilter)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wukong-2.0.0 examples/server_logs/logline.rb