shoesgem 0.1424.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +30 -0
- data/README.rdoc +31 -0
- data/lib/shoes.rb +4 -0
- data/shoes/CHANGELOG.txt +21 -0
- data/shoes/COPYING.txt +30 -0
- data/shoes/README.txt +117 -0
- data/shoes/VERSION.txt +1 -0
- data/shoes/fonts/Coolvetica.ttf +0 -0
- data/shoes/fonts/Lacuna.ttf +0 -0
- data/shoes/freetype6.dll +0 -0
- data/shoes/lib/shoes/cache.rb +54 -0
- data/shoes/lib/shoes/data.rb +39 -0
- data/shoes/lib/shoes/help.rb +421 -0
- data/shoes/lib/shoes/image.rb +25 -0
- data/shoes/lib/shoes/inspect.rb +128 -0
- data/shoes/lib/shoes/log.rb +48 -0
- data/shoes/lib/shoes/minitar.rb +986 -0
- data/shoes/lib/shoes/override.rb +38 -0
- data/shoes/lib/shoes/pack.rb +503 -0
- data/shoes/lib/shoes/search.rb +46 -0
- data/shoes/lib/shoes/setup.rb +329 -0
- data/shoes/lib/shoes/shy.rb +131 -0
- data/shoes/lib/shoes/shybuilder.rb +44 -0
- data/shoes/lib/shoes.rb +522 -0
- data/shoes/libcairo-2.dll +0 -0
- data/shoes/libeay32.dll +0 -0
- data/shoes/libexpat-1.dll +0 -0
- data/shoes/libfontconfig-1.dll +0 -0
- data/shoes/libgio-2.0-0.dll +0 -0
- data/shoes/libglib-2.0-0.dll +0 -0
- data/shoes/libgmodule-2.0-0.dll +0 -0
- data/shoes/libgobject-2.0-0.dll +0 -0
- data/shoes/libgthread-2.0-0.dll +0 -0
- data/shoes/libiconv2.dll +0 -0
- data/shoes/libjpeg-8.dll +0 -0
- data/shoes/libpango-1.0-0.dll +0 -0
- data/shoes/libpangocairo-1.0-0.dll +0 -0
- data/shoes/libpangoft2-1.0-0.dll +0 -0
- data/shoes/libpangowin32-1.0-0.dll +0 -0
- data/shoes/libpng14-14.dll +0 -0
- data/shoes/libportaudio-2.dll +0 -0
- data/shoes/libshoes.dll +0 -0
- data/shoes/libssl32.dll +0 -0
- data/shoes/libungif4.dll +0 -0
- data/shoes/msvcrt-ruby191.dll +0 -0
- data/shoes/readline5.dll +0 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/fast_xs.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/blankslate.rb +63 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/builder.rb +216 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/elements.rb +510 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/htmlinfo.rb +691 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/inspect.rb +103 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/modules.rb +40 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/parse.rb +38 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/tag.rb +202 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/tags.rb +164 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/traverse.rb +838 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/xchar.rb +94 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot.rb +26 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot_scan.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/add/core.rb +135 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/add/rails.rb +58 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/common.rb +354 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/ext/generator.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/ext/parser.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/ext.rb +13 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/version.rb +9 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json.rb +8 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/constants.rb +49 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/database.rb +721 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/dl/api.rb +152 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/dl/driver.rb +307 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/native/driver.rb +219 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/errors.rb +68 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/pragmas.rb +271 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/resultset.rb +180 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/statement.rb +231 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/translator.rb +109 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/value.rb +57 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/version.rb +16 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3.rb +1 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3_api.so +0 -0
- data/shoes/ruby/gems/1.9.1/specifications/hpricot-0.8.1.gemspec +32 -0
- data/shoes/ruby/gems/1.9.1/specifications/json-shoes-1.1.3.gemspec +34 -0
- data/shoes/ruby/gems/1.9.1/specifications/sqlite3-ruby-1.2.5-x86-mswin32.gemspec +46 -0
- data/shoes/ruby/lib/English.rb +155 -0
- data/shoes/ruby/lib/Win32API.rb +28 -0
- data/shoes/ruby/lib/abbrev.rb +103 -0
- data/shoes/ruby/lib/base64.rb +91 -0
- data/shoes/ruby/lib/benchmark.rb +573 -0
- data/shoes/ruby/lib/bigdecimal/jacobian.rb +85 -0
- data/shoes/ruby/lib/bigdecimal/ludcmp.rb +86 -0
- data/shoes/ruby/lib/bigdecimal/math.rb +237 -0
- data/shoes/ruby/lib/bigdecimal/newton.rb +77 -0
- data/shoes/ruby/lib/bigdecimal/util.rb +53 -0
- data/shoes/ruby/lib/cgi/cookie.rb +144 -0
- data/shoes/ruby/lib/cgi/core.rb +786 -0
- data/shoes/ruby/lib/cgi/html.rb +1021 -0
- data/shoes/ruby/lib/cgi/session/pstore.rb +111 -0
- data/shoes/ruby/lib/cgi/session.rb +537 -0
- data/shoes/ruby/lib/cgi/util.rb +181 -0
- data/shoes/ruby/lib/cgi.rb +274 -0
- data/shoes/ruby/lib/cmath.rb +233 -0
- data/shoes/ruby/lib/complex.rb +24 -0
- data/shoes/ruby/lib/csv.rb +2320 -0
- data/shoes/ruby/lib/date/format.rb +1313 -0
- data/shoes/ruby/lib/date.rb +1834 -0
- data/shoes/ruby/lib/debug.rb +907 -0
- data/shoes/ruby/lib/delegate.rb +311 -0
- data/shoes/ruby/lib/digest/hmac.rb +274 -0
- data/shoes/ruby/lib/digest/sha2.rb +74 -0
- data/shoes/ruby/lib/digest.rb +50 -0
- data/shoes/ruby/lib/dl/callback.rb +69 -0
- data/shoes/ruby/lib/dl/cparser.rb +109 -0
- data/shoes/ruby/lib/dl/func.rb +153 -0
- data/shoes/ruby/lib/dl/import.rb +215 -0
- data/shoes/ruby/lib/dl/pack.rb +173 -0
- data/shoes/ruby/lib/dl/stack.rb +146 -0
- data/shoes/ruby/lib/dl/struct.rb +213 -0
- data/shoes/ruby/lib/dl/types.rb +40 -0
- data/shoes/ruby/lib/dl/value.rb +112 -0
- data/shoes/ruby/lib/drb/acl.rb +146 -0
- data/shoes/ruby/lib/drb/drb.rb +1778 -0
- data/shoes/ruby/lib/drb/eq.rb +16 -0
- data/shoes/ruby/lib/drb/extserv.rb +71 -0
- data/shoes/ruby/lib/drb/extservm.rb +85 -0
- data/shoes/ruby/lib/drb/gw.rb +122 -0
- data/shoes/ruby/lib/drb/invokemethod.rb +34 -0
- data/shoes/ruby/lib/drb/observer.rb +22 -0
- data/shoes/ruby/lib/drb/ssl.rb +190 -0
- data/shoes/ruby/lib/drb/timeridconv.rb +91 -0
- data/shoes/ruby/lib/drb/unix.rb +108 -0
- data/shoes/ruby/lib/drb.rb +2 -0
- data/shoes/ruby/lib/e2mmap.rb +172 -0
- data/shoes/ruby/lib/erb.rb +902 -0
- data/shoes/ruby/lib/fileutils.rb +1592 -0
- data/shoes/ruby/lib/find.rb +81 -0
- data/shoes/ruby/lib/forwardable.rb +270 -0
- data/shoes/ruby/lib/ftsearch/analysis/analyzer.rb +16 -0
- data/shoes/ruby/lib/ftsearch/analysis/simple_identifier_analyzer.rb +23 -0
- data/shoes/ruby/lib/ftsearch/analysis/whitespace_analyzer.rb +22 -0
- data/shoes/ruby/lib/ftsearch/document_map_reader.rb +106 -0
- data/shoes/ruby/lib/ftsearch/document_map_writer.rb +46 -0
- data/shoes/ruby/lib/ftsearch/field_infos.rb +46 -0
- data/shoes/ruby/lib/ftsearch/fragment_writer.rb +114 -0
- data/shoes/ruby/lib/ftsearch/fulltext_reader.rb +52 -0
- data/shoes/ruby/lib/ftsearch/fulltext_writer.rb +75 -0
- data/shoes/ruby/lib/ftsearch/suffix_array_reader.rb +275 -0
- data/shoes/ruby/lib/ftsearch/suffix_array_writer.rb +99 -0
- data/shoes/ruby/lib/ftsearch/util.rb +21 -0
- data/shoes/ruby/lib/getoptlong.rb +610 -0
- data/shoes/ruby/lib/gserver.rb +253 -0
- data/shoes/ruby/lib/i386-mingw32/bigdecimal.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/binject.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/bloops.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/continuation.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/coverage.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/curses.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/bubblebabble.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/md5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/rmd160.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/sha1.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/sha2.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/dl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/big5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/cp949.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/emacs_mule.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/encdb.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_jp.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_kr.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_tw.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gb18030.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gb2312.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gbk.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_1.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_10.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_11.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_13.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_14.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_15.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_16.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_2.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_3.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_4.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_6.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_7.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_8.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_9.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/koi8_r.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/koi8_u.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/shift_jis.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/big5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/chinese.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/escape.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/gb18030.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/gbk.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/iso2022.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese_euc.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese_sjis.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/korean.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/single_byte.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/transdb.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/utf_16_32.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_16be.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_16le.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_32be.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_32le.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/windows_1251.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/etc.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/fcntl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/fiber.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/ftsearchrt.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/gdbm.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/iconv.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/io/wait.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/json/ext/generator.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/json/ext/parser.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/mathn/complex.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/mathn/rational.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/nkf.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/openssl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/racc/cparse.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/rbconfig.rb +196 -0
- data/shoes/ruby/lib/i386-mingw32/readline.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/ripper.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/sdbm.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/socket.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/stringio.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/strscan.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/syck.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/win32ole.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/zlib.so +0 -0
- data/shoes/ruby/lib/io/nonblock.rb +23 -0
- data/shoes/ruby/lib/ipaddr.rb +813 -0
- data/shoes/ruby/lib/irb/cmd/chws.rb +32 -0
- data/shoes/ruby/lib/irb/cmd/fork.rb +38 -0
- data/shoes/ruby/lib/irb/cmd/help.rb +36 -0
- data/shoes/ruby/lib/irb/cmd/load.rb +66 -0
- data/shoes/ruby/lib/irb/cmd/nop.rb +38 -0
- data/shoes/ruby/lib/irb/cmd/pushws.rb +38 -0
- data/shoes/ruby/lib/irb/cmd/subirb.rb +42 -0
- data/shoes/ruby/lib/irb/completion.rb +207 -0
- data/shoes/ruby/lib/irb/context.rb +255 -0
- data/shoes/ruby/lib/irb/ext/change-ws.rb +61 -0
- data/shoes/ruby/lib/irb/ext/history.rb +109 -0
- data/shoes/ruby/lib/irb/ext/loader.rb +119 -0
- data/shoes/ruby/lib/irb/ext/math-mode.rb +36 -0
- data/shoes/ruby/lib/irb/ext/multi-irb.rb +240 -0
- data/shoes/ruby/lib/irb/ext/save-history.rb +100 -0
- data/shoes/ruby/lib/irb/ext/tracer.rb +60 -0
- data/shoes/ruby/lib/irb/ext/use-loader.rb +64 -0
- data/shoes/ruby/lib/irb/ext/workspaces.rb +55 -0
- data/shoes/ruby/lib/irb/extend-command.rb +272 -0
- data/shoes/ruby/lib/irb/frame.rb +66 -0
- data/shoes/ruby/lib/irb/help.rb +35 -0
- data/shoes/ruby/lib/irb/init.rb +288 -0
- data/shoes/ruby/lib/irb/input-method.rb +142 -0
- data/shoes/ruby/lib/irb/lc/error.rb +29 -0
- data/shoes/ruby/lib/irb/lc/help-message +38 -0
- data/shoes/ruby/lib/irb/lc/ja/encoding_aliases.rb +8 -0
- data/shoes/ruby/lib/irb/lc/ja/error.rb +27 -0
- data/shoes/ruby/lib/irb/lc/ja/help-message +39 -0
- data/shoes/ruby/lib/irb/locale.rb +195 -0
- data/shoes/ruby/lib/irb/magic-file.rb +36 -0
- data/shoes/ruby/lib/irb/notifier.rb +144 -0
- data/shoes/ruby/lib/irb/output-method.rb +69 -0
- data/shoes/ruby/lib/irb/ruby-lex.rb +1188 -0
- data/shoes/ruby/lib/irb/ruby-token.rb +270 -0
- data/shoes/ruby/lib/irb/slex.rb +282 -0
- data/shoes/ruby/lib/irb/src_encoding.rb +4 -0
- data/shoes/ruby/lib/irb/version.rb +15 -0
- data/shoes/ruby/lib/irb/workspace.rb +108 -0
- data/shoes/ruby/lib/irb/ws-for-case-2.rb +14 -0
- data/shoes/ruby/lib/irb/xmp.rb +97 -0
- data/shoes/ruby/lib/irb.rb +354 -0
- data/shoes/ruby/lib/json/add/core.rb +135 -0
- data/shoes/ruby/lib/json/add/rails.rb +58 -0
- data/shoes/ruby/lib/json/common.rb +354 -0
- data/shoes/ruby/lib/json/editor.rb +1371 -0
- data/shoes/ruby/lib/json/ext.rb +15 -0
- data/shoes/ruby/lib/json/version.rb +9 -0
- data/shoes/ruby/lib/json.rb +297 -0
- data/shoes/ruby/lib/kconv.rb +282 -0
- data/shoes/ruby/lib/logger.rb +732 -0
- data/shoes/ruby/lib/mathn.rb +206 -0
- data/shoes/ruby/lib/matrix.rb +1381 -0
- data/shoes/ruby/lib/minitest/autorun.rb +9 -0
- data/shoes/ruby/lib/minitest/mock.rb +37 -0
- data/shoes/ruby/lib/minitest/spec.rb +89 -0
- data/shoes/ruby/lib/minitest/unit.rb +497 -0
- data/shoes/ruby/lib/mkmf.rb +1958 -0
- data/shoes/ruby/lib/monitor.rb +265 -0
- data/shoes/ruby/lib/mutex_m.rb +91 -0
- data/shoes/ruby/lib/net/ftp.rb +981 -0
- data/shoes/ruby/lib/net/http.rb +2399 -0
- data/shoes/ruby/lib/net/https.rb +136 -0
- data/shoes/ruby/lib/net/imap.rb +3500 -0
- data/shoes/ruby/lib/net/pop.rb +1000 -0
- data/shoes/ruby/lib/net/protocol.rb +382 -0
- data/shoes/ruby/lib/net/smtp.rb +1014 -0
- data/shoes/ruby/lib/net/telnet.rb +759 -0
- data/shoes/ruby/lib/observer.rb +193 -0
- data/shoes/ruby/lib/open-uri.rb +832 -0
- data/shoes/ruby/lib/open3.rb +98 -0
- data/shoes/ruby/lib/openssl/bn.rb +35 -0
- data/shoes/ruby/lib/openssl/buffering.rb +242 -0
- data/shoes/ruby/lib/openssl/cipher.rb +65 -0
- data/shoes/ruby/lib/openssl/digest.rb +61 -0
- data/shoes/ruby/lib/openssl/ssl.rb +178 -0
- data/shoes/ruby/lib/openssl/x509.rb +155 -0
- data/shoes/ruby/lib/openssl.rb +24 -0
- data/shoes/ruby/lib/optparse/date.rb +17 -0
- data/shoes/ruby/lib/optparse/shellwords.rb +6 -0
- data/shoes/ruby/lib/optparse/time.rb +10 -0
- data/shoes/ruby/lib/optparse/uri.rb +6 -0
- data/shoes/ruby/lib/optparse/version.rb +70 -0
- data/shoes/ruby/lib/optparse.rb +1810 -0
- data/shoes/ruby/lib/ostruct.rb +145 -0
- data/shoes/ruby/lib/pathname.rb +1099 -0
- data/shoes/ruby/lib/pp.rb +532 -0
- data/shoes/ruby/lib/prettyprint.rb +896 -0
- data/shoes/ruby/lib/prime.rb +471 -0
- data/shoes/ruby/lib/profile.rb +10 -0
- data/shoes/ruby/lib/profiler.rb +59 -0
- data/shoes/ruby/lib/pstore.rb +543 -0
- data/shoes/ruby/lib/racc/parser.rb +441 -0
- data/shoes/ruby/lib/rake/classic_namespace.rb +8 -0
- data/shoes/ruby/lib/rake/clean.rb +33 -0
- data/shoes/ruby/lib/rake/gempackagetask.rb +97 -0
- data/shoes/ruby/lib/rake/loaders/makefile.rb +35 -0
- data/shoes/ruby/lib/rake/packagetask.rb +185 -0
- data/shoes/ruby/lib/rake/rake_test_loader.rb +5 -0
- data/shoes/ruby/lib/rake/rdoctask.rb +147 -0
- data/shoes/ruby/lib/rake/runtest.rb +23 -0
- data/shoes/ruby/lib/rake/tasklib.rb +23 -0
- data/shoes/ruby/lib/rake/testtask.rb +161 -0
- data/shoes/ruby/lib/rake/win32.rb +34 -0
- data/shoes/ruby/lib/rake.rb +2465 -0
- data/shoes/ruby/lib/rational.rb +19 -0
- data/shoes/ruby/lib/rbconfig/datadir.rb +24 -0
- data/shoes/ruby/lib/rdoc/code_objects.rb +1061 -0
- data/shoes/ruby/lib/rdoc/diagram.rb +340 -0
- data/shoes/ruby/lib/rdoc/dot.rb +249 -0
- data/shoes/ruby/lib/rdoc/generator/chm/chm.rb +100 -0
- data/shoes/ruby/lib/rdoc/generator/chm.rb +113 -0
- data/shoes/ruby/lib/rdoc/generator/html/common.rb +24 -0
- data/shoes/ruby/lib/rdoc/generator/html/frameless.rb +92 -0
- data/shoes/ruby/lib/rdoc/generator/html/hefss.rb +150 -0
- data/shoes/ruby/lib/rdoc/generator/html/html.rb +769 -0
- data/shoes/ruby/lib/rdoc/generator/html/kilmer.rb +151 -0
- data/shoes/ruby/lib/rdoc/generator/html/kilmerfactory.rb +427 -0
- data/shoes/ruby/lib/rdoc/generator/html/one_page_html.rb +122 -0
- data/shoes/ruby/lib/rdoc/generator/html.rb +445 -0
- data/shoes/ruby/lib/rdoc/generator/ri.rb +226 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo/class.texinfo.erb +44 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo/file.texinfo.erb +6 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo/method.texinfo.erb +6 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo/texinfo.erb +28 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo.rb +81 -0
- data/shoes/ruby/lib/rdoc/generator/xml/rdf.rb +113 -0
- data/shoes/ruby/lib/rdoc/generator/xml/xml.rb +123 -0
- data/shoes/ruby/lib/rdoc/generator/xml.rb +117 -0
- data/shoes/ruby/lib/rdoc/generator.rb +1082 -0
- data/shoes/ruby/lib/rdoc/known_classes.rb +68 -0
- data/shoes/ruby/lib/rdoc/markup/attribute_manager.rb +265 -0
- data/shoes/ruby/lib/rdoc/markup/formatter.rb +14 -0
- data/shoes/ruby/lib/rdoc/markup/fragments.rb +337 -0
- data/shoes/ruby/lib/rdoc/markup/inline.rb +101 -0
- data/shoes/ruby/lib/rdoc/markup/lines.rb +152 -0
- data/shoes/ruby/lib/rdoc/markup/preprocess.rb +75 -0
- data/shoes/ruby/lib/rdoc/markup/to_flow.rb +185 -0
- data/shoes/ruby/lib/rdoc/markup/to_html.rb +403 -0
- data/shoes/ruby/lib/rdoc/markup/to_html_crossref.rb +148 -0
- data/shoes/ruby/lib/rdoc/markup/to_latex.rb +328 -0
- data/shoes/ruby/lib/rdoc/markup/to_test.rb +50 -0
- data/shoes/ruby/lib/rdoc/markup/to_texinfo.rb +69 -0
- data/shoes/ruby/lib/rdoc/markup.rb +378 -0
- data/shoes/ruby/lib/rdoc/options.rb +638 -0
- data/shoes/ruby/lib/rdoc/parser/c.rb +661 -0
- data/shoes/ruby/lib/rdoc/parser/f95.rb +1835 -0
- data/shoes/ruby/lib/rdoc/parser/perl.rb +165 -0
- data/shoes/ruby/lib/rdoc/parser/ruby.rb +2829 -0
- data/shoes/ruby/lib/rdoc/parser/simple.rb +38 -0
- data/shoes/ruby/lib/rdoc/parser.rb +142 -0
- data/shoes/ruby/lib/rdoc/rdoc.rb +293 -0
- data/shoes/ruby/lib/rdoc/ri/cache.rb +187 -0
- data/shoes/ruby/lib/rdoc/ri/descriptions.rb +156 -0
- data/shoes/ruby/lib/rdoc/ri/display.rb +392 -0
- data/shoes/ruby/lib/rdoc/ri/driver.rb +669 -0
- data/shoes/ruby/lib/rdoc/ri/formatter.rb +616 -0
- data/shoes/ruby/lib/rdoc/ri/paths.rb +99 -0
- data/shoes/ruby/lib/rdoc/ri/reader.rb +106 -0
- data/shoes/ruby/lib/rdoc/ri/util.rb +79 -0
- data/shoes/ruby/lib/rdoc/ri/writer.rb +68 -0
- data/shoes/ruby/lib/rdoc/ri.rb +8 -0
- data/shoes/ruby/lib/rdoc/stats.rb +115 -0
- data/shoes/ruby/lib/rdoc/template.rb +64 -0
- data/shoes/ruby/lib/rdoc/tokenstream.rb +33 -0
- data/shoes/ruby/lib/rdoc.rb +395 -0
- data/shoes/ruby/lib/resolv-replace.rb +63 -0
- data/shoes/ruby/lib/resolv.rb +2262 -0
- data/shoes/ruby/lib/rexml/attlistdecl.rb +62 -0
- data/shoes/ruby/lib/rexml/attribute.rb +188 -0
- data/shoes/ruby/lib/rexml/cdata.rb +67 -0
- data/shoes/ruby/lib/rexml/child.rb +96 -0
- data/shoes/ruby/lib/rexml/comment.rb +80 -0
- data/shoes/ruby/lib/rexml/doctype.rb +270 -0
- data/shoes/ruby/lib/rexml/document.rb +231 -0
- data/shoes/ruby/lib/rexml/dtd/attlistdecl.rb +10 -0
- data/shoes/ruby/lib/rexml/dtd/dtd.rb +51 -0
- data/shoes/ruby/lib/rexml/dtd/elementdecl.rb +17 -0
- data/shoes/ruby/lib/rexml/dtd/entitydecl.rb +56 -0
- data/shoes/ruby/lib/rexml/dtd/notationdecl.rb +39 -0
- data/shoes/ruby/lib/rexml/element.rb +1246 -0
- data/shoes/ruby/lib/rexml/encoding.rb +71 -0
- data/shoes/ruby/lib/rexml/encodings/CP-1252.rb +103 -0
- data/shoes/ruby/lib/rexml/encodings/EUC-JP.rb +35 -0
- data/shoes/ruby/lib/rexml/encodings/ICONV.rb +22 -0
- data/shoes/ruby/lib/rexml/encodings/ISO-8859-1.rb +7 -0
- data/shoes/ruby/lib/rexml/encodings/ISO-8859-15.rb +72 -0
- data/shoes/ruby/lib/rexml/encodings/SHIFT-JIS.rb +37 -0
- data/shoes/ruby/lib/rexml/encodings/SHIFT_JIS.rb +1 -0
- data/shoes/ruby/lib/rexml/encodings/UNILE.rb +34 -0
- data/shoes/ruby/lib/rexml/encodings/US-ASCII.rb +30 -0
- data/shoes/ruby/lib/rexml/encodings/UTF-16.rb +35 -0
- data/shoes/ruby/lib/rexml/encodings/UTF-8.rb +18 -0
- data/shoes/ruby/lib/rexml/entity.rb +166 -0
- data/shoes/ruby/lib/rexml/formatters/default.rb +109 -0
- data/shoes/ruby/lib/rexml/formatters/pretty.rb +139 -0
- data/shoes/ruby/lib/rexml/formatters/transitive.rb +58 -0
- data/shoes/ruby/lib/rexml/functions.rb +388 -0
- data/shoes/ruby/lib/rexml/instruction.rb +70 -0
- data/shoes/ruby/lib/rexml/light/node.rb +196 -0
- data/shoes/ruby/lib/rexml/namespace.rb +47 -0
- data/shoes/ruby/lib/rexml/node.rb +75 -0
- data/shoes/ruby/lib/rexml/output.rb +24 -0
- data/shoes/ruby/lib/rexml/parent.rb +166 -0
- data/shoes/ruby/lib/rexml/parseexception.rb +51 -0
- data/shoes/ruby/lib/rexml/parsers/baseparser.rb +530 -0
- data/shoes/ruby/lib/rexml/parsers/lightparser.rb +58 -0
- data/shoes/ruby/lib/rexml/parsers/pullparser.rb +196 -0
- data/shoes/ruby/lib/rexml/parsers/sax2parser.rb +247 -0
- data/shoes/ruby/lib/rexml/parsers/streamparser.rb +46 -0
- data/shoes/ruby/lib/rexml/parsers/treeparser.rb +100 -0
- data/shoes/ruby/lib/rexml/parsers/ultralightparser.rb +56 -0
- data/shoes/ruby/lib/rexml/parsers/xpathparser.rb +698 -0
- data/shoes/ruby/lib/rexml/quickpath.rb +263 -0
- data/shoes/ruby/lib/rexml/rexml.rb +31 -0
- data/shoes/ruby/lib/rexml/sax2listener.rb +97 -0
- data/shoes/ruby/lib/rexml/source.rb +258 -0
- data/shoes/ruby/lib/rexml/streamlistener.rb +92 -0
- data/shoes/ruby/lib/rexml/syncenumerator.rb +32 -0
- data/shoes/ruby/lib/rexml/text.rb +404 -0
- data/shoes/ruby/lib/rexml/undefinednamespaceexception.rb +8 -0
- data/shoes/ruby/lib/rexml/validation/relaxng.rb +559 -0
- data/shoes/ruby/lib/rexml/validation/validation.rb +155 -0
- data/shoes/ruby/lib/rexml/validation/validationexception.rb +9 -0
- data/shoes/ruby/lib/rexml/xmldecl.rb +119 -0
- data/shoes/ruby/lib/rexml/xmltokens.rb +18 -0
- data/shoes/ruby/lib/rexml/xpath.rb +77 -0
- data/shoes/ruby/lib/rexml/xpath_parser.rb +792 -0
- data/shoes/ruby/lib/rinda/rinda.rb +283 -0
- data/shoes/ruby/lib/rinda/ring.rb +271 -0
- data/shoes/ruby/lib/rinda/tuplespace.rb +642 -0
- data/shoes/ruby/lib/ripper/core.rb +70 -0
- data/shoes/ruby/lib/ripper/filter.rb +70 -0
- data/shoes/ruby/lib/ripper/lexer.rb +179 -0
- data/shoes/ruby/lib/ripper/sexp.rb +99 -0
- data/shoes/ruby/lib/ripper.rb +4 -0
- data/shoes/ruby/lib/rss/0.9.rb +427 -0
- data/shoes/ruby/lib/rss/1.0.rb +452 -0
- data/shoes/ruby/lib/rss/2.0.rb +111 -0
- data/shoes/ruby/lib/rss/atom.rb +748 -0
- data/shoes/ruby/lib/rss/content/1.0.rb +10 -0
- data/shoes/ruby/lib/rss/content/2.0.rb +12 -0
- data/shoes/ruby/lib/rss/content.rb +31 -0
- data/shoes/ruby/lib/rss/converter.rb +170 -0
- data/shoes/ruby/lib/rss/dublincore/1.0.rb +13 -0
- data/shoes/ruby/lib/rss/dublincore/2.0.rb +13 -0
- data/shoes/ruby/lib/rss/dublincore/atom.rb +17 -0
- data/shoes/ruby/lib/rss/dublincore.rb +161 -0
- data/shoes/ruby/lib/rss/image.rb +193 -0
- data/shoes/ruby/lib/rss/itunes.rb +410 -0
- data/shoes/ruby/lib/rss/maker/0.9.rb +467 -0
- data/shoes/ruby/lib/rss/maker/1.0.rb +434 -0
- data/shoes/ruby/lib/rss/maker/2.0.rb +223 -0
- data/shoes/ruby/lib/rss/maker/atom.rb +172 -0
- data/shoes/ruby/lib/rss/maker/base.rb +880 -0
- data/shoes/ruby/lib/rss/maker/content.rb +21 -0
- data/shoes/ruby/lib/rss/maker/dublincore.rb +124 -0
- data/shoes/ruby/lib/rss/maker/entry.rb +163 -0
- data/shoes/ruby/lib/rss/maker/feed.rb +430 -0
- data/shoes/ruby/lib/rss/maker/image.rb +111 -0
- data/shoes/ruby/lib/rss/maker/itunes.rb +242 -0
- data/shoes/ruby/lib/rss/maker/slash.rb +33 -0
- data/shoes/ruby/lib/rss/maker/syndication.rb +18 -0
- data/shoes/ruby/lib/rss/maker/taxonomy.rb +118 -0
- data/shoes/ruby/lib/rss/maker/trackback.rb +61 -0
- data/shoes/ruby/lib/rss/maker.rb +44 -0
- data/shoes/ruby/lib/rss/parser.rb +568 -0
- data/shoes/ruby/lib/rss/rexmlparser.rb +54 -0
- data/shoes/ruby/lib/rss/rss.rb +1313 -0
- data/shoes/ruby/lib/rss/slash.rb +49 -0
- data/shoes/ruby/lib/rss/syndication.rb +67 -0
- data/shoes/ruby/lib/rss/taxonomy.rb +145 -0
- data/shoes/ruby/lib/rss/trackback.rb +288 -0
- data/shoes/ruby/lib/rss/utils.rb +111 -0
- data/shoes/ruby/lib/rss/xml-stylesheet.rb +105 -0
- data/shoes/ruby/lib/rss/xml.rb +71 -0
- data/shoes/ruby/lib/rss/xmlparser.rb +93 -0
- data/shoes/ruby/lib/rss/xmlscanner.rb +121 -0
- data/shoes/ruby/lib/rss.rb +19 -0
- data/shoes/ruby/lib/rubygems/builder.rb +88 -0
- data/shoes/ruby/lib/rubygems/command.rb +406 -0
- data/shoes/ruby/lib/rubygems/command_manager.rb +146 -0
- data/shoes/ruby/lib/rubygems/commands/build_command.rb +53 -0
- data/shoes/ruby/lib/rubygems/commands/cert_command.rb +86 -0
- data/shoes/ruby/lib/rubygems/commands/check_command.rb +75 -0
- data/shoes/ruby/lib/rubygems/commands/cleanup_command.rb +91 -0
- data/shoes/ruby/lib/rubygems/commands/contents_command.rb +74 -0
- data/shoes/ruby/lib/rubygems/commands/dependency_command.rb +188 -0
- data/shoes/ruby/lib/rubygems/commands/environment_command.rb +128 -0
- data/shoes/ruby/lib/rubygems/commands/fetch_command.rb +62 -0
- data/shoes/ruby/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/shoes/ruby/lib/rubygems/commands/help_command.rb +172 -0
- data/shoes/ruby/lib/rubygems/commands/install_command.rb +148 -0
- data/shoes/ruby/lib/rubygems/commands/list_command.rb +35 -0
- data/shoes/ruby/lib/rubygems/commands/lock_command.rb +110 -0
- data/shoes/ruby/lib/rubygems/commands/mirror_command.rb +111 -0
- data/shoes/ruby/lib/rubygems/commands/outdated_command.rb +33 -0
- data/shoes/ruby/lib/rubygems/commands/pristine_command.rb +93 -0
- data/shoes/ruby/lib/rubygems/commands/query_command.rb +233 -0
- data/shoes/ruby/lib/rubygems/commands/rdoc_command.rb +82 -0
- data/shoes/ruby/lib/rubygems/commands/search_command.rb +37 -0
- data/shoes/ruby/lib/rubygems/commands/server_command.rb +48 -0
- data/shoes/ruby/lib/rubygems/commands/sources_command.rb +152 -0
- data/shoes/ruby/lib/rubygems/commands/specification_command.rb +77 -0
- data/shoes/ruby/lib/rubygems/commands/stale_command.rb +27 -0
- data/shoes/ruby/lib/rubygems/commands/uninstall_command.rb +73 -0
- data/shoes/ruby/lib/rubygems/commands/unpack_command.rb +95 -0
- data/shoes/ruby/lib/rubygems/commands/update_command.rb +181 -0
- data/shoes/ruby/lib/rubygems/commands/which_command.rb +87 -0
- data/shoes/ruby/lib/rubygems/config_file.rb +266 -0
- data/shoes/ruby/lib/rubygems/custom_require.rb +46 -0
- data/shoes/ruby/lib/rubygems/defaults.rb +89 -0
- data/shoes/ruby/lib/rubygems/dependency.rb +119 -0
- data/shoes/ruby/lib/rubygems/dependency_installer.rb +258 -0
- data/shoes/ruby/lib/rubygems/dependency_list.rb +165 -0
- data/shoes/ruby/lib/rubygems/digest/digest_adapter.rb +40 -0
- data/shoes/ruby/lib/rubygems/digest/md5.rb +23 -0
- data/shoes/ruby/lib/rubygems/digest/sha1.rb +17 -0
- data/shoes/ruby/lib/rubygems/digest/sha2.rb +17 -0
- data/shoes/ruby/lib/rubygems/doc_manager.rb +214 -0
- data/shoes/ruby/lib/rubygems/exceptions.rb +84 -0
- data/shoes/ruby/lib/rubygems/ext/builder.rb +56 -0
- data/shoes/ruby/lib/rubygems/ext/configure_builder.rb +24 -0
- data/shoes/ruby/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/shoes/ruby/lib/rubygems/ext/rake_builder.rb +27 -0
- data/shoes/ruby/lib/rubygems/ext.rb +18 -0
- data/shoes/ruby/lib/rubygems/format.rb +87 -0
- data/shoes/ruby/lib/rubygems/gem_openssl.rb +83 -0
- data/shoes/ruby/lib/rubygems/gem_path_searcher.rb +100 -0
- data/shoes/ruby/lib/rubygems/gem_runner.rb +58 -0
- data/shoes/ruby/lib/rubygems/indexer/abstract_index_builder.rb +88 -0
- data/shoes/ruby/lib/rubygems/indexer/latest_index_builder.rb +35 -0
- data/shoes/ruby/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/shoes/ruby/lib/rubygems/indexer/master_index_builder.rb +54 -0
- data/shoes/ruby/lib/rubygems/indexer/quick_index_builder.rb +50 -0
- data/shoes/ruby/lib/rubygems/indexer.rb +370 -0
- data/shoes/ruby/lib/rubygems/install_update_options.rb +113 -0
- data/shoes/ruby/lib/rubygems/installer.rb +578 -0
- data/shoes/ruby/lib/rubygems/local_remote_options.rb +134 -0
- data/shoes/ruby/lib/rubygems/old_format.rb +148 -0
- data/shoes/ruby/lib/rubygems/package/f_sync_dir.rb +24 -0
- data/shoes/ruby/lib/rubygems/package/tar_header.rb +245 -0
- data/shoes/ruby/lib/rubygems/package/tar_input.rb +219 -0
- data/shoes/ruby/lib/rubygems/package/tar_output.rb +143 -0
- data/shoes/ruby/lib/rubygems/package/tar_reader/entry.rb +99 -0
- data/shoes/ruby/lib/rubygems/package/tar_reader.rb +86 -0
- data/shoes/ruby/lib/rubygems/package/tar_writer.rb +180 -0
- data/shoes/ruby/lib/rubygems/package.rb +95 -0
- data/shoes/ruby/lib/rubygems/platform.rb +178 -0
- data/shoes/ruby/lib/rubygems/remote_fetcher.rb +344 -0
- data/shoes/ruby/lib/rubygems/require_paths_builder.rb +15 -0
- data/shoes/ruby/lib/rubygems/requirement.rb +163 -0
- data/shoes/ruby/lib/rubygems/rubygems_version.rb +6 -0
- data/shoes/ruby/lib/rubygems/security.rb +786 -0
- data/shoes/ruby/lib/rubygems/server.rb +629 -0
- data/shoes/ruby/lib/rubygems/source_index.rb +559 -0
- data/shoes/ruby/lib/rubygems/source_info_cache.rb +393 -0
- data/shoes/ruby/lib/rubygems/source_info_cache_entry.rb +56 -0
- data/shoes/ruby/lib/rubygems/spec_fetcher.rb +249 -0
- data/shoes/ruby/lib/rubygems/specification.rb +1262 -0
- data/shoes/ruby/lib/rubygems/test_utilities.rb +131 -0
- data/shoes/ruby/lib/rubygems/timer.rb +25 -0
- data/shoes/ruby/lib/rubygems/uninstaller.rb +242 -0
- data/shoes/ruby/lib/rubygems/user_interaction.rb +360 -0
- data/shoes/ruby/lib/rubygems/validator.rb +208 -0
- data/shoes/ruby/lib/rubygems/version.rb +167 -0
- data/shoes/ruby/lib/rubygems/version_option.rb +48 -0
- data/shoes/ruby/lib/rubygems.rb +888 -0
- data/shoes/ruby/lib/scanf.rb +703 -0
- data/shoes/ruby/lib/securerandom.rb +182 -0
- data/shoes/ruby/lib/set.rb +1274 -0
- data/shoes/ruby/lib/shell/builtin-command.rb +160 -0
- data/shoes/ruby/lib/shell/command-processor.rb +593 -0
- data/shoes/ruby/lib/shell/error.rb +25 -0
- data/shoes/ruby/lib/shell/filter.rb +109 -0
- data/shoes/ruby/lib/shell/process-controller.rb +319 -0
- data/shoes/ruby/lib/shell/system-command.rb +159 -0
- data/shoes/ruby/lib/shell/version.rb +15 -0
- data/shoes/ruby/lib/shell.rb +300 -0
- data/shoes/ruby/lib/shellwords.rb +156 -0
- data/shoes/ruby/lib/singleton.rb +313 -0
- data/shoes/ruby/lib/sync.rb +307 -0
- data/shoes/ruby/lib/tempfile.rb +218 -0
- data/shoes/ruby/lib/test/unit/assertions.rb +122 -0
- data/shoes/ruby/lib/test/unit/testcase.rb +12 -0
- data/shoes/ruby/lib/test/unit.rb +66 -0
- data/shoes/ruby/lib/thread.rb +367 -0
- data/shoes/ruby/lib/thwait.rb +168 -0
- data/shoes/ruby/lib/time.rb +869 -0
- data/shoes/ruby/lib/timeout.rb +108 -0
- data/shoes/ruby/lib/tmpdir.rb +138 -0
- data/shoes/ruby/lib/tracer.rb +166 -0
- data/shoes/ruby/lib/tsort.rb +290 -0
- data/shoes/ruby/lib/ubygems.rb +10 -0
- data/shoes/ruby/lib/un.rb +304 -0
- data/shoes/ruby/lib/uri/common.rb +727 -0
- data/shoes/ruby/lib/uri/ftp.rb +198 -0
- data/shoes/ruby/lib/uri/generic.rb +1128 -0
- data/shoes/ruby/lib/uri/http.rb +100 -0
- data/shoes/ruby/lib/uri/https.rb +20 -0
- data/shoes/ruby/lib/uri/ldap.rb +190 -0
- data/shoes/ruby/lib/uri/ldaps.rb +12 -0
- data/shoes/ruby/lib/uri/mailto.rb +266 -0
- data/shoes/ruby/lib/uri.rb +29 -0
- data/shoes/ruby/lib/weakref.rb +80 -0
- data/shoes/ruby/lib/webrick/accesslog.rb +75 -0
- data/shoes/ruby/lib/webrick/cgi.rb +260 -0
- data/shoes/ruby/lib/webrick/compat.rb +15 -0
- data/shoes/ruby/lib/webrick/config.rb +100 -0
- data/shoes/ruby/lib/webrick/cookie.rb +110 -0
- data/shoes/ruby/lib/webrick/htmlutils.rb +25 -0
- data/shoes/ruby/lib/webrick/httpauth/authenticator.rb +79 -0
- data/shoes/ruby/lib/webrick/httpauth/basicauth.rb +65 -0
- data/shoes/ruby/lib/webrick/httpauth/digestauth.rb +344 -0
- data/shoes/ruby/lib/webrick/httpauth/htdigest.rb +91 -0
- data/shoes/ruby/lib/webrick/httpauth/htgroup.rb +61 -0
- data/shoes/ruby/lib/webrick/httpauth/htpasswd.rb +83 -0
- data/shoes/ruby/lib/webrick/httpauth/userdb.rb +29 -0
- data/shoes/ruby/lib/webrick/httpauth.rb +45 -0
- data/shoes/ruby/lib/webrick/httpproxy.rb +288 -0
- data/shoes/ruby/lib/webrick/httprequest.rb +402 -0
- data/shoes/ruby/lib/webrick/httpresponse.rb +326 -0
- data/shoes/ruby/lib/webrick/https.rb +63 -0
- data/shoes/ruby/lib/webrick/httpserver.rb +217 -0
- data/shoes/ruby/lib/webrick/httpservlet/abstract.rb +70 -0
- data/shoes/ruby/lib/webrick/httpservlet/cgi_runner.rb +47 -0
- data/shoes/ruby/lib/webrick/httpservlet/cgihandler.rb +110 -0
- data/shoes/ruby/lib/webrick/httpservlet/erbhandler.rb +54 -0
- data/shoes/ruby/lib/webrick/httpservlet/filehandler.rb +435 -0
- data/shoes/ruby/lib/webrick/httpservlet/prochandler.rb +33 -0
- data/shoes/ruby/lib/webrick/httpservlet.rb +22 -0
- data/shoes/ruby/lib/webrick/httpstatus.rb +132 -0
- data/shoes/ruby/lib/webrick/httputils.rb +392 -0
- data/shoes/ruby/lib/webrick/httpversion.rb +49 -0
- data/shoes/ruby/lib/webrick/log.rb +88 -0
- data/shoes/ruby/lib/webrick/server.rb +210 -0
- data/shoes/ruby/lib/webrick/ssl.rb +126 -0
- data/shoes/ruby/lib/webrick/utils.rb +175 -0
- data/shoes/ruby/lib/webrick/version.rb +13 -0
- data/shoes/ruby/lib/webrick.rb +29 -0
- data/shoes/ruby/lib/win32/registry.rb +832 -0
- data/shoes/ruby/lib/win32/resolv.rb +370 -0
- data/shoes/ruby/lib/win32/sspi.rb +330 -0
- data/shoes/ruby/lib/win32ole/property.rb +16 -0
- data/shoes/ruby/lib/xmlrpc/base64.rb +81 -0
- data/shoes/ruby/lib/xmlrpc/client.rb +625 -0
- data/shoes/ruby/lib/xmlrpc/config.rb +40 -0
- data/shoes/ruby/lib/xmlrpc/create.rb +290 -0
- data/shoes/ruby/lib/xmlrpc/datetime.rb +142 -0
- data/shoes/ruby/lib/xmlrpc/httpserver.rb +178 -0
- data/shoes/ruby/lib/xmlrpc/marshal.rb +76 -0
- data/shoes/ruby/lib/xmlrpc/parser.rb +813 -0
- data/shoes/ruby/lib/xmlrpc/server.rb +778 -0
- data/shoes/ruby/lib/xmlrpc/utils.rb +165 -0
- data/shoes/ruby/lib/yaml/baseemitter.rb +242 -0
- data/shoes/ruby/lib/yaml/basenode.rb +216 -0
- data/shoes/ruby/lib/yaml/constants.rb +45 -0
- data/shoes/ruby/lib/yaml/dbm.rb +111 -0
- data/shoes/ruby/lib/yaml/encoding.rb +33 -0
- data/shoes/ruby/lib/yaml/error.rb +34 -0
- data/shoes/ruby/lib/yaml/loader.rb +14 -0
- data/shoes/ruby/lib/yaml/rubytypes.rb +446 -0
- data/shoes/ruby/lib/yaml/store.rb +43 -0
- data/shoes/ruby/lib/yaml/stream.rb +40 -0
- data/shoes/ruby/lib/yaml/stringio.rb +83 -0
- data/shoes/ruby/lib/yaml/syck.rb +19 -0
- data/shoes/ruby/lib/yaml/tag.rb +91 -0
- data/shoes/ruby/lib/yaml/types.rb +192 -0
- data/shoes/ruby/lib/yaml/yamlnode.rb +54 -0
- data/shoes/ruby/lib/yaml/ypath.rb +52 -0
- data/shoes/ruby/lib/yaml.rb +440 -0
- data/shoes/samples/class-book.rb +43 -0
- data/shoes/samples/class-book.yaml +387 -0
- data/shoes/samples/expert-definr.rb +23 -0
- data/shoes/samples/expert-funnies.rb +51 -0
- data/shoes/samples/expert-irb.rb +112 -0
- data/shoes/samples/expert-minesweeper.rb +267 -0
- data/shoes/samples/expert-othello.rb +319 -0
- data/shoes/samples/expert-pong.rb +62 -0
- data/shoes/samples/expert-tankspank.rb +385 -0
- data/shoes/samples/good-arc.rb +37 -0
- data/shoes/samples/good-clock.rb +51 -0
- data/shoes/samples/good-follow.rb +26 -0
- data/shoes/samples/good-reminder.rb +174 -0
- data/shoes/samples/good-vjot.rb +56 -0
- data/shoes/samples/simple-accordion.rb +75 -0
- data/shoes/samples/simple-anim-shapes.rb +17 -0
- data/shoes/samples/simple-anim-text.rb +13 -0
- data/shoes/samples/simple-arc.rb +23 -0
- data/shoes/samples/simple-bounce.rb +24 -0
- data/shoes/samples/simple-calc.rb +70 -0
- data/shoes/samples/simple-control-sizes.rb +24 -0
- data/shoes/samples/simple-curve.rb +26 -0
- data/shoes/samples/simple-dialogs.rb +29 -0
- data/shoes/samples/simple-downloader.rb +27 -0
- data/shoes/samples/simple-draw.rb +13 -0
- data/shoes/samples/simple-editor.rb +28 -0
- data/shoes/samples/simple-form.rb +28 -0
- data/shoes/samples/simple-form.shy +0 -0
- data/shoes/samples/simple-mask.rb +21 -0
- data/shoes/samples/simple-menu.rb +31 -0
- data/shoes/samples/simple-menu1.rb +35 -0
- data/shoes/samples/simple-rubygems.rb +29 -0
- data/shoes/samples/simple-slide.rb +45 -0
- data/shoes/samples/simple-sphere.rb +28 -0
- data/shoes/samples/simple-timer.rb +13 -0
- data/shoes/samples/simple-video.rb +13 -0
- data/shoes/shoes +21 -0
- data/shoes/shoes.exe +0 -0
- data/shoes/shoes.exe.manifest +17 -0
- data/shoes/sqlite3.dll +0 -0
- data/shoes/static/Shoes.icns +0 -0
- data/shoes/static/Thumbs.db +0 -0
- data/shoes/static/app-icon.png +0 -0
- data/shoes/static/avatar.png +0 -0
- data/shoes/static/code_highlighter.js +188 -0
- data/shoes/static/code_highlighter_ruby.js +26 -0
- data/shoes/static/icon-debug.png +0 -0
- data/shoes/static/icon-error.png +0 -0
- data/shoes/static/icon-info.png +0 -0
- data/shoes/static/icon-warn.png +0 -0
- data/shoes/static/listbox_button1.png +0 -0
- data/shoes/static/listbox_button2.png +0 -0
- data/shoes/static/man-app.png +0 -0
- data/shoes/static/man-builds.png +0 -0
- data/shoes/static/man-editor-notepad.png +0 -0
- data/shoes/static/man-editor-osx.png +0 -0
- data/shoes/static/man-ele-background.png +0 -0
- data/shoes/static/man-ele-border.png +0 -0
- data/shoes/static/man-ele-button.png +0 -0
- data/shoes/static/man-ele-check.png +0 -0
- data/shoes/static/man-ele-editbox.png +0 -0
- data/shoes/static/man-ele-editline.png +0 -0
- data/shoes/static/man-ele-image.png +0 -0
- data/shoes/static/man-ele-listbox.png +0 -0
- data/shoes/static/man-ele-progress.png +0 -0
- data/shoes/static/man-ele-radio.png +0 -0
- data/shoes/static/man-ele-shape.png +0 -0
- data/shoes/static/man-ele-textblock.png +0 -0
- data/shoes/static/man-ele-video.png +0 -0
- data/shoes/static/man-intro-dmg.png +0 -0
- data/shoes/static/man-intro-exe.png +0 -0
- data/shoes/static/man-look-tiger.png +0 -0
- data/shoes/static/man-look-ubuntu.png +0 -0
- data/shoes/static/man-look-vista.png +0 -0
- data/shoes/static/man-run-osx.png +0 -0
- data/shoes/static/man-run-vista.png +0 -0
- data/shoes/static/man-run-xp.png +0 -0
- data/shoes/static/man-shot1.png +0 -0
- data/shoes/static/manual-en.txt +2783 -0
- data/shoes/static/manual-ja.txt +2780 -0
- data/shoes/static/manual.css +167 -0
- data/shoes/static/menu-corner1.png +0 -0
- data/shoes/static/menu-corner2.png +0 -0
- data/shoes/static/menu-gray.png +0 -0
- data/shoes/static/menu-left.png +0 -0
- data/shoes/static/menu-right.png +0 -0
- data/shoes/static/menu-top.png +0 -0
- data/shoes/static/shoes-dmg.jpg +0 -0
- data/shoes/static/shoes-icon-blue.png +0 -0
- data/shoes/static/shoes-icon.png +0 -0
- data/shoes/static/shoes-manual-apps.gif +0 -0
- data/shoes/static/stripe.png +0 -0
- data/shoes/static/stubs/blank.exe +0 -0
- data/shoes/static/stubs/blank.hfz +0 -0
- data/shoes/static/stubs/blank.run +375 -0
- data/shoes/static/stubs/cocoa-install +0 -0
- data/shoes/static/stubs/sh-install +48 -0
- data/shoes/static/tutor-back.png +0 -0
- data/shoes/zlib.dll +0 -0
- data/shoes/zlib1.dll +0 -0
- metadata +887 -0
@@ -0,0 +1,1778 @@
|
|
1
|
+
#
|
2
|
+
# = drb/drb.rb
|
3
|
+
#
|
4
|
+
# Distributed Ruby: _dRuby_ version 2.0.4
|
5
|
+
#
|
6
|
+
# Copyright (c) 1999-2003 Masatoshi SEKI. You can redistribute it and/or
|
7
|
+
# modify it under the same terms as Ruby.
|
8
|
+
#
|
9
|
+
# Author:: Masatoshi SEKI
|
10
|
+
#
|
11
|
+
# Documentation:: William Webber (william@williamwebber.com)
|
12
|
+
#
|
13
|
+
# == Overview
|
14
|
+
#
|
15
|
+
# dRuby is a distributed object system for Ruby. It allows an object in one
|
16
|
+
# Ruby process to invoke methods on an object in another Ruby process on the
|
17
|
+
# same or a different machine.
|
18
|
+
#
|
19
|
+
# The Ruby standard library contains the core classes of the dRuby package.
|
20
|
+
# However, the full package also includes access control lists and the
|
21
|
+
# Rinda tuple-space distributed task management system, as well as a
|
22
|
+
# large number of samples. The full dRuby package can be downloaded from
|
23
|
+
# the dRuby home page (see *References*).
|
24
|
+
#
|
25
|
+
# For an introduction and examples of usage see the documentation to the
|
26
|
+
# DRb module.
|
27
|
+
#
|
28
|
+
# == References
|
29
|
+
#
|
30
|
+
# [http://www2a.biglobe.ne.jp/~seki/ruby/druby.html]
|
31
|
+
# The dRuby home page, in Japanese. Contains the full dRuby package
|
32
|
+
# and links to other Japanese-language sources.
|
33
|
+
#
|
34
|
+
# [http://www2a.biglobe.ne.jp/~seki/ruby/druby.en.html]
|
35
|
+
# The English version of the dRuby home page.
|
36
|
+
#
|
37
|
+
# [http://www.chadfowler.com/ruby/drb.html]
|
38
|
+
# A quick tutorial introduction to using dRuby by Chad Fowler.
|
39
|
+
#
|
40
|
+
# [http://www.linux-mag.com/2002-09/ruby_05.html]
|
41
|
+
# A tutorial introduction to dRuby in Linux Magazine by Dave Thomas.
|
42
|
+
# Includes a discussion of Rinda.
|
43
|
+
#
|
44
|
+
# [http://www.eng.cse.dmu.ac.uk/~hgs/ruby/dRuby/]
|
45
|
+
# Links to English-language Ruby material collected by Hugh Sasse.
|
46
|
+
#
|
47
|
+
# [http://www.rubycentral.com/book/ospace.html]
|
48
|
+
# The chapter from *Programming* *Ruby* by Dave Thomas and Andy Hunt
|
49
|
+
# which discusses dRuby.
|
50
|
+
#
|
51
|
+
# [http://www.clio.ne.jp/home/web-i31s/Flotuard/Ruby/PRC2K_seki/dRuby.en.html]
|
52
|
+
# Translation of presentation on Ruby by Masatoshi Seki.
|
53
|
+
|
54
|
+
require 'socket'
|
55
|
+
require 'thread'
|
56
|
+
require 'fcntl'
|
57
|
+
require 'drb/eq'
|
58
|
+
|
59
|
+
#
|
60
|
+
# == Overview
|
61
|
+
#
|
62
|
+
# dRuby is a distributed object system for Ruby. It is written in
|
63
|
+
# pure Ruby and uses its own protocol. No add-in services are needed
|
64
|
+
# beyond those provided by the Ruby runtime, such as TCP sockets. It
|
65
|
+
# does not rely on or interoperate with other distributed object
|
66
|
+
# systems such as CORBA, RMI, or .NET.
|
67
|
+
#
|
68
|
+
# dRuby allows methods to be called in one Ruby process upon a Ruby
|
69
|
+
# object located in another Ruby process, even on another machine.
|
70
|
+
# References to objects can be passed between processes. Method
|
71
|
+
# arguments and return values are dumped and loaded in marshalled
|
72
|
+
# format. All of this is done transparently to both the caller of the
|
73
|
+
# remote method and the object that it is called upon.
|
74
|
+
#
|
75
|
+
# An object in a remote process is locally represented by a
|
76
|
+
# DRb::DRbObject instance. This acts as a sort of proxy for the
|
77
|
+
# remote object. Methods called upon this DRbObject instance are
|
78
|
+
# forwarded to its remote object. This is arranged dynamically at run
|
79
|
+
# time. There are no statically declared interfaces for remote
|
80
|
+
# objects, such as CORBA's IDL.
|
81
|
+
#
|
82
|
+
# dRuby calls made into a process are handled by a DRb::DRbServer
|
83
|
+
# instance within that process. This reconstitutes the method call,
|
84
|
+
# invokes it upon the specified local object, and returns the value to
|
85
|
+
# the remote caller. Any object can receive calls over dRuby. There
|
86
|
+
# is no need to implement a special interface, or mixin special
|
87
|
+
# functionality. Nor, in the general case, does an object need to
|
88
|
+
# explicitly register itself with a DRbServer in order to receive
|
89
|
+
# dRuby calls.
|
90
|
+
#
|
91
|
+
# One process wishing to make dRuby calls upon another process must
|
92
|
+
# somehow obtain an initial reference to an object in the remote
|
93
|
+
# process by some means other than as the return value of a remote
|
94
|
+
# method call, as there is initially no remote object reference it can
|
95
|
+
# invoke a method upon. This is done by attaching to the server by
|
96
|
+
# URI. Each DRbServer binds itself to a URI such as
|
97
|
+
# 'druby://example.com:8787'. A DRbServer can have an object attached
|
98
|
+
# to it that acts as the server's *front* *object*. A DRbObject can
|
99
|
+
# be explicitly created from the server's URI. This DRbObject's
|
100
|
+
# remote object will be the server's front object. This front object
|
101
|
+
# can then return references to other Ruby objects in the DRbServer's
|
102
|
+
# process.
|
103
|
+
#
|
104
|
+
# Method calls made over dRuby behave largely the same as normal Ruby
|
105
|
+
# method calls made within a process. Method calls with blocks are
|
106
|
+
# supported, as are raising exceptions. In addition to a method's
|
107
|
+
# standard errors, a dRuby call may also raise one of the
|
108
|
+
# dRuby-specific errors, all of which are subclasses of DRb::DRbError.
|
109
|
+
#
|
110
|
+
# Any type of object can be passed as an argument to a dRuby call or
|
111
|
+
# returned as its return value. By default, such objects are dumped
|
112
|
+
# or marshalled at the local end, then loaded or unmarshalled at the
|
113
|
+
# remote end. The remote end therefore receives a copy of the local
|
114
|
+
# object, not a distributed reference to it; methods invoked upon this
|
115
|
+
# copy are executed entirely in the remote process, not passed on to
|
116
|
+
# the local original. This has semantics similar to pass-by-value.
|
117
|
+
#
|
118
|
+
# However, if an object cannot be marshalled, a dRuby reference to it
|
119
|
+
# is passed or returned instead. This will turn up at the remote end
|
120
|
+
# as a DRbObject instance. All methods invoked upon this remote proxy
|
121
|
+
# are forwarded to the local object, as described in the discussion of
|
122
|
+
# DRbObjects. This has semantics similar to the normal Ruby
|
123
|
+
# pass-by-reference.
|
124
|
+
#
|
125
|
+
# The easiest way to signal that we want an otherwise marshallable
|
126
|
+
# object to be passed or returned as a DRbObject reference, rather
|
127
|
+
# than marshalled and sent as a copy, is to include the
|
128
|
+
# DRb::DRbUndumped mixin module.
|
129
|
+
#
|
130
|
+
# dRuby supports calling remote methods with blocks. As blocks (or
|
131
|
+
# rather the Proc objects that represent them) are not marshallable,
|
132
|
+
# the block executes in the local, not the remote, context. Each
|
133
|
+
# value yielded to the block is passed from the remote object to the
|
134
|
+
# local block, then the value returned by each block invocation is
|
135
|
+
# passed back to the remote execution context to be collected, before
|
136
|
+
# the collected values are finally returned to the local context as
|
137
|
+
# the return value of the method invocation.
|
138
|
+
#
|
139
|
+
# == Examples of usage
|
140
|
+
#
|
141
|
+
# For more dRuby samples, see the +samples+ directory in the full
|
142
|
+
# dRuby distribution.
|
143
|
+
#
|
144
|
+
# === dRuby in client/server mode
|
145
|
+
#
|
146
|
+
# This illustrates setting up a simple client-server drb
|
147
|
+
# system. Run the server and client code in different terminals,
|
148
|
+
# starting the server code first.
|
149
|
+
#
|
150
|
+
# ==== Server code
|
151
|
+
#
|
152
|
+
# require 'drb/drb'
|
153
|
+
#
|
154
|
+
# # The URI for the server to connect to
|
155
|
+
# URI="druby://localhost:8787"
|
156
|
+
#
|
157
|
+
# class TimeServer
|
158
|
+
#
|
159
|
+
# def get_current_time
|
160
|
+
# return Time.now
|
161
|
+
# end
|
162
|
+
#
|
163
|
+
# end
|
164
|
+
#
|
165
|
+
# # The object that handles requests on the server
|
166
|
+
# FRONT_OBJECT=TimeServer.new
|
167
|
+
#
|
168
|
+
# $SAFE = 1 # disable eval() and friends
|
169
|
+
#
|
170
|
+
# DRb.start_service(URI, FRONT_OBJECT)
|
171
|
+
# # Wait for the drb server thread to finish before exiting.
|
172
|
+
# DRb.thread.join
|
173
|
+
#
|
174
|
+
# ==== Client code
|
175
|
+
#
|
176
|
+
# require 'drb/drb'
|
177
|
+
#
|
178
|
+
# # The URI to connect to
|
179
|
+
# SERVER_URI="druby://localhost:8787"
|
180
|
+
#
|
181
|
+
# # Start a local DRbServer to handle callbacks.
|
182
|
+
# #
|
183
|
+
# # Not necessary for this small example, but will be required
|
184
|
+
# # as soon as we pass a non-marshallable object as an argument
|
185
|
+
# # to a dRuby call.
|
186
|
+
# DRb.start_service
|
187
|
+
#
|
188
|
+
# timeserver = DRbObject.new_with_uri(SERVER_URI)
|
189
|
+
# puts timeserver.get_current_time
|
190
|
+
#
|
191
|
+
# === Remote objects under dRuby
|
192
|
+
#
|
193
|
+
# This example illustrates returning a reference to an object
|
194
|
+
# from a dRuby call. The Logger instances live in the server
|
195
|
+
# process. References to them are returned to the client process,
|
196
|
+
# where methods can be invoked upon them. These methods are
|
197
|
+
# executed in the server process.
|
198
|
+
#
|
199
|
+
# ==== Server code
|
200
|
+
#
|
201
|
+
# require 'drb/drb'
|
202
|
+
#
|
203
|
+
# URI="druby://localhost:8787"
|
204
|
+
#
|
205
|
+
# class Logger
|
206
|
+
#
|
207
|
+
# # Make dRuby send Logger instances as dRuby references,
|
208
|
+
# # not copies.
|
209
|
+
# include DRb::DRbUndumped
|
210
|
+
#
|
211
|
+
# def initialize(n, fname)
|
212
|
+
# @name = n
|
213
|
+
# @filename = fname
|
214
|
+
# end
|
215
|
+
#
|
216
|
+
# def log(message)
|
217
|
+
# File.open(@filename, "a") do |f|
|
218
|
+
# f.puts("#{Time.now}: #{@name}: #{message}")
|
219
|
+
# end
|
220
|
+
# end
|
221
|
+
#
|
222
|
+
# end
|
223
|
+
#
|
224
|
+
# # We have a central object for creating and retrieving loggers.
|
225
|
+
# # This retains a local reference to all loggers created. This
|
226
|
+
# # is so an existing logger can be looked up by name, but also
|
227
|
+
# # to prevent loggers from being garbage collected. A dRuby
|
228
|
+
# # reference to an object is not sufficient to prevent it being
|
229
|
+
# # garbage collected!
|
230
|
+
# class LoggerFactory
|
231
|
+
#
|
232
|
+
# def initialize(bdir)
|
233
|
+
# @basedir = bdir
|
234
|
+
# @loggers = {}
|
235
|
+
# end
|
236
|
+
#
|
237
|
+
# def get_logger(name)
|
238
|
+
# if !@loggers.has_key? name
|
239
|
+
# # make the filename safe, then declare it to be so
|
240
|
+
# fname = name.gsub(/[.\/]/, "_").untaint
|
241
|
+
# @loggers[name] = Logger.new(name, @basedir + "/" + fname)
|
242
|
+
# end
|
243
|
+
# return @loggers[name]
|
244
|
+
# end
|
245
|
+
#
|
246
|
+
# end
|
247
|
+
#
|
248
|
+
# FRONT_OBJECT=LoggerFactory.new("/tmp/dlog")
|
249
|
+
#
|
250
|
+
# $SAFE = 1 # disable eval() and friends
|
251
|
+
#
|
252
|
+
# DRb.start_service(URI, FRONT_OBJECT)
|
253
|
+
# DRb.thread.join
|
254
|
+
#
|
255
|
+
# ==== Client code
|
256
|
+
#
|
257
|
+
# require 'drb/drb'
|
258
|
+
#
|
259
|
+
# SERVER_URI="druby://localhost:8787"
|
260
|
+
#
|
261
|
+
# DRb.start_service
|
262
|
+
#
|
263
|
+
# log_service=DRbObject.new_with_uri(SERVER_URI)
|
264
|
+
#
|
265
|
+
# ["loga", "logb", "logc"].each do |logname|
|
266
|
+
#
|
267
|
+
# logger=log_service.get_logger(logname)
|
268
|
+
#
|
269
|
+
# logger.log("Hello, world!")
|
270
|
+
# logger.log("Goodbye, world!")
|
271
|
+
# logger.log("=== EOT ===")
|
272
|
+
#
|
273
|
+
# end
|
274
|
+
#
|
275
|
+
# == Security
|
276
|
+
#
|
277
|
+
# As with all network services, security needs to be considered when
|
278
|
+
# using dRuby. By allowing external access to a Ruby object, you are
|
279
|
+
# not only allowing outside clients to call the methods you have
|
280
|
+
# defined for that object, but by default to execute arbitrary Ruby
|
281
|
+
# code on your server. Consider the following:
|
282
|
+
#
|
283
|
+
# # !!! UNSAFE CODE !!!
|
284
|
+
# ro = DRbObject::new_with_uri("druby://your.server.com:8989")
|
285
|
+
# class << ro
|
286
|
+
# undef :instance_eval # force call to be passed to remote object
|
287
|
+
# end
|
288
|
+
# ro.instance_eval("`rm -rf *`")
|
289
|
+
#
|
290
|
+
# The dangers posed by instance_eval and friends are such that a
|
291
|
+
# DRbServer should generally be run with $SAFE set to at least
|
292
|
+
# level 1. This will disable eval() and related calls on strings
|
293
|
+
# passed across the wire. The sample usage code given above follows
|
294
|
+
# this practice.
|
295
|
+
#
|
296
|
+
# A DRbServer can be configured with an access control list to
|
297
|
+
# selectively allow or deny access from specified IP addresses. The
|
298
|
+
# main druby distribution provides the ACL class for this purpose. In
|
299
|
+
# general, this mechanism should only be used alongside, rather than
|
300
|
+
# as a replacement for, a good firewall.
|
301
|
+
#
|
302
|
+
# == dRuby internals
|
303
|
+
#
|
304
|
+
# dRuby is implemented using three main components: a remote method
|
305
|
+
# call marshaller/unmarshaller; a transport protocol; and an
|
306
|
+
# ID-to-object mapper. The latter two can be directly, and the first
|
307
|
+
# indirectly, replaced, in order to provide different behaviour and
|
308
|
+
# capabilities.
|
309
|
+
#
|
310
|
+
# Marshalling and unmarshalling of remote method calls is performed by
|
311
|
+
# a DRb::DRbMessage instance. This uses the Marshal module to dump
|
312
|
+
# the method call before sending it over the transport layer, then
|
313
|
+
# reconstitute it at the other end. There is normally no need to
|
314
|
+
# replace this component, and no direct way is provided to do so.
|
315
|
+
# However, it is possible to implement an alternative marshalling
|
316
|
+
# scheme as part of an implementation of the transport layer.
|
317
|
+
#
|
318
|
+
# The transport layer is responsible for opening client and server
|
319
|
+
# network connections and forwarding dRuby request across them.
|
320
|
+
# Normally, it uses DRb::DRbMessage internally to manage marshalling
|
321
|
+
# and unmarshalling. The transport layer is managed by
|
322
|
+
# DRb::DRbProtocol. Multiple protocols can be installed in
|
323
|
+
# DRbProtocol at the one time; selection between them is determined by
|
324
|
+
# the scheme of a dRuby URI. The default transport protocol is
|
325
|
+
# selected by the scheme 'druby:', and implemented by
|
326
|
+
# DRb::DRbTCPSocket. This uses plain TCP/IP sockets for
|
327
|
+
# communication. An alternative protocol, using UNIX domain sockets,
|
328
|
+
# is implemented by DRb::DRbUNIXSocket in the file drb/unix.rb, and
|
329
|
+
# selected by the scheme 'drbunix:'. A sample implementation over
|
330
|
+
# HTTP can be found in the samples accompanying the main dRuby
|
331
|
+
# distribution.
|
332
|
+
#
|
333
|
+
# The ID-to-object mapping component maps dRuby object ids to the
|
334
|
+
# objects they refer to, and vice versa. The implementation to use
|
335
|
+
# can be specified as part of a DRb::DRbServer's configuration. The
|
336
|
+
# default implementation is provided by DRb::DRbIdConv. It uses an
|
337
|
+
# object's ObjectSpace id as its dRuby id. This means that the dRuby
|
338
|
+
# reference to that object only remains meaningful for the lifetime of
|
339
|
+
# the object's process and the lifetime of the object within that
|
340
|
+
# process. A modified implementation is provided by DRb::TimerIdConv
|
341
|
+
# in the file drb/timeridconv.rb. This implementation retains a local
|
342
|
+
# reference to all objects exported over dRuby for a configurable
|
343
|
+
# period of time (defaulting to ten minutes), to prevent them being
|
344
|
+
# garbage-collected within this time. Another sample implementation
|
345
|
+
# is provided in sample/name.rb in the main dRuby distribution. This
|
346
|
+
# allows objects to specify their own id or "name". A dRuby reference
|
347
|
+
# can be made persistent across processes by having each process
|
348
|
+
# register an object using the same dRuby name.
|
349
|
+
#
|
350
|
+
module DRb
|
351
|
+
|
352
|
+
# Superclass of all errors raised in the DRb module.
|
353
|
+
class DRbError < RuntimeError; end
|
354
|
+
|
355
|
+
# Error raised when an error occurs on the underlying communication
|
356
|
+
# protocol.
|
357
|
+
class DRbConnError < DRbError; end
|
358
|
+
|
359
|
+
# Class responsible for converting between an object and its id.
|
360
|
+
#
|
361
|
+
# This, the default implementation, uses an object's local ObjectSpace
|
362
|
+
# __id__ as its id. This means that an object's identification over
|
363
|
+
# drb remains valid only while that object instance remains alive
|
364
|
+
# within the server runtime.
|
365
|
+
#
|
366
|
+
# For alternative mechanisms, see DRb::TimerIdConv in rdb/timeridconv.rb
|
367
|
+
# and DRbNameIdConv in sample/name.rb in the full drb distribution.
|
368
|
+
class DRbIdConv
|
369
|
+
|
370
|
+
# Convert an object reference id to an object.
|
371
|
+
#
|
372
|
+
# This implementation looks up the reference id in the local object
|
373
|
+
# space and returns the object it refers to.
|
374
|
+
def to_obj(ref)
|
375
|
+
ObjectSpace._id2ref(ref)
|
376
|
+
end
|
377
|
+
|
378
|
+
# Convert an object into a reference id.
|
379
|
+
#
|
380
|
+
# This implementation returns the object's __id__ in the local
|
381
|
+
# object space.
|
382
|
+
def to_id(obj)
|
383
|
+
obj.nil? ? nil : obj.__id__
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
# Mixin module making an object undumpable or unmarshallable.
|
388
|
+
#
|
389
|
+
# If an object which includes this module is returned by method
|
390
|
+
# called over drb, then the object remains in the server space
|
391
|
+
# and a reference to the object is returned, rather than the
|
392
|
+
# object being marshalled and moved into the client space.
|
393
|
+
module DRbUndumped
|
394
|
+
def _dump(dummy) # :nodoc:
|
395
|
+
raise TypeError, 'can\'t dump'
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
# Error raised by the DRb module when an attempt is made to refer to
|
400
|
+
# the context's current drb server but the context does not have one.
|
401
|
+
# See #current_server.
|
402
|
+
class DRbServerNotFound < DRbError; end
|
403
|
+
|
404
|
+
# Error raised by the DRbProtocol module when it cannot find any
|
405
|
+
# protocol implementation support the scheme specified in a URI.
|
406
|
+
class DRbBadURI < DRbError; end
|
407
|
+
|
408
|
+
# Error raised by a dRuby protocol when it doesn't support the
|
409
|
+
# scheme specified in a URI. See DRb::DRbProtocol.
|
410
|
+
class DRbBadScheme < DRbError; end
|
411
|
+
|
412
|
+
# An exception wrapping a DRb::DRbUnknown object
|
413
|
+
class DRbUnknownError < DRbError
|
414
|
+
|
415
|
+
# Create a new DRbUnknownError for the DRb::DRbUnknown object +unknown+
|
416
|
+
def initialize(unknown)
|
417
|
+
@unknown = unknown
|
418
|
+
super(unknown.name)
|
419
|
+
end
|
420
|
+
|
421
|
+
# Get the wrapped DRb::DRbUnknown object.
|
422
|
+
attr_reader :unknown
|
423
|
+
|
424
|
+
def self._load(s) # :nodoc:
|
425
|
+
Marshal::load(s)
|
426
|
+
end
|
427
|
+
|
428
|
+
def _dump(lv) # :nodoc:
|
429
|
+
Marshal::dump(@unknown)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
# An exception wrapping an error object
|
434
|
+
class DRbRemoteError < DRbError
|
435
|
+
def initialize(error)
|
436
|
+
@reason = error.class.to_s
|
437
|
+
super("#{error.message} (#{error.class})")
|
438
|
+
set_backtrace(error.backtrace)
|
439
|
+
end
|
440
|
+
|
441
|
+
# the class of the error, as a string.
|
442
|
+
attr_reader :reason
|
443
|
+
end
|
444
|
+
|
445
|
+
# Class wrapping a marshalled object whose type is unknown locally.
|
446
|
+
#
|
447
|
+
# If an object is returned by a method invoked over drb, but the
|
448
|
+
# class of the object is unknown in the client namespace, or
|
449
|
+
# the object is a constant unknown in the client namespace, then
|
450
|
+
# the still-marshalled object is returned wrapped in a DRbUnknown instance.
|
451
|
+
#
|
452
|
+
# If this object is passed as an argument to a method invoked over
|
453
|
+
# drb, then the wrapped object is passed instead.
|
454
|
+
#
|
455
|
+
# The class or constant name of the object can be read from the
|
456
|
+
# +name+ attribute. The marshalled object is held in the +buf+
|
457
|
+
# attribute.
|
458
|
+
class DRbUnknown
|
459
|
+
|
460
|
+
# Create a new DRbUnknown object.
|
461
|
+
#
|
462
|
+
# +buf+ is a string containing a marshalled object that could not
|
463
|
+
# be unmarshalled. +err+ is the error message that was raised
|
464
|
+
# when the unmarshalling failed. It is used to determine the
|
465
|
+
# name of the unmarshalled object.
|
466
|
+
def initialize(err, buf)
|
467
|
+
case err.to_s
|
468
|
+
when /uninitialized constant (\S+)/
|
469
|
+
@name = $1
|
470
|
+
when /undefined class\/module (\S+)/
|
471
|
+
@name = $1
|
472
|
+
else
|
473
|
+
@name = nil
|
474
|
+
end
|
475
|
+
@buf = buf
|
476
|
+
end
|
477
|
+
|
478
|
+
# The name of the unknown thing.
|
479
|
+
#
|
480
|
+
# Class name for unknown objects; variable name for unknown
|
481
|
+
# constants.
|
482
|
+
attr_reader :name
|
483
|
+
|
484
|
+
# Buffer contained the marshalled, unknown object.
|
485
|
+
attr_reader :buf
|
486
|
+
|
487
|
+
def self._load(s) # :nodoc:
|
488
|
+
begin
|
489
|
+
Marshal::load(s)
|
490
|
+
rescue NameError, ArgumentError
|
491
|
+
DRbUnknown.new($!, s)
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
def _dump(lv) # :nodoc:
|
496
|
+
@buf
|
497
|
+
end
|
498
|
+
|
499
|
+
# Attempt to load the wrapped marshalled object again.
|
500
|
+
#
|
501
|
+
# If the class of the object is now known locally, the object
|
502
|
+
# will be unmarshalled and returned. Otherwise, a new
|
503
|
+
# but identical DRbUnknown object will be returned.
|
504
|
+
def reload
|
505
|
+
self.class._load(@buf)
|
506
|
+
end
|
507
|
+
|
508
|
+
# Create a DRbUnknownError exception containing this object.
|
509
|
+
def exception
|
510
|
+
DRbUnknownError.new(self)
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
class DRbArray
|
515
|
+
def initialize(ary)
|
516
|
+
@ary = ary.collect { |obj|
|
517
|
+
if obj.kind_of? DRbUndumped
|
518
|
+
DRbObject.new(obj)
|
519
|
+
else
|
520
|
+
begin
|
521
|
+
Marshal.dump(obj)
|
522
|
+
obj
|
523
|
+
rescue
|
524
|
+
DRbObject.new(obj)
|
525
|
+
end
|
526
|
+
end
|
527
|
+
}
|
528
|
+
end
|
529
|
+
|
530
|
+
def self._load(s)
|
531
|
+
Marshal::load(s)
|
532
|
+
end
|
533
|
+
|
534
|
+
def _dump(lv)
|
535
|
+
Marshal.dump(@ary)
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
539
|
+
# Handler for sending and receiving drb messages.
|
540
|
+
#
|
541
|
+
# This takes care of the low-level marshalling and unmarshalling
|
542
|
+
# of drb requests and responses sent over the wire between server
|
543
|
+
# and client. This relieves the implementor of a new drb
|
544
|
+
# protocol layer with having to deal with these details.
|
545
|
+
#
|
546
|
+
# The user does not have to directly deal with this object in
|
547
|
+
# normal use.
|
548
|
+
class DRbMessage
|
549
|
+
def initialize(config) # :nodoc:
|
550
|
+
@load_limit = config[:load_limit]
|
551
|
+
@argc_limit = config[:argc_limit]
|
552
|
+
end
|
553
|
+
|
554
|
+
def dump(obj, error=false) # :nodoc:
|
555
|
+
obj = make_proxy(obj, error) if obj.kind_of? DRbUndumped
|
556
|
+
begin
|
557
|
+
str = Marshal::dump(obj)
|
558
|
+
rescue
|
559
|
+
str = Marshal::dump(make_proxy(obj, error))
|
560
|
+
end
|
561
|
+
[str.size].pack('N') + str
|
562
|
+
end
|
563
|
+
|
564
|
+
def load(soc) # :nodoc:
|
565
|
+
begin
|
566
|
+
sz = soc.read(4) # sizeof (N)
|
567
|
+
rescue
|
568
|
+
raise(DRbConnError, $!.message, $!.backtrace)
|
569
|
+
end
|
570
|
+
raise(DRbConnError, 'connection closed') if sz.nil?
|
571
|
+
raise(DRbConnError, 'premature header') if sz.size < 4
|
572
|
+
sz = sz.unpack('N')[0]
|
573
|
+
raise(DRbConnError, "too large packet #{sz}") if @load_limit < sz
|
574
|
+
begin
|
575
|
+
str = soc.read(sz)
|
576
|
+
rescue
|
577
|
+
raise(DRbConnError, $!.message, $!.backtrace)
|
578
|
+
end
|
579
|
+
raise(DRbConnError, 'connection closed') if str.nil?
|
580
|
+
raise(DRbConnError, 'premature marshal format(can\'t read)') if str.size < sz
|
581
|
+
DRb.mutex.synchronize do
|
582
|
+
begin
|
583
|
+
save = Thread.current[:drb_untaint]
|
584
|
+
Thread.current[:drb_untaint] = []
|
585
|
+
Marshal::load(str)
|
586
|
+
rescue NameError, ArgumentError
|
587
|
+
DRbUnknown.new($!, str)
|
588
|
+
ensure
|
589
|
+
Thread.current[:drb_untaint].each do |x|
|
590
|
+
x.untaint
|
591
|
+
end
|
592
|
+
Thread.current[:drb_untaint] = save
|
593
|
+
end
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
def send_request(stream, ref, msg_id, arg, b) # :nodoc:
|
598
|
+
ary = []
|
599
|
+
ary.push(dump(ref.__drbref))
|
600
|
+
ary.push(dump(msg_id.id2name))
|
601
|
+
ary.push(dump(arg.length))
|
602
|
+
arg.each do |e|
|
603
|
+
ary.push(dump(e))
|
604
|
+
end
|
605
|
+
ary.push(dump(b))
|
606
|
+
stream.write(ary.join(''))
|
607
|
+
rescue
|
608
|
+
raise(DRbConnError, $!.message, $!.backtrace)
|
609
|
+
end
|
610
|
+
|
611
|
+
def recv_request(stream) # :nodoc:
|
612
|
+
ref = load(stream)
|
613
|
+
ro = DRb.to_obj(ref)
|
614
|
+
msg = load(stream)
|
615
|
+
argc = load(stream)
|
616
|
+
raise ArgumentError, 'too many arguments' if @argc_limit < argc
|
617
|
+
argv = Array.new(argc, nil)
|
618
|
+
argc.times do |n|
|
619
|
+
argv[n] = load(stream)
|
620
|
+
end
|
621
|
+
block = load(stream)
|
622
|
+
return ro, msg, argv, block
|
623
|
+
end
|
624
|
+
|
625
|
+
def send_reply(stream, succ, result) # :nodoc:
|
626
|
+
stream.write(dump(succ) + dump(result, !succ))
|
627
|
+
rescue
|
628
|
+
raise(DRbConnError, $!.message, $!.backtrace)
|
629
|
+
end
|
630
|
+
|
631
|
+
def recv_reply(stream) # :nodoc:
|
632
|
+
succ = load(stream)
|
633
|
+
result = load(stream)
|
634
|
+
[succ, result]
|
635
|
+
end
|
636
|
+
|
637
|
+
private
|
638
|
+
def make_proxy(obj, error=false)
|
639
|
+
if error
|
640
|
+
DRbRemoteError.new(obj)
|
641
|
+
else
|
642
|
+
DRbObject.new(obj)
|
643
|
+
end
|
644
|
+
end
|
645
|
+
end
|
646
|
+
|
647
|
+
# Module managing the underlying network protocol(s) used by drb.
|
648
|
+
#
|
649
|
+
# By default, drb uses the DRbTCPSocket protocol. Other protocols
|
650
|
+
# can be defined. A protocol must define the following class methods:
|
651
|
+
#
|
652
|
+
# [open(uri, config)] Open a client connection to the server at +uri+,
|
653
|
+
# using configuration +config+. Return a protocol
|
654
|
+
# instance for this connection.
|
655
|
+
# [open_server(uri, config)] Open a server listening at +uri+,
|
656
|
+
# using configuration +config+. Return a
|
657
|
+
# protocol instance for this listener.
|
658
|
+
# [uri_option(uri, config)] Take a URI, possibly containing an option
|
659
|
+
# component (e.g. a trailing '?param=val'),
|
660
|
+
# and return a [uri, option] tuple.
|
661
|
+
#
|
662
|
+
# All of these methods should raise a DRbBadScheme error if the URI
|
663
|
+
# does not identify the protocol they support (e.g. "druby:" for
|
664
|
+
# the standard Ruby protocol). This is how the DRbProtocol module,
|
665
|
+
# given a URI, determines which protocol implementation serves that
|
666
|
+
# protocol.
|
667
|
+
#
|
668
|
+
# The protocol instance returned by #open_server must have the
|
669
|
+
# following methods:
|
670
|
+
#
|
671
|
+
# [accept] Accept a new connection to the server. Returns a protocol
|
672
|
+
# instance capable of communicating with the client.
|
673
|
+
# [close] Close the server connection.
|
674
|
+
# [uri] Get the URI for this server.
|
675
|
+
#
|
676
|
+
# The protocol instance returned by #open must have the following methods:
|
677
|
+
#
|
678
|
+
# [send_request (ref, msg_id, arg, b)]
|
679
|
+
# Send a request to +ref+ with the given message id and arguments.
|
680
|
+
# This is most easily implemented by calling DRbMessage.send_request,
|
681
|
+
# providing a stream that sits on top of the current protocol.
|
682
|
+
# [recv_reply]
|
683
|
+
# Receive a reply from the server and return it as a [success-boolean,
|
684
|
+
# reply-value] pair. This is most easily implemented by calling
|
685
|
+
# DRb.recv_reply, providing a stream that sits on top of the
|
686
|
+
# current protocol.
|
687
|
+
# [alive?]
|
688
|
+
# Is this connection still alive?
|
689
|
+
# [close]
|
690
|
+
# Close this connection.
|
691
|
+
#
|
692
|
+
# The protocol instance returned by #open_server().accept() must have
|
693
|
+
# the following methods:
|
694
|
+
#
|
695
|
+
# [recv_request]
|
696
|
+
# Receive a request from the client and return a [object, message,
|
697
|
+
# args, block] tuple. This is most easily implemented by calling
|
698
|
+
# DRbMessage.recv_request, providing a stream that sits on top of
|
699
|
+
# the current protocol.
|
700
|
+
# [send_reply(succ, result)]
|
701
|
+
# Send a reply to the client. This is most easily implemented
|
702
|
+
# by calling DRbMessage.send_reply, providing a stream that sits
|
703
|
+
# on top of the current protocol.
|
704
|
+
# [close]
|
705
|
+
# Close this connection.
|
706
|
+
#
|
707
|
+
# A new protocol is registered with the DRbProtocol module using
|
708
|
+
# the add_protocol method.
|
709
|
+
#
|
710
|
+
# For examples of other protocols, see DRbUNIXSocket in drb/unix.rb,
|
711
|
+
# and HTTP0 in sample/http0.rb and sample/http0serv.rb in the full
|
712
|
+
# drb distribution.
|
713
|
+
module DRbProtocol
|
714
|
+
|
715
|
+
# Add a new protocol to the DRbProtocol module.
|
716
|
+
def add_protocol(prot)
|
717
|
+
@protocol.push(prot)
|
718
|
+
end
|
719
|
+
module_function :add_protocol
|
720
|
+
|
721
|
+
# Open a client connection to +uri+ with the configuration +config+.
|
722
|
+
#
|
723
|
+
# The DRbProtocol module asks each registered protocol in turn to
|
724
|
+
# try to open the URI. Each protocol signals that it does not handle that
|
725
|
+
# URI by raising a DRbBadScheme error. If no protocol recognises the
|
726
|
+
# URI, then a DRbBadURI error is raised. If a protocol accepts the
|
727
|
+
# URI, but an error occurs in opening it, a DRbConnError is raised.
|
728
|
+
def open(uri, config, first=true)
|
729
|
+
@protocol.each do |prot|
|
730
|
+
begin
|
731
|
+
return prot.open(uri, config)
|
732
|
+
rescue DRbBadScheme
|
733
|
+
rescue DRbConnError
|
734
|
+
raise($!)
|
735
|
+
rescue
|
736
|
+
raise(DRbConnError, "#{uri} - #{$!.inspect}")
|
737
|
+
end
|
738
|
+
end
|
739
|
+
if first && (config[:auto_load] != false)
|
740
|
+
auto_load(uri, config)
|
741
|
+
return open(uri, config, false)
|
742
|
+
end
|
743
|
+
raise DRbBadURI, 'can\'t parse uri:' + uri
|
744
|
+
end
|
745
|
+
module_function :open
|
746
|
+
|
747
|
+
# Open a server listening for connections at +uri+ with
|
748
|
+
# configuration +config+.
|
749
|
+
#
|
750
|
+
# The DRbProtocol module asks each registered protocol in turn to
|
751
|
+
# try to open a server at the URI. Each protocol signals that it does
|
752
|
+
# not handle that URI by raising a DRbBadScheme error. If no protocol
|
753
|
+
# recognises the URI, then a DRbBadURI error is raised. If a protocol
|
754
|
+
# accepts the URI, but an error occurs in opening it, the underlying
|
755
|
+
# error is passed on to the caller.
|
756
|
+
def open_server(uri, config, first=true)
|
757
|
+
@protocol.each do |prot|
|
758
|
+
begin
|
759
|
+
return prot.open_server(uri, config)
|
760
|
+
rescue DRbBadScheme
|
761
|
+
end
|
762
|
+
end
|
763
|
+
if first && (config[:auto_load] != false)
|
764
|
+
auto_load(uri, config)
|
765
|
+
return open_server(uri, config, false)
|
766
|
+
end
|
767
|
+
raise DRbBadURI, 'can\'t parse uri:' + uri
|
768
|
+
end
|
769
|
+
module_function :open_server
|
770
|
+
|
771
|
+
# Parse +uri+ into a [uri, option] pair.
|
772
|
+
#
|
773
|
+
# The DRbProtocol module asks each registered protocol in turn to
|
774
|
+
# try to parse the URI. Each protocol signals that it does not handle that
|
775
|
+
# URI by raising a DRbBadScheme error. If no protocol recognises the
|
776
|
+
# URI, then a DRbBadURI error is raised.
|
777
|
+
def uri_option(uri, config, first=true)
|
778
|
+
@protocol.each do |prot|
|
779
|
+
begin
|
780
|
+
uri, opt = prot.uri_option(uri, config)
|
781
|
+
# opt = nil if opt == ''
|
782
|
+
return uri, opt
|
783
|
+
rescue DRbBadScheme
|
784
|
+
end
|
785
|
+
end
|
786
|
+
if first && (config[:auto_load] != false)
|
787
|
+
auto_load(uri, config)
|
788
|
+
return uri_option(uri, config, false)
|
789
|
+
end
|
790
|
+
raise DRbBadURI, 'can\'t parse uri:' + uri
|
791
|
+
end
|
792
|
+
module_function :uri_option
|
793
|
+
|
794
|
+
def auto_load(uri, config) # :nodoc:
|
795
|
+
if uri =~ /^drb([a-z0-9]+):/
|
796
|
+
require("drb/#{$1}") rescue nil
|
797
|
+
end
|
798
|
+
end
|
799
|
+
module_function :auto_load
|
800
|
+
end
|
801
|
+
|
802
|
+
# The default drb protocol.
|
803
|
+
#
|
804
|
+
# Communicates over a TCP socket.
|
805
|
+
class DRbTCPSocket
|
806
|
+
private
|
807
|
+
def self.parse_uri(uri)
|
808
|
+
if uri =~ /^druby:\/\/(.*?):(\d+)(\?(.*))?$/
|
809
|
+
host = $1
|
810
|
+
port = $2.to_i
|
811
|
+
option = $4
|
812
|
+
[host, port, option]
|
813
|
+
else
|
814
|
+
raise(DRbBadScheme, uri) unless uri =~ /^druby:/
|
815
|
+
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
816
|
+
end
|
817
|
+
end
|
818
|
+
|
819
|
+
public
|
820
|
+
|
821
|
+
# Open a client connection to +uri+ using configuration +config+.
|
822
|
+
def self.open(uri, config)
|
823
|
+
host, port, option = parse_uri(uri)
|
824
|
+
host.untaint
|
825
|
+
port.untaint
|
826
|
+
soc = TCPSocket.open(host, port)
|
827
|
+
self.new(uri, soc, config)
|
828
|
+
end
|
829
|
+
|
830
|
+
def self.getservername
|
831
|
+
host = Socket::gethostname
|
832
|
+
begin
|
833
|
+
Socket::gethostbyname(host)[0]
|
834
|
+
rescue
|
835
|
+
'localhost'
|
836
|
+
end
|
837
|
+
end
|
838
|
+
|
839
|
+
def self.open_server_inaddr_any(host, port)
|
840
|
+
infos = Socket::getaddrinfo(host, nil,
|
841
|
+
Socket::AF_UNSPEC,
|
842
|
+
Socket::SOCK_STREAM,
|
843
|
+
0,
|
844
|
+
Socket::AI_PASSIVE)
|
845
|
+
families = Hash[*infos.collect { |af, *_| af }.uniq.zip([]).flatten]
|
846
|
+
return TCPServer.open('0.0.0.0', port) if families.has_key?('AF_INET')
|
847
|
+
return TCPServer.open('::', port) if families.has_key?('AF_INET6')
|
848
|
+
return TCPServer.open(port)
|
849
|
+
end
|
850
|
+
|
851
|
+
# Open a server listening for connections at +uri+ using
|
852
|
+
# configuration +config+.
|
853
|
+
def self.open_server(uri, config)
|
854
|
+
uri = 'druby://:0' unless uri
|
855
|
+
host, port, opt = parse_uri(uri)
|
856
|
+
config = {:tcp_original_host => host}.update(config)
|
857
|
+
if host.size == 0
|
858
|
+
host = getservername
|
859
|
+
soc = open_server_inaddr_any(host, port)
|
860
|
+
else
|
861
|
+
soc = TCPServer.open(host, port)
|
862
|
+
end
|
863
|
+
port = soc.addr[1] if port == 0
|
864
|
+
config[:tcp_port] = port
|
865
|
+
uri = "druby://#{host}:#{port}"
|
866
|
+
self.new(uri, soc, config)
|
867
|
+
end
|
868
|
+
|
869
|
+
# Parse +uri+ into a [uri, option] pair.
|
870
|
+
def self.uri_option(uri, config)
|
871
|
+
host, port, option = parse_uri(uri)
|
872
|
+
return "druby://#{host}:#{port}", option
|
873
|
+
end
|
874
|
+
|
875
|
+
# Create a new DRbTCPSocket instance.
|
876
|
+
#
|
877
|
+
# +uri+ is the URI we are connected to.
|
878
|
+
# +soc+ is the tcp socket we are bound to. +config+ is our
|
879
|
+
# configuration.
|
880
|
+
def initialize(uri, soc, config={})
|
881
|
+
@uri = uri
|
882
|
+
@socket = soc
|
883
|
+
@config = config
|
884
|
+
@acl = config[:tcp_acl]
|
885
|
+
@msg = DRbMessage.new(config)
|
886
|
+
set_sockopt(@socket)
|
887
|
+
end
|
888
|
+
|
889
|
+
# Get the URI that we are connected to.
|
890
|
+
attr_reader :uri
|
891
|
+
|
892
|
+
# Get the address of our TCP peer (the other end of the socket
|
893
|
+
# we are bound to.
|
894
|
+
def peeraddr
|
895
|
+
@socket.peeraddr
|
896
|
+
end
|
897
|
+
|
898
|
+
# Get the socket.
|
899
|
+
def stream; @socket; end
|
900
|
+
|
901
|
+
# On the client side, send a request to the server.
|
902
|
+
def send_request(ref, msg_id, arg, b)
|
903
|
+
@msg.send_request(stream, ref, msg_id, arg, b)
|
904
|
+
end
|
905
|
+
|
906
|
+
# On the server side, receive a request from the client.
|
907
|
+
def recv_request
|
908
|
+
@msg.recv_request(stream)
|
909
|
+
end
|
910
|
+
|
911
|
+
# On the server side, send a reply to the client.
|
912
|
+
def send_reply(succ, result)
|
913
|
+
@msg.send_reply(stream, succ, result)
|
914
|
+
end
|
915
|
+
|
916
|
+
# On the client side, receive a reply from the server.
|
917
|
+
def recv_reply
|
918
|
+
@msg.recv_reply(stream)
|
919
|
+
end
|
920
|
+
|
921
|
+
public
|
922
|
+
|
923
|
+
# Close the connection.
|
924
|
+
#
|
925
|
+
# If this is an instance returned by #open_server, then this stops
|
926
|
+
# listening for new connections altogether. If this is an instance
|
927
|
+
# returned by #open or by #accept, then it closes this particular
|
928
|
+
# client-server session.
|
929
|
+
def close
|
930
|
+
if @socket
|
931
|
+
@socket.close
|
932
|
+
@socket = nil
|
933
|
+
end
|
934
|
+
end
|
935
|
+
|
936
|
+
# On the server side, for an instance returned by #open_server,
|
937
|
+
# accept a client connection and return a new instance to handle
|
938
|
+
# the server's side of this client-server session.
|
939
|
+
def accept
|
940
|
+
while true
|
941
|
+
s = @socket.accept
|
942
|
+
break if (@acl ? @acl.allow_socket?(s) : true)
|
943
|
+
s.close
|
944
|
+
end
|
945
|
+
if @config[:tcp_original_host].to_s.size == 0
|
946
|
+
uri = "druby://#{s.addr[3]}:#{@config[:tcp_port]}"
|
947
|
+
else
|
948
|
+
uri = @uri
|
949
|
+
end
|
950
|
+
self.class.new(uri, s, @config)
|
951
|
+
end
|
952
|
+
|
953
|
+
# Check to see if this connection is alive.
|
954
|
+
def alive?
|
955
|
+
return false unless @socket
|
956
|
+
if IO.select([@socket], nil, nil, 0)
|
957
|
+
close
|
958
|
+
return false
|
959
|
+
end
|
960
|
+
true
|
961
|
+
end
|
962
|
+
|
963
|
+
def set_sockopt(soc) # :nodoc:
|
964
|
+
soc.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
965
|
+
soc.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
|
966
|
+
end
|
967
|
+
end
|
968
|
+
|
969
|
+
module DRbProtocol
|
970
|
+
@protocol = [DRbTCPSocket] # default
|
971
|
+
end
|
972
|
+
|
973
|
+
class DRbURIOption # :nodoc: I don't understand the purpose of this class...
|
974
|
+
def initialize(option)
|
975
|
+
@option = option.to_s
|
976
|
+
end
|
977
|
+
attr :option
|
978
|
+
def to_s; @option; end
|
979
|
+
|
980
|
+
def ==(other)
|
981
|
+
return false unless DRbURIOption === other
|
982
|
+
@option == other.option
|
983
|
+
end
|
984
|
+
|
985
|
+
def hash
|
986
|
+
@option.hash
|
987
|
+
end
|
988
|
+
|
989
|
+
alias eql? ==
|
990
|
+
end
|
991
|
+
|
992
|
+
# Object wrapping a reference to a remote drb object.
|
993
|
+
#
|
994
|
+
# Method calls on this object are relayed to the remote
|
995
|
+
# object that this object is a stub for.
|
996
|
+
class DRbObject
|
997
|
+
|
998
|
+
# Unmarshall a marshalled DRbObject.
|
999
|
+
#
|
1000
|
+
# If the referenced object is located within the local server, then
|
1001
|
+
# the object itself is returned. Otherwise, a new DRbObject is
|
1002
|
+
# created to act as a stub for the remote referenced object.
|
1003
|
+
def self._load(s)
|
1004
|
+
uri, ref = Marshal.load(s)
|
1005
|
+
|
1006
|
+
if DRb.here?(uri)
|
1007
|
+
obj = DRb.to_obj(ref)
|
1008
|
+
if ((! obj.tainted?) && Thread.current[:drb_untaint])
|
1009
|
+
Thread.current[:drb_untaint].push(obj)
|
1010
|
+
end
|
1011
|
+
return obj
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
self.new_with(uri, ref)
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
def self.new_with(uri, ref)
|
1018
|
+
it = self.allocate
|
1019
|
+
it.instance_variable_set('@uri', uri)
|
1020
|
+
it.instance_variable_set('@ref', ref)
|
1021
|
+
it
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
# Create a new DRbObject from a URI alone.
|
1025
|
+
def self.new_with_uri(uri)
|
1026
|
+
self.new(nil, uri)
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
# Marshall this object.
|
1030
|
+
#
|
1031
|
+
# The URI and ref of the object are marshalled.
|
1032
|
+
def _dump(lv)
|
1033
|
+
Marshal.dump([@uri, @ref])
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
# Create a new remote object stub.
|
1037
|
+
#
|
1038
|
+
# +obj+ is the (local) object we want to create a stub for. Normally
|
1039
|
+
# this is +nil+. +uri+ is the URI of the remote object that this
|
1040
|
+
# will be a stub for.
|
1041
|
+
def initialize(obj, uri=nil)
|
1042
|
+
@uri = nil
|
1043
|
+
@ref = nil
|
1044
|
+
if obj.nil?
|
1045
|
+
return if uri.nil?
|
1046
|
+
@uri, option = DRbProtocol.uri_option(uri, DRb.config)
|
1047
|
+
@ref = DRbURIOption.new(option) unless option.nil?
|
1048
|
+
else
|
1049
|
+
@uri = uri ? uri : (DRb.uri rescue nil)
|
1050
|
+
@ref = obj ? DRb.to_id(obj) : nil
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
# Get the URI of the remote object.
|
1055
|
+
def __drburi
|
1056
|
+
@uri
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
# Get the reference of the object, if local.
|
1060
|
+
def __drbref
|
1061
|
+
@ref
|
1062
|
+
end
|
1063
|
+
|
1064
|
+
undef :to_s
|
1065
|
+
undef :to_a if respond_to?(:to_a)
|
1066
|
+
|
1067
|
+
def respond_to?(msg_id, priv=false)
|
1068
|
+
case msg_id
|
1069
|
+
when :_dump
|
1070
|
+
true
|
1071
|
+
when :marshal_dump
|
1072
|
+
false
|
1073
|
+
else
|
1074
|
+
method_missing(:respond_to?, msg_id, priv)
|
1075
|
+
end
|
1076
|
+
end
|
1077
|
+
|
1078
|
+
# Routes method calls to the referenced object.
|
1079
|
+
def method_missing(msg_id, *a, &b)
|
1080
|
+
if DRb.here?(@uri)
|
1081
|
+
obj = DRb.to_obj(@ref)
|
1082
|
+
DRb.current_server.check_insecure_method(obj, msg_id)
|
1083
|
+
return obj.__send__(msg_id, *a, &b)
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
succ, result = self.class.with_friend(@uri) do
|
1087
|
+
DRbConn.open(@uri) do |conn|
|
1088
|
+
conn.send_message(self, msg_id, a, b)
|
1089
|
+
end
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
if succ
|
1093
|
+
return result
|
1094
|
+
elsif DRbUnknown === result
|
1095
|
+
raise result
|
1096
|
+
else
|
1097
|
+
bt = self.class.prepare_backtrace(@uri, result)
|
1098
|
+
result.set_backtrace(bt + caller)
|
1099
|
+
raise result
|
1100
|
+
end
|
1101
|
+
end
|
1102
|
+
|
1103
|
+
def self.with_friend(uri)
|
1104
|
+
friend = DRb.fetch_server(uri)
|
1105
|
+
return yield() unless friend
|
1106
|
+
|
1107
|
+
save = Thread.current['DRb']
|
1108
|
+
Thread.current['DRb'] = { 'server' => friend }
|
1109
|
+
return yield
|
1110
|
+
ensure
|
1111
|
+
Thread.current['DRb'] = save if friend
|
1112
|
+
end
|
1113
|
+
|
1114
|
+
def self.prepare_backtrace(uri, result)
|
1115
|
+
prefix = "(#{uri}) "
|
1116
|
+
bt = []
|
1117
|
+
result.backtrace.each do |x|
|
1118
|
+
break if /`__send__'$/ =~ x
|
1119
|
+
if /^\(druby:\/\// =~ x
|
1120
|
+
bt.push(x)
|
1121
|
+
else
|
1122
|
+
bt.push(prefix + x)
|
1123
|
+
end
|
1124
|
+
end
|
1125
|
+
bt
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
def pretty_print(q) # :nodoc:
|
1129
|
+
q.pp_object(self)
|
1130
|
+
end
|
1131
|
+
|
1132
|
+
def pretty_print_cycle(q) # :nodoc:
|
1133
|
+
q.object_address_group(self) {
|
1134
|
+
q.breakable
|
1135
|
+
q.text '...'
|
1136
|
+
}
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
# Class handling the connection between a DRbObject and the
|
1141
|
+
# server the real object lives on.
|
1142
|
+
#
|
1143
|
+
# This class maintains a pool of connections, to reduce the
|
1144
|
+
# overhead of starting and closing down connections for each
|
1145
|
+
# method call.
|
1146
|
+
#
|
1147
|
+
# This class is used internally by DRbObject. The user does
|
1148
|
+
# not normally need to deal with it directly.
|
1149
|
+
class DRbConn
|
1150
|
+
POOL_SIZE = 16 # :nodoc:
|
1151
|
+
@mutex = Mutex.new
|
1152
|
+
@pool = []
|
1153
|
+
|
1154
|
+
def self.open(remote_uri) # :nodoc:
|
1155
|
+
begin
|
1156
|
+
conn = nil
|
1157
|
+
|
1158
|
+
@mutex.synchronize do
|
1159
|
+
#FIXME
|
1160
|
+
new_pool = []
|
1161
|
+
@pool.each do |c|
|
1162
|
+
if conn.nil? and c.uri == remote_uri
|
1163
|
+
conn = c if c.alive?
|
1164
|
+
else
|
1165
|
+
new_pool.push c
|
1166
|
+
end
|
1167
|
+
end
|
1168
|
+
@pool = new_pool
|
1169
|
+
end
|
1170
|
+
|
1171
|
+
conn = self.new(remote_uri) unless conn
|
1172
|
+
succ, result = yield(conn)
|
1173
|
+
return succ, result
|
1174
|
+
|
1175
|
+
ensure
|
1176
|
+
if conn
|
1177
|
+
if succ
|
1178
|
+
@mutex.synchronize do
|
1179
|
+
@pool.unshift(conn)
|
1180
|
+
@pool.pop.close while @pool.size > POOL_SIZE
|
1181
|
+
end
|
1182
|
+
else
|
1183
|
+
conn.close
|
1184
|
+
end
|
1185
|
+
end
|
1186
|
+
end
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
def initialize(remote_uri) # :nodoc:
|
1190
|
+
@uri = remote_uri
|
1191
|
+
@protocol = DRbProtocol.open(remote_uri, DRb.config)
|
1192
|
+
end
|
1193
|
+
attr_reader :uri # :nodoc:
|
1194
|
+
|
1195
|
+
def send_message(ref, msg_id, arg, block) # :nodoc:
|
1196
|
+
@protocol.send_request(ref, msg_id, arg, block)
|
1197
|
+
@protocol.recv_reply
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
def close # :nodoc:
|
1201
|
+
@protocol.close
|
1202
|
+
@protocol = nil
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
def alive? # :nodoc:
|
1206
|
+
return false unless @protocol
|
1207
|
+
@protocol.alive?
|
1208
|
+
end
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
# Class representing a drb server instance.
|
1212
|
+
#
|
1213
|
+
# A DRbServer must be running in the local process before any incoming
|
1214
|
+
# dRuby calls can be accepted, or any local objects can be passed as
|
1215
|
+
# dRuby references to remote processes, even if those local objects are
|
1216
|
+
# never actually called remotely. You do not need to start a DRbServer
|
1217
|
+
# in the local process if you are only making outgoing dRuby calls
|
1218
|
+
# passing marshalled parameters.
|
1219
|
+
#
|
1220
|
+
# Unless multiple servers are being used, the local DRbServer is normally
|
1221
|
+
# started by calling DRb.start_service.
|
1222
|
+
class DRbServer
|
1223
|
+
@@acl = nil
|
1224
|
+
@@idconv = DRbIdConv.new
|
1225
|
+
@@secondary_server = nil
|
1226
|
+
@@argc_limit = 256
|
1227
|
+
@@load_limit = 256 * 102400
|
1228
|
+
@@verbose = false
|
1229
|
+
@@safe_level = 0
|
1230
|
+
|
1231
|
+
# Set the default value for the :argc_limit option.
|
1232
|
+
#
|
1233
|
+
# See #new(). The initial default value is 256.
|
1234
|
+
def self.default_argc_limit(argc)
|
1235
|
+
@@argc_limit = argc
|
1236
|
+
end
|
1237
|
+
|
1238
|
+
# Set the default value for the :load_limit option.
|
1239
|
+
#
|
1240
|
+
# See #new(). The initial default value is 25 MB.
|
1241
|
+
def self.default_load_limit(sz)
|
1242
|
+
@@load_limit = sz
|
1243
|
+
end
|
1244
|
+
|
1245
|
+
# Set the default value for the :acl option.
|
1246
|
+
#
|
1247
|
+
# See #new(). The initial default value is nil.
|
1248
|
+
def self.default_acl(acl)
|
1249
|
+
@@acl = acl
|
1250
|
+
end
|
1251
|
+
|
1252
|
+
# Set the default value for the :id_conv option.
|
1253
|
+
#
|
1254
|
+
# See #new(). The initial default value is a DRbIdConv instance.
|
1255
|
+
def self.default_id_conv(idconv)
|
1256
|
+
@@idconv = idconv
|
1257
|
+
end
|
1258
|
+
|
1259
|
+
def self.default_safe_level(level)
|
1260
|
+
@@safe_level = level
|
1261
|
+
end
|
1262
|
+
|
1263
|
+
# Set the default value of the :verbose option.
|
1264
|
+
#
|
1265
|
+
# See #new(). The initial default value is false.
|
1266
|
+
def self.verbose=(on)
|
1267
|
+
@@verbose = on
|
1268
|
+
end
|
1269
|
+
|
1270
|
+
# Get the default value of the :verbose option.
|
1271
|
+
def self.verbose
|
1272
|
+
@@verbose
|
1273
|
+
end
|
1274
|
+
|
1275
|
+
def self.make_config(hash={}) # :nodoc:
|
1276
|
+
default_config = {
|
1277
|
+
:idconv => @@idconv,
|
1278
|
+
:verbose => @@verbose,
|
1279
|
+
:tcp_acl => @@acl,
|
1280
|
+
:load_limit => @@load_limit,
|
1281
|
+
:argc_limit => @@argc_limit,
|
1282
|
+
:safe_level => @@safe_level
|
1283
|
+
}
|
1284
|
+
default_config.update(hash)
|
1285
|
+
end
|
1286
|
+
|
1287
|
+
# Create a new DRbServer instance.
|
1288
|
+
#
|
1289
|
+
# +uri+ is the URI to bind to. This is normally of the form
|
1290
|
+
# 'druby://<hostname>:<port>' where <hostname> is a hostname of
|
1291
|
+
# the local machine. If nil, then the system's default hostname
|
1292
|
+
# will be bound to, on a port selected by the system; these value
|
1293
|
+
# can be retrieved from the +uri+ attribute. 'druby:' specifies
|
1294
|
+
# the default dRuby transport protocol: another protocol, such
|
1295
|
+
# as 'drbunix:', can be specified instead.
|
1296
|
+
#
|
1297
|
+
# +front+ is the front object for the server, that is, the object
|
1298
|
+
# to which remote method calls on the server will be passed. If
|
1299
|
+
# nil, then the server will not accept remote method calls.
|
1300
|
+
#
|
1301
|
+
# If +config_or_acl+ is a hash, it is the configuration to
|
1302
|
+
# use for this server. The following options are recognised:
|
1303
|
+
#
|
1304
|
+
# :idconv :: an id-to-object conversion object. This defaults
|
1305
|
+
# to an instance of the class DRb::DRbIdConv.
|
1306
|
+
# :verbose :: if true, all unsuccessful remote calls on objects
|
1307
|
+
# in the server will be logged to $stdout. false
|
1308
|
+
# by default.
|
1309
|
+
# :tcp_acl :: the access control list for this server. See
|
1310
|
+
# the ACL class from the main dRuby distribution.
|
1311
|
+
# :load_limit :: the maximum message size in bytes accepted by
|
1312
|
+
# the server. Defaults to 25 MB (26214400).
|
1313
|
+
# :argc_limit :: the maximum number of arguments to a remote
|
1314
|
+
# method accepted by the server. Defaults to
|
1315
|
+
# 256.
|
1316
|
+
#
|
1317
|
+
# The default values of these options can be modified on
|
1318
|
+
# a class-wide basis by the class methods #default_argc_limit,
|
1319
|
+
# #default_load_limit, #default_acl, #default_id_conv,
|
1320
|
+
# and #verbose=
|
1321
|
+
#
|
1322
|
+
# If +config_or_acl+ is not a hash, but is not nil, it is
|
1323
|
+
# assumed to be the access control list for this server.
|
1324
|
+
# See the :tcp_acl option for more details.
|
1325
|
+
#
|
1326
|
+
# If no other server is currently set as the primary server,
|
1327
|
+
# this will become the primary server.
|
1328
|
+
#
|
1329
|
+
# The server will immediately start running in its own thread.
|
1330
|
+
def initialize(uri=nil, front=nil, config_or_acl=nil)
|
1331
|
+
if Hash === config_or_acl
|
1332
|
+
config = config_or_acl.dup
|
1333
|
+
else
|
1334
|
+
acl = config_or_acl || @@acl
|
1335
|
+
config = {
|
1336
|
+
:tcp_acl => acl
|
1337
|
+
}
|
1338
|
+
end
|
1339
|
+
|
1340
|
+
@config = self.class.make_config(config)
|
1341
|
+
|
1342
|
+
@protocol = DRbProtocol.open_server(uri, @config)
|
1343
|
+
@uri = @protocol.uri
|
1344
|
+
|
1345
|
+
@front = front
|
1346
|
+
@idconv = @config[:idconv]
|
1347
|
+
@safe_level = @config[:safe_level]
|
1348
|
+
|
1349
|
+
@grp = ThreadGroup.new
|
1350
|
+
@thread = run
|
1351
|
+
|
1352
|
+
DRb.regist_server(self)
|
1353
|
+
end
|
1354
|
+
|
1355
|
+
# The URI of this DRbServer.
|
1356
|
+
attr_reader :uri
|
1357
|
+
|
1358
|
+
# The main thread of this DRbServer.
|
1359
|
+
#
|
1360
|
+
# This is the thread that listens for and accepts connections
|
1361
|
+
# from clients, not that handles each client's request-response
|
1362
|
+
# session.
|
1363
|
+
attr_reader :thread
|
1364
|
+
|
1365
|
+
# The front object of the DRbServer.
|
1366
|
+
#
|
1367
|
+
# This object receives remote method calls made on the server's
|
1368
|
+
# URI alone, with an object id.
|
1369
|
+
attr_reader :front
|
1370
|
+
|
1371
|
+
# The configuration of this DRbServer
|
1372
|
+
attr_reader :config
|
1373
|
+
|
1374
|
+
attr_reader :safe_level
|
1375
|
+
|
1376
|
+
# Set whether to operate in verbose mode.
|
1377
|
+
#
|
1378
|
+
# In verbose mode, failed calls are logged to stdout.
|
1379
|
+
def verbose=(v); @config[:verbose]=v; end
|
1380
|
+
|
1381
|
+
# Get whether the server is in verbose mode.
|
1382
|
+
#
|
1383
|
+
# In verbose mode, failed calls are logged to stdout.
|
1384
|
+
def verbose; @config[:verbose]; end
|
1385
|
+
|
1386
|
+
# Is this server alive?
|
1387
|
+
def alive?
|
1388
|
+
@thread.alive?
|
1389
|
+
end
|
1390
|
+
|
1391
|
+
# Stop this server.
|
1392
|
+
def stop_service
|
1393
|
+
DRb.remove_server(self)
|
1394
|
+
if Thread.current['DRb'] && Thread.current['DRb']['server'] == self
|
1395
|
+
Thread.current['DRb']['stop_service'] = true
|
1396
|
+
else
|
1397
|
+
@thread.kill
|
1398
|
+
end
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
# Convert a dRuby reference to the local object it refers to.
|
1402
|
+
def to_obj(ref)
|
1403
|
+
return front if ref.nil?
|
1404
|
+
return front[ref.to_s] if DRbURIOption === ref
|
1405
|
+
@idconv.to_obj(ref)
|
1406
|
+
end
|
1407
|
+
|
1408
|
+
# Convert a local object to a dRuby reference.
|
1409
|
+
def to_id(obj)
|
1410
|
+
return nil if obj.__id__ == front.__id__
|
1411
|
+
@idconv.to_id(obj)
|
1412
|
+
end
|
1413
|
+
|
1414
|
+
private
|
1415
|
+
def kill_sub_thread
|
1416
|
+
Thread.new do
|
1417
|
+
grp = ThreadGroup.new
|
1418
|
+
grp.add(Thread.current)
|
1419
|
+
list = @grp.list
|
1420
|
+
while list.size > 0
|
1421
|
+
list.each do |th|
|
1422
|
+
th.kill if th.alive?
|
1423
|
+
end
|
1424
|
+
list = @grp.list
|
1425
|
+
end
|
1426
|
+
end
|
1427
|
+
end
|
1428
|
+
|
1429
|
+
def run
|
1430
|
+
Thread.start do
|
1431
|
+
begin
|
1432
|
+
while true
|
1433
|
+
main_loop
|
1434
|
+
end
|
1435
|
+
ensure
|
1436
|
+
@protocol.close if @protocol
|
1437
|
+
kill_sub_thread
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
end
|
1441
|
+
|
1442
|
+
# List of insecure methods.
|
1443
|
+
#
|
1444
|
+
# These methods are not callable via dRuby.
|
1445
|
+
INSECURE_METHOD = [
|
1446
|
+
:__send__
|
1447
|
+
]
|
1448
|
+
|
1449
|
+
# Has a method been included in the list of insecure methods?
|
1450
|
+
def insecure_method?(msg_id)
|
1451
|
+
INSECURE_METHOD.include?(msg_id)
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
# Coerce an object to a string, providing our own representation if
|
1455
|
+
# to_s is not defined for the object.
|
1456
|
+
def any_to_s(obj)
|
1457
|
+
obj.to_s + ":#{obj.class}"
|
1458
|
+
rescue
|
1459
|
+
sprintf("#<%s:0x%lx>", obj.class, obj.__id__)
|
1460
|
+
end
|
1461
|
+
|
1462
|
+
# Check that a method is callable via dRuby.
|
1463
|
+
#
|
1464
|
+
# +obj+ is the object we want to invoke the method on. +msg_id+ is the
|
1465
|
+
# method name, as a Symbol.
|
1466
|
+
#
|
1467
|
+
# If the method is an insecure method (see #insecure_method?) a
|
1468
|
+
# SecurityError is thrown. If the method is private or undefined,
|
1469
|
+
# a NameError is thrown.
|
1470
|
+
def check_insecure_method(obj, msg_id)
|
1471
|
+
return true if Proc === obj && msg_id == :__drb_yield
|
1472
|
+
raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
|
1473
|
+
raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
|
1474
|
+
|
1475
|
+
if obj.private_methods.include?(msg_id)
|
1476
|
+
desc = any_to_s(obj)
|
1477
|
+
raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
|
1478
|
+
elsif obj.protected_methods.include?(msg_id)
|
1479
|
+
desc = any_to_s(obj)
|
1480
|
+
raise NoMethodError, "protected method `#{msg_id}' called for #{desc}"
|
1481
|
+
else
|
1482
|
+
true
|
1483
|
+
end
|
1484
|
+
end
|
1485
|
+
public :check_insecure_method
|
1486
|
+
|
1487
|
+
class InvokeMethod # :nodoc:
|
1488
|
+
def initialize(drb_server, client)
|
1489
|
+
@drb_server = drb_server
|
1490
|
+
@safe_level = drb_server.safe_level
|
1491
|
+
@client = client
|
1492
|
+
end
|
1493
|
+
|
1494
|
+
def perform
|
1495
|
+
@result = nil
|
1496
|
+
@succ = false
|
1497
|
+
setup_message
|
1498
|
+
|
1499
|
+
if $SAFE < @safe_level
|
1500
|
+
info = Thread.current['DRb']
|
1501
|
+
if @block
|
1502
|
+
@result = Thread.new {
|
1503
|
+
Thread.current['DRb'] = info
|
1504
|
+
$SAFE = @safe_level
|
1505
|
+
perform_with_block
|
1506
|
+
}.value
|
1507
|
+
else
|
1508
|
+
@result = Thread.new {
|
1509
|
+
Thread.current['DRb'] = info
|
1510
|
+
$SAFE = @safe_level
|
1511
|
+
perform_without_block
|
1512
|
+
}.value
|
1513
|
+
end
|
1514
|
+
else
|
1515
|
+
if @block
|
1516
|
+
@result = perform_with_block
|
1517
|
+
else
|
1518
|
+
@result = perform_without_block
|
1519
|
+
end
|
1520
|
+
end
|
1521
|
+
@succ = true
|
1522
|
+
if @msg_id == :to_ary && @result.class == Array
|
1523
|
+
@result = DRbArray.new(@result)
|
1524
|
+
end
|
1525
|
+
return @succ, @result
|
1526
|
+
rescue StandardError, ScriptError, Interrupt
|
1527
|
+
@result = $!
|
1528
|
+
return @succ, @result
|
1529
|
+
end
|
1530
|
+
|
1531
|
+
private
|
1532
|
+
def init_with_client
|
1533
|
+
obj, msg, argv, block = @client.recv_request
|
1534
|
+
@obj = obj
|
1535
|
+
@msg_id = msg.intern
|
1536
|
+
@argv = argv
|
1537
|
+
@block = block
|
1538
|
+
end
|
1539
|
+
|
1540
|
+
def check_insecure_method
|
1541
|
+
@drb_server.check_insecure_method(@obj, @msg_id)
|
1542
|
+
end
|
1543
|
+
|
1544
|
+
def setup_message
|
1545
|
+
init_with_client
|
1546
|
+
check_insecure_method
|
1547
|
+
end
|
1548
|
+
|
1549
|
+
def perform_without_block
|
1550
|
+
if Proc === @obj && @msg_id == :__drb_yield
|
1551
|
+
if @argv.size == 1
|
1552
|
+
ary = @argv
|
1553
|
+
else
|
1554
|
+
ary = [@argv]
|
1555
|
+
end
|
1556
|
+
ary.collect(&@obj)[0]
|
1557
|
+
else
|
1558
|
+
@obj.__send__(@msg_id, *@argv)
|
1559
|
+
end
|
1560
|
+
end
|
1561
|
+
|
1562
|
+
end
|
1563
|
+
|
1564
|
+
if RUBY_VERSION >= '1.8'
|
1565
|
+
require 'drb/invokemethod'
|
1566
|
+
class InvokeMethod
|
1567
|
+
include InvokeMethod18Mixin
|
1568
|
+
end
|
1569
|
+
else
|
1570
|
+
require 'drb/invokemethod16'
|
1571
|
+
class InvokeMethod
|
1572
|
+
include InvokeMethod16Mixin
|
1573
|
+
end
|
1574
|
+
end
|
1575
|
+
|
1576
|
+
# The main loop performed by a DRbServer's internal thread.
|
1577
|
+
#
|
1578
|
+
# Accepts a connection from a client, and starts up its own
|
1579
|
+
# thread to handle it. This thread loops, receiving requests
|
1580
|
+
# from the client, invoking them on a local object, and
|
1581
|
+
# returning responses, until the client closes the connection
|
1582
|
+
# or a local method call fails.
|
1583
|
+
def main_loop
|
1584
|
+
Thread.start(@protocol.accept) do |client|
|
1585
|
+
@grp.add Thread.current
|
1586
|
+
Thread.current['DRb'] = { 'client' => client ,
|
1587
|
+
'server' => self }
|
1588
|
+
loop do
|
1589
|
+
begin
|
1590
|
+
succ = false
|
1591
|
+
invoke_method = InvokeMethod.new(self, client)
|
1592
|
+
succ, result = invoke_method.perform
|
1593
|
+
if !succ && verbose
|
1594
|
+
p result
|
1595
|
+
result.backtrace.each do |x|
|
1596
|
+
puts x
|
1597
|
+
end
|
1598
|
+
end
|
1599
|
+
client.send_reply(succ, result) rescue nil
|
1600
|
+
ensure
|
1601
|
+
client.close unless succ
|
1602
|
+
if Thread.current['DRb']['stop_service']
|
1603
|
+
Thread.new { stop_service }
|
1604
|
+
end
|
1605
|
+
break unless succ
|
1606
|
+
end
|
1607
|
+
end
|
1608
|
+
end
|
1609
|
+
end
|
1610
|
+
end
|
1611
|
+
|
1612
|
+
@primary_server = nil
|
1613
|
+
|
1614
|
+
# Start a dRuby server locally.
|
1615
|
+
#
|
1616
|
+
# The new dRuby server will become the primary server, even
|
1617
|
+
# if another server is currently the primary server.
|
1618
|
+
#
|
1619
|
+
# +uri+ is the URI for the server to bind to. If nil,
|
1620
|
+
# the server will bind to random port on the default local host
|
1621
|
+
# name and use the default dRuby protocol.
|
1622
|
+
#
|
1623
|
+
# +front+ is the server's front object. This may be nil.
|
1624
|
+
#
|
1625
|
+
# +config+ is the configuration for the new server. This may
|
1626
|
+
# be nil.
|
1627
|
+
#
|
1628
|
+
# See DRbServer::new.
|
1629
|
+
def start_service(uri=nil, front=nil, config=nil)
|
1630
|
+
@primary_server = DRbServer.new(uri, front, config)
|
1631
|
+
end
|
1632
|
+
module_function :start_service
|
1633
|
+
|
1634
|
+
# The primary local dRuby server.
|
1635
|
+
#
|
1636
|
+
# This is the server created by the #start_service call.
|
1637
|
+
attr_accessor :primary_server
|
1638
|
+
module_function :primary_server=, :primary_server
|
1639
|
+
|
1640
|
+
# Get the 'current' server.
|
1641
|
+
#
|
1642
|
+
# In the context of execution taking place within the main
|
1643
|
+
# thread of a dRuby server (typically, as a result of a remote
|
1644
|
+
# call on the server or one of its objects), the current
|
1645
|
+
# server is that server. Otherwise, the current server is
|
1646
|
+
# the primary server.
|
1647
|
+
#
|
1648
|
+
# If the above rule fails to find a server, a DRbServerNotFound
|
1649
|
+
# error is raised.
|
1650
|
+
def current_server
|
1651
|
+
drb = Thread.current['DRb']
|
1652
|
+
server = (drb && drb['server']) ? drb['server'] : @primary_server
|
1653
|
+
raise DRbServerNotFound unless server
|
1654
|
+
return server
|
1655
|
+
end
|
1656
|
+
module_function :current_server
|
1657
|
+
|
1658
|
+
# Stop the local dRuby server.
|
1659
|
+
#
|
1660
|
+
# This operates on the primary server. If there is no primary
|
1661
|
+
# server currently running, it is a noop.
|
1662
|
+
def stop_service
|
1663
|
+
@primary_server.stop_service if @primary_server
|
1664
|
+
@primary_server = nil
|
1665
|
+
end
|
1666
|
+
module_function :stop_service
|
1667
|
+
|
1668
|
+
# Get the URI defining the local dRuby space.
|
1669
|
+
#
|
1670
|
+
# This is the URI of the current server. See #current_server.
|
1671
|
+
def uri
|
1672
|
+
drb = Thread.current['DRb']
|
1673
|
+
client = (drb && drb['client'])
|
1674
|
+
if client
|
1675
|
+
uri = client.uri
|
1676
|
+
return uri if uri
|
1677
|
+
end
|
1678
|
+
current_server.uri
|
1679
|
+
end
|
1680
|
+
module_function :uri
|
1681
|
+
|
1682
|
+
# Is +uri+ the URI for the current local server?
|
1683
|
+
def here?(uri)
|
1684
|
+
(current_server.uri rescue nil) == uri
|
1685
|
+
end
|
1686
|
+
module_function :here?
|
1687
|
+
|
1688
|
+
# Get the configuration of the current server.
|
1689
|
+
#
|
1690
|
+
# If there is no current server, this returns the default configuration.
|
1691
|
+
# See #current_server and DRbServer::make_config.
|
1692
|
+
def config
|
1693
|
+
current_server.config
|
1694
|
+
rescue
|
1695
|
+
DRbServer.make_config
|
1696
|
+
end
|
1697
|
+
module_function :config
|
1698
|
+
|
1699
|
+
# Get the front object of the current server.
|
1700
|
+
#
|
1701
|
+
# This raises a DRbServerNotFound error if there is no current server.
|
1702
|
+
# See #current_server.
|
1703
|
+
def front
|
1704
|
+
current_server.front
|
1705
|
+
end
|
1706
|
+
module_function :front
|
1707
|
+
|
1708
|
+
# Convert a reference into an object using the current server.
|
1709
|
+
#
|
1710
|
+
# This raises a DRbServerNotFound error if there is no current server.
|
1711
|
+
# See #current_server.
|
1712
|
+
def to_obj(ref)
|
1713
|
+
current_server.to_obj(ref)
|
1714
|
+
end
|
1715
|
+
|
1716
|
+
# Get a reference id for an object using the current server.
|
1717
|
+
#
|
1718
|
+
# This raises a DRbServerNotFound error if there is no current server.
|
1719
|
+
# See #current_server.
|
1720
|
+
def to_id(obj)
|
1721
|
+
current_server.to_id(obj)
|
1722
|
+
end
|
1723
|
+
module_function :to_id
|
1724
|
+
module_function :to_obj
|
1725
|
+
|
1726
|
+
# Get the thread of the primary server.
|
1727
|
+
#
|
1728
|
+
# This returns nil if there is no primary server. See #primary_server.
|
1729
|
+
def thread
|
1730
|
+
@primary_server ? @primary_server.thread : nil
|
1731
|
+
end
|
1732
|
+
module_function :thread
|
1733
|
+
|
1734
|
+
# Set the default id conv object.
|
1735
|
+
#
|
1736
|
+
# See DRbServer#default_id_conv.
|
1737
|
+
def install_id_conv(idconv)
|
1738
|
+
DRbServer.default_id_conv(idconv)
|
1739
|
+
end
|
1740
|
+
module_function :install_id_conv
|
1741
|
+
|
1742
|
+
# Set the default acl.
|
1743
|
+
#
|
1744
|
+
# See DRb::DRbServer.default_acl.
|
1745
|
+
def install_acl(acl)
|
1746
|
+
DRbServer.default_acl(acl)
|
1747
|
+
end
|
1748
|
+
module_function :install_acl
|
1749
|
+
|
1750
|
+
@mutex = Mutex.new
|
1751
|
+
def mutex
|
1752
|
+
@mutex
|
1753
|
+
end
|
1754
|
+
module_function :mutex
|
1755
|
+
|
1756
|
+
@server = {}
|
1757
|
+
def regist_server(server)
|
1758
|
+
@server[server.uri] = server
|
1759
|
+
mutex.synchronize do
|
1760
|
+
@primary_server = server unless @primary_server
|
1761
|
+
end
|
1762
|
+
end
|
1763
|
+
module_function :regist_server
|
1764
|
+
|
1765
|
+
def remove_server(server)
|
1766
|
+
@server.delete(server.uri)
|
1767
|
+
end
|
1768
|
+
module_function :remove_server
|
1769
|
+
|
1770
|
+
def fetch_server(uri)
|
1771
|
+
@server[uri]
|
1772
|
+
end
|
1773
|
+
module_function :fetch_server
|
1774
|
+
end
|
1775
|
+
|
1776
|
+
DRbObject = DRb::DRbObject
|
1777
|
+
DRbUndumped = DRb::DRbUndumped
|
1778
|
+
DRbIdConv = DRb::DRbIdConv
|