Skip to content

Instantly share code, notes, and snippets.

View kematzy's full-sized avatar

Kematzy kematzy

View GitHub Profile
## I think these minor changes should fix some of the issues,
diff --git a/irclogger.rb b/irclogger.rb
index 7f5a1fb..b78be3b 100644
--- a/irclogger.rb
+++ b/irclogger.rb
@@ -57,6 +57,7 @@ get '/' do
end
# app1.rb
### APP 1 (Old Style) does work with static files in /public
require 'rubygems'
require 'sinatra'
get '/' do
"Hello world! from Sinatra v#{Sinatra::VERSION}"
# => Hello world! from Sinatra v0.9.0.4
# set the root of the whole app
APP_ROOT = File.expand_path(File.dirname(__FILE__)) unless defined?(APP_ROOT)
# running on Edge?, if so grab that version
# sin_version = 'sinatra-hacked'
sin_version = 'sinatra'
$LOAD_PATH.unshift "#{APP_ROOT}/vendor/#{sin_version}/lib" if File.directory?("#{APP_ROOT}/vendor/#{sin_version}")
# $LOAD_PATH.unshift "#{APP_ROOT}/vendor/sinatras-hat/lib" if File.directory?("#{APP_ROOT}/vendor/sinatras-hat")
CONFUSED SINATRA APP
Basic code is this: [http://gist.github.com/57920] with the following at the top
of the file:
# set the root of the whole app
APP_ROOT = File.expand_path(File.dirname(__FILE__)) unless defined?(APP_ROOT)
# running on Edge?, if so grab that version
$LOAD_PATH.unshift "#{APP_ROOT}/vendor/sinatra/lib" if test(?d, "#{APP_ROOT}/vendor/sinatra")
### NOTES
# This simple cache extension/class works fine in classic_app.rb below.
#
# However, when trying it in the new_app.rb (sub-classed Sinatra) it throws:
#
# NoMethodError: undefined method ‘set’ for Sinatra::Cache:Module
#
# Been re-reading [ http://www.sinatrarb.com/extensions.html ] but still not been able to work out
# what's wrong inside this code.
#
SINATRA EXTENSIONS & CONFIGURATION OPTIONS:: ( 2009-02-10 22:31 )
Tests made with Edge Sinatra version ( commit 4ab3b3bfcb66ace4f14b35b5d4b259be3742513f )
This is the description of this problem, three (3) test scenarios below:
===========================================================
CASE 1: Classic.rb (Classic Sinatra App)
===========================================================
require 'rubygems'
require 'sinatra/base'
module Sinatra
module AttrAccessorBug
# NB!! Using attr_accessor causes this error:
#
# SyntaxError: compile error (__DELEGATE__):2: syntax error, unexpected ',', expecting '=' ::Sinatra::Application.attr_accessor_bug_last=(*args, &b) ^
#
From 4325bb5e77976ba4dff46434aa0860b80d8c6952 Mon Sep 17 00:00:00 2001
From: kematzy <kematzy@gmail.com>
Date: Tue, 7 Apr 2009 14:21:13 +0800
Subject: [PATCH] [PATCH] Minor code fixes to remove un-necessary Ruby warnings when running scripts with the 'ruby -wKU' options
-- warning: `*' interpreted as argument prefix
-- warning: StringScanner#matchedsize is obsolete; use #matched_size instead
-- warning: instance variable @else not initialized
There's still an issue of warnings output on eval(), but can't work out where that comes from.
(eval):25: warning: statement not reached
From c579d6ab6d827bdff888bf143424353b70cc25ca Mon Sep 17 00:00:00 2001
From: kematzy <kematzy gmail com>
Date: Tue, 7 Apr 2009 13:54:23 +0800
Subject: [PATCH] [SASS] Bug fix: Fixing multiple duplicate paths in the Sass::Engine.options[:load_paths] value.
After one request the :load_paths value is:
:load_paths=>["./test/sass/templates", "./test/sass/more_templates"]
However, after a number of consecutive requests the :load_paths value becomes:
#!/usr/bin/env ruby -wKU
def form(name, attrs={},&block)
content = block.call if block_given?
"<form #{attrs.inspect}>#{content}</form>"
end
def textfield(name, attrs={})
out = "<input type=\"text\" name=\"#{name}\"#{attrs.inspect}>"
end