Skip to content

Instantly share code, notes, and snippets.

@okkez
Created August 21, 2009 14:06
Show Gist options
  • Save okkez/172023 to your computer and use it in GitHub Desktop.
Save okkez/172023 to your computer and use it in GitHub Desktop.
あなろぐ
# -*- coding: utf-8 -*-
require 'rubygems'
require 'rack'
module Rack
class Analog
ANALOG =<<-HTML
<div style="position:absolute;top:0;right:0;border:solid;width:5%;">
アナログ
</div>
HTML
def initialize(app, options = {})
@app = app
end
def call(env)
status, headers, response = @app.call(env)
return [status, headers, response] if Object.const_defined?(:Encoding)
unless response.body[0].gsub!(/<body>/, "<body>\n#{ANALOG}")
response.body << ANALOG
end
[status, headers, response]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment