Ramaze の 1.9 対応パッチを書いてみた

Ramaze のドキュメントを見る感じ、Rails よりずっと好みっぽい。Ruby 関係のものは「面白そうなおもちゃ」っぽさが重要ですよね。
しかも 1.9 対応!と聞いて試してみたら、全然テスト通りませんでした。しょうがないのでパッチ。とりあえず LANG=C rake test パスするはず。default external の関係で LANG=ja_JP.UTF-8 rake test は通らないけれど、とりあえず rake gem するのが目的だったのでここまで。
http://ramaze.net/contributing にあるように ramaze@googlegroups.com にメールしてみたんだけど、送れなかったみたい。Google Group には登録したはずなんだけどなあ。From が gmail のメールアドレスじゃないからダメなのかな。よくわからない。しょうがないのでここに晒しておきます。

From 75eca97e8ef5002410018f20b1422a40c2b10b7d Mon Sep 17 00:00:00 2001
From: mame <mame@tsg.ne.jp>
Date: Fri, 17 Oct 2008 22:04:17 +0900
Subject: [PATCH] Catch up change of the behavior of Array#to_s.

---
 lib/ramaze/controller/resolve.rb |    2 ++
 spec/ramaze/params.rb            |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/ramaze/controller/resolve.rb b/lib/ramaze/controller/resolve.rb
index 6cfa096..0ca247a 100644
--- a/lib/ramaze/controller/resolve.rb
+++ b/lib/ramaze/controller/resolve.rb
@@ -208,6 +208,8 @@ module Ramaze
       # longest controller path favoured, then longest action path.
 
       def patterns_for path
+        path = path.join if path.is_a?(Array)
+
         # Split into fragments, and remove empty ones (which split may have output).
         # The to_s is vital as sometimes we are passed an array.
         fragments = path.to_s.split '/'
diff --git a/spec/ramaze/params.rb b/spec/ramaze/params.rb
index dbf7eb4..5140090 100644
--- a/spec/ramaze/params.rb
+++ b/spec/ramaze/params.rb
@@ -51,7 +51,7 @@ class TCParamsController2 < Ramaze::Controller
   end
 
   def keys
-    request.params.keys.to_s.dump
+    request.params.keys.join.dump
   end
 end
 
-- 
1.6.0
From ef4e691ba5395e527044eed6f7542f2584be0326 Mon Sep 17 00:00:00 2001
From: mame <mame@tsg.ne.jp>
Date: Fri, 17 Oct 2008 22:06:45 +0900
Subject: [PATCH] Directly defines ::Fiber#state, etc. without inheritance.

In root fiber, Fiber.current returns an instance of ::Fiber,
not Ramaze::Fiber, which has no Ramaze::Fiber#state.
---
 lib/ramaze/snippets/ramaze/fiber.rb |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/lib/ramaze/snippets/ramaze/fiber.rb b/lib/ramaze/snippets/ramaze/fiber.rb
index 644e5bf..13a3ea0 100644
--- a/lib/ramaze/snippets/ramaze/fiber.rb
+++ b/lib/ramaze/snippets/ramaze/fiber.rb
@@ -1,24 +1,20 @@
 module Ramaze
-  class Fiber < ::Fiber
-    # initialize isn't being called, so we have to hook into ::new
-    def self.new(*args)
-      instance = super
-      instance.state = {}
-      instance
-    end
+  Fiber = ::Fiber
 
+  class ::Fiber
+    # initialize isn't being called, so we have to hook into ::new
     attr_accessor :state
 
     def [](key)
-      @state[key]
+      (@state ||= {})[key]
     end
 
     def []=(key, value)
-      @state[key] = value
+      (@state ||= {})[key] = value
     end
 
     def key?(key)
-      @state.key?(key)
+      (@state ||= {}).key?(key)
     end
   end if defined?(::Fiber)
 end
-- 
1.6.0
From 954bd0862283c9601352d02b4a896952c100f451 Mon Sep 17 00:00:00 2001
From: mame <mame@tsg.ne.jp>
Date: Fri, 17 Oct 2008 22:07:55 +0900
Subject: [PATCH] Pass the reference to Fiber.current.state between threads.

---
 lib/ramaze/snippets/thread/into.rb |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lib/ramaze/snippets/thread/into.rb b/lib/ramaze/snippets/thread/into.rb
index ae6e66b..4f2909b 100644
--- a/lib/ramaze/snippets/thread/into.rb
+++ b/lib/ramaze/snippets/thread/into.rb
@@ -7,10 +7,12 @@ class Thread
   # Copy all thread variables into the new thread
 
   def self.into *args
+    fiber = Fiber.current if Fiber.respond_to?(:current)
     Thread.new(Thread.current, *args) do |thread, *args|
       thread.keys.each do |k|
         Thread.current[k] = thread[k] unless k.to_s =~ /^__/
       end
+      Fiber.current.state = fiber.state if fiber
 
       yield(*args)
     end
-- 
1.6.0
From 1ba7316078306ccfe8eea010d4a3cc4299b6c679 Mon Sep 17 00:00:00 2001
From: mame <mame@tsg.ne.jp>
Date: Fri, 17 Oct 2008 22:08:05 +0900
Subject: [PATCH] Add a magic comment for M17N.

---
 spec/ramaze/gestalt.rb |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/spec/ramaze/gestalt.rb b/spec/ramaze/gestalt.rb
index 57ce262..15dc0dc 100644
--- a/spec/ramaze/gestalt.rb
+++ b/spec/ramaze/gestalt.rb
@@ -1,3 +1,4 @@
+# encoding: UTF-8
 #          Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
 # All files in this distribution are subject to the terms of the Ruby license.
 
-- 
1.6.0