[#42915] min(n), max(n), min_by(n), max_by(n) — Tanaka Akira <akr@...>
思ったんですが、
[#42937] Re: Proc#callの別名の提案 — hattorihiroaki1@...
服部裕暁です。
[#42944] [Ruby 1.8-Bug#4230][Open] PlatformSDKのヘッダでビルドするとSocket::getaddrinfoで例外 — Masahiro Kitajima <redmine@...>
Bug #4230: PlatformSDKのヘッダでビルドするとSocket::getaddrinfoで例外
[#42945] [Ruby 1.8-Bug#4231][Open] configure.bat --with-winsock2 が socket/extconf.rbに効いていない — Masahiro Kitajima <redmine@...>
Bug #4231: configure.bat --with-winsock2 が socket/extconf.rbに効いていない
> Bug #4231: configure.bat --with-winsock2 が socket/extconf.rbに効いていない
(2011/01/05 15:04), KOSAKI Motohiro wrote:
[#42970] Re: 特異メソッドの定義の簡略化 — hattorihiroaki1@...
服部裕暁です。
[#43001] Re: Hash#[]の別名(Symbolをキーにして) — hattorihiroaki1@...
服部裕暁です。
[#43027] [Ruby 1.9-Feature#4280][Assigned] SJIS should be an alias of Windows-31J, not of Shift_JIS — Usaku NAKAMURA <redmine@...>
Feature #4280: SJIS should be an alias of Windows-31J, not of Shift_JIS
チケット #4280 が更新されました。 (by Motohiro KOSAKI)
こんにちは、なかむら(う)です。
2011年1月14日16:35 U.Nakamura <usa@garbagecollect.jp>:
こんにちは、なかむら(う)です。
[#43039] ext/openssl development repository — Hiroshi Nakamura <nakahiro@...>
W3J1YnktY29yZTozNDQxNl3jga7ml6XmnKzlkJHjgZHniYjjgafjgZnjgIIKCuacgOi/kU1hcnRp
こんにちは、なかむら(う)です。
遠藤です。
MjAxMS8xLzE0IFl1c3VrZSBFTkRPSCA8bWFtZUB0c2cubmUuanA+Ogo+Pj4gwqAgwqAgwqAgwqAg
こんにちは、なかむら(う)です。
44G+44Go44KB44Oi44O844OJ44Gn44GZ44CCCgoyMDExLzEvMTcgVS5OYWthbXVyYSA8dXNhQGdh
[#43047] Fwd: [ruby-core:33987] [Ruby 1.9-Feature#4222][Open] Irb tab completion support for the valid (but rare) obj::method invocation syntax — Yugui <yugui@...>
=E7=9F=B3=E5=A1=9A=E3=81=95=E3=82=93=E3=80=81
[#43060] [Ruby 1.9-Bug#4287][Open] test_europe_lisbon(TestTimeTZ) Failure — Tomoyuki Chikanaga <redmine@...>
Bug #4287: test_europe_lisbon(TestTimeTZ) Failure
[#43079] [Backport87-Backport#4296][Open] getaddrinfoがOSXで動かない問題をバックポートしてほしい — Takeyuki Fujioka <redmine@...>
Backport #4296: getaddrinfoがOSXで動かない問題をバックポートしてほしい
[#43092] pthread_cond を用いたConditionVariable — keiju@... (Keiju ISHITSUKA)
けいじゅ@いしつかです.
小崎@便乗です
遠藤です。
PiAxLiBkZWFkbG9ja+OBruODgeOCp+ODg+OCr+OBjOOBp+OBjeOBpuOBhOOBquOBhC4gdGhyZWFk
[#43111] Hashのイテレーション中の新規キー追加 — masa <masap.hat@...>
ruby-list の方で同じタイトルで投稿した畠山です。
はじめまして、近永と申します。
[#43139] ext/dbmのデフォルトDBについて — KOSAKI Motohiro <kosaki.motohiro@...>
小崎です
[#43140] Fwd: [ruby-cvs:37153] Ruby:r29960 (trunk): * io.c (struct argf): make lineno long, and reorder members. — Yutaka Kanemoto <kinpoco@...>
金本と申します。
[#43144] 現在 win32 portが壊れています — KOSAKI Motohiro <kosaki.motohiro@...>
遠藤さん
[#43152] RubyのパッチレベルとABI互換 — Takahiro Kambe <taca@...>
こんにちは。
うーむ。なるほど...
> うーむ。なるほど...
[ruby-dev:42922] Remultilingualization of IRB.
Yuguiです。主に石塚さんへ。 [ruby-core:33987]のAbinoamが私に直メールでpt_BRのirb localizatoinを送ってくれました。 日本以外でもirbを母国語で使いたいというニーズはあるでしょうし、こんなこともあろうかとr20862でlib/irb/lc/ja に相当するlocaleサポートファイルをgemで配布して使えるようにしてありました。 "ポルトガル語対応"のようなものは全員が必要とするわけではありませんから、必要な人だけ追加できるほうがよかろうという判断です。ので、irb-pt_BR gemを作るが良かろうという返事をしようと思いました。 ところが、Ruby 1.9.1のhighest version of gemsを$LOAD_PATHに追加するという実装を前提としていたため、Ruby 1.9.2ではこれは機能しなくなっていたようです。 そこで、添付のパッチのようにlib/irb/locale.rbを変更したいと思います。石塚さんの反対がなければコミットしようと思いますがどうでしょうか。 -- Yuki Sonoda (Yugui) yugui@yugui.jp http://yugui.jp
Attachments (1)
commit 4f9106cec43904162d584b512ed7a5ee8839d182
Author: Yuki Sonoda (Yugui) <yugui@yugui.jp>
Date: Sat Jan 1 17:03:45 2011 +0900
* lib/irb/locale.rb (IRB::Locale#search_file): make it possible
to load a localization from a gem.
(IRB::Locale#lc_path): obsoleted because of the change of #search_file
(IRB::Locale#each_localized_path): new private method, based on lc_path
(IRB::Locale#find): follows the change of #search_file.
(IRB::Locale#load): removed duplicate with #find.
diff --git a/ChangeLog b/ChangeLog
index 1ce923a..cab7961 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sat Jan 1 17:02:50 2011 Yuki Sonoda (Yugui) <yugui@yugui.jp>
+
+ * lib/irb/locale.rb (IRB::Locale#search_file): make it possible
+ to load a localization from a gem.
+ (IRB::Locale#lc_path): obsoleted because of the change of #search_file
+ (IRB::Locale#each_localized_path): new private method, based on lc_path
+ (IRB::Locale#find): follows the change of #search_file.
+ (IRB::Locale#load): removed duplicate with #find.
+
Sat Jan 1 11:44:42 2011 Tanaka Akira <akr@fsij.org>
* strftime.c: parenthesize macro arguments.
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
index 9924409..b37ad08 100644
--- a/lib/irb/locale.rb
+++ b/lib/irb/locale.rb
@@ -50,7 +50,7 @@ module IRB
def String(mes)
mes = super(mes)
if @encoding
- mes.encode(@encoding)
+ mes.encode(@encoding, undef: :replace)
else
mes
end
@@ -111,22 +111,27 @@ module IRB
alias toplevel_load load
def load(file, priv=nil)
+ found = find(file)
+ if found
+ return real_load(found, priv)
+ else
+ raise LoadError, "No such file to load -- #{file}"
+ end
+ end
+
+ def find(file , paths = $:)
dir = File.dirname(file)
dir = "" if dir == "."
base = File.basename(file)
- if dir[0] == ?/ #/
- lc_path = search_file(dir, base)
- return real_load(lc_path, priv) if lc_path
- end
-
- for path in $:
- lc_path = search_file(path + "/" + dir, base)
- return real_load(lc_path, priv) if lc_path
+ if dir.start_with?('/')
+ return each_localized_path(dir, base).find{|full_path| File.readable? full_path}
+ else
+ return search_file(paths, dir, base)
end
- raise LoadError, "No such file to load -- #{file}"
end
+ private
def real_load(path, priv)
src = MagicFile.open(path){|f| f.read}
if priv
@@ -135,41 +140,30 @@ module IRB
eval(src, TOPLEVEL_BINDING, path)
end
end
- private :real_load
- def find(file , paths = $:)
- dir = File.dirname(file)
- dir = "" if dir == "."
- base = File.basename(file)
- if dir =~ /^\//
- return lc_path = search_file(dir, base)
- else
- for path in $:
- if lc_path = search_file(path + "/" + dir, base)
- return lc_path
- end
- end
+ # @param paths load paths in which IRB find a localized file.
+ # @param dir directory
+ # @param file basename to be localized
+ #
+ # typically, for the parameters and a <path> in paths, it searches
+ # <path>/<dir>/<locale>/<file>
+ def search_file(lib_paths, dir, file)
+ each_localized_path(dir, file) do |lc_path|
+ lib_paths.each do |libpath|
+ full_path = File.join(libpath, lc_path)
+ return full_path if File.readable?(full_path)
+ end
+ redo if Gem.try_activate(lc_path)
end
nil
end
- def search_file(path, file)
+ def each_localized_path(dir, file)
+ return enum_for(:each_localized_path) unless block_given?
each_sublocale do |lc|
- full_path = path + lc_path(file, lc)
- return full_path if File.exist?(full_path)
- end
- nil
- end
- private :search_file
-
- def lc_path(file = "", lc = @locale)
- if lc.nil?
- LOCALE_DIR + file
- else
- LOCALE_DIR + @lang + "/" + file
+ yield lc.nil? ? File.join(dir, LOCALE_DIR, file) : File.join(dir, LOCALE_DIR, lc, file)
end
end
- private :lc_path
def each_sublocale
if @lang
@@ -186,10 +180,5 @@ module IRB
end
yield nil
end
- private :each_sublocale
end
end
-
-
-
-