From 3fa9a0549b38f8e2a31b50db6582cc2e8c16a41e Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Thu, 12 May 2005 08:35:15 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'v1_8_3_preview1'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_3_preview1@8439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/README.ActiveTcl | 49 --- ext/tk/lib/tcltk.rb | 367 -------------------- ext/tk/old-README.tcltklib.eucj | 159 --------- ext/tk/sample/tcltklib/batsu.gif | Bin 538 -> 0 bytes ext/tk/sample/tcltklib/lines0.tcl | 42 --- ext/tk/sample/tcltklib/lines1.rb | 50 --- ext/tk/sample/tcltklib/lines2.rb | 54 --- ext/tk/sample/tcltklib/lines3.rb | 54 --- ext/tk/sample/tcltklib/lines4.rb | 54 --- ext/tk/sample/tcltklib/maru.gif | Bin 481 -> 0 bytes ext/tk/sample/tcltklib/safeTk.rb | 22 -- ext/tk/sample/tcltklib/sample0.rb | 39 --- ext/tk/sample/tcltklib/sample1.rb | 634 ---------------------------------- ext/tk/sample/tcltklib/sample2.rb | 451 ------------------------ ext/tk/tkutil/.cvsignore | 3 - ext/tk/tkutil/depend | 1 - ext/tk/tkutil/extconf.rb | 4 - lib/net/https.rb | 171 --------- lib/xmlrpc/.document | 1 - misc/ruby-electric.el | 200 ----------- test/ruby/test_super.rb | 88 ----- test/xmlrpc/data/bug_bool.expected | 3 - test/xmlrpc/data/bug_bool.xml | 8 - test/xmlrpc/data/bug_cdata.expected | 3 - test/xmlrpc/data/bug_cdata.xml | 8 - test/xmlrpc/data/bug_covert.expected | 10 - test/xmlrpc/data/bug_covert.xml | 6 - test/xmlrpc/data/datetime_iso8601.xml | 8 - test/xmlrpc/data/fault.xml | 16 - test/xmlrpc/data/value.expected | 7 - test/xmlrpc/data/value.xml | 22 -- test/xmlrpc/data/xml1.expected | 243 ------------- test/xmlrpc/data/xml1.xml | 1 - test/xmlrpc/test_datetime.rb | 159 --------- test/xmlrpc/test_features.rb | 48 --- test/xmlrpc/test_marshal.rb | 93 ----- test/xmlrpc/test_parser.rb | 85 ----- test/xmlrpc/test_webrick_server.rb | 92 ----- test/xmlrpc/webrick_testing.rb | 37 -- 39 files changed, 3292 deletions(-) delete mode 100644 ext/tk/README.ActiveTcl delete mode 100644 ext/tk/lib/tcltk.rb delete mode 100644 ext/tk/old-README.tcltklib.eucj delete mode 100644 ext/tk/sample/tcltklib/batsu.gif delete mode 100644 ext/tk/sample/tcltklib/lines0.tcl delete mode 100644 ext/tk/sample/tcltklib/lines1.rb delete mode 100644 ext/tk/sample/tcltklib/lines2.rb delete mode 100644 ext/tk/sample/tcltklib/lines3.rb delete mode 100644 ext/tk/sample/tcltklib/lines4.rb delete mode 100644 ext/tk/sample/tcltklib/maru.gif delete mode 100644 ext/tk/sample/tcltklib/safeTk.rb delete mode 100644 ext/tk/sample/tcltklib/sample0.rb delete mode 100644 ext/tk/sample/tcltklib/sample1.rb delete mode 100644 ext/tk/sample/tcltklib/sample2.rb delete mode 100644 ext/tk/tkutil/.cvsignore delete mode 100644 ext/tk/tkutil/depend delete mode 100644 ext/tk/tkutil/extconf.rb delete mode 100644 lib/net/https.rb delete mode 100644 lib/xmlrpc/.document delete mode 100644 misc/ruby-electric.el delete mode 100644 test/ruby/test_super.rb delete mode 100644 test/xmlrpc/data/bug_bool.expected delete mode 100644 test/xmlrpc/data/bug_bool.xml delete mode 100644 test/xmlrpc/data/bug_cdata.expected delete mode 100644 test/xmlrpc/data/bug_cdata.xml delete mode 100644 test/xmlrpc/data/bug_covert.expected delete mode 100644 test/xmlrpc/data/bug_covert.xml delete mode 100644 test/xmlrpc/data/datetime_iso8601.xml delete mode 100644 test/xmlrpc/data/fault.xml delete mode 100644 test/xmlrpc/data/value.expected delete mode 100644 test/xmlrpc/data/value.xml delete mode 100644 test/xmlrpc/data/xml1.expected delete mode 100644 test/xmlrpc/data/xml1.xml delete mode 100644 test/xmlrpc/test_datetime.rb delete mode 100644 test/xmlrpc/test_features.rb delete mode 100644 test/xmlrpc/test_marshal.rb delete mode 100644 test/xmlrpc/test_parser.rb delete mode 100644 test/xmlrpc/test_webrick_server.rb delete mode 100644 test/xmlrpc/webrick_testing.rb diff --git a/ext/tk/README.ActiveTcl b/ext/tk/README.ActiveTcl deleted file mode 100644 index 3afb3f4cf6..0000000000 --- a/ext/tk/README.ActiveTcl +++ /dev/null @@ -1,49 +0,0 @@ -ActiveTcl is ActiveState's quality-assured distribution of Tcl. - -# see -# - -If you want to use ActiveTcl binary package as the Tcl/Tk libraries, -please use the following configure options. - - --with-tcl-dir= - --with-tk-dir= - -And use the followings if you need. - - --with-tcllib= - --with-tklib= - --enable-tcltk-stubs - -For example, when you install ActiveTcl-8.4.x to '/usr/local/ActiveTcl', - - configure --with-tcl-dir=/usr/local/ActiveTcl/ \ - --with-tk-dir=/usr/local/ActiveTcl/ \ - --with-tcllib=tclstub8.4 \ - --with-tklib=tkstub8.4 \ - --enable-tcltk-stubs - -It depends on your environment that you have to add the directory of -ActiveTcl's libraries to your library path when execute Ruby/Tk. -One of the way is to add entries to TCLLIBPATH environment variable, -and one of the others add to LD_LIBRARY_PATH environment variable - -Probably, using TCLLIBPATH is better. The value is appended at the -head of Tcl's 'auto_path' variable. You can see the value of the -variable by using 'Tk::AUTO_PATH.value' or 'Tk::AUTO_PATH.list'. - -For example, on Linux, one of the ways is to use LD_LIBRARY_PATH -environment variable. -------------------------------------------------------------------------- - [bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH \ - ruby your-Ruby/Tk-script - - [bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH irb -------------------------------------------------------------------------- -Based on it, the Tcl interpreter changes auto_path variable's value. - -Then, you'll be able to use Tcl/Tk extension libraries included in the -ActiveTcl package (e.g. call TkPackage.require('BWidget'), and then, -use functions/widgets of BWidget extention). - - Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) diff --git a/ext/tk/lib/tcltk.rb b/ext/tk/lib/tcltk.rb deleted file mode 100644 index 1a6694dbff..0000000000 --- a/ext/tk/lib/tcltk.rb +++ /dev/null @@ -1,367 +0,0 @@ -# tof - -#### tcltk library, more direct manipulation of tcl/tk -#### Sep. 5, 1997 Y. Shigehiro - -require "tcltklib" - -################ - -# module TclTk: collection of tcl/tk utilities (supplies namespace.) -module TclTk - - # initialize Hash to hold unique symbols and such - @namecnt = {} - - # initialize Hash to hold callbacks - @callback = {} -end - -# TclTk.mainloop(): call TclTkLib.mainloop() -def TclTk.mainloop() - print("mainloop: start\n") if $DEBUG - TclTkLib.mainloop() - print("mainloop: end\n") if $DEBUG -end - -# TclTk.deletecallbackkey(ca): remove callback from TclTk module -# this does not remove callbacks from tcl/tk interpreter -# without calling this method, TclTkInterpreter will not be GCed -# ca: callback(TclTkCallback) -def TclTk.deletecallbackkey(ca) - print("deletecallbackkey: ", ca.to_s(), "\n") if $DEBUG - @callback.delete(ca.to_s) -end - -# TclTk.dcb(ca, wid, W): call TclTk.deletecallbackkey() for each callbacks -# in an array. -# this is for callback for top-level -# ca: array of callbacks(TclTkCallback) -# wid: top-level widget(TclTkWidget) -# w: information about window given by %W(String) -def TclTk.dcb(ca, wid, w) - if wid.to_s() == w - ca.each{|i| - TclTk.deletecallbackkey(i) - } - end -end - -# TclTk._addcallback(ca): register callback -# ca: callback(TclTkCallback) -def TclTk._addcallback(ca) - print("_addcallback: ", ca.to_s(), "\n") if $DEBUG - @callback[ca.to_s()] = ca -end - -# TclTk._callcallback(key, arg): invoke registered callback -# key: key to select callback (to_s value of the TclTkCallback) -# arg: parameter from tcl/tk interpreter -def TclTk._callcallback(key, arg) - print("_callcallback: ", @callback[key].inspect, "\n") if $DEBUG - @callback[key]._call(arg) - # throw out callback value - # should return String to satisfy rb_eval_string() - return "" -end - -# TclTk._newname(prefix): generate unique name(String) -# prefix: prefix of the unique name -def TclTk._newname(prefix) - # generated name counter is stored in @namecnt - if !@namecnt.key?(prefix) - # first appearing prefix, initialize - @namecnt[prefix] = 1 - else - # already appeared prefix, generate next name - @namecnt[prefix] += 1 - end - return "#{prefix}#{@namecnt[prefix]}" -end - -################ - -# class TclTkInterpreter: tcl/tk interpreter -class TclTkInterpreter - - # initialize(): - def initialize() - # generate interpreter object - @ip = TclTkIp.new() - - # add ruby_fmt command to tcl interpreter - # ruby_fmt command format arguments by `format' and call `ruby' command - # (notice ruby command receives only one argument) - if $DEBUG - @ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt $args\" ; set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }") - else - @ip._eval("proc ruby_fmt {fmt args} { set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }") - end - - # @ip._get_eval_string(*args): generate string to evaluate in tcl interpreter - # *args: script which is going to be evaluated under tcl/tk - def @ip._get_eval_string(*args) - argstr = "" - args.each{|arg| - argstr += " " if argstr != "" - # call to_eval if it is defined - if (arg.respond_to?(:to_eval)) - argstr += arg.to_eval() - else - # call to_s unless defined - argstr += arg.to_s() - end - } - return argstr - end - - # @ip._eval_args(*args): evaluate string under tcl/tk interpreter - # returns result string. - # *args: script which is going to be evaluated under tcl/tk - def @ip._eval_args(*args) - # calculate the string to eval in the interpreter - argstr = _get_eval_string(*args) - - # evaluate under the interpreter - print("_eval: \"", argstr, "\"") if $DEBUG - res = _eval(argstr) - if $DEBUG - print(" -> \"", res, "\"\n") - elsif _return_value() != 0 - print(res, "\n") - end - fail(%Q/can't eval "#{argstr}"/) if _return_value() != 0 #' - return res - end - - # generate tcl/tk command object and register in the hash - @commands = {} - # for all commands registered in tcl/tk interpreter: - @ip._eval("info command").split(/ /).each{|comname| - if comname =~ /^[.]/ - # if command is a widget (path), generate TclTkWidget, - # and register it in the hash - @commands[comname] = TclTkWidget.new(@ip, comname) - else - # otherwise, generate TclTkCommand - @commands[comname] = TclTkCommand.new(@ip, comname) - end - } - end - - # commands(): returns hash of the tcl/tk commands - def commands() - return @commands - end - - # rootwidget(): returns root widget(TclTkWidget) - def rootwidget() - return @commands["."] - end - - # _tcltkip(): returns @ip(TclTkIp) - def _tcltkip() - return @ip - end - - # method_missing(id, *args): execute undefined method as tcl/tk command - # id: method symbol - # *args: method arguments - def method_missing(id, *args) - # if command named by id registered, then execute it - if @commands.key?(id.id2name) - return @commands[id.id2name].e(*args) - else - # otherwise, exception - super - end - end -end - -# class TclTkObject: base class of the tcl/tk objects -class TclTkObject - - # initialize(ip, exp): - # ip: interpreter(TclTkIp) - # exp: tcl/tk representation - def initialize(ip, exp) - fail("type is not TclTkIp") if !ip.kind_of?(TclTkIp) - @ip = ip - @exp = exp - end - - # to_s(): returns tcl/tk representation - def to_s() - return @exp - end -end - -# class TclTkCommand: tcl/tk commands -# you should not call TclTkCommand.new() -# commands are created by TclTkInterpreter:initialize() -class TclTkCommand < TclTkObject - - # e(*args): execute command. returns String (e is for exec or eval) - # *args: command arguments - def e(*args) - return @ip._eval_args(to_s(), *args) - end -end - -# class TclTkLibCommand: tcl/tk commands in the library -class TclTkLibCommand < TclTkCommand - - # initialize(ip, name): - # ip: interpreter(TclTkInterpreter) - # name: command name (String) - def initialize(ip, name) - super(ip._tcltkip, name) - end -end - -# class TclTkVariable: tcl/tk variable -class TclTkVariable < TclTkObject - - # initialize(interp, dat): - # interp: interpreter(TclTkInterpreter) - # dat: the value to set(String) - # if nil, not initialize variable - def initialize(interp, dat) - # auto-generate tcl/tk representation (variable name) - exp = TclTk._newname("v_") - # initialize TclTkObject - super(interp._tcltkip(), exp) - # safe this for `set' command - @set = interp.commands()["set"] - # set value - set(dat) if dat - end - - # although you can set/refer variable by using set in tcl/tk, - # we provide the method for accessing variables - - # set(data): set tcl/tk variable using `set' - # data: new value - def set(data) - @set.e(to_s(), data.to_s()) - end - - # get(): read tcl/tk variable(String) using `set' - def get() - return @set.e(to_s()) - end -end - -# class TclTkWidget: tcl/tk widget -class TclTkWidget < TclTkCommand - - # initialize(*args): - # *args: parameters - def initialize(*args) - if args[0].kind_of?(TclTkIp) - # in case the 1st argument is TclTkIp: - - # Wrap tcl/tk widget by TclTkWidget - # (used in TclTkInterpreter#initialize()) - - # need two arguments - fail("illegal # of parameter") if args.size != 2 - - # ip: interpreter(TclTkIp) - # exp: tcl/tk representation - ip, exp = args - - # initialize TclTkObject - super(ip, exp) - elsif args[0].kind_of?(TclTkInterpreter) - # in case 1st parameter is TclTkInterpreter: - - # generate new widget from parent widget - - # interp: interpreter(TclTkInterpreter) - # parent: parent widget - # command: widget generating tk command(label 等) - # *args: argument to the command - interp, parent, command, *args = args - - # generate widget name - exp = parent.to_s() - exp += "." if exp !~ /[.]$/ - exp += TclTk._newname("w_") - # initialize TclTkObject - super(interp._tcltkip(), exp) - # generate widget - res = @ip._eval_args(command, exp, *args) -# fail("can't create Widget") if res != exp - # for tk_optionMenu, it is legal res != exp - else - fail("first parameter is not TclTkInterpreter") - end - end -end - -# class TclTkCallback: tcl/tk callbacks -class TclTkCallback < TclTkObject - - # initialize(interp, pr, arg): - # interp: interpreter(TclTkInterpreter) - # pr: callback procedure(Proc) - # arg: string to pass as block parameters of pr - # bind command of tcl/tk uses % replacement for parameters - # pr can receive replaced data using block parameter - # its format is specified by arg string - # You should not specify arg for the command like - # scrollbar with -command option, which receives parameters - # without specifying any replacement - def initialize(interp, pr, arg = nil) - # auto-generate tcl/tk representation (variable name) - exp = TclTk._newname("c_") - # initialize TclTkObject - super(interp._tcltkip(), exp) - # save parameters - @pr = pr - @arg = arg - # register in the module - TclTk._addcallback(self) - end - - # to_eval(): retuens string representation for @ip._eval_args - def to_eval() - if @arg - # bind replaces %s before calling ruby_fmt, so %%s is used - s = %Q/{ruby_fmt {TclTk._callcallback("#{to_s()}", "%%s")} #{@arg}}/ - else - s = %Q/{ruby_fmt {TclTk._callcallback("#{to_s()}", "%s")}}/ - end - - return s - end - - # _call(arg): invoke callback - # arg: callback parameter - def _call(arg) - @pr.call(arg) - end -end - -# class TclTkImage: tcl/tk images -class TclTkImage < TclTkCommand - - # initialize(interp, t, *args): - # generating image is done by TclTkImage.new() - # destrying is done by image delete (inconsistent, sigh) - # interp: interpreter(TclTkInterpreter) - # t: image type (photo, bitmap, etc.) - # *args: command argument - def initialize(interp, t, *args) - # auto-generate tcl/tk representation - exp = TclTk._newname("i_") - # initialize TclTkObject - super(interp._tcltkip(), exp) - # generate image - res = @ip._eval_args("image create", t, exp, *args) - fail("can't create Image") if res != exp - end -end - -# eof diff --git a/ext/tk/old-README.tcltklib.eucj b/ext/tk/old-README.tcltklib.eucj deleted file mode 100644 index fd75202c18..0000000000 --- a/ext/tk/old-README.tcltklib.eucj +++ /dev/null @@ -1,159 +0,0 @@ -(tof) - 2003/06/19 Hidetoshi NAGAI - -本ドキュメントには古い tcltk ライブラリ,tcltklib ライブラリの説明 -が含まれていますが,その記述内容は古いものとなっています. - -まず,現在の Ruby/Tk の中心である tk.rb は wish を呼び出したりはせ -ず,tcltklib ライブラリを wrap して動作するものとなっています.その -ため,古い説明記述で述べられているようなプロセス間通信によるオーバ -ヘッドは存在しません. - -現在の tcltklib ライブラリでも,Tcl/Tk の C ライブラリをリンクして -直接に動かすことで,オーバヘッドを押さえつつ Tcl/Tk インタープリタ -のほぼ全機能(拡張ライブラリを含む)を使える点は同じです.しかし, -その役割はほぼ「tk.rb 以下のライブラリを効果的に働かせるためのもの」 -と見なされており,その目的でメンテナンスされています. - -tk.rb の高機能化に伴って,中水準のライブラリである tcltk ライブラリ -(tcltk.rb)はその存在意義を減じており,現在ではメンテナンスは行わ -れていません. - -なお,古い説明ではバインディングにおけるスクリプトの追加はできないこ -ととなっていますが,現在の tk.rb ではこれも可能であることを補足して -おきます. - -以下がライブラリの古い説明文書です. -============================================================== - tcltk ライブラリ - tcltklib ライブラリ - Sep. 19, 1997 Y. Shigehiro - -以下, 「tcl/tk」という表記は, tclsh や wish を実現している, 一般でいう -ところの tcl/tk を指します. 「tcltk ライブラリ」, 「tcltklib ライブラ -リ」という表記は, 本パッケージに含まれる ruby 用のライブラリを指します. - -[ファイルについて] - -README.euc : このファイル(注意, 特徴, インストールの方法). -MANUAL.euc : マニュアル. - -lib/, ext/ : ライブラリの実体. - -sample/ : マニュアル代わりのサンプルプログラム. -sample/sample0.rb : tcltklib ライブラリのテスト. -sample/sample1.rb : tcltk ライブラリのテスト. - tcl/tk (wish) でできそうなことを一通り書いてみました. -sample/sample2.rb : tcltk ライブラリのサンプル. - maeda shugo (shugo@po.aianet.ne.jp) 氏による - (`rb.tk' で書かれていた) ruby のサンプルプログラム - http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz - を tcltk ライブラリを使うように, 機械的に変更してみました. - -demo/ : 100 本の線を 100 回描くデモプログラム. - 最初に空ループの時間を測定し, 続いて実際に線を引く時間を測定します. - tcl/tk は(再)描画のときに backing store を使わずに律義に 10000 本(?) - 線を引くので, (再)描画を始めると, マシンがかなり重くなります. -demo/lines0.tcl : wish 用のスクリプト. -demo/lines1.rb : `tk.rb' 用のスクリプト. -demo/lines2.rb : tcltk ライブラリ用のスクリプト. - -[注意] - -コンパイル/実行には, tcl/tk の C ライブラリが必要です. - -このライブラリは, - - ruby-1.0-970701, ruby-1.0-970911, ruby-1.0-970919 - FreeBSD 2.2.2-RELEASE - およびそのパッケージ jp-tcl-7.6.tgz, jp-tk-4.2.tgz - -で作成/動作確認しました. 他の環境では動作するかどうかわかりません. - -TclTkLib.mainloop を実行中に Control-C が効かないのは不便なので, ruby -のソースを参考に, #include "sig.h" して trap_immediate を操作していま -すが, ruby の README.EXT にも書いてないのに, こんなことをして良いのか -どうかわかりません. - --d オプションでデバッグ情報を表示させるために, ruby のソースを参考に, -debug という大域変数を参照していますが, ruby の README.EXT にも書いて -ないのに, こんなことをして良いのかどうかわかりません. - -extconf.rb は書きましたが, (いろいろな意味で)これで良いのか良く分かり -ません. - -[特徴] - -ruby から tcl/tk ライブラリを利用できます. - -tcl/tk インタプリタのスクリプトは, 機械的に tcltk ライブラリ用の ruby -スクリプトに変換できます. - -(`tk.rb' との違い) - -1. tcl/tk インタプリタのスクリプトが, どのように, tcltk ライブラリ用の - ruby スクリプトに変換されるかが理解できれば, マニュアル類が無いに等 - しい `tk.rb' とは異なり - - tcl/tk のマニュアルやオンラインドキュメントを用いて - - 効率良くプログラミングを行うことができます. - 記述方法がわからない, コマンドに与えるパラメータがわからない... - - Canvas.new { ... } と, なぜイテレータブロックを書けるの?? - - Canvas の bbox は数値のリストを返すのに, xview は文字列を返すの?? - と, いちいち, ライブラリのソースを追いかける必要はありません. - -2. 個々の機能(オプション)を個別処理によりサポートしており, そのためサ - ポートしていない機能は使うことができない(本当は使えないこともないの - ですが) `tk.rb' とは異なり, tcl/tk インタプリタで可能なことは - - ほとんど - - ruby からも実行できます. 現在, ruby から実行できないことが確認され - ているのは, - - bind コマンドでスクリプトを追加する構文 - 「bind tag sequence +script」 - ^ - - のみです. - - `. configure -width' をしようとして, `Tk.root.height()' と書い - たのに, `undefined method `height'' と怒られてしまった. tk.rb を - 読んでみて, ガーン. できないのか... - ということはありません. - -3. wish プロセスを起動しプロセス間通信で wish を利用する `tk.rb' とは - 異なり, tcl/tk の C ライブラリをリンクし - - より高速に (といっても, 思った程は速くないですが) - - 処理を行います. - -4. `tk.rb' ほど, 高水準なインターフェースを備えていないため, tcl/tk イ - ンタプリタの生成等 - - 何から何まで自分で記述 - - しなければなりません(その代わり, tcl/tk ライブラリの仕様通り, - tcl/tk インタプリタを複数生成することもできますが). - インターフェースは(おそらく) ruby の思想に沿ったものではありません. - また, スクリプトの記述は - - ダサダサ - - です. スクリプトは, 一見, 読みづらいものとなります. が, 書く人にとっ - ては, それほど煩わしいものではないと思います. - -[インストールの方法] - -0. ruby のソースファイル(ruby-1.0-なんたら.tgz)を展開しておきます. - -1. ruby-1.0-なんたら/ext に ext/tcltklib をコピーします. - cp -r ext/tcltklib ???/ruby-1.0-なんたら/ext/ - -2. ruby のインストール法に従い make 等をします. - -3. ruby のライブラリ置場に lib/* をコピーします. - cp lib/* /usr/local/lib/ruby/ - -(eof) diff --git a/ext/tk/sample/tcltklib/batsu.gif b/ext/tk/sample/tcltklib/batsu.gif deleted file mode 100644 index 880cc73e09..0000000000 Binary files a/ext/tk/sample/tcltklib/batsu.gif and /dev/null differ diff --git a/ext/tk/sample/tcltklib/lines0.tcl b/ext/tk/sample/tcltklib/lines0.tcl deleted file mode 100644 index 8ed3c5e1c1..0000000000 --- a/ext/tk/sample/tcltklib/lines0.tcl +++ /dev/null @@ -1,42 +0,0 @@ -#! /usr/local/bin/wish - -proc drawlines {} { - puts [clock format [clock seconds]] - - for {set j 0} {$j < 100} {incr j} { - puts -nonewline "*" - flush stdout - if {$j & 1} { - set c "blue" - } { - set c "red" - } - for {set i 0} {$i < 100} {incr i} { -# .a create line $i 0 0 [expr 500 - $i] -fill $c - } - } - - puts [clock format [clock seconds]] - - for {set j 0} {$j < 100} {incr j} { - puts -nonewline "*" - flush stdout - if {$j & 1} { - set c "blue" - } { - set c "red" - } - for {set i 0} {$i < 100} {incr i} { - .a create line $i 0 0 [expr 500 - $i] -fill $c - } - } - - puts [clock format [clock seconds]] -# destroy . -} - -canvas .a -height 500 -width 500 -button .b -text draw -command drawlines -pack .a .b -side left - -# eof diff --git a/ext/tk/sample/tcltklib/lines1.rb b/ext/tk/sample/tcltklib/lines1.rb deleted file mode 100644 index 9f21ae6377..0000000000 --- a/ext/tk/sample/tcltklib/lines1.rb +++ /dev/null @@ -1,50 +0,0 @@ -#! /usr/local/bin/ruby - -require "tcltk" - -def drawlines() - print Time.now, "\n" - - for j in 0 .. 99 - print "*" - $stdout.flush - if (j & 1) != 0 - col = "blue" - else - col = "red" - end - for i in 0 .. 99 -# $a.e("create line", i, 0, 0, 500 - i, "-fill", col) - end - end - - print Time.now, "\n" - - for j in 0 .. 99 - print "*" - $stdout.flush - if (j & 1) != 0 - col = "blue" - else - col = "red" - end - for i in 0 .. 99 - $a.e("create line", i, 0, 0, 500 - i, "-fill", col) - end - end - - print Time.now, "\n" -# $ip.commands()["destroy"].e($root) -end - -$ip = TclTkInterpreter.new() -$root = $ip.rootwidget() -$a = TclTkWidget.new($ip, $root, "canvas", "-height 500 -width 500") -$c = TclTkCallback.new($ip, proc{drawlines()}) -$b = TclTkWidget.new($ip, $root, "button", "-text draw -command", $c) - -$ip.commands()["pack"].e($a, $b, "-side left") - -TclTk.mainloop - -# eof diff --git a/ext/tk/sample/tcltklib/lines2.rb b/ext/tk/sample/tcltklib/lines2.rb deleted file mode 100644 index e459589f50..0000000000 --- a/ext/tk/sample/tcltklib/lines2.rb +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/local/bin/ruby - -require "tk" - -def drawlines() - print Time.now, "\n" - - for j in 0 .. 99 - print "*" - $stdout.flush - if (j & 1) != 0 - col = "blue" - else - col = "red" - end - for i in 0 .. 99 -# TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col) - end - end - - print Time.now, "\n" - - for j in 0 .. 99 - print "*" - $stdout.flush - if (j & 1) != 0 - col = "blue" - else - col = "red" - end - for i in 0 .. 99 - TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col) - end - end - - print Time.now, "\n" -# Tk.root.destroy -end - -$a = TkCanvas.new{ - height(500) - width(500) -} - -$b = TkButton.new{ - text("draw") - command(proc{drawlines()}) -} - -TkPack.configure($a, $b, {"side"=>"left"}) - -Tk.mainloop - -# eof diff --git a/ext/tk/sample/tcltklib/lines3.rb b/ext/tk/sample/tcltklib/lines3.rb deleted file mode 100644 index caa50f92e7..0000000000 --- a/ext/tk/sample/tcltklib/lines3.rb +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/local/bin/ruby - -require "tk" - -def drawlines() - print Time.now, "\n" - - for j in 0 .. 99 - print "*" - $stdout.flush - if (j & 1) != 0 - col = "blue" - else - col = "red" - end - for i in 0 .. 99 -# $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col) - end - end - - print Time.now, "\n" - - for j in 0 .. 99 - print "*" - $stdout.flush - if (j & 1) != 0 - col = "blue" - else - col = "red" - end - for i in 0 .. 99 - $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col) - end - end - - print Time.now, "\n" -# Tk.root.destroy -end - -$a = TkCanvas.new{ - height(500) - width(500) -} - -$b = TkButton.new{ - text("draw") - command(proc{drawlines()}) -} - -TkPack.configure($a, $b, {"side"=>"left"}) - -Tk.mainloop - -# eof diff --git a/ext/tk/sample/tcltklib/lines4.rb b/ext/tk/sample/tcltklib/lines4.rb deleted file mode 100644 index 7a1175bce0..0000000000 --- a/ext/tk/sample/tcltklib/lines4.rb +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/local/bin/ruby - -require "tk" - -def drawlines() - print Time.now, "\n" - - for j in 0 .. 99 - print "*" - $stdout.flush - if (j & 1) != 0 - col = "blue" - else - col = "red" - end - for i in 0 .. 99 -# TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-fill", col) - end - end - - print Time.now, "\n" - - for j in 0 .. 99 - print "*" - $stdout.flush - if (j & 1) != 0 - col = "blue" - else - col = "red" - end - for i in 0 .. 99 - TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-fill", col) - end - end - - print Time.now, "\n" -# Tk.root.destroy -end - -$a = TkCanvas.new{ - height(500) - width(500) -} - -$b = TkButton.new{ - text("draw") - command(proc{drawlines()}) -} - -TkPack.configure($a, $b, {"side"=>"left"}) - -Tk.mainloop - -# eof diff --git a/ext/tk/sample/tcltklib/maru.gif b/ext/tk/sample/tcltklib/maru.gif deleted file mode 100644 index 2c0202892e..0000000000 Binary files a/ext/tk/sample/tcltklib/maru.gif and /dev/null differ diff --git a/ext/tk/sample/tcltklib/safeTk.rb b/ext/tk/sample/tcltklib/safeTk.rb deleted file mode 100644 index 5d2c60e700..0000000000 --- a/ext/tk/sample/tcltklib/safeTk.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby -require 'tcltklib' - -master = TclTkIp.new -slave_name = 'slave0' -slave = master.create_slave(slave_name, true) -master._eval("::safe::interpInit #{slave_name}") -master._eval("::safe::loadTk #{slave_name}") - -master._invoke('label', '.l1', '-text', 'master') -master._invoke('pack', '.l1', '-padx', '30', '-pady', '50') -master._eval('label .l2 -text {root widget of master-ip}') -master._eval('pack .l2 -padx 30 -pady 50') - -slave._invoke('label', '.l1', '-text', 'slave') -slave._invoke('pack', '.l1', '-padx', '30', '-pady', '50') -slave._eval('label .l2 -text {root widget of slave-ip}') -slave._eval('pack .l2 -padx 30 -pady 20') -slave._eval('label .l3 -text {( container frame widget of master-ip )}') -slave._eval('pack .l3 -padx 30 -pady 20') - -TclTkLib.mainloop diff --git a/ext/tk/sample/tcltklib/sample0.rb b/ext/tk/sample/tcltklib/sample0.rb deleted file mode 100644 index cd4c8069b4..0000000000 --- a/ext/tk/sample/tcltklib/sample0.rb +++ /dev/null @@ -1,39 +0,0 @@ -#! /usr/local/bin/ruby -vd - -# tcltklib ライブラリのテスト - -require "tcltklib" - -def test - # インタプリタを生成する - ip1 = TclTkIp.new() - - # 評価してみる - print ip1._return_value().inspect, "\n" - print ip1._eval("puts {abc}").inspect, "\n" - - # ボタンを作ってみる - print ip1._return_value().inspect, "\n" - print ip1._eval("button .lab -text exit -command \"destroy .\"").inspect, - "\n" - print ip1._return_value().inspect, "\n" - print ip1._eval("pack .lab").inspect, "\n" - print ip1._return_value().inspect, "\n" - - # インタプリタから ruby コマンドを評価してみる -# print ip1._eval(%q/ruby {print "print by ruby\n"}/).inspect, "\n" - print ip1._eval(%q+puts [ruby {print "print by ruby\n"; "puts by tcl/tk"}]+).inspect, "\n" - print ip1._return_value().inspect, "\n" - - # もう一つインタプリタを生成してみる - ip2 = TclTkIp.new() - ip2._eval("button .lab -text test -command \"puts test ; destroy .\"") - ip2._eval("pack .lab") - - TclTkLib.mainloop -end - -test -GC.start - -print "exit\n" diff --git a/ext/tk/sample/tcltklib/sample1.rb b/ext/tk/sample/tcltklib/sample1.rb deleted file mode 100644 index 13df440751..0000000000 --- a/ext/tk/sample/tcltklib/sample1.rb +++ /dev/null @@ -1,634 +0,0 @@ -#! /usr/local/bin/ruby -d -#! /usr/local/bin/ruby -# -d オプションを付けると, デバッグ情報を表示する. - -# tcltk ライブラリのサンプル - -# まず, ライブラリを require する. -require "tcltk" - -# 以下は, Test1 のインスタンスの initialize() で, -# tcl/tk に関する処理を行う例である. -# 必ずしもそのようにする必要は無く, -# (もし, そうしたければ) class の外で tcl/tk に関する処理を行っても良い. - -class Test1 - # 初期化(インタプリタを生成してウィジェットを生成する). - def initialize() - - #### 使う前のおまじない - - # インタプリタの生成. - ip = TclTkInterpreter.new() - # コマンドに対応するオブジェクトを c に設定しておく. - c = ip.commands() - # 使用するコマンドに対応するオブジェクトは変数に入れておく. - append, bind, button, destroy, incr, info, label, place, set, wm = - c.values_at( - "append", "bind", "button", "destroy", "incr", "info", "label", "place", - "set", "wm") - - #### tcl/tk のコマンドに対応するオブジェクト(TclTkCommand)の操作 - - # 実行する時は, e() メソッドを使う. - # (以下は, tcl/tk における info command r* を実行.) - print info.e("command", "r*"), "\n" - # 引数は, まとめた文字列にしても同じ. - print info.e("command r*"), "\n" - # 変数を用いなくとも実行できるが, 見ためが悪い. - print c["info"].e("command", "r*"), "\n" - # インタプリタのメソッドとしても実行できるが, 効率が悪い. - print ip.info("command", "r*"), "\n" - - #### - - # 以下, 生成したオブジェクトは変数に代入しておかないと - # GC の対象になってしまう. - - #### tcl/tk の変数に対応するオブジェクト(TclTkVariable)の操作 - - # 生成と同時に値を設定する. - v1 = TclTkVariable.new(ip, "20") - # 読み出しは get メソッドを使う. - print v1.get(), "\n" - # 設定は set メソッドを使う. - v1.set(40) - print v1.get(), "\n" - # set コマンドを使って読み出し, 設定は可能だが見ためが悪い. - # e() メソッド等の引数に直接 TclTkObject や数値を書いても良い. - set.e(v1, 30) - print set.e(v1), "\n" - # tcl/tk のコマンドで変数を操作できる. - incr.e(v1) - print v1.get(), "\n" - append.e(v1, 10) - print v1.get(), "\n" - - #### tcl/tk のウィジェットに対応するオブジェクト(TclTkWidget)の操作 - - # ルートウィジェットを取り出す. - root = ip.rootwidget() - # ウィジェットの操作. - root.e("configure -height 300 -width 300") - # タイトルを付けるときは wm を使う. - wm.e("title", root, $0) - # 親ウィジェットとコマンドを指定して, ウィジェットを作る. - l1 = TclTkWidget.new(ip, root, label, "-text {type `x' to print}") - # place すると表示される. - place.e(l1, "-x 0 -rely 0.0 -relwidth 1 -relheight 0.1") - # コマンド名は文字列で指定しても良いが, 見ためが悪い. - # (コマンド名は独立した引数でなければならない.) - l2 = TclTkWidget.new(ip, root, "label") - # ウィジェットの操作. - l2.e("configure -text {type `q' to exit}") - place.e(l2, "-x 0 -rely 0.1 -relwidth 1 -relheight 0.1") - - #### tcl/tk のコールバックに対応するオブジェクト(TclTkCallback)の操作 - - # コールバックを生成する. - c1 = TclTkCallback.new(ip, proc{sample(ip, root)}) - # コールバックを持つウィジェットを生成する. - b1 = TclTkWidget.new(ip, root, button, "-text sample -command", c1) - place.e(b1, "-x 0 -rely 0.2 -relwidth 1 -relheight 0.1") - # イベントループを抜けるには destroy.e(root) する. - c2 = TclTkCallback.new(ip, proc{destroy.e(root)}) - b2 = TclTkWidget.new(ip, root, button, "-text exit -command", c2) - place.e(b2, "-x 0 -rely 0.3 -relwidth 1 -relheight 0.1") - - #### イベントのバインド - # script の追加 (bind tag sequence +script) は今のところできない. - # (イテレータ変数の設定がうまくいかない.) - - # 基本的にはウィジェットに対するコールバックと同じ. - c3 = TclTkCallback.new(ip, proc{print("q pressed\n"); destroy.e(root)}) - bind.e(root, "q", c3) - # bind コマンドで % 置換によりパラメータを受け取りたいときは, - # proc{} の後ろに文字列で指定すると, - # 置換結果をイテレータ変数を通して受け取ることができる. - # ただし proc{} の後ろの文字列は, - # bind コマンドに与えるコールバック以外で指定してはいけない. - c4 = TclTkCallback.new(ip, proc{|i| print("#{i} pressed\n")}, "%A") - bind.e(root, "x", c4) - # TclTkCallback を GC の対象にしたければ, - # dcb() (または deletecallbackkeys()) する必要がある. - cb = [c1, c2, c3, c4] - c5 = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, root, w)}, "%W") - bind.e(root, "", c5) - cb.push(c5) - - #### tcl/tk のイメージに対応するオブジェクト(TclTkImage)の操作 - - # データを指定して生成する. - i1 = TclTkImage.new(ip, "photo", "-file maru.gif") - # ラベルに張り付けてみる. - l3 = TclTkWidget.new(ip, root, label, "-relief raised -image", i1) - place.e(l3, "-x 0 -rely 0.4 -relwidth 0.2 -relheight 0.2") - # 空のイメージを生成して後で操作する. - i2 = TclTkImage.new(ip, "photo") - # イメージを操作する. - i2.e("copy", i1) - i2.e("configure -gamma 0.5") - l4 = TclTkWidget.new(ip, root, label, "-relief raised -image", i2) - place.e(l4, "-relx 0.2 -rely 0.4 -relwidth 0.2 -relheight 0.2") - - #### - end - - # サンプルのためのウィジェットを生成する. - def sample(ip, parent) - bind, button, destroy, grid, toplevel, wm = ip.commands().values_at( - "bind", "button", "destroy", "grid", "toplevel", "wm") - - ## toplevel - - # 新しいウインドウを開くには, toplevel を使う. - t1 = TclTkWidget.new(ip, parent, toplevel) - # タイトルを付けておく - wm.e("title", t1, "sample") - - # ウィジェットが破壊されたとき, コールバックが GC の対象になるようにする. - cb = [] - cb.push(c = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, t1, w)}, "%W")) - bind.e(t1, "", c) - - # ボタンの生成. - wid = [] - # toplevel ウィジェットを破壊するには destroy する. - cb.push(c = TclTkCallback.new(ip, proc{destroy.e(t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text close -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_label(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text label -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_button(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text button -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_checkbutton(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text checkbutton -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_radiobutton(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text radiobutton -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_scale(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text scale -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_entry(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text entry -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_text(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text text -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_raise(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text raise/lower -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_modal(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text message/modal -command", - c)) - cb.push(c = TclTkCallback.new(ip, proc{test_menu(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text menu -command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_listbox(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text listbox/scrollbar", - "-command", c)) - cb.push(c = TclTkCallback.new(ip, proc{test_canvas(ip, t1)})) - wid.push(TclTkWidget.new(ip, t1, button, "-text canvas -command", c)) - - # grid で表示する. - ro = co = 0 - wid.each{|w| - grid.e(w, "-row", ro, "-column", co, "-sticky news") - ro += 1 - if ro == 7 - ro = 0 - co += 1 - end - } - end - - # inittoplevel(ip, parent, title) - # 以下の処理をまとめて行う. - # 1. toplevel ウィジェットを作成する. - # 2. コールバックを登録する配列を用意し, toplevel ウィジェットの - # イベントにコールバックを削除する手続きを登録する. - # 3. クローズボタンを作る. - # 作成した toplevel ウィジェット, クローズボタン, コールバック登録用変数 - # を返す. - # ip: インタプリタ - # parent: 親ウィジェット - # title: toplevel ウィジェットのウインドウのタイトル - def inittoplevel(ip, parent, title) - bind, button, destroy, toplevel, wm = ip.commands().values_at( - "bind", "button", "destroy", "toplevel", "wm") - - # 新しいウインドウを開くには, toplevel を使う. - t1 = TclTkWidget.new(ip, parent, toplevel) - # タイトルを付けておく - wm.e("title", t1, title) - - # ウィジェットが破壊されたとき, コールバックが GC の対象になるようにする. - cb = [] - cb.push(c = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, t1, w)}, "%W")) - bind.e(t1, "", c) - # close ボタンを作っておく. - # toplevel ウィジェットを破壊するには destroy する. - cb.push(c = TclTkCallback.new(ip, proc{destroy.e(t1)})) - b1 = TclTkWidget.new(ip, t1, button, "-text close -command", c) - - return t1, b1, cb - end - - # label のサンプル. - def test_label(ip, parent) - button, global, label, pack = ip.commands().values_at( - "button", "global", "label", "pack") - t1, b1, cb = inittoplevel(ip, parent, "label") - - ## label - - # いろいろな形のラベル. - l1 = TclTkWidget.new(ip, t1, label, "-text {default(flat)}") - l2 = TclTkWidget.new(ip, t1, label, "-text raised -relief raised") - l3 = TclTkWidget.new(ip, t1, label, "-text sunken -relief sunken") - l4 = TclTkWidget.new(ip, t1, label, "-text groove -relief groove") - l5 = TclTkWidget.new(ip, t1, label, "-text ridge -relief ridge") - l6 = TclTkWidget.new(ip, t1, label, "-bitmap error") - l7 = TclTkWidget.new(ip, t1, label, "-bitmap questhead") - - # pack しても表示される. - pack.e(b1, l1, l2, l3, l4, l5, l6, l7, "-pady 3") - - ## -textvariable - - # tcltk ライブラリの実装では, コールバックは tcl/tk の``手続き''を通して - # 呼ばれる. したがって, コールバックの中で(大域)変数にアクセスするときは, - # global する必要がある. - # global する前に変数に値を設定してしまうとエラーになるので, - # tcl/tk における表現形だけ生成して, 実際に値を設定しないように, - # 2 番目の引数には nil を与える. - v1 = TclTkVariable.new(ip, nil) - global.e(v1) - v1.set(100) - # -textvariable で変数を設定する. - l6 = TclTkWidget.new(ip, t1, label, "-textvariable", v1) - # コールバックの中から変数を操作する. - cb.push(c = TclTkCallback.new(ip, proc{ - global.e(v1); v1.set(v1.get().to_i + 10)})) - b2 = TclTkWidget.new(ip, t1, button, "-text +10 -command", c) - cb.push(c = TclTkCallback.new(ip, proc{ - global.e(v1); v1.set(v1.get().to_i - 10)})) - b3 = TclTkWidget.new(ip, t1, button, "-text -10 -command", c) - pack.e(l6, b2, b3) - end - - # button のサンプル. - def test_button(ip, parent) - button, pack = ip.commands().values_at("button", "pack") - t1, b1, cb = inittoplevel(ip, parent, "button") - - ## button - - # コールバック内で参照する変数は先に宣言しておかなければならない. - b3 = b4 = nil - cb.push(c = TclTkCallback.new(ip, proc{b3.e("flash"); b4.e("flash")})) - b2 = TclTkWidget.new(ip, t1, button, "-text flash -command", c) - cb.push(c = TclTkCallback.new(ip, proc{b2.e("configure -state normal")})) - b3 = TclTkWidget.new(ip, t1, button, "-text normal -command", c) - cb.push(c = TclTkCallback.new(ip, proc{b2.e("configure -state disabled")})) - b4 = TclTkWidget.new(ip, t1, button, "-text disable -command", c) - pack.e(b1, b2, b3, b4) - end - - # checkbutton のサンプル. - def test_checkbutton(ip, parent) - checkbutton, global, pack = ip.commands().values_at( - "checkbutton", "global", "pack") - t1, b1, cb = inittoplevel(ip, parent, "checkbutton") - - ## checkbutton - - v1 = TclTkVariable.new(ip, nil) - global.e(v1) - # -variable で変数を設定する. - ch1 = TclTkWidget.new(ip, t1, checkbutton, "-onvalue on -offvalue off", - "-textvariable", v1, "-variable", v1) - pack.e(b1, ch1) - end - - # radiobutton のサンプル. - def test_radiobutton(ip, parent) - global, label, pack, radiobutton = ip.commands().values_at( - "global", "label", "pack", "radiobutton") - t1, b1, cb = inittoplevel(ip, parent, "radiobutton") - - ## radiobutton - - v1 = TclTkVariable.new(ip, nil) - global.e(v1) - # ヌルストリングは "{}" で指定する. - v1.set("{}") - l1 = TclTkWidget.new(ip, t1, label, "-textvariable", v1) - # -variable で同じ変数を指定すると同じグループになる. - ra1 = TclTkWidget.new(ip, t1, radiobutton, - "-text radio1 -value r1 -variable", v1) - ra2 = TclTkWidget.new(ip, t1, radiobutton, - "-text radio2 -value r2 -variable", v1) - cb.push(c = TclTkCallback.new(ip, proc{global.e(v1); v1.set("{}")})) - ra3 = TclTkWidget.new(ip, t1, radiobutton, - "-text clear -value r3 -variable", v1, "-command", c) - pack.e(b1, l1, ra1, ra2, ra3) - end - - # scale のサンプル. - def test_scale(ip, parent) - global, pack, scale = ip.commands().values_at( - "global", "pack", "scale") - t1, b1, cb = inittoplevel(ip, parent, "scale") - - ## scale - - v1 = TclTkVariable.new(ip, nil) - global.e(v1) - v1.set(219) - # コールバック内で参照する変数は先に宣言しておかなければならない. - sca1 = nil - cb.push(c = TclTkCallback.new(ip, proc{global.e(v1); v = v1.get(); - sca1.e("configure -background", format("#%02x%02x%02x", v, v, v))})) - sca1 = TclTkWidget.new(ip, t1, scale, - "-label scale -orient h -from 0 -to 255 -variable", v1, "-command", c) - pack.e(b1, sca1) - end - - # entry のサンプル. - def test_entry(ip, parent) - button, entry, global, pack = ip.commands().values_at( - "button", "entry", "global", "pack") - t1, b1, cb = inittoplevel(ip, parent, "entry") - - ## entry - - v1 = TclTkVariable.new(ip, nil) - global.e(v1) - # ヌルストリングは "{}" で指定する. - v1.set("{}") - en1 = TclTkWidget.new(ip, t1, entry, "-textvariable", v1) - cb.push(c = TclTkCallback.new(ip, proc{ - global.e(v1); print(v1.get(), "\n"); v1.set("{}")})) - b2 = TclTkWidget.new(ip, t1, button, "-text print -command", c) - pack.e(b1, en1, b2) - end - - # text のサンプル. - def test_text(ip, parent) - button, pack, text = ip.commands().values_at( - "button", "pack", "text") - t1, b1, cb = inittoplevel(ip, parent, "text") - - ## text - - te1 = TclTkWidget.new(ip, t1, text) - cb.push(c = TclTkCallback.new(ip, proc{ - # 1 行目の 0 文字目から最後までを表示し, 削除する. - print(te1.e("get 1.0 end")); te1.e("delete 1.0 end")})) - b2 = TclTkWidget.new(ip, t1, button, "-text print -command", c) - pack.e(b1, te1, b2) - end - - # raise/lower のサンプル. - def test_raise(ip, parent) - button, frame, lower, pack, raise = ip.commands().values_at( - "button", "frame", "lower", "pack", "raise") - t1, b1, cb = inittoplevel(ip, parent, "raise/lower") - - ## raise/lower - - # button を隠すテストのために, frame を使う. - f1 = TclTkWidget.new(ip, t1, frame) - # コールバック内で参照する変数は先に宣言しておかなければならない. - b2 = nil - cb.push(c = TclTkCallback.new(ip, proc{raise.e(f1, b2)})) - b2 = TclTkWidget.new(ip, t1, button, "-text raise -command", c) - cb.push(c = TclTkCallback.new(ip, proc{lower.e(f1, b2)})) - b3 = TclTkWidget.new(ip, t1, button, "-text lower -command", c) - lower.e(f1, b3) - - pack.e(b2, b3, "-in", f1) - pack.e(b1, f1) - end - - # modal なウィジェットのサンプル. - def test_modal(ip, parent) - button, frame, message, pack, tk_chooseColor, tk_getOpenFile, - tk_messageBox = ip.commands().values_at( - "button", "frame", "message", "pack", "tk_chooseColor", - "tk_getOpenFile", "tk_messageBox") - # 最初に load されていないライブラリは ip.commands() に存在しないので, - # TclTkLibCommand を生成する必要がある. - tk_dialog = TclTkLibCommand.new(ip, "tk_dialog") - t1, b1, cb = inittoplevel(ip, parent, "message/modal") - - ## message - - mes = "これは message ウィジェットのテストです." - mes += "以下は modal なウィジェットのテストです." - me1 = TclTkWidget.new(ip, t1, message, "-text {#{mes}}") - - ## modal - - # tk_messageBox - cb.push(c = TclTkCallback.new(ip, proc{ - print tk_messageBox.e("-type yesnocancel -message messageBox", - "-icon error -default cancel -title messageBox"), "\n"})) - b2 = TclTkWidget.new(ip, t1, button, "-text messageBox -command", c) - # tk_dialog - cb.push(c = TclTkCallback.new(ip, proc{ - # ウィジェット名を生成するためにダミーの frame を生成. - print tk_dialog.e(TclTkWidget.new(ip, t1, frame), - "dialog dialog error 2 yes no cancel"), "\n"})) - b3 = TclTkWidget.new(ip, t1, button, "-text dialog -command", c) - # tk_chooseColor - cb.push(c = TclTkCallback.new(ip, proc{ - print tk_chooseColor.e("-title chooseColor"), "\n"})) - b4 = TclTkWidget.new(ip, t1, button, "-text chooseColor -command", c) - # tk_getOpenFile - cb.push(c = TclTkCallback.new(ip, proc{ - print tk_getOpenFile.e("-defaultextension .rb", - "-filetypes {{{Ruby Script} {.rb}} {{All Files} {*}}}", - "-title getOpenFile"), "\n"})) - b5 = TclTkWidget.new(ip, t1, button, "-text getOpenFile -command", c) - - pack.e(b1, me1, b2, b3, b4, b5) - end - - # menu のサンプル. - def test_menu(ip, parent) - global, menu, menubutton, pack = ip.commands().values_at( - "global", "menu", "menubutton", "pack") - tk_optionMenu = TclTkLibCommand.new(ip, "tk_optionMenu") - t1, b1, cb = inittoplevel(ip, parent, "menu") - - ## menu - - # menubutton を生成する. - mb1 = TclTkWidget.new(ip, t1, menubutton, "-text menu") - # menu を生成する. - me1 = TclTkWidget.new(ip, mb1, menu) - # mb1 から me1 が起動されるようにする. - mb1.e("configure -menu", me1) - - # cascade で起動される menu を生成する. - me11 = TclTkWidget.new(ip, me1, menu) - # radiobutton のサンプル. - v1 = TclTkVariable.new(ip, nil); global.e(v1); v1.set("r1") - me11.e("add radiobutton -label radio1 -value r1 -variable", v1) - me11.e("add radiobutton -label radio2 -value r2 -variable", v1) - me11.e("add radiobutton -label radio3 -value r3 -variable", v1) - # cascade により mb11 が起動されるようにする. - me1.e("add cascade -label cascade -menu", me11) - - # checkbutton のサンプル. - v2 = TclTkVariable.new(ip, nil); global.e(v2); v2.set("none") - me1.e("add checkbutton -label check -variable", v2) - # separator のサンプル. - me1.e("add separator") - # command のサンプル. - v3 = nil - cb.push(c = TclTkCallback.new(ip, proc{ - global.e(v1, v2, v3); print "v1: ", v1.get(), ", v2: ", v2.get(), - ", v3: ", v3.get(), "\n"})) - me1.e("add command -label print -command", c) - - ## tk_optionMenu - - v3 = TclTkVariable.new(ip, nil); global.e(v3); v3.set("opt2") - om1 = TclTkWidget.new(ip, t1, tk_optionMenu, v3, "opt1 opt2 opt3 opt4") - - pack.e(b1, mb1, om1, "-side left") - end - - # listbox のサンプル. - def test_listbox(ip, parent) - clipboard, frame, grid, listbox, lower, menu, menubutton, pack, scrollbar, - selection = ip.commands().values_at( - "clipboard", "frame", "grid", "listbox", "lower", "menu", "menubutton", - "pack", "scrollbar", "selection") - t1, b1, cb = inittoplevel(ip, parent, "listbox") - - ## listbox/scrollbar - - f1 = TclTkWidget.new(ip, t1, frame) - # コールバック内で参照する変数は先に宣言しておかなければならない. - li1 = sc1 = sc2 = nil - # 実行時に, 後ろにパラメータがつくコールバックは, - # イテレータ変数でそのパラメータを受け取ることができる. - # (複数のパラメータはひとつの文字列にまとめられる.) - cb.push(c1 = TclTkCallback.new(ip, proc{|i| li1.e("xview", i)})) - cb.push(c2 = TclTkCallback.new(ip, proc{|i| li1.e("yview", i)})) - cb.push(c3 = TclTkCallback.new(ip, proc{|i| sc1.e("set", i)})) - cb.push(c4 = TclTkCallback.new(ip, proc{|i| sc2.e("set", i)})) - # listbox - li1 = TclTkWidget.new(ip, f1, listbox, - "-xscrollcommand", c3, "-yscrollcommand", c4, - "-selectmode extended -exportselection true") - for i in 1..20 - li1.e("insert end {line #{i} line #{i} line #{i} line #{i} line #{i}}") - end - # scrollbar - sc1 = TclTkWidget.new(ip, f1, scrollbar, "-orient horizontal -command", c1) - sc2 = TclTkWidget.new(ip, f1, scrollbar, "-orient vertical -command", c2) - - ## selection/clipboard - - mb1 = TclTkWidget.new(ip, t1, menubutton, "-text edit") - me1 = TclTkWidget.new(ip, mb1, menu) - mb1.e("configure -menu", me1) - cb.push(c = TclTkCallback.new(ip, proc{ - # clipboard をクリア. - clipboard.e("clear") - # selection から文字列を読み込み clipboard に追加する. - clipboard.e("append {#{selection.e('get')}}")})) - me1.e("add command -label {selection -> clipboard} -command",c) - cb.push(c = TclTkCallback.new(ip, proc{ - # li1 をクリア. - li1.e("delete 0 end") - # clipboard から文字列を取り出し, 1 行ずつ - selection.e("get -selection CLIPBOARD").split(/\n/).each{|line| - # li1 に挿入する. - li1.e("insert end {#{line}}")}})) - me1.e("add command -label {clipboard -> listbox} -command",c) - - grid.e(li1, "-row 0 -column 0 -sticky news") - grid.e(sc1, "-row 1 -column 0 -sticky ew") - grid.e(sc2, "-row 0 -column 1 -sticky ns") - grid.e("rowconfigure", f1, "0 -weight 100") - grid.e("columnconfigure", f1, "0 -weight 100") - f2 = TclTkWidget.new(ip, t1, frame) - lower.e(f2, b1) - pack.e(b1, mb1, "-in", f2, "-side left") - pack.e(f2, f1) - end - - # canvas のサンプル. - def test_canvas(ip, parent) - canvas, lower, pack = ip.commands().values_at("canvas", "lower", "pack") - t1, b1, cb = inittoplevel(ip, parent, "canvas") - - ## canvas - - ca1 = TclTkWidget.new(ip, t1, canvas, "-width 400 -height 300") - lower.e(ca1, b1) - # rectangle を作る. - idr = ca1.e("create rectangle 10 10 20 20") - # oval を作る. - ca1.e("create oval 60 10 100 50") - # polygon を作る. - ca1.e("create polygon 110 10 110 30 140 10") - # line を作る. - ca1.e("create line 150 10 150 30 190 10") - # arc を作る. - ca1.e("create arc 200 10 250 50 -start 0 -extent 90 -style pieslice") - # i1 は本当は, どこかで破壊しなければならないが, 面倒なので放ってある. - i1 = TclTkImage.new(ip, "photo", "-file maru.gif") - # image を作る. - ca1.e("create image 100 100 -image", i1) - # bitmap を作る. - ca1.e("create bitmap 260 50 -bitmap questhead") - # text を作る. - ca1.e("create text 320 50 -text {drag rectangle}") - # window を作る(クローズボタン). - ca1.e("create window 200 200 -window", b1) - - # bind により rectangle を drag できるようにする. - cb.push(c = TclTkCallback.new(ip, proc{|i| - # i に x と y を受け取るので, 取り出す. - x, y = i.split(/ /); x = x.to_f; y = y.to_f - # 座標を変更する. - ca1.e("coords current #{x - 5} #{y - 5} #{x + 5} #{y + 5}")}, - # x, y 座標を空白で区切ったものをイテレータ変数へ渡すように指定. - "%x %y")) - # rectangle に bind する. - ca1.e("bind", idr, "", c) - - pack.e(ca1) - end -end - -# test driver - -if ARGV.size == 0 - print "#{$0} n で, n 個のインタプリタを起動します.\n" - n = 1 -else - n = ARGV[0].to_i -end - -print "start\n" -ip = [] - -# インタプリタ, ウィジェット等の生成. -for i in 1 .. n - ip.push(Test1.new()) -end - -# 用意ができたらイベントループに入る. -TclTk.mainloop() -print "exit from mainloop\n" - -# インタプリタが GC されるかのテスト. -ip = [] -print "GC.start\n" if $DEBUG -GC.start() if $DEBUG -print "end\n" - -exit - -# end diff --git a/ext/tk/sample/tcltklib/sample2.rb b/ext/tk/sample/tcltklib/sample2.rb deleted file mode 100644 index 444bb1eef7..0000000000 --- a/ext/tk/sample/tcltklib/sample2.rb +++ /dev/null @@ -1,451 +0,0 @@ -#!/usr/local/bin/ruby -#----------------------> pretty simple othello game <----------------------- -# othello.rb -# -# version 0.3 -# maeda shugo (shuto@po.aianet.ne.jp) -#--------------------------------------------------------------------------- - -# Sep. 17, 1997 modified by Y. Shigehiro for tcltk library -# maeda shugo (shugo@po.aianet.ne.jp) 氏による -# (ruby/tk で書かれていた) ruby のサンプルプログラム -# http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz -# を tcltk ライブラリを使うように, 機械的に変更してみました. -# -# なるべくオリジナルと同じになるようにしてあります. - -require "observer" -require "tcltk" -$ip = TclTkInterpreter.new() -$root = $ip.rootwidget() -$button, $canvas, $checkbutton, $frame, $label, $pack, $update, $wm = - $ip.commands().values_at( - "button", "canvas", "checkbutton", "frame", "label", "pack", "update", "wm") - -class Othello - - EMPTY = 0 - BLACK = 1 - WHITE = - BLACK - - attr :in_com_turn - attr :game_over - - class Board - - include Observable - - DIRECTIONS = [ - [-1, -1], [-1, 0], [-1, 1], - [ 0, -1], [ 0, 1], - [ 1, -1], [ 1, 0], [ 1, 1] - ] - - attr :com_disk, TRUE - - def initialize(othello) - @othello = othello - reset - end - - def notify_observers(*arg) - if @observer_peers != nil - super(*arg) - end - end - - def reset - @data = [ - [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY], - [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY], - [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY], - [EMPTY, EMPTY, EMPTY, WHITE, BLACK, EMPTY, EMPTY, EMPTY], - [EMPTY, EMPTY, EMPTY, BLACK, WHITE, EMPTY, EMPTY, EMPTY], - [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY], - [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY], - [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY] - ] - changed - notify_observers - end - - def man_disk - return - @com_disk - end - - def other_disk(disk) - return - disk - end - - def get_disk(row, col) - return @data[row][col] - end - - def reverse_to(row, col, my_disk, dir_y, dir_x) - y = row - x = col - begin - y += dir_y - x += dir_x - if y < 0 || x < 0 || y > 7 || x > 7 || - @data[y][x] == EMPTY - return - end - end until @data[y][x] == my_disk - begin - @data[y][x] = my_disk - changed - notify_observers(y, x) - y -= dir_y - x -= dir_x - end until y == row && x == col - end - - def put_disk(row, col, disk) - @data[row][col] = disk - changed - notify_observers(row, col) - DIRECTIONS.each do |dir| - reverse_to(row, col, disk, *dir) - end - end - - def count_disk(disk) - num = 0 - @data.each do |rows| - rows.each do |d| - if d == disk - num += 1 - end - end - end - return num - end - - def count_point_to(row, col, my_disk, dir_y, dir_x) - return 0 if @data[row][col] != EMPTY - count = 0 - loop do - row += dir_y - col += dir_x - break if row < 0 || col < 0 || row > 7 || col > 7 - case @data[row][col] - when my_disk - return count - when other_disk(my_disk) - count += 1 - when EMPTY - break - end - end - return 0 - end - - def count_point(row, col, my_disk) - count = 0 - DIRECTIONS.each do |dir| - count += count_point_to(row, col, my_disk, *dir) - end - return count - end - - def corner?(row, col) - return (row == 0 && col == 0) || - (row == 0 && col == 7) || - (row == 7 && col == 0) || - (row == 7 && col == 7) - end - - def search(my_disk) - max = 0 - max_row = nil - max_col = nil - for row in 0 .. 7 - for col in 0 .. 7 - buf = count_point(row, col, my_disk) - if (corner?(row, col) && buf > 0) || max < buf - max = buf - max_row = row - max_col = col - end - end - end - return max_row, max_col - end - end #--------------------------> class Board ends here - - class BoardView < TclTkWidget - - BACK_GROUND_COLOR = "DarkGreen" - HILIT_BG_COLOR = "green" - BORDER_COLOR = "black" - BLACK_COLOR = "black" - WHITE_COLOR = "white" - STOP_COLOR = "red" - - attr :left - attr :top - attr :right - attr :bottom - - class Square - - attr :oval, TRUE - attr :row - attr :col - - def initialize(view, row, col) - @view = view - @id = @view.e("create rectangle", - *(view.tk_rect(view.left + col, - view.top + row, - view.left + col + 1, - view.top + row + 1) \ - << "-fill #{BACK_GROUND_COLOR}") ) - @row = row - @col = col - @view.e("itemconfigure", @id, - "-width 0.5m -outline #{BORDER_COLOR}") - @view.e("bind", @id, "", TclTkCallback.new($ip, proc{ - if @oval == nil - view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}") - end - })) - @view.e("bind", @id, "", TclTkCallback.new($ip, proc{ - view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}") - })) - @view.e("bind", @id, "", TclTkCallback.new($ip, - proc{ - view.click_square(self) - })) - end - - def blink(color) - @view.e("itemconfigure", @id, "-fill #{color}") - $update.e() - sleep(0.1) - @view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}") - end - end #-----------------------> class Square ends here - - def initialize(othello, board) - super($ip, $root, $canvas) - @othello = othello - @board = board - @board.add_observer(self) - - @squares = Array.new(8) - for i in 0 .. 7 - @squares[i] = Array.new(8) - end - @left = 1 - @top = 0.5 - @right = @left + 8 - @bottom = @top + 8 - - i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom)) - self.e("itemconfigure", i, - "-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}") - - for row in 0 .. 7 - for col in 0 .. 7 - @squares[row][col] = Square.new(self, row, col) - end - end - - update - end - - def tk_rect(left, top, right, bottom) - return left.to_s + "c", top.to_s + "c", - right.to_s + "c", bottom.to_s + "c" - end - - def clear - each_square do |square| - if square.oval != nil - self.e("delete", square.oval) - square.oval = nil - end - end - end - - def draw_disk(row, col, disk) - if disk == EMPTY - if @squares[row][col].oval != nil - self.e("delete", @squares[row][col].oval) - @squares[row][col].oval = nil - end - return - end - - $update.e() - sleep(0.05) - oval = @squares[row][col].oval - if oval == nil - oval = self.e("create oval", *tk_rect(@left + col + 0.2, - @top + row + 0.2, - @left + col + 0.8, - @top + row + 0.8)) - @squares[row][col].oval = oval - end - case disk - when BLACK - color = BLACK_COLOR - when WHITE - color = WHITE_COLOR - else - fail format("Unknown disk type: %d", disk) - end - self.e("itemconfigure", oval, "-outline #{color} -fill #{color}") - end - - def update(row = nil, col = nil) - if row && col - draw_disk(row, col, @board.get_disk(row, col)) - else - each_square do |square| - draw_disk(square.row, square.col, - @board.get_disk(square.row, square.col)) - end - end - @othello.show_point - end - - def each_square - @squares.each do |rows| - rows.each do |square| - yield(square) - end - end - end - - def click_square(square) - if @othello.in_com_turn || @othello.game_over || - @board.count_point(square.row, - square.col, - @board.man_disk) == 0 - square.blink(STOP_COLOR) - return - end - @board.put_disk(square.row, square.col, @board.man_disk) - @othello.com_turn - end - - private :draw_disk - public :update - end #----------------------> class BoardView ends here - - def initialize - @msg_label = TclTkWidget.new($ip, $root, $label) - $pack.e(@msg_label) - - @board = Board.new(self) - @board_view = BoardView.new(self, @board) - #### added by Y. Shigehiro - ## board_view の大きさを設定する. - x1, y1, x2, y2 = @board_view.e("bbox all").split(/ /).collect{|i| i.to_f} - @board_view.e("configure -width", x2 - x1) - @board_view.e("configure -height", y2 - y1) - ## scrollregion を設定する. - @board_view.e("configure -scrollregion {", @board_view.e("bbox all"), - "}") - #### ここまで - $pack.e(@board_view, "-fill both -expand true") - - panel = TclTkWidget.new($ip, $root, $frame) - - @play_black = TclTkWidget.new($ip, panel, $checkbutton, - "-text {com is black} -command", TclTkCallback.new($ip, proc{ - switch_side - })) - $pack.e(@play_black, "-side left") - - quit = TclTkWidget.new($ip, panel, $button, "-text Quit -command", - TclTkCallback.new($ip, proc{ - exit - })) - $pack.e(quit, "-side right -fill x") - - reset = TclTkWidget.new($ip, panel, $button, "-text Reset -command", - TclTkCallback.new($ip, proc{ - reset_game - })) - $pack.e(reset, "-side right -fill x") - - $pack.e(panel, "-side bottom -fill x") - -# root = Tk.root - $wm.e("title", $root, "Othello") - $wm.e("iconname", $root, "Othello") - - @board.com_disk = WHITE - @game_over = FALSE - - TclTk.mainloop - end - - def switch_side - if @in_com_turn - @play_black.e("toggle") - else - @board.com_disk = @board.man_disk - com_turn unless @game_over - end - end - - def reset_game - if @board.com_disk == BLACK - @board.com_disk = WHITE - @play_black.e("toggle") - end - @board_view.clear - @board.reset - $wm.e("title", $root, "Othello") - @game_over = FALSE - end - - def com_turn - @in_com_turn = TRUE - $update.e() - sleep(0.5) - begin - com_disk = @board.count_disk(@board.com_disk) - man_disk = @board.count_disk(@board.man_disk) - if @board.count_disk(EMPTY) == 0 - if man_disk == com_disk - $wm.e("title", $root, "{Othello - Draw!}") - elsif man_disk > com_disk - $wm.e("title", $root, "{Othello - You Win!}") - else - $wm.e("title", $root, "{Othello - You Loose!}") - end - @game_over = TRUE - break - elsif com_disk == 0 - $wm.e("title", $root, "{Othello - You Win!}") - @game_over = TRUE - break - elsif man_disk == 0 - $wm.e("title", $root, "{Othello - You Loose!}") - @game_over = TRUE - break - end - row, col = @board.search(@board.com_disk) - break if row == nil || col == nil - @board.put_disk(row, col, @board.com_disk) - end while @board.search(@board.man_disk) == [nil, nil] - @in_com_turn = FALSE - end - - def show_point - black = @board.count_disk(BLACK) - white = @board.count_disk(WHITE) - @msg_label.e("configure -text", - %Q/{#{format("BLACK: %.2d WHITE: %.2d", black, white)}}/) - end -end #----------------------> class Othello ends here - -Othello.new - -#----------------------------------------------> othello.rb ends here diff --git a/ext/tk/tkutil/.cvsignore b/ext/tk/tkutil/.cvsignore deleted file mode 100644 index 90c83ed9b1..0000000000 --- a/ext/tk/tkutil/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -*.log -*.def diff --git a/ext/tk/tkutil/depend b/ext/tk/tkutil/depend deleted file mode 100644 index fd63e230f0..0000000000 --- a/ext/tk/tkutil/depend +++ /dev/null @@ -1 +0,0 @@ -tkutil.o: tkutil.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h diff --git a/ext/tk/tkutil/extconf.rb b/ext/tk/tkutil/extconf.rb deleted file mode 100644 index e3aa00a4b2..0000000000 --- a/ext/tk/tkutil/extconf.rb +++ /dev/null @@ -1,4 +0,0 @@ -if compiled?('tk') - require 'mkmf' - create_makefile('tkutil') -end diff --git a/lib/net/https.rb b/lib/net/https.rb deleted file mode 100644 index fb329df43d..0000000000 --- a/lib/net/https.rb +++ /dev/null @@ -1,171 +0,0 @@ -=begin - -= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP. - -== Info - 'OpenSSL for Ruby 2' project - Copyright (C) 2001 GOTOU Yuuzou - All rights reserved. - -== Licence - This program is licenced under the same licence as Ruby. - (See the file 'LICENCE'.) - -== Requirements - This program requires Net 1.2.0 or higher version. - You can get it from RAA or Ruby's CVS repository. - -== Version - $Id$ - - 2001-11-06: Contiributed to Ruby/OpenSSL project. - 2004-03-06: Some code is merged in to net/http. - -== Example - -Here is a simple HTTP client: - - require 'net/http' - require 'uri' - - uri = URI.parse(ARGV[0] || 'http://localhost/') - http = Net::HTTP.new(uri.host, uri.port) - http.start { - http.request_get(uri.path) {|res| - print res.body - } - } - -It can be replaced by the following code: - - require 'net/https' - require 'uri' - - uri = URI.parse(ARGV[0] || 'https://localhost/') - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = true if uri.scheme == "https" # enable SSL/TLS - http.start { - http.request_get(uri.path) {|res| - print res.body - } - } - -== class Net::HTTP - -=== Instance Methods - -: use_ssl? - returns true if use SSL/TLS with HTTP. - -: use_ssl=((|true_or_false|)) - sets use_ssl. - -: peer_cert - return the X.509 certificates the server presented. - -: key, key=((|key|)) - Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object. - (This method is appeared in Michal Rokos's OpenSSL extention.) - -: cert, cert=((|cert|)) - Sets an OpenSSL::X509::Certificate object as client certificate - (This method is appeared in Michal Rokos's OpenSSL extention). - -: ca_file, ca_file=((|path|)) - Sets path of a CA certification file in PEM format. - The file can contrain several CA certificats. - -: ca_path, ca_path=((|path|)) - Sets path of a CA certification directory containing certifications - in PEM format. - -: verify_mode, verify_mode=((|mode|)) - Sets the flags for server the certification verification at - begining of SSL/TLS session. - OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable. - -: verify_callback, verify_callback=((|proc|)) - Sets the verify callback for the server certification verification. - -: verify_depth, verify_depth=((|num|)) - Sets the maximum depth for the certificate chain verification. - -: cert_store, cert_store=((|store|)) - Sets the X509::Store to verify peer certificate. - -: ssl_timeout, ssl_timeout=((|sec|)) - Sets the SSL timeout seconds. - -=end - -require 'net/http' -require 'openssl' - -module Net - - class HTTP - remove_method :use_ssl? - def use_ssl? - @use_ssl - end - - alias use_ssl use_ssl? # for backward compatibility - - # Turn on/off SSL. - # This flag must be set before starting session. - # If you change use_ssl value after session started, - # a Net::HTTP object raises IOError. - def use_ssl=(flag) - flag = (flag ? true : false) - raise IOError, "use_ssl value changed, but session already started" \ - if started? and @use_ssl != flag - if flag and not @ssl_context - @ssl_context = OpenSSL::SSL::SSLContext.new - end - @use_ssl = flag - end - - def self.ssl_context_accessor(name) - module_eval(<<-End, __FILE__, __LINE__ + 1) - def #{name} - return nil unless @ssl_context - @ssl_context.#{name} - end - - def #{name}=(val) - @ssl_context ||= OpenSSL::SSL::SSLContext.new - @ssl_context.#{name} = val - end - End - end - - ssl_context_accessor :key - ssl_context_accessor :cert - ssl_context_accessor :ca_file - ssl_context_accessor :ca_path - ssl_context_accessor :verify_mode - ssl_context_accessor :verify_callback - ssl_context_accessor :verify_depth - ssl_context_accessor :cert_store - - def ssl_timeout - return nil unless @ssl_context - @ssl_context.timeout - end - - def ssl_timeout=(sec) - raise ArgumentError, 'Net::HTTP#ssl_timeout= called but use_ssl=false' \ - unless use_ssl? - @ssl_context ||= OpenSSL::SSL::SSLContext.new - @ssl_context.timeout = sec - end - - alias timeout= ssl_timeout= # for backward compatibility - - def peer_cert - return nil if not use_ssl? or not @socket - @socket.io.peer_cert - end - end - -end diff --git a/lib/xmlrpc/.document b/lib/xmlrpc/.document deleted file mode 100644 index e475c53ed0..0000000000 --- a/lib/xmlrpc/.document +++ /dev/null @@ -1 +0,0 @@ -README.rdoc diff --git a/misc/ruby-electric.el b/misc/ruby-electric.el deleted file mode 100644 index c361089938..0000000000 --- a/misc/ruby-electric.el +++ /dev/null @@ -1,200 +0,0 @@ -;; -*-Emacs-Lisp-*- -;; -;; ruby-electric.el --- electric editing commands for ruby files -;; -;; Copyright (C) 2005 by Dee Zsombor . -;; Released under same license terms as Ruby. -;; -;; Due credit: this work was inspired by a code snippet posted by -;; Frederick Ros at http://rubygarden.org/ruby?EmacsExtensions. -;; -;; Following improvements where added: -;; -;; - handling of strings of type 'here document' -;; - more keywords, with special handling for 'do' -;; - packaged into a minor mode -;; -;; Usage: -;; -;; 0) copy ruby-electric.el into directory where emacs can find it. -;; -;; 1) modify your startup file (.emacs or whatever) by adding -;; following line: -;; -;; (require 'ruby-electric) -;; -;; note that you need to have font lock enabled beforehand. -;; -;; 2) toggle Ruby Electric Mode on/off with ruby-electric-mode. -;; -;; Changelog: -;; -;; 2005/Jan/14: inserts matching pair delimiters like {, [, (, ', ", -;; ' and | . -;; -;; 2005/Jan/14: added basic Custom support for configuring keywords -;; with electric closing. -;; -;; 2005/Jan/18: more Custom support for configuring characters for -;; which matching expansion should occur. -;; -;; 2005/Jan/18: no longer uses 'looking-back' or regexp character -;; classes like [:space:] since they are not implemented on XEmacs. -;; -;; 2005/Feb/01: explicitly provide default argument of 1 to -;; 'backward-word' as it requires it on Emacs 21.3 -;; -;; 2005/Mar/06: now stored inside ruby CVS; customize pages now have -;; ruby as parent; cosmetic fixes. - - -(require 'ruby-mode) - -(defgroup ruby-electric nil - "Minor mode providing electric editing commands for ruby files" - :group 'ruby) - -(defconst ruby-electric-expandable-do-re - "do\\s-$") - -(defconst ruby-electric-expandable-bar - "\\s-\\(do\\|{\\)\\s-+|") - -(defvar ruby-electric-matching-delimeter-alist - '((?\[ . ?\]) - (?\( . ?\)) - (?\' . ?\') - (?\` . ?\`) - (?\" . ?\"))) - -(defcustom ruby-electric-simple-keywords-re - "\\(def\\|if\\|class\\|module\\|unless\\|case\\|while\\|do\\|until\\|for\\|begin\\)" - "*Regular expresion matching keywords for which closing 'end' -is to be inserted." - :type 'regexp :group 'ruby-electric) - -(defcustom ruby-electric-expand-delimiters-list '(all) - "*List of contexts where matching delimiter should be -inserted. The word 'all' will do all insertions." - :type '(set :extra-offset 8 - (const :tag "Everything" all ) - (const :tag "Curly brace" ?\{ ) - (const :tag "Square brace" ?\[ ) - (const :tag "Round brace" ?\( ) - (const :tag "Quote" ?\' ) - (const :tag "Double quote" ?\" ) - (const :tag "Back quote" ?\` ) - (const :tag "Vertical bar" ?\| )) - :group 'ruby-electric) - -(defcustom ruby-electric-newline-before-closing-bracket nil - "*Controls whether a newline should be inserted before the -closing bracket or not." - :type 'boolean :group 'ruby-electric) - -(define-minor-mode ruby-electric-mode - "Toggle Ruby Electric minor mode. -With no argument, this command toggles the mode. Non-null prefix -argument turns on the mode. Null prefix argument turns off the -mode. - -When Ruby Electric mode is enabled, an indented 'end' is -heuristicaly inserted whenever typing a word like 'module', -'class', 'def', 'if', 'unless', 'case', 'until', 'for', 'begin', -'do'. Simple, double and back quotes as well as braces are paired -auto-magically. Expansion does not occur inside comments and -strings. Note that you must have Font Lock enabled." - ;; initial value. - nil - ;;indicator for the mode line. - " REl" - ;;keymap - ruby-mode-map - (ruby-electric-setup-keymap)) - -(defun ruby-electric-setup-keymap() - (define-key ruby-mode-map " " 'ruby-electric-space) - (define-key ruby-mode-map "{" 'ruby-electric-curlies) - (define-key ruby-mode-map "(" 'ruby-electric-matching-char) - (define-key ruby-mode-map "[" 'ruby-electric-matching-char) - (define-key ruby-mode-map "\"" 'ruby-electric-matching-char) - (define-key ruby-mode-map "\'" 'ruby-electric-matching-char) - (define-key ruby-mode-map "|" 'ruby-electric-bar)) - -(defun ruby-electric-space (arg) - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (if (ruby-electric-space-can-be-expanded-p) - (save-excursion - (ruby-indent-line t) - (newline) - (ruby-insert-end)))) - -(defun ruby-electric-code-at-point-p() - (and ruby-electric-mode - (let* ((properties (text-properties-at (point)))) - (and (null (memq 'font-lock-string-face properties)) - (null (memq 'font-lock-comment-face properties)))))) - -(defun ruby-electric-string-at-point-p() - (and ruby-electric-mode - (consp (memq 'font-lock-string-face (text-properties-at (point)))))) - -(defun ruby-electric-is-last-command-char-expandable-punct-p() - (or (memq 'all ruby-electric-expand-delimiters-list) - (memq last-command-char ruby-electric-expand-delimiters-list))) - -(defun ruby-electric-space-can-be-expanded-p() - (if (ruby-electric-code-at-point-p) - (let* ((ruby-electric-keywords-re - (concat ruby-electric-simple-keywords-re "\\s-$")) - (ruby-electric-single-keyword-in-line-re - (concat "\\s-*" ruby-electric-keywords-re))) - (save-excursion - (backward-word 1) - (or (looking-at ruby-electric-expandable-do-re) - (and (looking-at ruby-electric-keywords-re) - (not (string= "do" (match-string 1))) - (progn - (beginning-of-line) - (looking-at ruby-electric-single-keyword-in-line-re)))))))) - - -(defun ruby-electric-curlies(arg) - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (if (ruby-electric-is-last-command-char-expandable-punct-p) - (cond ((ruby-electric-code-at-point-p) - (insert " ") - (save-excursion - (if ruby-electric-newline-before-closing-bracket - (newline)) - (insert "}"))) - ((ruby-electric-string-at-point-p) - (save-excursion - (backward-char 1) - (when (char-equal ?\# (preceding-char)) - (forward-char 1) - (insert "}"))))))) - -(defun ruby-electric-matching-char(arg) - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (and (ruby-electric-is-last-command-char-expandable-punct-p) - (ruby-electric-code-at-point-p) - (save-excursion - (insert (cdr (assoc last-command-char - ruby-electric-matching-delimeter-alist)))))) - -(defun ruby-electric-bar(arg) - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (and (ruby-electric-is-last-command-char-expandable-punct-p) - (ruby-electric-code-at-point-p) - (and (save-excursion (re-search-backward ruby-electric-expandable-bar nil t)) - (= (point) (match-end 0))) ;looking-back is missing on XEmacs - (save-excursion - (insert "|")))) - - -(provide 'ruby-electric) diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb deleted file mode 100644 index df229a8f1a..0000000000 --- a/test/ruby/test_super.rb +++ /dev/null @@ -1,88 +0,0 @@ -require 'test/unit' - -class TestSuper < Test::Unit::TestCase - class Base - def single(a) a end - def double(a, b) [a,b] end - def array(*a) a end - end - class Single1 < Base - def single(*) super end - end - class Single2 < Base - def single(a,*) super end - end - class Double1 < Base - def double(*) super end - end - class Double2 < Base - def double(a,*) super end - end - class Double3 < Base - def double(a,b,*) super end - end - class Array1 < Base - def array(*) super end - end - class Array2 < Base - def array(a,*) super end - end - class Array3 < Base - def array(a,b,*) super end - end - class Array4 < Base - def array(a,b,c,*) super end - end - - def test_single1 - assert_equal(1, Single1.new.single(1)) - end - def test_single2 - assert_equal(1, Single2.new.single(1)) - end - def test_double1 - assert_equal([1, 2], Double1.new.double(1, 2)) - end - def test_double2 - assert_equal([1, 2], Double2.new.double(1, 2)) - end - def test_double3 - assert_equal([1, 2], Double3.new.double(1, 2)) - end - def test_array1 - assert_equal([], Array1.new.array()) - assert_equal([1], Array1.new.array(1)) - end - def test_array2 - assert_equal([1], Array2.new.array(1)) - assert_equal([1,2], Array2.new.array(1, 2)) - end - def test_array3 - assert_equal([1,2], Array3.new.array(1, 2)) - assert_equal([1,2,3], Array3.new.array(1, 2, 3)) - end - def test_array4 - assert_equal([1,2,3], Array4.new.array(1, 2, 3)) - assert_equal([1,2,3,4], Array4.new.array(1, 2, 3, 4)) - end - - class A - def tt(aa) - "A#tt" - end - - def uu(a) - class << self - define_method(:tt) do |sym| - super - end - end - end - end - - def test_define_method # [ruby-core:03856] - a = A.new - a.uu(12) - assert_equal("A#tt", a.tt(12)) - end -end diff --git a/test/xmlrpc/data/bug_bool.expected b/test/xmlrpc/data/bug_bool.expected deleted file mode 100644 index 121e3a84ba..0000000000 --- a/test/xmlrpc/data/bug_bool.expected +++ /dev/null @@ -1,3 +0,0 @@ ---- -- true -- false \ No newline at end of file diff --git a/test/xmlrpc/data/bug_bool.xml b/test/xmlrpc/data/bug_bool.xml deleted file mode 100644 index 04ed00709e..0000000000 --- a/test/xmlrpc/data/bug_bool.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - 0 - - - diff --git a/test/xmlrpc/data/bug_cdata.expected b/test/xmlrpc/data/bug_cdata.expected deleted file mode 100644 index 17d7861318..0000000000 --- a/test/xmlrpc/data/bug_cdata.expected +++ /dev/null @@ -1,3 +0,0 @@ ---- -- true -- test \ No newline at end of file diff --git a/test/xmlrpc/data/bug_cdata.xml b/test/xmlrpc/data/bug_cdata.xml deleted file mode 100644 index ba990e04f1..0000000000 --- a/test/xmlrpc/data/bug_cdata.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/test/xmlrpc/data/bug_covert.expected b/test/xmlrpc/data/bug_covert.expected deleted file mode 100644 index a9ac103c64..0000000000 --- a/test/xmlrpc/data/bug_covert.expected +++ /dev/null @@ -1,10 +0,0 @@ ---- -- true -- > - Site,SANs,Array - - Configured Capacity,Array Reserved Capacity,Array Ava - - ilable Capacity,Array % Reserved,Host Allocated,Host Used,Host Free,Host % - - Used diff --git a/test/xmlrpc/data/bug_covert.xml b/test/xmlrpc/data/bug_covert.xml deleted file mode 100644 index 1d9abd2a06..0000000000 --- a/test/xmlrpc/data/bug_covert.xml +++ /dev/null @@ -1,6 +0,0 @@ -Site,SANs,Array -Configured Capacity,Array Reserved Capacity,Array Ava -ilable Capacity,Array % Reserved,Host Allocated,Host Used,Host Free,Host % -Used - diff --git a/test/xmlrpc/data/datetime_iso8601.xml b/test/xmlrpc/data/datetime_iso8601.xml deleted file mode 100644 index 43d8da6c13..0000000000 --- a/test/xmlrpc/data/datetime_iso8601.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - 20041105T01:15:23Z - - - diff --git a/test/xmlrpc/data/fault.xml b/test/xmlrpc/data/fault.xml deleted file mode 100644 index 041c464eb3..0000000000 --- a/test/xmlrpc/data/fault.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - faultCode - 4 - - - faultString - an error message - - - - - diff --git a/test/xmlrpc/data/value.expected b/test/xmlrpc/data/value.expected deleted file mode 100644 index 9463d02b13..0000000000 --- a/test/xmlrpc/data/value.expected +++ /dev/null @@ -1,7 +0,0 @@ ---- -- Test -- - - Hallo Leute - - " Hallo " - - '' - - " " \ No newline at end of file diff --git a/test/xmlrpc/data/value.xml b/test/xmlrpc/data/value.xml deleted file mode 100644 index 1978616099..0000000000 --- a/test/xmlrpc/data/value.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - Test - - - Hallo Leute - - - Hallo - - - - - - - - - - - - - diff --git a/test/xmlrpc/data/xml1.expected b/test/xmlrpc/data/xml1.expected deleted file mode 100644 index ff96de8df3..0000000000 --- a/test/xmlrpc/data/xml1.expected +++ /dev/null @@ -1,243 +0,0 @@ ---- -- true -- - - - subscriber: MegaCorp - lastName: Baker - telephone1: 1-508-791-1267 - telephone2: 1-800-445-2588 - password: p1111 - OID: "1" - email: hbaker@yahoo.com - adminId: hbaker - objectName: AdministratorDO - - - subscriber: CornerStore - lastName: Dragon - telephone1: 1-781-789-9089 - telephone2: 1-800-445-2588 - password: p3333 - OID: "3" - email: adragon@yahoo.com - adminId: adragon - objectName: AdministratorDO - - - subscriber: Cyberdyne - lastName: Rodman - telephone1: 1-617-789-1890 - telephone2: 1-800-445-2588 - password: p4444 - OID: "4" - email: mrodman@yahoo.com - adminId: mrodman - objectName: AdministratorDO - - - subscriber: StarSports - lastName: Jordan - telephone1: 1-617-890-7897 - telephone2: 1-800-445-2588 - password: p5555 - OID: "5" - email: mjordan@yahoo.com - adminId: mjordan - objectName: AdministratorDO - - - subscriber: GreatBooks - lastName: Pippen - telephone1: 1-781-789-9876 - telephone2: 1-800-445-2588 - password: p6666 - OID: "6" - email: gpippen@yahoo.com - adminId: gpippen - objectName: AdministratorDO - - - subscriber: AxisChemicals - lastName: Andhrew - telephone1: 1-781-678-8970 - telephone2: 1-800-445-2588 - password: p7777 - OID: "7" - email: aandrew@yahoo.com - adminId: aandrew - objectName: AdministratorDO - - - subscriber: MediaShop - lastName: Vincent - telephone1: 1-786-897-8908 - telephone2: 1-800-445-2588 - password: p8888 - OID: "8" - email: tvincent@yahoo.com - adminId: tvincent - objectName: AdministratorDO - - - subscriber: SmartShop - lastName: Richard - telephone1: 1-508-789-6789 - telephone2: 1-800-445-2588 - password: p9999 - OID: "9" - email: krichard@yahoo.com - adminId: krichard - objectName: AdministratorDO - - - subscriber: HomeNeeds - lastName: Cornell - telephone1: 1-617-789-8979 - telephone2: 1-800-445-2588 - password: paaaa - OID: "10" - email: gconell@yahoo.com - adminId: gcornell - objectName: AdministratorDO - - - subscriber: MegaCorp - lastName: HorstMann - telephone1: 1-508-791-1267 - telephone2: 1-800-445-2588 - password: p1111 - OID: "11" - email: shorstmann@yahoo.com - adminId: shorstmann - objectName: AdministratorDO - - - subscriber: CornerStore - lastName: Bob - telephone1: 1-781-789-9089 - telephone2: 1-800-445-2588 - password: p3333 - OID: "13" - email: rbob@yahoo.com - adminId: rbob - objectName: AdministratorDO - - - subscriber: Cyberdyne - lastName: Peter - telephone1: 1-617-789-1890 - telephone2: 1-800-445-2588 - password: p4444 - OID: "14" - email: speter@yahoo.com - adminId: speter - objectName: AdministratorDO - - - subscriber: StarSports - lastName: Novak - telephone1: 1-617-890-7897 - telephone2: 1-800-445-2588 - password: p5555 - OID: "15" - email: pnovak@yahoo.com - adminId: pnovak - objectName: AdministratorDO - - - subscriber: GreatBooks - lastName: Nancy - telephone1: 1-781-789-9876 - telephone2: 1-800-445-2588 - password: p6666 - OID: "16" - email: pnancy@yahoo.com - adminId: pnancy - objectName: AdministratorDO - - - subscriber: AxisChemicals - lastName: Michel - telephone1: 1-781-678-8970 - telephone2: 1-800-445-2588 - password: p7777 - OID: "17" - email: hmichel@yahoo.com - adminId: hmichel - objectName: AdministratorDO - - - subscriber: MediaShop - lastName: David - telephone1: 1-786-897-8908 - telephone2: 1-800-445-2588 - password: p8888 - OID: "18" - email: kdavid@yahoo.com - adminId: kdavid - objectName: AdministratorDO - - - subscriber: SmartShop - lastName: Valnoor - telephone1: 1-508-789-6789 - telephone2: 1-800-445-2588 - password: p9999 - OID: "19" - email: pvalnoor@yahoo.com - adminId: pvalnoor - objectName: AdministratorDO - - - subscriber: HomeNeeds - lastName: Smith - telephone1: 1-617-789-8979 - telephone2: 1-800-445-2588 - password: paaaa - OID: "20" - email: wsmith@yahoo.com - adminId: wsmith - objectName: AdministratorDO - - - subscriber: MegaCorp - lastName: Caral - telephone1: 1-781-789-9876 - telephone2: 1-800-445-2588 - password: p6666 - OID: "21" - email: gcaral@yahoo.com - adminId: gcaral - objectName: AdministratorDO - - - subscriber: CornerStore - lastName: Hillary - telephone1: 1-786-897-8908 - telephone2: 1-800-445-2588 - password: p8888 - OID: "23" - email: phillary@yahoo.com - adminId: phillary - objectName: AdministratorDO - - - subscriber: Cyberdyne - lastName: Philip - telephone1: 1-508-789-6789 - telephone2: 1-800-445-2588 - password: p9999 - OID: "24" - email: bphilip@yahoo.com - adminId: bphilip - objectName: AdministratorDO - - - subscriber: StarSports - lastName: Andrea - telephone1: 1-617-789-8979 - telephone2: 1-800-445-2588 - password: paaaa - OID: "25" - email: sandrea@yahoo.com - adminId: sandrea - objectName: AdministratorDO - - - subscriber: s4 - lastName: "null" - telephone1: "null" - telephone2: "null" - password: s4 - OID: "26" - email: "null" - adminId: s4 - objectName: AdministratorDO - - - subscriber: BigBank - lastName: administrator - telephone1: '' - telephone2: '' - password: admin - OID: "82" - email: '' - adminId: admin - objectName: AdministratorDO \ No newline at end of file diff --git a/test/xmlrpc/data/xml1.xml b/test/xmlrpc/data/xml1.xml deleted file mode 100644 index 10aa55483b..0000000000 --- a/test/xmlrpc/data/xml1.xml +++ /dev/null @@ -1 +0,0 @@ -objectNameAdministratorDOadminIdhbakeremailhbaker@yahoo.comtelephone21-800-445-2588telephone11-508-791-1267OID1passwordp1111lastNameBakersubscriberMegaCorpobjectNameAdministratorDOadminIdadragonemailadragon@yahoo.comtelephone21-800-445-2588telephone11-781-789-9089OID3passwordp3333lastNameDragonsubscriberCornerStoreobjectNameAdministratorDOadminIdmrodmanemailmrodman@yahoo.comtelephone21-800-445-2588telephone11-617-789-1890OID4passwordp4444lastNameRodmansubscriberCyberdyneobjectNameAdministratorDOadminIdmjordanemailmjordan@yahoo.comtelephone21-800-445-2588telephone11-617-890-7897OID5passwordp5555lastNameJordansubscriberStarSportsobjectNameAdministratorDOadminIdgpippenemailgpippen@yahoo.comtelephone21-800-445-2588telephone11-781-789-9876OID6passwordp6666lastNamePippensubscriberGreatBooksobjectNameAdministratorDOadminIdaandrewemailaandrew@yahoo.comtelephone21-800-445-2588telephone11-781-678-8970OID7passwordp7777lastNameAndhrewsubscriberAxisChemicalsobjectNameAdministratorDOadminIdtvincentemailtvincent@yahoo.comtelephone21-800-445-2588telephone11-786-897-8908OID8passwordp8888lastNameVincentsubscriberMediaShopobjectNameAdministratorDOadminIdkrichardemailkrichard@yahoo.comtelephone21-800-445-2588telephone11-508-789-6789OID9passwordp9999lastNameRichardsubscriberSmartShopobjectNameAdministratorDOadminIdgcornellemailgconell@yahoo.comtelephone21-800-445-2588telephone11-617-789-8979OID10passwordpaaaalastNameCornellsubscriberHomeNeedsobjectNameAdministratorDOadminIdshorstmannemailshorstmann@yahoo.comtelephone21-800-445-2588telephone11-508-791-1267OID11passwordp1111lastNameHorstMannsubscriberMegaCorpobjectNameAdministratorDOadminIdrbobemailrbob@yahoo.comtelephone21-800-445-2588telephone11-781-789-9089OID13passwordp3333lastNameBobsubscriberCornerStoreobjectNameAdministratorDOadminIdspeteremailspeter@yahoo.comtelephone21-800-445-2588telephone11-617-789-1890OID14passwordp4444lastNamePetersubscriberCyberdyneobjectNameAdministratorDOadminIdpnovakemailpnovak@yahoo.comtelephone21-800-445-2588telephone11-617-890-7897OID15passwordp5555lastNameNovaksubscriberStarSportsobjectNameAdministratorDOadminIdpnancyemailpnancy@yahoo.comtelephone21-800-445-2588telephone11-781-789-9876OID16passwordp6666lastNameNancysubscriberGreatBooksobjectNameAdministratorDOadminIdhmichelemailhmichel@yahoo.comtelephone21-800-445-2588telephone11-781-678-8970OID17passwordp7777lastNameMichelsubscriberAxisChemicalsobjectNameAdministratorDOadminIdkdavidemailkdavid@yahoo.comtelephone21-800-445-2588telephone11-786-897-8908OID18passwordp8888lastNameDavidsubscriberMediaShopobjectNameAdministratorDOadminIdpvalnooremailpvalnoor@yahoo.comtelephone21-800-445-2588telephone11-508-789-6789OID19passwordp9999lastNameValnoorsubscriberSmartShopobjectNameAdministratorDOadminIdwsmithemailwsmith@yahoo.comtelephone21-800-445-2588telephone11-617-789-8979OID20passwordpaaaalastNameSmithsubscriberHomeNeedsobjectNameAdministratorDOadminIdgcaralemailgcaral@yahoo.comtelephone21-800-445-2588telephone11-781-789-9876OID21passwordp6666lastNameCaralsubscriberMegaCorpobjectNameAdministratorDOadminIdphillaryemailphillary@yahoo.comtelephone21-800-445-2588telephone11-786-897-8908OID23passwordp8888lastNameHillarysubscriberCornerStoreobjectNameAdministratorDOadminIdbphilipemailbphilip@yahoo.comtelephone21-800-445-2588telephone11-508-789-6789OID24passwordp9999lastNamePhilipsubscriberCyberdyneobjectNameAdministratorDOadminIdsandreaemailsandrea@yahoo.comtelephone21-800-445-2588telephone11-617-789-8979OID25passwordpaaaalastNameAndreasubscriberStarSportsobjectNameAdministratorDOadminIds4emailnulltelephone2nulltelephone1nullOID26passwords4lastNamenullsubscribers4objectNameAdministratorDOadminIdadminemailtelephone2telephone1OID82passwordadminlastNameadministratorsubscriberBigBank diff --git a/test/xmlrpc/test_datetime.rb b/test/xmlrpc/test_datetime.rb deleted file mode 100644 index e38cea6f74..0000000000 --- a/test/xmlrpc/test_datetime.rb +++ /dev/null @@ -1,159 +0,0 @@ -require 'test/unit' -require "xmlrpc/datetime" - -class Test_DateTime < Test::Unit::TestCase - - def test_new - dt = createDateTime() - - assert_instance_of(XMLRPC::DateTime, dt) - end - - def test_new_exception - assert_raises(ArgumentError) { XMLRPC::DateTime.new(4.5, 13, 32, 25, 60, 60) } - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 32, 25, 60, 60) } - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 31, 25, 60, 60) } - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 31, 24, 60, 60) } - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 31, 24, 59, 60) } - assert_nothing_raised(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 31, 24, 59, 59) } - - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 0, 0, -1, -1, -1) } - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 0, -1, -1, -1) } - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 1, -1, -1, -1) } - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 1, 0, -1, -1) } - assert_raises(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 1, 0, 0, -1) } - assert_nothing_raised(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 1, 0, 0, 0) } - end - - - def test_get_values - y, m, d, h, mi, s = 1970, 3, 24, 12, 0, 5 - dt = XMLRPC::DateTime.new(y, m, d, h, mi, s) - - assert_equal(y, dt.year) - assert_equal(m, dt.month) - assert_equal(m, dt.mon) - assert_equal(d, dt.day) - - assert_equal(h, dt.hour) - assert_equal(mi,dt.min) - assert_equal(s, dt.sec) - end - - def test_set_values - dt = createDateTime() - y, m, d, h, mi, s = 1950, 12, 9, 8, 52, 30 - - dt.year = y - dt.month = m - dt.day = d - dt.hour = h - dt.min = mi - dt.sec = s - - assert_equal(y, dt.year) - assert_equal(m, dt.month) - assert_equal(m, dt.mon) - assert_equal(d, dt.day) - - assert_equal(h, dt.hour) - assert_equal(mi,dt.min) - assert_equal(s, dt.sec) - - dt.mon = 5 - assert_equal(5, dt.month) - assert_equal(5, dt.mon) - end - - def test_set_exception - dt = createDateTime() - - assert_raises(ArgumentError) { dt.year = 4.5 } - assert_nothing_raised(ArgumentError) { dt.year = -2000 } - - assert_raises(ArgumentError) { dt.month = 0 } - assert_raises(ArgumentError) { dt.month = 13 } - assert_nothing_raised(ArgumentError) { dt.month = 7 } - - assert_raises(ArgumentError) { dt.mon = 0 } - assert_raises(ArgumentError) { dt.mon = 13 } - assert_nothing_raised(ArgumentError) { dt.mon = 7 } - - assert_raises(ArgumentError) { dt.day = 0 } - assert_raises(ArgumentError) { dt.day = 32 } - assert_nothing_raised(ArgumentError) { dt.day = 16 } - - assert_raises(ArgumentError) { dt.hour = -1 } - assert_raises(ArgumentError) { dt.hour = 25 } - assert_nothing_raised(ArgumentError) { dt.hour = 12 } - - assert_raises(ArgumentError) { dt.min = -1 } - assert_raises(ArgumentError) { dt.min = 60 } - assert_nothing_raised(ArgumentError) { dt.min = 30 } - - assert_raises(ArgumentError) { dt.sec = -1 } - assert_raises(ArgumentError) { dt.sec = 60 } - assert_nothing_raised(ArgumentError) { dt.sec = 30 } - end - - def test_to_a - y, m, d, h, mi, s = 1970, 3, 24, 12, 0, 5 - dt = XMLRPC::DateTime.new(y, m, d, h, mi, s) - a = dt.to_a - - assert_instance_of(Array, a) - assert_equal(6, a.size, "Returned array has wrong size") - - assert_equal(y, a[0]) - assert_equal(m, a[1]) - assert_equal(d, a[2]) - assert_equal(h, a[3]) - assert_equal(mi, a[4]) - assert_equal(s, a[5]) - end - - def test_to_time1 - y, m, d, h, mi, s = 1970, 3, 24, 12, 0, 5 - dt = XMLRPC::DateTime.new(y, m, d, h, mi, s) - time = dt.to_time - - assert_not_nil(time) - - assert_equal(y, time.year) - assert_equal(m, time.month) - assert_equal(d, time.day) - assert_equal(h, time.hour) - assert_equal(mi, time.min) - assert_equal(s, time.sec) - end - - def test_to_time2 - dt = createDateTime() - dt.year = 1969 - - assert_nil(dt.to_time) - end - - def test_to_date1 - y, m, d, h, mi, s = 1970, 3, 24, 12, 0, 5 - dt = XMLRPC::DateTime.new(y, m, d, h, mi, s) - date = dt.to_date - - assert_equal(y, date.year) - assert_equal(m, date.month) - assert_equal(d, date.day) - end - - def test_to_date2 - dt = createDateTime() - dt.year = 666 - - assert_equal(666, dt.to_date.year) - end - - - def createDateTime - XMLRPC::DateTime.new(1970, 3, 24, 12, 0, 5) - end - -end diff --git a/test/xmlrpc/test_features.rb b/test/xmlrpc/test_features.rb deleted file mode 100644 index 96a6313202..0000000000 --- a/test/xmlrpc/test_features.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'test/unit' -require "xmlrpc/create" -require "xmlrpc/parser" -require "xmlrpc/config" - -class Test_Features < Test::Unit::TestCase - - def setup - @params = [nil, {"test" => nil}, [nil, 1, nil]] - end - - def test_nil_create - XMLRPC::XMLWriter.each_installed_writer do |writer| - c = XMLRPC::Create.new(writer) - - XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_CREATE)} - XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, false) - assert_raises(RuntimeError) { str = c.methodCall("test", *@params) } - - XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_CREATE)} - XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, true) - assert_nothing_raised { str = c.methodCall("test", *@params) } - end - end - - def test_nil_parse - XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_CREATE)} - XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, true) - - XMLRPC::XMLWriter.each_installed_writer do |writer| - c = XMLRPC::Create.new(writer) - str = c.methodCall("test", *@params) - XMLRPC::XMLParser.each_installed_parser do |parser| - para = nil - - XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_PARSER)} - XMLRPC::Config.const_set(:ENABLE_NIL_PARSER, false) - assert_raises(RuntimeError) { para = parser.parseMethodCall(str) } - - XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_PARSER)} - XMLRPC::Config.const_set(:ENABLE_NIL_PARSER, true) - assert_nothing_raised { para = parser.parseMethodCall(str) } - assert_equal(para[1], @params) - end - end - end - -end diff --git a/test/xmlrpc/test_marshal.rb b/test/xmlrpc/test_marshal.rb deleted file mode 100644 index 38bc8c646f..0000000000 --- a/test/xmlrpc/test_marshal.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'test/unit' -require "xmlrpc/marshal" - -class Test_Marshal < Test::Unit::TestCase - # for test_parser_values - class Person - include XMLRPC::Marshallable - attr_reader :name - def initialize(name) - @name = name - end - end - - - def test1_dump_response - assert_nothing_raised(NameError) { - XMLRPC::Marshal.dump_response('arg') - } - end - - def test1_dump_call - assert_nothing_raised(NameError) { - XMLRPC::Marshal.dump_call('methodName', 'arg') - } - end - - def test2_dump_load_response - value = [1, 2, 3, {"test" => true}, 3.4] - res = XMLRPC::Marshal.dump_response(value) - - assert_equal(value, XMLRPC::Marshal.load_response(res)) - end - - def test2_dump_load_call - methodName = "testMethod" - value = [1, 2, 3, {"test" => true}, 3.4] - exp = [methodName, [value, value]] - - res = XMLRPC::Marshal.dump_call(methodName, value, value) - - assert_equal(exp, XMLRPC::Marshal.load_call(res)) - end - - def test_parser_values - v1 = [ - 1, -7778, # integers - 1.0, 0.0, -333.0, 2343434343.0, # floats - false, true, true, false, # booleans - "Hallo", "with < and >", "" # strings - ] - - v2 = [ - [v1, v1, v1], - {"a" => v1} - ] - - v3 = [ - XMLRPC::Base64.new("\001"*1000), # base64 - :aSymbol, :anotherSym # symbols (-> string) - ] - v3_exp = [ - "\001"*1000, - "aSymbol", "anotherSym" - ] - person = Person.new("Michael") - - XMLRPC::XMLParser.each_installed_parser do |parser| - m = XMLRPC::Marshal.new(parser) - - assert_equal( v1, m.load_response(m.dump_response(v1)) ) - assert_equal( v2, m.load_response(m.dump_response(v2)) ) - assert_equal( v3_exp, m.load_response(m.dump_response(v3)) ) - - pers = m.load_response(m.dump_response(person)) - - assert( pers.is_a?(Person) ) - assert( person.name == pers.name ) - end - - # missing, Date, Time, DateTime - # Struct - end - - def test_no_params_tag - # bug found by Idan Sofer - - expect = %{myMethod\n} - - str = XMLRPC::Marshal.dump_call("myMethod") - assert_equal(expect, str) - end - -end diff --git a/test/xmlrpc/test_parser.rb b/test/xmlrpc/test_parser.rb deleted file mode 100644 index 44ca1f88b7..0000000000 --- a/test/xmlrpc/test_parser.rb +++ /dev/null @@ -1,85 +0,0 @@ -require 'test/unit' -require 'xmlrpc/datetime' -require "xmlrpc/parser" -require 'yaml' - -module GenericParserTest - def datafile(base) - File.join(File.dirname(__FILE__), "data", base) - end - - def load_data(name) - [File.read(datafile(name) + ".xml"), YAML.load(File.read(datafile(name) + ".expected"))] - end - - def setup - @xml1, @expected1 = load_data('xml1') - @xml2, @expected2 = load_data('bug_covert') - @xml3, @expected3 = load_data('bug_bool') - @xml4, @expected4 = load_data('value') - - @cdata_xml, @cdata_expected = load_data('bug_cdata') - - @datetime_xml = File.read(datafile('datetime_iso8601.xml')) - @datetime_expected = XMLRPC::DateTime.new(2004, 11, 5, 1, 15, 23) - - @fault_doc = File.read(datafile('fault.xml')) - end - - # test parseMethodResponse -------------------------------------------------- - - def test_parseMethodResponse1 - assert_equal(@expected1, @p.parseMethodResponse(@xml1)) - end - - def test_parseMethodResponse2 - assert_equal(@expected2, @p.parseMethodResponse(@xml2)) - end - - def test_parseMethodResponse3 - assert_equal(@expected3, @p.parseMethodResponse(@xml3)) - end - - def test_cdata - assert_equal(@cdata_expected, @p.parseMethodResponse(@cdata_xml)) - end - - def test_dateTime - assert_equal(@datetime_expected, @p.parseMethodResponse(@datetime_xml)[1]) - end - - # test parseMethodCall ------------------------------------------------------ - - def test_parseMethodCall - assert_equal(@expected4, @p.parseMethodCall(@xml4)) - end - - # test fault ---------------------------------------------------------------- - - def test_fault - flag, fault = @p.parseMethodResponse(@fault_doc) - assert_equal(flag, false) - unless fault.is_a? XMLRPC::FaultException - assert(false, "must be an instance of class XMLRPC::FaultException") - end - assert_equal(fault.faultCode, 4) - assert_equal(fault.faultString, "an error message") - end -end - -# create test class for each installed parser -XMLRPC::XMLParser.each_installed_parser do |parser| - klass = parser.class - name = klass.to_s.split("::").last - - eval %{ - class Test_#{name} < Test::Unit::TestCase - include GenericParserTest - - def setup - super - @p = #{klass}.new - end - end - } -end diff --git a/test/xmlrpc/test_webrick_server.rb b/test/xmlrpc/test_webrick_server.rb deleted file mode 100644 index e7fed016b0..0000000000 --- a/test/xmlrpc/test_webrick_server.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'test/unit' -require 'webrick' -require File.join(File.dirname(__FILE__), 'webrick_testing') -require "xmlrpc/server" -require 'xmlrpc/client' - -class Test_Webrick < Test::Unit::TestCase - include WEBrick_Testing - - def create_servlet - s = XMLRPC::WEBrickServlet.new - - s.add_handler("test.add") do |a,b| - a + b - end - - s.add_handler("test.div") do |a,b| - if b == 0 - raise XMLRPC::FaultException.new(1, "division by zero") - else - a / b - end - end - - s.set_default_handler do |name, *args| - raise XMLRPC::FaultException.new(-99, "Method #{name} missing" + - " or wrong number of parameters!") - end - - s.add_introspection - - return s - end - - def setup_http_server(port, use_ssl) - require 'webrick/https' - start_server( - :Port => port, - :SSLEnable => use_ssl, - :SSLVerifyClient => ::OpenSSL::SSL::VERIFY_NONE, - :SSLCertName => [] - ) {|w| w.mount('/RPC2', create_servlet) } - - @s = XMLRPC::Client.new3(:port => port, :use_ssl => use_ssl) - end - - PORT = 8070 - def test_client_server - # NOTE: I don't enable SSL testing as this hangs - [false].each do |use_ssl| - begin - setup_http_server(PORT, use_ssl) - do_test - ensure - stop_server - end - end - end - - def do_test - # simple call - assert_equal 9, @s.call('test.add', 4, 5) - - # fault exception - assert_raises(XMLRPC::FaultException) { @s.call('test.div', 1, 0) } - - # fault exception via call2 - ok, param = @s.call2('test.div', 1, 0) - assert_equal false, ok - assert_instance_of XMLRPC::FaultException, param - assert_equal 1, param.faultCode - assert_equal 'division by zero', param.faultString - - # call2 without fault exception - ok, param = @s.call2('test.div', 10, 5) - assert_equal true, ok - assert_equal param, 2 - - # introspection - assert_equal ["test.add", "test.div", "system.listMethods", "system.methodSignature", "system.methodHelp"], @s.call("system.listMethods") - - # default handler (missing handler) - ok, param = @s.call2('test.nonexisting') - assert_equal false, ok - assert_equal -99, param.faultCode - - # default handler (wrong number of arguments) - ok, param = @s.call2('test.add', 1, 2, 3) - assert_equal false, ok - assert_equal -99, param.faultCode - end -end diff --git a/test/xmlrpc/webrick_testing.rb b/test/xmlrpc/webrick_testing.rb deleted file mode 100644 index a6830cece1..0000000000 --- a/test/xmlrpc/webrick_testing.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'timeout' - -module WEBrick_Testing - class DummyLog < WEBrick::BasicLog - def initialize() super(self) end - def <<(*args) end - end - - def start_server(config={}) - raise "already started" if @__server - @__started = false - - Thread.new { - @__server = WEBrick::HTTPServer.new( - { - :Logger => DummyLog.new, - :AccessLog => [], - :StartCallback => proc { @__started = true } - }.update(config)) - yield @__server - @__server.start - @__started = false - } - - Timeout.timeout(5) { - nil until @__started # wait until the server is ready - } - end - - def stop_server - Timeout.timeout(5) { - @__server.shutdown - nil while @__started # wait until the server is down - } - @__server = nil - end -end -- cgit v1.2.3