Sha256: b6940d521a8b62047bb731ac88750f6cc770bda5556dc7433e814fbe91300f77
Contents?: true
Size: 913 Bytes
Versions: 1
Compression:
Stored size: 913 Bytes
Contents
require 'tailog/version' require 'sinatra/base' class File def tail(n) buffer = 1024 idx = size > buffer ? size - buffer : 0 chunks = [] lines = 0 begin seek(idx) chunk = read(buffer) break unless chunk lines += chunk.count("\n") chunks.unshift chunk idx -= buffer end while lines < ( n + 1 ) && idx >= 0 chunks.join('').split(/\n/).last(n) end end module Tailog class << self attr_accessor :log_path end self.log_path = File.expand_path("log", Dir.pwd) class App < Sinatra::Base set :root, File.expand_path("../../app", __FILE__) set :public_folder do "#{root}/assets" end set :views do "#{root}/views" end helpers do def h(text) Rack::Utils.escape_html(text) end end get '/' do if params[:seek] erb :ajax else erb :index end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tailog-0.1.2 | lib/tailog.rb |