Skip to content

Commit

Permalink
fixed ruby-1.9.2 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyabe authored and komagata committed Oct 19, 2010
1 parent 92982f3 commit 4c853e4
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions lib/lokka.rb
Expand Up @@ -65,29 +65,45 @@ def self.default_external

module Rack
module Utils
alias :escape_org :escape
alias :unescape_org :unescape

def escape(s)
s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
'%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
}.tr(' ', '+')
s.force_encoding(Encoding.default_external)
escape_org(s).force_encoding(Encoding.default_external)
end
def unescape(s)
s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){
[$1.delete('%')].pack('H*')
}
s.force_encoding(Encoding.default_external)
unescape_org(s).force_encoding(Encoding.default_external)
end
end
end

module DataMapper
module Validations
class LengthValidator < GenericValidator
class LengthValidator
alias :value_length_org :value_length
def value_length(value)
value.force_encoding(Encoding.default_external)
value.to_str.split(//u).size
value_length_org(value)
end
end
end
end

module LuckySneaks
module StringExtensions
alias :to_url_org :to_url
def to_url
self.force_encoding(Encoding.default_external)
end
end
end

module Tilt
class Template
alias :render_org :render
def render(scope=Object.new, locals={}, &block)
output = render_org(scope, locals, &block)
output.force_encoding(Encoding.default_external) unless output.nil?
end
end
end

0 comments on commit 4c853e4

Please sign in to comment.