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,1246 @@
|
|
1
|
+
require "rexml/parent"
|
2
|
+
require "rexml/namespace"
|
3
|
+
require "rexml/attribute"
|
4
|
+
require "rexml/cdata"
|
5
|
+
require "rexml/xpath"
|
6
|
+
require "rexml/parseexception"
|
7
|
+
|
8
|
+
module REXML
|
9
|
+
# An implementation note about namespaces:
|
10
|
+
# As we parse, when we find namespaces we put them in a hash and assign
|
11
|
+
# them a unique ID. We then convert the namespace prefix for the node
|
12
|
+
# to the unique ID. This makes namespace lookup much faster for the
|
13
|
+
# cost of extra memory use. We save the namespace prefix for the
|
14
|
+
# context node and convert it back when we write it.
|
15
|
+
@@namespaces = {}
|
16
|
+
|
17
|
+
# Represents a tagged XML element. Elements are characterized by
|
18
|
+
# having children, attributes, and names, and can themselves be
|
19
|
+
# children.
|
20
|
+
class Element < Parent
|
21
|
+
include Namespace
|
22
|
+
|
23
|
+
UNDEFINED = "UNDEFINED"; # The default name
|
24
|
+
|
25
|
+
# Mechanisms for accessing attributes and child elements of this
|
26
|
+
# element.
|
27
|
+
attr_reader :attributes, :elements
|
28
|
+
# The context holds information about the processing environment, such as
|
29
|
+
# whitespace handling.
|
30
|
+
attr_accessor :context
|
31
|
+
|
32
|
+
# Constructor
|
33
|
+
# arg::
|
34
|
+
# if not supplied, will be set to the default value.
|
35
|
+
# If a String, the name of this object will be set to the argument.
|
36
|
+
# If an Element, the object will be shallowly cloned; name,
|
37
|
+
# attributes, and namespaces will be copied. Children will +not+ be
|
38
|
+
# copied.
|
39
|
+
# parent::
|
40
|
+
# if supplied, must be a Parent, and will be used as
|
41
|
+
# the parent of this object.
|
42
|
+
# context::
|
43
|
+
# If supplied, must be a hash containing context items. Context items
|
44
|
+
# include:
|
45
|
+
# * <tt>:respect_whitespace</tt> the value of this is :+all+ or an array of
|
46
|
+
# strings being the names of the elements to respect
|
47
|
+
# whitespace for. Defaults to :+all+.
|
48
|
+
# * <tt>:compress_whitespace</tt> the value can be :+all+ or an array of
|
49
|
+
# strings being the names of the elements to ignore whitespace on.
|
50
|
+
# Overrides :+respect_whitespace+.
|
51
|
+
# * <tt>:ignore_whitespace_nodes</tt> the value can be :+all+ or an array
|
52
|
+
# of strings being the names of the elements in which to ignore
|
53
|
+
# whitespace-only nodes. If this is set, Text nodes which contain only
|
54
|
+
# whitespace will not be added to the document tree.
|
55
|
+
# * <tt>:raw</tt> can be :+all+, or an array of strings being the names of
|
56
|
+
# the elements to process in raw mode. In raw mode, special
|
57
|
+
# characters in text is not converted to or from entities.
|
58
|
+
def initialize( arg = UNDEFINED, parent=nil, context=nil )
|
59
|
+
super(parent)
|
60
|
+
|
61
|
+
@elements = Elements.new(self)
|
62
|
+
@attributes = Attributes.new(self)
|
63
|
+
@context = context
|
64
|
+
|
65
|
+
if arg.kind_of? String
|
66
|
+
self.name = arg
|
67
|
+
elsif arg.kind_of? Element
|
68
|
+
self.name = arg.expanded_name
|
69
|
+
arg.attributes.each_attribute{ |attribute|
|
70
|
+
@attributes << Attribute.new( attribute )
|
71
|
+
}
|
72
|
+
@context = arg.context
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def inspect
|
77
|
+
rv = "<#@expanded_name"
|
78
|
+
|
79
|
+
@attributes.each_attribute do |attr|
|
80
|
+
rv << " "
|
81
|
+
attr.write( rv, 0 )
|
82
|
+
end
|
83
|
+
|
84
|
+
if children.size > 0
|
85
|
+
rv << "> ... </>"
|
86
|
+
else
|
87
|
+
rv << "/>"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
# Creates a shallow copy of self.
|
93
|
+
# d = Document.new "<a><b/><b/><c><d/></c></a>"
|
94
|
+
# new_a = d.root.clone
|
95
|
+
# puts new_a # => "<a/>"
|
96
|
+
def clone
|
97
|
+
self.class.new self
|
98
|
+
end
|
99
|
+
|
100
|
+
# Evaluates to the root node of the document that this element
|
101
|
+
# belongs to. If this element doesn't belong to a document, but does
|
102
|
+
# belong to another Element, the parent's root will be returned, until the
|
103
|
+
# earliest ancestor is found.
|
104
|
+
#
|
105
|
+
# Note that this is not the same as the document element.
|
106
|
+
# In the following example, <a> is the document element, and the root
|
107
|
+
# node is the parent node of the document element. You may ask yourself
|
108
|
+
# why the root node is useful: consider the doctype and XML declaration,
|
109
|
+
# and any processing instructions before the document element... they
|
110
|
+
# are children of the root node, or siblings of the document element.
|
111
|
+
# The only time this isn't true is when an Element is created that is
|
112
|
+
# not part of any Document. In this case, the ancestor that has no
|
113
|
+
# parent acts as the root node.
|
114
|
+
# d = Document.new '<a><b><c/></b></a>'
|
115
|
+
# a = d[1] ; c = a[1][1]
|
116
|
+
# d.root_node == d # TRUE
|
117
|
+
# a.root_node # namely, d
|
118
|
+
# c.root_node # again, d
|
119
|
+
def root_node
|
120
|
+
parent.nil? ? self : parent.root_node
|
121
|
+
end
|
122
|
+
|
123
|
+
def root
|
124
|
+
return elements[1] if self.kind_of? Document
|
125
|
+
return self if parent.kind_of? Document or parent.nil?
|
126
|
+
return parent.root
|
127
|
+
end
|
128
|
+
|
129
|
+
# Evaluates to the document to which this element belongs, or nil if this
|
130
|
+
# element doesn't belong to a document.
|
131
|
+
def document
|
132
|
+
rt = root
|
133
|
+
rt.parent if rt
|
134
|
+
end
|
135
|
+
|
136
|
+
# Evaluates to +true+ if whitespace is respected for this element. This
|
137
|
+
# is the case if:
|
138
|
+
# 1. Neither :+respect_whitespace+ nor :+compress_whitespace+ has any value
|
139
|
+
# 2. The context has :+respect_whitespace+ set to :+all+ or
|
140
|
+
# an array containing the name of this element, and
|
141
|
+
# :+compress_whitespace+ isn't set to :+all+ or an array containing the
|
142
|
+
# name of this element.
|
143
|
+
# The evaluation is tested against +expanded_name+, and so is namespace
|
144
|
+
# sensitive.
|
145
|
+
def whitespace
|
146
|
+
@whitespace = nil
|
147
|
+
if @context
|
148
|
+
if @context[:respect_whitespace]
|
149
|
+
@whitespace = (@context[:respect_whitespace] == :all or
|
150
|
+
@context[:respect_whitespace].include? expanded_name)
|
151
|
+
end
|
152
|
+
@whitespace = false if (@context[:compress_whitespace] and
|
153
|
+
(@context[:compress_whitespace] == :all or
|
154
|
+
@context[:compress_whitespace].include? expanded_name)
|
155
|
+
)
|
156
|
+
end
|
157
|
+
@whitespace = true unless @whitespace == false
|
158
|
+
@whitespace
|
159
|
+
end
|
160
|
+
|
161
|
+
def ignore_whitespace_nodes
|
162
|
+
@ignore_whitespace_nodes = false
|
163
|
+
if @context
|
164
|
+
if @context[:ignore_whitespace_nodes]
|
165
|
+
@ignore_whitespace_nodes =
|
166
|
+
(@context[:ignore_whitespace_nodes] == :all or
|
167
|
+
@context[:ignore_whitespace_nodes].include? expanded_name)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Evaluates to +true+ if raw mode is set for this element. This
|
173
|
+
# is the case if the context has :+raw+ set to :+all+ or
|
174
|
+
# an array containing the name of this element.
|
175
|
+
#
|
176
|
+
# The evaluation is tested against +expanded_name+, and so is namespace
|
177
|
+
# sensitive.
|
178
|
+
def raw
|
179
|
+
@raw = (@context and @context[:raw] and
|
180
|
+
(@context[:raw] == :all or
|
181
|
+
@context[:raw].include? expanded_name))
|
182
|
+
@raw
|
183
|
+
end
|
184
|
+
|
185
|
+
#once :whitespace, :raw, :ignore_whitespace_nodes
|
186
|
+
|
187
|
+
#################################################
|
188
|
+
# Namespaces #
|
189
|
+
#################################################
|
190
|
+
|
191
|
+
# Evaluates to an +Array+ containing the prefixes (names) of all defined
|
192
|
+
# namespaces at this context node.
|
193
|
+
# doc = Document.new("<a xmlns:x='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
|
194
|
+
# doc.elements['//b'].prefixes # -> ['x', 'y']
|
195
|
+
def prefixes
|
196
|
+
prefixes = []
|
197
|
+
prefixes = parent.prefixes if parent
|
198
|
+
prefixes |= attributes.prefixes
|
199
|
+
return prefixes
|
200
|
+
end
|
201
|
+
|
202
|
+
def namespaces
|
203
|
+
namespaces = {}
|
204
|
+
namespaces = parent.namespaces if parent
|
205
|
+
namespaces = namespaces.merge( attributes.namespaces )
|
206
|
+
return namespaces
|
207
|
+
end
|
208
|
+
|
209
|
+
# Evalutas to the URI for a prefix, or the empty string if no such
|
210
|
+
# namespace is declared for this element. Evaluates recursively for
|
211
|
+
# ancestors. Returns the default namespace, if there is one.
|
212
|
+
# prefix::
|
213
|
+
# the prefix to search for. If not supplied, returns the default
|
214
|
+
# namespace if one exists
|
215
|
+
# Returns::
|
216
|
+
# the namespace URI as a String, or nil if no such namespace
|
217
|
+
# exists. If the namespace is undefined, returns an empty string
|
218
|
+
# doc = Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
|
219
|
+
# b = doc.elements['//b']
|
220
|
+
# b.namespace # -> '1'
|
221
|
+
# b.namespace("y") # -> '2'
|
222
|
+
def namespace(prefix=nil)
|
223
|
+
if prefix.nil?
|
224
|
+
prefix = prefix()
|
225
|
+
end
|
226
|
+
if prefix == ''
|
227
|
+
prefix = "xmlns"
|
228
|
+
else
|
229
|
+
prefix = "xmlns:#{prefix}" unless prefix[0,5] == 'xmlns'
|
230
|
+
end
|
231
|
+
ns = attributes[ prefix ]
|
232
|
+
ns = parent.namespace(prefix) if ns.nil? and parent
|
233
|
+
ns = '' if ns.nil? and prefix == 'xmlns'
|
234
|
+
return ns
|
235
|
+
end
|
236
|
+
|
237
|
+
# Adds a namespace to this element.
|
238
|
+
# prefix::
|
239
|
+
# the prefix string, or the namespace URI if +uri+ is not
|
240
|
+
# supplied
|
241
|
+
# uri::
|
242
|
+
# the namespace URI. May be nil, in which +prefix+ is used as
|
243
|
+
# the URI
|
244
|
+
# Evaluates to: this Element
|
245
|
+
# a = Element.new("a")
|
246
|
+
# a.add_namespace("xmlns:foo", "bar" )
|
247
|
+
# a.add_namespace("foo", "bar") # shorthand for previous line
|
248
|
+
# a.add_namespace("twiddle")
|
249
|
+
# puts a #-> <a xmlns:foo='bar' xmlns='twiddle'/>
|
250
|
+
def add_namespace( prefix, uri=nil )
|
251
|
+
unless uri
|
252
|
+
@attributes["xmlns"] = prefix
|
253
|
+
else
|
254
|
+
prefix = "xmlns:#{prefix}" unless prefix =~ /^xmlns:/
|
255
|
+
@attributes[ prefix ] = uri
|
256
|
+
end
|
257
|
+
self
|
258
|
+
end
|
259
|
+
|
260
|
+
# Removes a namespace from this node. This only works if the namespace is
|
261
|
+
# actually declared in this node. If no argument is passed, deletes the
|
262
|
+
# default namespace.
|
263
|
+
#
|
264
|
+
# Evaluates to: this element
|
265
|
+
# doc = Document.new "<a xmlns:foo='bar' xmlns='twiddle'/>"
|
266
|
+
# doc.root.delete_namespace
|
267
|
+
# puts doc # -> <a xmlns:foo='bar'/>
|
268
|
+
# doc.root.delete_namespace 'foo'
|
269
|
+
# puts doc # -> <a/>
|
270
|
+
def delete_namespace namespace="xmlns"
|
271
|
+
namespace = "xmlns:#{namespace}" unless namespace == 'xmlns'
|
272
|
+
attribute = attributes.get_attribute(namespace)
|
273
|
+
attribute.remove unless attribute.nil?
|
274
|
+
self
|
275
|
+
end
|
276
|
+
|
277
|
+
#################################################
|
278
|
+
# Elements #
|
279
|
+
#################################################
|
280
|
+
|
281
|
+
# Adds a child to this element, optionally setting attributes in
|
282
|
+
# the element.
|
283
|
+
# element::
|
284
|
+
# optional. If Element, the element is added.
|
285
|
+
# Otherwise, a new Element is constructed with the argument (see
|
286
|
+
# Element.initialize).
|
287
|
+
# attrs::
|
288
|
+
# If supplied, must be a Hash containing String name,value
|
289
|
+
# pairs, which will be used to set the attributes of the new Element.
|
290
|
+
# Returns:: the Element that was added
|
291
|
+
# el = doc.add_element 'my-tag'
|
292
|
+
# el = doc.add_element 'my-tag', {'attr1'=>'val1', 'attr2'=>'val2'}
|
293
|
+
# el = Element.new 'my-tag'
|
294
|
+
# doc.add_element el
|
295
|
+
def add_element element, attrs=nil
|
296
|
+
raise "First argument must be either an element name, or an Element object" if element.nil?
|
297
|
+
el = @elements.add(element)
|
298
|
+
attrs.each do |key, value|
|
299
|
+
el.attributes[key]=value
|
300
|
+
end if attrs.kind_of? Hash
|
301
|
+
el
|
302
|
+
end
|
303
|
+
|
304
|
+
# Deletes a child element.
|
305
|
+
# element::
|
306
|
+
# Must be an +Element+, +String+, or +Integer+. If Element,
|
307
|
+
# the element is removed. If String, the element is found (via XPath)
|
308
|
+
# and removed. <em>This means that any parent can remove any
|
309
|
+
# descendant.<em> If Integer, the Element indexed by that number will be
|
310
|
+
# removed.
|
311
|
+
# Returns:: the element that was removed.
|
312
|
+
# doc.delete_element "/a/b/c[@id='4']"
|
313
|
+
# doc.delete_element doc.elements["//k"]
|
314
|
+
# doc.delete_element 1
|
315
|
+
def delete_element element
|
316
|
+
@elements.delete element
|
317
|
+
end
|
318
|
+
|
319
|
+
# Evaluates to +true+ if this element has at least one child Element
|
320
|
+
# doc = Document.new "<a><b/><c>Text</c></a>"
|
321
|
+
# doc.root.has_elements # -> true
|
322
|
+
# doc.elements["/a/b"].has_elements # -> false
|
323
|
+
# doc.elements["/a/c"].has_elements # -> false
|
324
|
+
def has_elements?
|
325
|
+
!@elements.empty?
|
326
|
+
end
|
327
|
+
|
328
|
+
# Iterates through the child elements, yielding for each Element that
|
329
|
+
# has a particular attribute set.
|
330
|
+
# key::
|
331
|
+
# the name of the attribute to search for
|
332
|
+
# value::
|
333
|
+
# the value of the attribute
|
334
|
+
# max::
|
335
|
+
# (optional) causes this method to return after yielding
|
336
|
+
# for this number of matching children
|
337
|
+
# name::
|
338
|
+
# (optional) if supplied, this is an XPath that filters
|
339
|
+
# the children to check.
|
340
|
+
#
|
341
|
+
# doc = Document.new "<a><b @id='1'/><c @id='2'/><d @id='1'/><e/></a>"
|
342
|
+
# # Yields b, c, d
|
343
|
+
# doc.root.each_element_with_attribute( 'id' ) {|e| p e}
|
344
|
+
# # Yields b, d
|
345
|
+
# doc.root.each_element_with_attribute( 'id', '1' ) {|e| p e}
|
346
|
+
# # Yields b
|
347
|
+
# doc.root.each_element_with_attribute( 'id', '1', 1 ) {|e| p e}
|
348
|
+
# # Yields d
|
349
|
+
# doc.root.each_element_with_attribute( 'id', '1', 0, 'd' ) {|e| p e}
|
350
|
+
def each_element_with_attribute( key, value=nil, max=0, name=nil, &block ) # :yields: Element
|
351
|
+
each_with_something( proc {|child|
|
352
|
+
if value.nil?
|
353
|
+
child.attributes[key] != nil
|
354
|
+
else
|
355
|
+
child.attributes[key]==value
|
356
|
+
end
|
357
|
+
}, max, name, &block )
|
358
|
+
end
|
359
|
+
|
360
|
+
# Iterates through the children, yielding for each Element that
|
361
|
+
# has a particular text set.
|
362
|
+
# text::
|
363
|
+
# the text to search for. If nil, or not supplied, will iterate
|
364
|
+
# over all +Element+ children that contain at least one +Text+ node.
|
365
|
+
# max::
|
366
|
+
# (optional) causes this method to return after yielding
|
367
|
+
# for this number of matching children
|
368
|
+
# name::
|
369
|
+
# (optional) if supplied, this is an XPath that filters
|
370
|
+
# the children to check.
|
371
|
+
#
|
372
|
+
# doc = Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
|
373
|
+
# # Yields b, c, d
|
374
|
+
# doc.each_element_with_text {|e|p e}
|
375
|
+
# # Yields b, c
|
376
|
+
# doc.each_element_with_text('b'){|e|p e}
|
377
|
+
# # Yields b
|
378
|
+
# doc.each_element_with_text('b', 1){|e|p e}
|
379
|
+
# # Yields d
|
380
|
+
# doc.each_element_with_text(nil, 0, 'd'){|e|p e}
|
381
|
+
def each_element_with_text( text=nil, max=0, name=nil, &block ) # :yields: Element
|
382
|
+
each_with_something( proc {|child|
|
383
|
+
if text.nil?
|
384
|
+
child.has_text?
|
385
|
+
else
|
386
|
+
child.text == text
|
387
|
+
end
|
388
|
+
}, max, name, &block )
|
389
|
+
end
|
390
|
+
|
391
|
+
# Synonym for Element.elements.each
|
392
|
+
def each_element( xpath=nil, &block ) # :yields: Element
|
393
|
+
@elements.each( xpath, &block )
|
394
|
+
end
|
395
|
+
|
396
|
+
# Synonym for Element.to_a
|
397
|
+
# This is a little slower than calling elements.each directly.
|
398
|
+
# xpath:: any XPath by which to search for elements in the tree
|
399
|
+
# Returns:: an array of Elements that match the supplied path
|
400
|
+
def get_elements( xpath )
|
401
|
+
@elements.to_a( xpath )
|
402
|
+
end
|
403
|
+
|
404
|
+
# Returns the next sibling that is an element, or nil if there is
|
405
|
+
# no Element sibling after this one
|
406
|
+
# doc = Document.new '<a><b/>text<c/></a>'
|
407
|
+
# doc.root.elements['b'].next_element #-> <c/>
|
408
|
+
# doc.root.elements['c'].next_element #-> nil
|
409
|
+
def next_element
|
410
|
+
element = next_sibling
|
411
|
+
element = element.next_sibling until element.nil? or element.kind_of? Element
|
412
|
+
return element
|
413
|
+
end
|
414
|
+
|
415
|
+
# Returns the previous sibling that is an element, or nil if there is
|
416
|
+
# no Element sibling prior to this one
|
417
|
+
# doc = Document.new '<a><b/>text<c/></a>'
|
418
|
+
# doc.root.elements['c'].previous_element #-> <b/>
|
419
|
+
# doc.root.elements['b'].previous_element #-> nil
|
420
|
+
def previous_element
|
421
|
+
element = previous_sibling
|
422
|
+
element = element.previous_sibling until element.nil? or element.kind_of? Element
|
423
|
+
return element
|
424
|
+
end
|
425
|
+
|
426
|
+
|
427
|
+
#################################################
|
428
|
+
# Text #
|
429
|
+
#################################################
|
430
|
+
|
431
|
+
# Evaluates to +true+ if this element has at least one Text child
|
432
|
+
def has_text?
|
433
|
+
not text().nil?
|
434
|
+
end
|
435
|
+
|
436
|
+
# A convenience method which returns the String value of the _first_
|
437
|
+
# child text element, if one exists, and +nil+ otherwise.
|
438
|
+
#
|
439
|
+
# <em>Note that an element may have multiple Text elements, perhaps
|
440
|
+
# separated by other children</em>. Be aware that this method only returns
|
441
|
+
# the first Text node.
|
442
|
+
#
|
443
|
+
# This method returns the +value+ of the first text child node, which
|
444
|
+
# ignores the +raw+ setting, so always returns normalized text. See
|
445
|
+
# the Text::value documentation.
|
446
|
+
#
|
447
|
+
# doc = Document.new "<p>some text <b>this is bold!</b> more text</p>"
|
448
|
+
# # The element 'p' has two text elements, "some text " and " more text".
|
449
|
+
# doc.root.text #-> "some text "
|
450
|
+
def text( path = nil )
|
451
|
+
rv = get_text(path)
|
452
|
+
return rv.value unless rv.nil?
|
453
|
+
nil
|
454
|
+
end
|
455
|
+
|
456
|
+
# Returns the first child Text node, if any, or +nil+ otherwise.
|
457
|
+
# This method returns the actual +Text+ node, rather than the String content.
|
458
|
+
# doc = Document.new "<p>some text <b>this is bold!</b> more text</p>"
|
459
|
+
# # The element 'p' has two text elements, "some text " and " more text".
|
460
|
+
# doc.root.get_text.value #-> "some text "
|
461
|
+
def get_text path = nil
|
462
|
+
rv = nil
|
463
|
+
if path
|
464
|
+
element = @elements[ path ]
|
465
|
+
rv = element.get_text unless element.nil?
|
466
|
+
else
|
467
|
+
rv = @children.find { |node| node.kind_of? Text }
|
468
|
+
end
|
469
|
+
return rv
|
470
|
+
end
|
471
|
+
|
472
|
+
# Sets the first Text child of this object. See text() for a
|
473
|
+
# discussion about Text children.
|
474
|
+
#
|
475
|
+
# If a Text child already exists, the child is replaced by this
|
476
|
+
# content. This means that Text content can be deleted by calling
|
477
|
+
# this method with a nil argument. In this case, the next Text
|
478
|
+
# child becomes the first Text child. In no case is the order of
|
479
|
+
# any siblings disturbed.
|
480
|
+
# text::
|
481
|
+
# If a String, a new Text child is created and added to
|
482
|
+
# this Element as the first Text child. If Text, the text is set
|
483
|
+
# as the first Child element. If nil, then any existing first Text
|
484
|
+
# child is removed.
|
485
|
+
# Returns:: this Element.
|
486
|
+
# doc = Document.new '<a><b/></a>'
|
487
|
+
# doc.root.text = 'Sean' #-> '<a><b/>Sean</a>'
|
488
|
+
# doc.root.text = 'Elliott' #-> '<a><b/>Elliott</a>'
|
489
|
+
# doc.root.add_element 'c' #-> '<a><b/>Elliott<c/></a>'
|
490
|
+
# doc.root.text = 'Russell' #-> '<a><b/>Russell<c/></a>'
|
491
|
+
# doc.root.text = nil #-> '<a><b/><c/></a>'
|
492
|
+
def text=( text )
|
493
|
+
if text.kind_of? String
|
494
|
+
text = Text.new( text, whitespace(), nil, raw() )
|
495
|
+
elsif text and !text.kind_of? Text
|
496
|
+
text = Text.new( text.to_s, whitespace(), nil, raw() )
|
497
|
+
end
|
498
|
+
old_text = get_text
|
499
|
+
if text.nil?
|
500
|
+
old_text.remove unless old_text.nil?
|
501
|
+
else
|
502
|
+
if old_text.nil?
|
503
|
+
self << text
|
504
|
+
else
|
505
|
+
old_text.replace_with( text )
|
506
|
+
end
|
507
|
+
end
|
508
|
+
return self
|
509
|
+
end
|
510
|
+
|
511
|
+
# A helper method to add a Text child. Actual Text instances can
|
512
|
+
# be added with regular Parent methods, such as add() and <<()
|
513
|
+
# text::
|
514
|
+
# if a String, a new Text instance is created and added
|
515
|
+
# to the parent. If Text, the object is added directly.
|
516
|
+
# Returns:: this Element
|
517
|
+
# e = Element.new('a') #-> <e/>
|
518
|
+
# e.add_text 'foo' #-> <e>foo</e>
|
519
|
+
# e.add_text Text.new(' bar') #-> <e>foo bar</e>
|
520
|
+
# Note that at the end of this example, the branch has <b>3</b> nodes; the 'e'
|
521
|
+
# element and <b>2</b> Text node children.
|
522
|
+
def add_text( text )
|
523
|
+
if text.kind_of? String
|
524
|
+
if @children[-1].kind_of? Text
|
525
|
+
@children[-1] << text
|
526
|
+
return
|
527
|
+
end
|
528
|
+
text = Text.new( text, whitespace(), nil, raw() )
|
529
|
+
end
|
530
|
+
self << text unless text.nil?
|
531
|
+
return self
|
532
|
+
end
|
533
|
+
|
534
|
+
def node_type
|
535
|
+
:element
|
536
|
+
end
|
537
|
+
|
538
|
+
def xpath
|
539
|
+
path_elements = []
|
540
|
+
cur = self
|
541
|
+
path_elements << __to_xpath_helper( self )
|
542
|
+
while cur.parent
|
543
|
+
cur = cur.parent
|
544
|
+
path_elements << __to_xpath_helper( cur )
|
545
|
+
end
|
546
|
+
return path_elements.reverse.join( "/" )
|
547
|
+
end
|
548
|
+
|
549
|
+
#################################################
|
550
|
+
# Attributes #
|
551
|
+
#################################################
|
552
|
+
|
553
|
+
def attribute( name, namespace=nil )
|
554
|
+
prefix = nil
|
555
|
+
if namespaces.respond_to? :key
|
556
|
+
prefix = namespaces.key(namespace) if namespace
|
557
|
+
else
|
558
|
+
prefix = namespaces.index(namespace) if namespace
|
559
|
+
end
|
560
|
+
prefix = nil if prefix == 'xmlns'
|
561
|
+
|
562
|
+
ret_val =
|
563
|
+
attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
|
564
|
+
|
565
|
+
return ret_val unless ret_val.nil?
|
566
|
+
return nil if prefix.nil?
|
567
|
+
|
568
|
+
# now check that prefix'es namespace is not the same as the
|
569
|
+
# default namespace
|
570
|
+
return nil unless ( namespaces[ prefix ] == namespaces[ 'xmlns' ] )
|
571
|
+
|
572
|
+
attributes.get_attribute( name )
|
573
|
+
|
574
|
+
end
|
575
|
+
|
576
|
+
# Evaluates to +true+ if this element has any attributes set, false
|
577
|
+
# otherwise.
|
578
|
+
def has_attributes?
|
579
|
+
return !@attributes.empty?
|
580
|
+
end
|
581
|
+
|
582
|
+
# Adds an attribute to this element, overwriting any existing attribute
|
583
|
+
# by the same name.
|
584
|
+
# key::
|
585
|
+
# can be either an Attribute or a String. If an Attribute,
|
586
|
+
# the attribute is added to the list of Element attributes. If String,
|
587
|
+
# the argument is used as the name of the new attribute, and the value
|
588
|
+
# parameter must be supplied.
|
589
|
+
# value::
|
590
|
+
# Required if +key+ is a String, and ignored if the first argument is
|
591
|
+
# an Attribute. This is a String, and is used as the value
|
592
|
+
# of the new Attribute. This should be the unnormalized value of the
|
593
|
+
# attribute (without entities).
|
594
|
+
# Returns:: the Attribute added
|
595
|
+
# e = Element.new 'e'
|
596
|
+
# e.add_attribute( 'a', 'b' ) #-> <e a='b'/>
|
597
|
+
# e.add_attribute( 'x:a', 'c' ) #-> <e a='b' x:a='c'/>
|
598
|
+
# e.add_attribute Attribute.new('b', 'd') #-> <e a='b' x:a='c' b='d'/>
|
599
|
+
def add_attribute( key, value=nil )
|
600
|
+
if key.kind_of? Attribute
|
601
|
+
@attributes << key
|
602
|
+
else
|
603
|
+
@attributes[key] = value
|
604
|
+
end
|
605
|
+
end
|
606
|
+
|
607
|
+
# Add multiple attributes to this element.
|
608
|
+
# hash:: is either a hash, or array of arrays
|
609
|
+
# el.add_attributes( {"name1"=>"value1", "name2"=>"value2"} )
|
610
|
+
# el.add_attributes( [ ["name1","value1"], ["name2"=>"value2"] ] )
|
611
|
+
def add_attributes hash
|
612
|
+
if hash.kind_of? Hash
|
613
|
+
hash.each_pair {|key, value| @attributes[key] = value }
|
614
|
+
elsif hash.kind_of? Array
|
615
|
+
hash.each { |value| @attributes[ value[0] ] = value[1] }
|
616
|
+
end
|
617
|
+
end
|
618
|
+
|
619
|
+
# Removes an attribute
|
620
|
+
# key::
|
621
|
+
# either an Attribute or a String. In either case, the
|
622
|
+
# attribute is found by matching the attribute name to the argument,
|
623
|
+
# and then removed. If no attribute is found, no action is taken.
|
624
|
+
# Returns::
|
625
|
+
# the attribute removed, or nil if this Element did not contain
|
626
|
+
# a matching attribute
|
627
|
+
# e = Element.new('E')
|
628
|
+
# e.add_attribute( 'name', 'Sean' ) #-> <E name='Sean'/>
|
629
|
+
# r = e.add_attribute( 'sur:name', 'Russell' ) #-> <E name='Sean' sur:name='Russell'/>
|
630
|
+
# e.delete_attribute( 'name' ) #-> <E sur:name='Russell'/>
|
631
|
+
# e.delete_attribute( r ) #-> <E/>
|
632
|
+
def delete_attribute(key)
|
633
|
+
attr = @attributes.get_attribute(key)
|
634
|
+
attr.remove unless attr.nil?
|
635
|
+
end
|
636
|
+
|
637
|
+
#################################################
|
638
|
+
# Other Utilities #
|
639
|
+
#################################################
|
640
|
+
|
641
|
+
# Get an array of all CData children.
|
642
|
+
# IMMUTABLE
|
643
|
+
def cdatas
|
644
|
+
find_all { |child| child.kind_of? CData }.freeze
|
645
|
+
end
|
646
|
+
|
647
|
+
# Get an array of all Comment children.
|
648
|
+
# IMMUTABLE
|
649
|
+
def comments
|
650
|
+
find_all { |child| child.kind_of? Comment }.freeze
|
651
|
+
end
|
652
|
+
|
653
|
+
# Get an array of all Instruction children.
|
654
|
+
# IMMUTABLE
|
655
|
+
def instructions
|
656
|
+
find_all { |child| child.kind_of? Instruction }.freeze
|
657
|
+
end
|
658
|
+
|
659
|
+
# Get an array of all Text children.
|
660
|
+
# IMMUTABLE
|
661
|
+
def texts
|
662
|
+
find_all { |child| child.kind_of? Text }.freeze
|
663
|
+
end
|
664
|
+
|
665
|
+
# == DEPRECATED
|
666
|
+
# See REXML::Formatters
|
667
|
+
#
|
668
|
+
# Writes out this element, and recursively, all children.
|
669
|
+
# output::
|
670
|
+
# output an object which supports '<< string'; this is where the
|
671
|
+
# document will be written.
|
672
|
+
# indent::
|
673
|
+
# An integer. If -1, no indenting will be used; otherwise, the
|
674
|
+
# indentation will be this number of spaces, and children will be
|
675
|
+
# indented an additional amount. Defaults to -1
|
676
|
+
# transitive::
|
677
|
+
# If transitive is true and indent is >= 0, then the output will be
|
678
|
+
# pretty-printed in such a way that the added whitespace does not affect
|
679
|
+
# the parse tree of the document
|
680
|
+
# ie_hack::
|
681
|
+
# Internet Explorer is the worst piece of crap to have ever been
|
682
|
+
# written, with the possible exception of Windows itself. Since IE is
|
683
|
+
# unable to parse proper XML, we have to provide a hack to generate XML
|
684
|
+
# that IE's limited abilities can handle. This hack inserts a space
|
685
|
+
# before the /> on empty tags. Defaults to false
|
686
|
+
#
|
687
|
+
# out = ''
|
688
|
+
# doc.write( out ) #-> doc is written to the string 'out'
|
689
|
+
# doc.write( $stdout ) #-> doc written to the console
|
690
|
+
def write(output=$stdout, indent=-1, transitive=false, ie_hack=false)
|
691
|
+
Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters")
|
692
|
+
formatter = if indent > -1
|
693
|
+
if transitive
|
694
|
+
require "rexml/formatters/transitive"
|
695
|
+
REXML::Formatters::Transitive.new( indent, ie_hack )
|
696
|
+
else
|
697
|
+
REXML::Formatters::Pretty.new( indent, ie_hack )
|
698
|
+
end
|
699
|
+
else
|
700
|
+
REXML::Formatters::Default.new( ie_hack )
|
701
|
+
end
|
702
|
+
formatter.write( self, output )
|
703
|
+
end
|
704
|
+
|
705
|
+
|
706
|
+
private
|
707
|
+
def __to_xpath_helper node
|
708
|
+
rv = node.expanded_name.clone
|
709
|
+
if node.parent
|
710
|
+
results = node.parent.find_all {|n|
|
711
|
+
n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name
|
712
|
+
}
|
713
|
+
if results.length > 1
|
714
|
+
idx = results.index( node )
|
715
|
+
rv << "[#{idx+1}]"
|
716
|
+
end
|
717
|
+
end
|
718
|
+
rv
|
719
|
+
end
|
720
|
+
|
721
|
+
# A private helper method
|
722
|
+
def each_with_something( test, max=0, name=nil )
|
723
|
+
num = 0
|
724
|
+
@elements.each( name ){ |child|
|
725
|
+
yield child if test.call(child) and num += 1
|
726
|
+
return if max>0 and num == max
|
727
|
+
}
|
728
|
+
end
|
729
|
+
end
|
730
|
+
|
731
|
+
########################################################################
|
732
|
+
# ELEMENTS #
|
733
|
+
########################################################################
|
734
|
+
|
735
|
+
# A class which provides filtering of children for Elements, and
|
736
|
+
# XPath search support. You are expected to only encounter this class as
|
737
|
+
# the <tt>element.elements</tt> object. Therefore, you are
|
738
|
+
# _not_ expected to instantiate this yourself.
|
739
|
+
class Elements
|
740
|
+
include Enumerable
|
741
|
+
# Constructor
|
742
|
+
# parent:: the parent Element
|
743
|
+
def initialize parent
|
744
|
+
@element = parent
|
745
|
+
end
|
746
|
+
|
747
|
+
# Fetches a child element. Filters only Element children, regardless of
|
748
|
+
# the XPath match.
|
749
|
+
# index::
|
750
|
+
# the search parameter. This is either an Integer, which
|
751
|
+
# will be used to find the index'th child Element, or an XPath,
|
752
|
+
# which will be used to search for the Element. <em>Because
|
753
|
+
# of the nature of XPath searches, any element in the connected XML
|
754
|
+
# document can be fetched through any other element.</em> <b>The
|
755
|
+
# Integer index is 1-based, not 0-based.</b> This means that the first
|
756
|
+
# child element is at index 1, not 0, and the +n+th element is at index
|
757
|
+
# +n+, not <tt>n-1</tt>. This is because XPath indexes element children
|
758
|
+
# starting from 1, not 0, and the indexes should be the same.
|
759
|
+
# name::
|
760
|
+
# optional, and only used in the first argument is an
|
761
|
+
# Integer. In that case, the index'th child Element that has the
|
762
|
+
# supplied name will be returned. Note again that the indexes start at 1.
|
763
|
+
# Returns:: the first matching Element, or nil if no child matched
|
764
|
+
# doc = Document.new '<a><b/><c id="1"/><c id="2"/><d/></a>'
|
765
|
+
# doc.root.elements[1] #-> <b/>
|
766
|
+
# doc.root.elements['c'] #-> <c id="1"/>
|
767
|
+
# doc.root.elements[2,'c'] #-> <c id="2"/>
|
768
|
+
def []( index, name=nil)
|
769
|
+
if index.kind_of? Integer
|
770
|
+
raise "index (#{index}) must be >= 1" if index < 1
|
771
|
+
name = literalize(name) if name
|
772
|
+
num = 0
|
773
|
+
@element.find { |child|
|
774
|
+
child.kind_of? Element and
|
775
|
+
(name.nil? ? true : child.has_name?( name )) and
|
776
|
+
(num += 1) == index
|
777
|
+
}
|
778
|
+
else
|
779
|
+
return XPath::first( @element, index )
|
780
|
+
#{ |element|
|
781
|
+
# return element if element.kind_of? Element
|
782
|
+
#}
|
783
|
+
#return nil
|
784
|
+
end
|
785
|
+
end
|
786
|
+
|
787
|
+
# Sets an element, replacing any previous matching element. If no
|
788
|
+
# existing element is found ,the element is added.
|
789
|
+
# index:: Used to find a matching element to replace. See []().
|
790
|
+
# element::
|
791
|
+
# The element to replace the existing element with
|
792
|
+
# the previous element
|
793
|
+
# Returns:: nil if no previous element was found.
|
794
|
+
#
|
795
|
+
# doc = Document.new '<a/>'
|
796
|
+
# doc.root.elements[10] = Element.new('b') #-> <a><b/></a>
|
797
|
+
# doc.root.elements[1] #-> <b/>
|
798
|
+
# doc.root.elements[1] = Element.new('c') #-> <a><c/></a>
|
799
|
+
# doc.root.elements['c'] = Element.new('d') #-> <a><d/></a>
|
800
|
+
def []=( index, element )
|
801
|
+
previous = self[index]
|
802
|
+
if previous.nil?
|
803
|
+
@element.add element
|
804
|
+
else
|
805
|
+
previous.replace_with element
|
806
|
+
end
|
807
|
+
return previous
|
808
|
+
end
|
809
|
+
|
810
|
+
# Returns +true+ if there are no +Element+ children, +false+ otherwise
|
811
|
+
def empty?
|
812
|
+
@element.find{ |child| child.kind_of? Element}.nil?
|
813
|
+
end
|
814
|
+
|
815
|
+
# Returns the index of the supplied child (starting at 1), or -1 if
|
816
|
+
# the element is not a child
|
817
|
+
# element:: an +Element+ child
|
818
|
+
def index element
|
819
|
+
rv = 0
|
820
|
+
found = @element.find do |child|
|
821
|
+
child.kind_of? Element and
|
822
|
+
(rv += 1) and
|
823
|
+
child == element
|
824
|
+
end
|
825
|
+
return rv if found == element
|
826
|
+
return -1
|
827
|
+
end
|
828
|
+
|
829
|
+
# Deletes a child Element
|
830
|
+
# element::
|
831
|
+
# Either an Element, which is removed directly; an
|
832
|
+
# xpath, where the first matching child is removed; or an Integer,
|
833
|
+
# where the n'th Element is removed.
|
834
|
+
# Returns:: the removed child
|
835
|
+
# doc = Document.new '<a><b/><c/><c id="1"/></a>'
|
836
|
+
# b = doc.root.elements[1]
|
837
|
+
# doc.root.elements.delete b #-> <a><c/><c id="1"/></a>
|
838
|
+
# doc.elements.delete("a/c[@id='1']") #-> <a><c/></a>
|
839
|
+
# doc.root.elements.delete 1 #-> <a/>
|
840
|
+
def delete element
|
841
|
+
if element.kind_of? Element
|
842
|
+
@element.delete element
|
843
|
+
else
|
844
|
+
el = self[element]
|
845
|
+
el.remove if el
|
846
|
+
end
|
847
|
+
end
|
848
|
+
|
849
|
+
# Removes multiple elements. Filters for Element children, regardless of
|
850
|
+
# XPath matching.
|
851
|
+
# xpath:: all elements matching this String path are removed.
|
852
|
+
# Returns:: an Array of Elements that have been removed
|
853
|
+
# doc = Document.new '<a><c/><c/><c/><c/></a>'
|
854
|
+
# deleted = doc.elements.delete_all 'a/c' #-> [<c/>, <c/>, <c/>, <c/>]
|
855
|
+
def delete_all( xpath )
|
856
|
+
rv = []
|
857
|
+
XPath::each( @element, xpath) {|element|
|
858
|
+
rv << element if element.kind_of? Element
|
859
|
+
}
|
860
|
+
rv.each do |element|
|
861
|
+
@element.delete element
|
862
|
+
element.remove
|
863
|
+
end
|
864
|
+
return rv
|
865
|
+
end
|
866
|
+
|
867
|
+
# Adds an element
|
868
|
+
# element::
|
869
|
+
# if supplied, is either an Element, String, or
|
870
|
+
# Source (see Element.initialize). If not supplied or nil, a
|
871
|
+
# new, default Element will be constructed
|
872
|
+
# Returns:: the added Element
|
873
|
+
# a = Element.new('a')
|
874
|
+
# a.elements.add(Element.new('b')) #-> <a><b/></a>
|
875
|
+
# a.elements.add('c') #-> <a><b/><c/></a>
|
876
|
+
def add element=nil
|
877
|
+
rv = nil
|
878
|
+
if element.nil?
|
879
|
+
Element.new("", self, @element.context)
|
880
|
+
elsif not element.kind_of?(Element)
|
881
|
+
Element.new(element, self, @element.context)
|
882
|
+
else
|
883
|
+
@element << element
|
884
|
+
element.context = @element.context
|
885
|
+
element
|
886
|
+
end
|
887
|
+
end
|
888
|
+
|
889
|
+
alias :<< :add
|
890
|
+
|
891
|
+
# Iterates through all of the child Elements, optionally filtering
|
892
|
+
# them by a given XPath
|
893
|
+
# xpath::
|
894
|
+
# optional. If supplied, this is a String XPath, and is used to
|
895
|
+
# filter the children, so that only matching children are yielded. Note
|
896
|
+
# that XPaths are automatically filtered for Elements, so that
|
897
|
+
# non-Element children will not be yielded
|
898
|
+
# doc = Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>'
|
899
|
+
# doc.root.each {|e|p e} #-> Yields b, c, d, b, c, d elements
|
900
|
+
# doc.root.each('b') {|e|p e} #-> Yields b, b elements
|
901
|
+
# doc.root.each('child::node()') {|e|p e}
|
902
|
+
# #-> Yields <b/>, <c/>, <d/>, <b/>, <c/>, <d/>
|
903
|
+
# XPath.each(doc.root, 'child::node()', &block)
|
904
|
+
# #-> Yields <b/>, <c/>, <d/>, sean, <b/>, <c/>, <d/>
|
905
|
+
def each( xpath=nil, &block)
|
906
|
+
XPath::each( @element, xpath ) {|e| yield e if e.kind_of? Element }
|
907
|
+
end
|
908
|
+
|
909
|
+
def collect( xpath=nil, &block )
|
910
|
+
collection = []
|
911
|
+
XPath::each( @element, xpath ) {|e|
|
912
|
+
collection << yield(e) if e.kind_of?(Element)
|
913
|
+
}
|
914
|
+
collection
|
915
|
+
end
|
916
|
+
|
917
|
+
def inject( xpath=nil, initial=nil, &block )
|
918
|
+
first = true
|
919
|
+
XPath::each( @element, xpath ) {|e|
|
920
|
+
if (e.kind_of? Element)
|
921
|
+
if (first and initial == nil)
|
922
|
+
initial = e
|
923
|
+
first = false
|
924
|
+
else
|
925
|
+
initial = yield( initial, e ) if e.kind_of? Element
|
926
|
+
end
|
927
|
+
end
|
928
|
+
}
|
929
|
+
initial
|
930
|
+
end
|
931
|
+
|
932
|
+
# Returns the number of +Element+ children of the parent object.
|
933
|
+
# doc = Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
|
934
|
+
# doc.root.size #-> 6, 3 element and 3 text nodes
|
935
|
+
# doc.root.elements.size #-> 3
|
936
|
+
def size
|
937
|
+
count = 0
|
938
|
+
@element.each {|child| count+=1 if child.kind_of? Element }
|
939
|
+
count
|
940
|
+
end
|
941
|
+
|
942
|
+
# Returns an Array of Element children. An XPath may be supplied to
|
943
|
+
# filter the children. Only Element children are returned, even if the
|
944
|
+
# supplied XPath matches non-Element children.
|
945
|
+
# doc = Document.new '<a>sean<b/>elliott<c/></a>'
|
946
|
+
# doc.root.elements.to_a #-> [ <b/>, <c/> ]
|
947
|
+
# doc.root.elements.to_a("child::node()") #-> [ <b/>, <c/> ]
|
948
|
+
# XPath.match(doc.root, "child::node()") #-> [ sean, <b/>, elliott, <c/> ]
|
949
|
+
def to_a( xpath=nil )
|
950
|
+
rv = XPath.match( @element, xpath )
|
951
|
+
return rv.find_all{|e| e.kind_of? Element} if xpath
|
952
|
+
rv
|
953
|
+
end
|
954
|
+
|
955
|
+
private
|
956
|
+
# Private helper class. Removes quotes from quoted strings
|
957
|
+
def literalize name
|
958
|
+
name = name[1..-2] if name[0] == ?' or name[0] == ?" #'
|
959
|
+
name
|
960
|
+
end
|
961
|
+
end
|
962
|
+
|
963
|
+
########################################################################
|
964
|
+
# ATTRIBUTES #
|
965
|
+
########################################################################
|
966
|
+
|
967
|
+
# A class that defines the set of Attributes of an Element and provides
|
968
|
+
# operations for accessing elements in that set.
|
969
|
+
class Attributes < Hash
|
970
|
+
# Constructor
|
971
|
+
# element:: the Element of which this is an Attribute
|
972
|
+
def initialize element
|
973
|
+
@element = element
|
974
|
+
end
|
975
|
+
|
976
|
+
# Fetches an attribute value. If you want to get the Attribute itself,
|
977
|
+
# use get_attribute()
|
978
|
+
# name:: an XPath attribute name. Namespaces are relevant here.
|
979
|
+
# Returns::
|
980
|
+
# the String value of the matching attribute, or +nil+ if no
|
981
|
+
# matching attribute was found. This is the unnormalized value
|
982
|
+
# (with entities expanded).
|
983
|
+
#
|
984
|
+
# doc = Document.new "<a foo:att='1' bar:att='2' att='<'/>"
|
985
|
+
# doc.root.attributes['att'] #-> '<'
|
986
|
+
# doc.root.attributes['bar:att'] #-> '2'
|
987
|
+
def [](name)
|
988
|
+
attr = get_attribute(name)
|
989
|
+
return attr.value unless attr.nil?
|
990
|
+
return nil
|
991
|
+
end
|
992
|
+
|
993
|
+
def to_a
|
994
|
+
values.flatten
|
995
|
+
end
|
996
|
+
|
997
|
+
# Returns the number of attributes the owning Element contains.
|
998
|
+
# doc = Document "<a x='1' y='2' foo:x='3'/>"
|
999
|
+
# doc.root.attributes.length #-> 3
|
1000
|
+
def length
|
1001
|
+
c = 0
|
1002
|
+
each_attribute { c+=1 }
|
1003
|
+
c
|
1004
|
+
end
|
1005
|
+
alias :size :length
|
1006
|
+
|
1007
|
+
# Iterates over the attributes of an Element. Yields actual Attribute
|
1008
|
+
# nodes, not String values.
|
1009
|
+
#
|
1010
|
+
# doc = Document.new '<a x="1" y="2"/>'
|
1011
|
+
# doc.root.attributes.each_attribute {|attr|
|
1012
|
+
# p attr.expanded_name+" => "+attr.value
|
1013
|
+
# }
|
1014
|
+
def each_attribute # :yields: attribute
|
1015
|
+
each_value do |val|
|
1016
|
+
if val.kind_of? Attribute
|
1017
|
+
yield val
|
1018
|
+
else
|
1019
|
+
val.each_value { |atr| yield atr }
|
1020
|
+
end
|
1021
|
+
end
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
# Iterates over each attribute of an Element, yielding the expanded name
|
1025
|
+
# and value as a pair of Strings.
|
1026
|
+
#
|
1027
|
+
# doc = Document.new '<a x="1" y="2"/>'
|
1028
|
+
# doc.root.attributes.each {|name, value| p name+" => "+value }
|
1029
|
+
def each
|
1030
|
+
each_attribute do |attr|
|
1031
|
+
yield [attr.expanded_name, attr.value]
|
1032
|
+
end
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
# Fetches an attribute
|
1036
|
+
# name::
|
1037
|
+
# the name by which to search for the attribute. Can be a
|
1038
|
+
# <tt>prefix:name</tt> namespace name.
|
1039
|
+
# Returns:: The first matching attribute, or nil if there was none. This
|
1040
|
+
# value is an Attribute node, not the String value of the attribute.
|
1041
|
+
# doc = Document.new '<a x:foo="1" foo="2" bar="3"/>'
|
1042
|
+
# doc.root.attributes.get_attribute("foo").value #-> "2"
|
1043
|
+
# doc.root.attributes.get_attribute("x:foo").value #-> "1"
|
1044
|
+
def get_attribute( name )
|
1045
|
+
attr = fetch( name, nil )
|
1046
|
+
if attr.nil?
|
1047
|
+
return nil if name.nil?
|
1048
|
+
# Look for prefix
|
1049
|
+
name =~ Namespace::NAMESPLIT
|
1050
|
+
prefix, n = $1, $2
|
1051
|
+
if prefix
|
1052
|
+
attr = fetch( n, nil )
|
1053
|
+
# check prefix
|
1054
|
+
if attr == nil
|
1055
|
+
elsif attr.kind_of? Attribute
|
1056
|
+
return attr if prefix == attr.prefix
|
1057
|
+
else
|
1058
|
+
attr = attr[ prefix ]
|
1059
|
+
return attr
|
1060
|
+
end
|
1061
|
+
end
|
1062
|
+
element_document = @element.document
|
1063
|
+
if element_document and element_document.doctype
|
1064
|
+
expn = @element.expanded_name
|
1065
|
+
expn = element_document.doctype.name if expn.size == 0
|
1066
|
+
attr_val = element_document.doctype.attribute_of(expn, name)
|
1067
|
+
return Attribute.new( name, attr_val ) if attr_val
|
1068
|
+
end
|
1069
|
+
return nil
|
1070
|
+
end
|
1071
|
+
if attr.kind_of? Hash
|
1072
|
+
attr = attr[ @element.prefix ]
|
1073
|
+
end
|
1074
|
+
return attr
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
# Sets an attribute, overwriting any existing attribute value by the
|
1078
|
+
# same name. Namespace is significant.
|
1079
|
+
# name:: the name of the attribute
|
1080
|
+
# value::
|
1081
|
+
# (optional) If supplied, the value of the attribute. If
|
1082
|
+
# nil, any existing matching attribute is deleted.
|
1083
|
+
# Returns::
|
1084
|
+
# Owning element
|
1085
|
+
# doc = Document.new "<a x:foo='1' foo='3'/>"
|
1086
|
+
# doc.root.attributes['y:foo'] = '2'
|
1087
|
+
# doc.root.attributes['foo'] = '4'
|
1088
|
+
# doc.root.attributes['x:foo'] = nil
|
1089
|
+
def []=( name, value )
|
1090
|
+
if value.nil? # Delete the named attribute
|
1091
|
+
attr = get_attribute(name)
|
1092
|
+
delete attr
|
1093
|
+
return
|
1094
|
+
end
|
1095
|
+
element_document = @element.document
|
1096
|
+
unless value.kind_of? Attribute
|
1097
|
+
if @element.document and @element.document.doctype
|
1098
|
+
value = Text::normalize( value, @element.document.doctype )
|
1099
|
+
else
|
1100
|
+
value = Text::normalize( value, nil )
|
1101
|
+
end
|
1102
|
+
value = Attribute.new(name, value)
|
1103
|
+
end
|
1104
|
+
value.element = @element
|
1105
|
+
old_attr = fetch(value.name, nil)
|
1106
|
+
if old_attr.nil?
|
1107
|
+
store(value.name, value)
|
1108
|
+
elsif old_attr.kind_of? Hash
|
1109
|
+
old_attr[value.prefix] = value
|
1110
|
+
elsif old_attr.prefix != value.prefix
|
1111
|
+
# Check for conflicting namespaces
|
1112
|
+
raise ParseException.new(
|
1113
|
+
"Namespace conflict in adding attribute \"#{value.name}\": "+
|
1114
|
+
"Prefix \"#{old_attr.prefix}\" = "+
|
1115
|
+
"\"#{@element.namespace(old_attr.prefix)}\" and prefix "+
|
1116
|
+
"\"#{value.prefix}\" = \"#{@element.namespace(value.prefix)}\"") if
|
1117
|
+
value.prefix != "xmlns" and old_attr.prefix != "xmlns" and
|
1118
|
+
@element.namespace( old_attr.prefix ) ==
|
1119
|
+
@element.namespace( value.prefix )
|
1120
|
+
store value.name, { old_attr.prefix => old_attr,
|
1121
|
+
value.prefix => value }
|
1122
|
+
else
|
1123
|
+
store value.name, value
|
1124
|
+
end
|
1125
|
+
return @element
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
# Returns an array of Strings containing all of the prefixes declared
|
1129
|
+
# by this set of # attributes. The array does not include the default
|
1130
|
+
# namespace declaration, if one exists.
|
1131
|
+
# doc = Document.new("<a xmlns='foo' xmlns:x='bar' xmlns:y='twee' "+
|
1132
|
+
# "z='glorp' p:k='gru'/>")
|
1133
|
+
# prefixes = doc.root.attributes.prefixes #-> ['x', 'y']
|
1134
|
+
def prefixes
|
1135
|
+
ns = []
|
1136
|
+
each_attribute do |attribute|
|
1137
|
+
ns << attribute.name if attribute.prefix == 'xmlns'
|
1138
|
+
end
|
1139
|
+
if @element.document and @element.document.doctype
|
1140
|
+
expn = @element.expanded_name
|
1141
|
+
expn = @element.document.doctype.name if expn.size == 0
|
1142
|
+
@element.document.doctype.attributes_of(expn).each {
|
1143
|
+
|attribute|
|
1144
|
+
ns << attribute.name if attribute.prefix == 'xmlns'
|
1145
|
+
}
|
1146
|
+
end
|
1147
|
+
ns
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
def namespaces
|
1151
|
+
namespaces = {}
|
1152
|
+
each_attribute do |attribute|
|
1153
|
+
namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
|
1154
|
+
end
|
1155
|
+
if @element.document and @element.document.doctype
|
1156
|
+
expn = @element.expanded_name
|
1157
|
+
expn = @element.document.doctype.name if expn.size == 0
|
1158
|
+
@element.document.doctype.attributes_of(expn).each {
|
1159
|
+
|attribute|
|
1160
|
+
namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
|
1161
|
+
}
|
1162
|
+
end
|
1163
|
+
namespaces
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
# Removes an attribute
|
1167
|
+
# attribute::
|
1168
|
+
# either a String, which is the name of the attribute to remove --
|
1169
|
+
# namespaces are significant here -- or the attribute to remove.
|
1170
|
+
# Returns:: the owning element
|
1171
|
+
# doc = Document.new "<a y:foo='0' x:foo='1' foo='3' z:foo='4'/>"
|
1172
|
+
# doc.root.attributes.delete 'foo' #-> <a y:foo='0' x:foo='1' z:foo='4'/>"
|
1173
|
+
# doc.root.attributes.delete 'x:foo' #-> <a y:foo='0' z:foo='4'/>"
|
1174
|
+
# attr = doc.root.attributes.get_attribute('y:foo')
|
1175
|
+
# doc.root.attributes.delete attr #-> <a z:foo='4'/>"
|
1176
|
+
def delete( attribute )
|
1177
|
+
name = nil
|
1178
|
+
prefix = nil
|
1179
|
+
if attribute.kind_of? Attribute
|
1180
|
+
name = attribute.name
|
1181
|
+
prefix = attribute.prefix
|
1182
|
+
else
|
1183
|
+
attribute =~ Namespace::NAMESPLIT
|
1184
|
+
prefix, name = $1, $2
|
1185
|
+
prefix = '' unless prefix
|
1186
|
+
end
|
1187
|
+
old = fetch(name, nil)
|
1188
|
+
attr = nil
|
1189
|
+
if old.kind_of? Hash # the supplied attribute is one of many
|
1190
|
+
attr = old.delete(prefix)
|
1191
|
+
if old.size == 1
|
1192
|
+
repl = nil
|
1193
|
+
old.each_value{|v| repl = v}
|
1194
|
+
store name, repl
|
1195
|
+
end
|
1196
|
+
elsif old.nil?
|
1197
|
+
return @element
|
1198
|
+
else # the supplied attribute is a top-level one
|
1199
|
+
attr = old
|
1200
|
+
res = super(name)
|
1201
|
+
end
|
1202
|
+
@element
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
# Adds an attribute, overriding any existing attribute by the
|
1206
|
+
# same name. Namespaces are significant.
|
1207
|
+
# attribute:: An Attribute
|
1208
|
+
def add( attribute )
|
1209
|
+
self[attribute.name] = attribute
|
1210
|
+
end
|
1211
|
+
|
1212
|
+
alias :<< :add
|
1213
|
+
|
1214
|
+
# Deletes all attributes matching a name. Namespaces are significant.
|
1215
|
+
# name::
|
1216
|
+
# A String; all attributes that match this path will be removed
|
1217
|
+
# Returns:: an Array of the Attributes that were removed
|
1218
|
+
def delete_all( name )
|
1219
|
+
rv = []
|
1220
|
+
each_attribute { |attribute|
|
1221
|
+
rv << attribute if attribute.expanded_name == name
|
1222
|
+
}
|
1223
|
+
rv.each{ |attr| attr.remove }
|
1224
|
+
return rv
|
1225
|
+
end
|
1226
|
+
|
1227
|
+
# The +get_attribute_ns+ method retrieves a method by its namespace
|
1228
|
+
# and name. Thus it is possible to reliably identify an attribute
|
1229
|
+
# even if an XML processor has changed the prefix.
|
1230
|
+
#
|
1231
|
+
# Method contributed by Henrik Martensson
|
1232
|
+
def get_attribute_ns(namespace, name)
|
1233
|
+
result = nil
|
1234
|
+
each_attribute() { |attribute|
|
1235
|
+
if name == attribute.name &&
|
1236
|
+
namespace == attribute.namespace() &&
|
1237
|
+
( !namespace.empty? || !attribute.fully_expanded_name.index(':') )
|
1238
|
+
# foo will match xmlns:foo, but only if foo isn't also an attribute
|
1239
|
+
result = attribute if !result or !namespace.empty? or
|
1240
|
+
!attribute.fully_expanded_name.index(':')
|
1241
|
+
end
|
1242
|
+
}
|
1243
|
+
result
|
1244
|
+
end
|
1245
|
+
end
|
1246
|
+
end
|