ruby_on_ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.rvmrc +1 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/lib/ruby_on_ruby.rb +5 -0
- data/lib/ruby_on_ruby/console.rb +7 -0
- data/lib/ruby_on_ruby/context.rb +33 -0
- data/lib/ruby_on_ruby/file_loader.rb +31 -0
- data/lib/ruby_on_ruby/ruby_stream.rb +27 -0
- data/lib/ruby_on_ruby/version.rb +3 -0
- data/lib/rubyonruby.rb +1 -0
- data/ruby_in_ruby.gemspec +19 -0
- data/vendor/javascripts/emscripted-ruby/lib/.document +106 -0
- data/vendor/javascripts/emscripted-ruby/lib/English.rb +155 -0
- data/vendor/javascripts/emscripted-ruby/lib/Env.rb +18 -0
- data/vendor/javascripts/emscripted-ruby/lib/README +96 -0
- data/vendor/javascripts/emscripted-ruby/lib/abbrev.rb +103 -0
- data/vendor/javascripts/emscripted-ruby/lib/base64.rb +133 -0
- data/vendor/javascripts/emscripted-ruby/lib/benchmark.rb +572 -0
- data/vendor/javascripts/emscripted-ruby/lib/cgi-lib.rb +272 -0
- data/vendor/javascripts/emscripted-ruby/lib/cgi.rb +2308 -0
- data/vendor/javascripts/emscripted-ruby/lib/cgi/.document +2 -0
- data/vendor/javascripts/emscripted-ruby/lib/cgi/session.rb +498 -0
- data/vendor/javascripts/emscripted-ruby/lib/cgi/session/pstore.rb +111 -0
- data/vendor/javascripts/emscripted-ruby/lib/complex.rb +663 -0
- data/vendor/javascripts/emscripted-ruby/lib/csv.rb +992 -0
- data/vendor/javascripts/emscripted-ruby/lib/date.rb +1767 -0
- data/vendor/javascripts/emscripted-ruby/lib/date/format.rb +1190 -0
- data/vendor/javascripts/emscripted-ruby/lib/date2.rb +5 -0
- data/vendor/javascripts/emscripted-ruby/lib/debug.rb +947 -0
- data/vendor/javascripts/emscripted-ruby/lib/delegate.rb +337 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb.rb +2 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/acl.rb +146 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/drb.rb +1782 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/eq.rb +16 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/extserv.rb +64 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/extservm.rb +89 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/gw.rb +122 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/invokemethod.rb +36 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/observer.rb +22 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/ssl.rb +190 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/timeridconv.rb +91 -0
- data/vendor/javascripts/emscripted-ruby/lib/drb/unix.rb +108 -0
- data/vendor/javascripts/emscripted-ruby/lib/e2mmap.rb +195 -0
- data/vendor/javascripts/emscripted-ruby/lib/erb.rb +880 -0
- data/vendor/javascripts/emscripted-ruby/lib/eregex.rb +37 -0
- data/vendor/javascripts/emscripted-ruby/lib/fileutils.rb +1591 -0
- data/vendor/javascripts/emscripted-ruby/lib/finalize.rb +193 -0
- data/vendor/javascripts/emscripted-ruby/lib/find.rb +79 -0
- data/vendor/javascripts/emscripted-ruby/lib/forwardable.rb +218 -0
- data/vendor/javascripts/emscripted-ruby/lib/ftools.rb +261 -0
- data/vendor/javascripts/emscripted-ruby/lib/generator.rb +418 -0
- data/vendor/javascripts/emscripted-ruby/lib/getoptlong.rb +621 -0
- data/vendor/javascripts/emscripted-ruby/lib/getopts.rb +127 -0
- data/vendor/javascripts/emscripted-ruby/lib/gserver.rb +253 -0
- data/vendor/javascripts/emscripted-ruby/lib/importenv.rb +33 -0
- data/vendor/javascripts/emscripted-ruby/lib/ipaddr.rb +814 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb.rb +346 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/chws.rb +33 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/fork.rb +39 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/help.rb +34 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/load.rb +67 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/nop.rb +39 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/pushws.rb +39 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/subirb.rb +43 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/completion.rb +205 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/context.rb +255 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/change-ws.rb +62 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/history.rb +110 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/loader.rb +120 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/math-mode.rb +37 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/multi-irb.rb +241 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/save-history.rb +85 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/tracer.rb +61 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/use-loader.rb +65 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ext/workspaces.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/extend-command.rb +264 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/frame.rb +67 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/help.rb +33 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/init.rb +259 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/input-method.rb +120 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/lc/error.rb +30 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/lc/help-message +35 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/lc/ja/error.rb +27 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/lc/ja/help-message +36 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/locale.rb +184 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/notifier.rb +145 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/output-method.rb +85 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ruby-lex.rb +1149 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ruby-token.rb +273 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/slex.rb +285 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/version.rb +16 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/workspace.rb +107 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/ws-for-case-2.rb +15 -0
- data/vendor/javascripts/emscripted-ruby/lib/irb/xmp.rb +86 -0
- data/vendor/javascripts/emscripted-ruby/lib/jcode.rb +220 -0
- data/vendor/javascripts/emscripted-ruby/lib/logger.rb +703 -0
- data/vendor/javascripts/emscripted-ruby/lib/mailread.rb +62 -0
- data/vendor/javascripts/emscripted-ruby/lib/mathn.rb +308 -0
- data/vendor/javascripts/emscripted-ruby/lib/matrix.rb +1278 -0
- data/vendor/javascripts/emscripted-ruby/lib/mkmf.rb +1811 -0
- data/vendor/javascripts/emscripted-ruby/lib/monitor.rb +352 -0
- data/vendor/javascripts/emscripted-ruby/lib/mutex_m.rb +122 -0
- data/vendor/javascripts/emscripted-ruby/lib/net/ftp.rb +927 -0
- data/vendor/javascripts/emscripted-ruby/lib/net/http.rb +2277 -0
- data/vendor/javascripts/emscripted-ruby/lib/net/https.rb +173 -0
- data/vendor/javascripts/emscripted-ruby/lib/net/imap.rb +3371 -0
- data/vendor/javascripts/emscripted-ruby/lib/net/pop.rb +999 -0
- data/vendor/javascripts/emscripted-ruby/lib/net/protocol.rb +392 -0
- data/vendor/javascripts/emscripted-ruby/lib/net/smtp.rb +1014 -0
- data/vendor/javascripts/emscripted-ruby/lib/net/telnet.rb +756 -0
- data/vendor/javascripts/emscripted-ruby/lib/observer.rb +192 -0
- data/vendor/javascripts/emscripted-ruby/lib/open-uri.rb +678 -0
- data/vendor/javascripts/emscripted-ruby/lib/open3.rb +101 -0
- data/vendor/javascripts/emscripted-ruby/lib/optparse.rb +1790 -0
- data/vendor/javascripts/emscripted-ruby/lib/optparse/date.rb +17 -0
- data/vendor/javascripts/emscripted-ruby/lib/optparse/shellwords.rb +6 -0
- data/vendor/javascripts/emscripted-ruby/lib/optparse/time.rb +10 -0
- data/vendor/javascripts/emscripted-ruby/lib/optparse/uri.rb +6 -0
- data/vendor/javascripts/emscripted-ruby/lib/optparse/version.rb +70 -0
- data/vendor/javascripts/emscripted-ruby/lib/ostruct.rb +146 -0
- data/vendor/javascripts/emscripted-ruby/lib/parsearg.rb +87 -0
- data/vendor/javascripts/emscripted-ruby/lib/parsedate.rb +53 -0
- data/vendor/javascripts/emscripted-ruby/lib/pathname.rb +1062 -0
- data/vendor/javascripts/emscripted-ruby/lib/ping.rb +64 -0
- data/vendor/javascripts/emscripted-ruby/lib/pp.rb +654 -0
- data/vendor/javascripts/emscripted-ruby/lib/prettyprint.rb +896 -0
- data/vendor/javascripts/emscripted-ruby/lib/profile.rb +6 -0
- data/vendor/javascripts/emscripted-ruby/lib/profiler.rb +59 -0
- data/vendor/javascripts/emscripted-ruby/lib/pstore.rb +395 -0
- data/vendor/javascripts/emscripted-ruby/lib/racc/parser.rb +442 -0
- data/vendor/javascripts/emscripted-ruby/lib/rational.rb +564 -0
- data/vendor/javascripts/emscripted-ruby/lib/readbytes.rb +41 -0
- data/vendor/javascripts/emscripted-ruby/lib/resolv-replace.rb +62 -0
- data/vendor/javascripts/emscripted-ruby/lib/resolv.rb +2210 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/attlistdecl.rb +62 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/attribute.rb +185 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/cdata.rb +67 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/child.rb +96 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/comment.rb +80 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/doctype.rb +271 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/document.rb +208 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/attlistdecl.rb +10 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/dtd.rb +51 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/elementdecl.rb +17 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/entitydecl.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/notationdecl.rb +39 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/element.rb +1227 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encoding.rb +71 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/CP-1252.rb +103 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/EUC-JP.rb +35 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/ICONV.rb +22 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/ISO-8859-1.rb +7 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/ISO-8859-15.rb +72 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/SHIFT-JIS.rb +37 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/SHIFT_JIS.rb +1 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/UNILE.rb +34 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/US-ASCII.rb +30 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/UTF-16.rb +35 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/UTF-8.rb +18 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/entity.rb +165 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/formatters/default.rb +109 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/formatters/pretty.rb +137 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/formatters/transitive.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/functions.rb +382 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/instruction.rb +70 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/light/node.rb +196 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/namespace.rb +47 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/node.rb +75 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/output.rb +24 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parent.rb +166 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parseexception.rb +51 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/baseparser.rb +503 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/lightparser.rb +60 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/pullparser.rb +196 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/sax2parser.rb +238 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/streamparser.rb +46 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/treeparser.rb +97 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/ultralightparser.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/xpathparser.rb +698 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/quickpath.rb +266 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/rexml.rb +32 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/sax2listener.rb +97 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/source.rb +251 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/streamlistener.rb +92 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/syncenumerator.rb +33 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/text.rb +344 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/undefinednamespaceexception.rb +8 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/validation/relaxng.rb +559 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/validation/validation.rb +155 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/validation/validationexception.rb +9 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/xmldecl.rb +119 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/xmltokens.rb +18 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/xpath.rb +66 -0
- data/vendor/javascripts/emscripted-ruby/lib/rexml/xpath_parser.rb +792 -0
- data/vendor/javascripts/emscripted-ruby/lib/rinda/rinda.rb +283 -0
- data/vendor/javascripts/emscripted-ruby/lib/rinda/ring.rb +271 -0
- data/vendor/javascripts/emscripted-ruby/lib/rinda/tuplespace.rb +642 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss.rb +19 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/0.9.rb +428 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/1.0.rb +452 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/2.0.rb +111 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/atom.rb +749 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/content.rb +31 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/content/1.0.rb +10 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/content/2.0.rb +12 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/converter.rb +162 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/dublincore.rb +161 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/dublincore/1.0.rb +13 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/dublincore/2.0.rb +13 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/dublincore/atom.rb +17 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/image.rb +193 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/itunes.rb +410 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker.rb +44 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/0.9.rb +467 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/1.0.rb +434 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/2.0.rb +223 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/atom.rb +172 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/base.rb +868 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/content.rb +21 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/dublincore.rb +124 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/entry.rb +163 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/feed.rb +429 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/image.rb +111 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/itunes.rb +242 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/slash.rb +33 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/syndication.rb +18 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/taxonomy.rb +118 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/maker/trackback.rb +61 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/parser.rb +541 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/rexmlparser.rb +54 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/rss.rb +1312 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/slash.rb +49 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/syndication.rb +67 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/taxonomy.rb +145 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/trackback.rb +288 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/utils.rb +111 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/xml-stylesheet.rb +105 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/xml.rb +71 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/xmlparser.rb +93 -0
- data/vendor/javascripts/emscripted-ruby/lib/rss/xmlscanner.rb +121 -0
- data/vendor/javascripts/emscripted-ruby/lib/rubyunit.rb +6 -0
- data/vendor/javascripts/emscripted-ruby/lib/runit/assert.rb +73 -0
- data/vendor/javascripts/emscripted-ruby/lib/runit/cui/testrunner.rb +51 -0
- data/vendor/javascripts/emscripted-ruby/lib/runit/error.rb +9 -0
- data/vendor/javascripts/emscripted-ruby/lib/runit/testcase.rb +45 -0
- data/vendor/javascripts/emscripted-ruby/lib/runit/testresult.rb +44 -0
- data/vendor/javascripts/emscripted-ruby/lib/runit/testsuite.rb +26 -0
- data/vendor/javascripts/emscripted-ruby/lib/runit/topublic.rb +8 -0
- data/vendor/javascripts/emscripted-ruby/lib/scanf.rb +702 -0
- data/vendor/javascripts/emscripted-ruby/lib/securerandom.rb +137 -0
- data/vendor/javascripts/emscripted-ruby/lib/set.rb +1233 -0
- data/vendor/javascripts/emscripted-ruby/lib/shell.rb +269 -0
- data/vendor/javascripts/emscripted-ruby/lib/shell/builtin-command.rb +154 -0
- data/vendor/javascripts/emscripted-ruby/lib/shell/command-processor.rb +592 -0
- data/vendor/javascripts/emscripted-ruby/lib/shell/error.rb +26 -0
- data/vendor/javascripts/emscripted-ruby/lib/shell/filter.rb +110 -0
- data/vendor/javascripts/emscripted-ruby/lib/shell/process-controller.rb +260 -0
- data/vendor/javascripts/emscripted-ruby/lib/shell/system-command.rb +168 -0
- data/vendor/javascripts/emscripted-ruby/lib/shell/version.rb +16 -0
- data/vendor/javascripts/emscripted-ruby/lib/shellwords.rb +172 -0
- data/vendor/javascripts/emscripted-ruby/lib/singleton.rb +360 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/attachment.rb +107 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/baseData.rb +942 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/element.rb +258 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/encodingstyle/aspDotNetHandler.rb +213 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/encodingstyle/handler.rb +100 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/encodingstyle/literalHandler.rb +226 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/encodingstyle/soapHandler.rb +582 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/generator.rb +268 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/header/handler.rb +57 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/header/handlerset.rb +70 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/header/simplehandler.rb +44 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/httpconfigloader.rb +119 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mapping.rb +10 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/factory.rb +355 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/mapping.rb +381 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/registry.rb +541 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/rubytypeFactory.rb +475 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/typeMap.rb +50 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/wsdlencodedregistry.rb +280 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/wsdlliteralregistry.rb +418 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/marshal.rb +59 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/mimemessage.rb +240 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/netHttpClient.rb +190 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/parser.rb +251 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/processor.rb +66 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/property.rb +333 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/cgistub.rb +206 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/driver.rb +254 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/element.rb +325 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/httpserver.rb +129 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/proxy.rb +497 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/router.rb +594 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/rpc.rb +25 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/soaplet.rb +162 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/standaloneServer.rb +43 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/soap.rb +140 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/streamHandler.rb +229 -0
- data/vendor/javascripts/emscripted-ruby/lib/soap/wsdlDriver.rb +575 -0
- data/vendor/javascripts/emscripted-ruby/lib/sync.rb +311 -0
- data/vendor/javascripts/emscripted-ruby/lib/tempfile.rb +209 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit.rb +280 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/assertionfailederror.rb +14 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/assertions.rb +622 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/autorunner.rb +220 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/collector.rb +43 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/collector/dir.rb +107 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/collector/objectspace.rb +34 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/error.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/failure.rb +51 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/testcase.rb +160 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/testresult.rb +80 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/testsuite.rb +76 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/console/testrunner.rb +127 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/fox/testrunner.rb +268 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/gtk/testrunner.rb +416 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/gtk2/testrunner.rb +465 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/testrunnermediator.rb +68 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/testrunnerutilities.rb +46 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/tk/testrunner.rb +260 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/util/backtracefilter.rb +40 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/util/observable.rb +90 -0
- data/vendor/javascripts/emscripted-ruby/lib/test/unit/util/procwrapper.rb +48 -0
- data/vendor/javascripts/emscripted-ruby/lib/thread.rb +479 -0
- data/vendor/javascripts/emscripted-ruby/lib/thwait.rb +169 -0
- data/vendor/javascripts/emscripted-ruby/lib/time.rb +797 -0
- data/vendor/javascripts/emscripted-ruby/lib/timeout.rb +122 -0
- data/vendor/javascripts/emscripted-ruby/lib/tmpdir.rb +130 -0
- data/vendor/javascripts/emscripted-ruby/lib/tracer.rb +167 -0
- data/vendor/javascripts/emscripted-ruby/lib/tsort.rb +290 -0
- data/vendor/javascripts/emscripted-ruby/lib/un.rb +235 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri.rb +29 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri/common.rb +611 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri/ftp.rb +198 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri/generic.rb +1122 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri/http.rb +100 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri/https.rb +20 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri/ldap.rb +190 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri/ldaps.rb +12 -0
- data/vendor/javascripts/emscripted-ruby/lib/uri/mailto.rb +266 -0
- data/vendor/javascripts/emscripted-ruby/lib/weakref.rb +100 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick.rb +29 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/accesslog.rb +67 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/cgi.rb +257 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/compat.rb +15 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/config.rb +97 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/cookie.rb +110 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/htmlutils.rb +25 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth.rb +45 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/authenticator.rb +79 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/basicauth.rb +65 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/digestauth.rb +343 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/htdigest.rb +91 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/htgroup.rb +61 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/htpasswd.rb +83 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/userdb.rb +29 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpproxy.rb +254 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httprequest.rb +365 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpresponse.rb +327 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/https.rb +63 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpserver.rb +210 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet.rb +22 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/abstract.rb +71 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/cgi_runner.rb +47 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/cgihandler.rb +108 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/erbhandler.rb +54 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/filehandler.rb +435 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/prochandler.rb +33 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpstatus.rb +126 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httputils.rb +399 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/httpversion.rb +49 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/log.rb +88 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/server.rb +200 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/ssl.rb +126 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/utils.rb +100 -0
- data/vendor/javascripts/emscripted-ruby/lib/webrick/version.rb +13 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/binding.rb +65 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/data.rb +64 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/definitions.rb +250 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/documentation.rb +32 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/import.rb +80 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/importer.rb +38 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/info.rb +39 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/message.rb +54 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/operation.rb +130 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/operationBinding.rb +108 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/param.rb +85 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/parser.rb +163 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/part.rb +52 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/port.rb +84 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/portType.rb +73 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/service.rb +61 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/address.rb +40 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/binding.rb +49 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/body.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/cgiStubCreator.rb +76 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/classDefCreator.rb +314 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/classDefCreatorSupport.rb +126 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/clientSkeltonCreator.rb +78 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/complexType.rb +161 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/data.rb +42 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/definitions.rb +149 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/driverCreator.rb +95 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/element.rb +28 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/fault.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/header.rb +86 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/headerfault.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/mappingRegistryCreator.rb +92 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/methodDefCreator.rb +228 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/operation.rb +122 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/servantSkeltonCreator.rb +67 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/standaloneServerStubCreator.rb +85 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/wsdl2ruby.rb +176 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/types.rb +43 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/wsdl.rb +23 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/all.rb +69 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/annotation.rb +34 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/any.rb +56 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/attribute.rb +127 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/choice.rb +69 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/complexContent.rb +92 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/complexType.rb +139 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/content.rb +96 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/data.rb +80 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/element.rb +154 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/enumeration.rb +36 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/import.rb +65 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/importer.rb +87 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/include.rb +54 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/length.rb +35 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/parser.rb +166 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/pattern.rb +36 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/schema.rb +143 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/sequence.rb +69 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/simpleContent.rb +65 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/simpleExtension.rb +54 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/simpleRestriction.rb +73 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/simpleType.rb +73 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/unique.rb +34 -0
- data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/xsd2ruby.rb +107 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/.document +1 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/README.txt +31 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/base64.rb +81 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/client.rb +624 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/config.rb +40 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/create.rb +290 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/datetime.rb +142 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/httpserver.rb +178 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/marshal.rb +76 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/parser.rb +813 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/server.rb +780 -0
- data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/utils.rb +165 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/charset.rb +187 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen.rb +12 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/classdef.rb +203 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/commentdef.rb +34 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/gensupport.rb +166 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/methoddef.rb +63 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/moduledef.rb +191 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/datatypes.rb +1269 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/datatypes1999.rb +20 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/iconvcharset.rb +33 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/mapping.rb +42 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/namedelements.rb +95 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/ns.rb +140 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/qname.rb +78 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser.rb +61 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser/parser.rb +96 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser/rexmlparser.rb +54 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser/xmlparser.rb +50 -0
- data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser/xmlscanner.rb +147 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml.rb +440 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/baseemitter.rb +247 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/basenode.rb +216 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/constants.rb +45 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/dbm.rb +111 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/encoding.rb +33 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/error.rb +34 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/loader.rb +14 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/rubytypes.rb +408 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/store.rb +43 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/stream.rb +40 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/stringio.rb +83 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/syck.rb +19 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/tag.rb +91 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/types.rb +192 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/yamlnode.rb +54 -0
- data/vendor/javascripts/emscripted-ruby/lib/yaml/ypath.rb +52 -0
- data/vendor/javascripts/emscripted-ruby/ruby.closure.js +7201 -0
- metadata +554 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
OptionParser.accept(DateTime) do |s,|
|
5
|
+
begin
|
6
|
+
DateTime.parse(s) if s
|
7
|
+
rescue ArgumentError
|
8
|
+
raise OptionParser::InvalidArgument, s
|
9
|
+
end
|
10
|
+
end
|
11
|
+
OptionParser.accept(Date) do |s,|
|
12
|
+
begin
|
13
|
+
Date.parse(s) if s
|
14
|
+
rescue ArgumentError
|
15
|
+
raise OptionParser::InvalidArgument, s
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# OptionParser internal utility
|
2
|
+
|
3
|
+
class << OptionParser
|
4
|
+
def show_version(*pkg)
|
5
|
+
progname = ARGV.options.program_name
|
6
|
+
result = false
|
7
|
+
show = proc do |klass, cname, version|
|
8
|
+
str = "#{progname}"
|
9
|
+
unless klass == ::Object and cname == :VERSION
|
10
|
+
version = version.join(".") if Array === version
|
11
|
+
str << ": #{klass}" unless klass == Object
|
12
|
+
str << " version #{version}"
|
13
|
+
end
|
14
|
+
[:Release, :RELEASE].find do |rel|
|
15
|
+
if klass.const_defined?(rel)
|
16
|
+
str << " (#{klass.const_get(rel)})"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
puts str
|
20
|
+
result = true
|
21
|
+
end
|
22
|
+
if pkg.size == 1 and pkg[0] == "all"
|
23
|
+
self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version|
|
24
|
+
unless cname[1] == ?e and klass.const_defined?(:Version)
|
25
|
+
show.call(klass, cname.intern, version)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
else
|
29
|
+
pkg.each do |pkg|
|
30
|
+
begin
|
31
|
+
pkg = pkg.split(/::|\//).inject(::Object) {|m, c| m.const_get(c)}
|
32
|
+
v = case
|
33
|
+
when pkg.const_defined?(:Version)
|
34
|
+
pkg.const_get(n = :Version)
|
35
|
+
when pkg.const_defined?(:VERSION)
|
36
|
+
pkg.const_get(n = :VERSION)
|
37
|
+
else
|
38
|
+
n = nil
|
39
|
+
"unknown"
|
40
|
+
end
|
41
|
+
show.call(pkg, n, v)
|
42
|
+
rescue NameError
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
result
|
47
|
+
end
|
48
|
+
|
49
|
+
def each_const(path, klass = ::Object)
|
50
|
+
path.split(/::|\//).inject(klass) do |klass, name|
|
51
|
+
raise NameError, path unless Module === klass
|
52
|
+
klass.constants.grep(/#{name}/i) do |c|
|
53
|
+
klass.const_defined?(c) or next
|
54
|
+
c = klass.const_get(c)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def search_const(klass, name)
|
60
|
+
klasses = [klass]
|
61
|
+
while klass = klasses.shift
|
62
|
+
klass.constants.each do |cname|
|
63
|
+
klass.const_defined?(cname) or next
|
64
|
+
const = klass.const_get(cname)
|
65
|
+
yield klass, cname, const if name === cname
|
66
|
+
klasses << const if Module === const and const != ::Object
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#
|
2
|
+
# = ostruct.rb: OpenStruct implementation
|
3
|
+
#
|
4
|
+
# Author:: Yukihiro Matsumoto
|
5
|
+
# Documentation:: Gavin Sinclair
|
6
|
+
#
|
7
|
+
# OpenStruct allows the creation of data objects with arbitrary attributes.
|
8
|
+
# See OpenStruct for an example.
|
9
|
+
#
|
10
|
+
|
11
|
+
#
|
12
|
+
# OpenStruct allows you to create data objects and set arbitrary attributes.
|
13
|
+
# For example:
|
14
|
+
#
|
15
|
+
# require 'ostruct'
|
16
|
+
#
|
17
|
+
# record = OpenStruct.new
|
18
|
+
# record.name = "John Smith"
|
19
|
+
# record.age = 70
|
20
|
+
# record.pension = 300
|
21
|
+
#
|
22
|
+
# puts record.name # -> "John Smith"
|
23
|
+
# puts record.address # -> nil
|
24
|
+
#
|
25
|
+
# It is like a hash with a different way to access the data. In fact, it is
|
26
|
+
# implemented with a hash, and you can initialize it with one.
|
27
|
+
#
|
28
|
+
# hash = { "country" => "Australia", :population => 20_000_000 }
|
29
|
+
# data = OpenStruct.new(hash)
|
30
|
+
#
|
31
|
+
# p data # -> <OpenStruct country="Australia" population=20000000>
|
32
|
+
#
|
33
|
+
class OpenStruct
|
34
|
+
#
|
35
|
+
# Create a new OpenStruct object. The optional +hash+, if given, will
|
36
|
+
# generate attributes and values. For example.
|
37
|
+
#
|
38
|
+
# require 'ostruct'
|
39
|
+
# hash = { "country" => "Australia", :population => 20_000_000 }
|
40
|
+
# data = OpenStruct.new(hash)
|
41
|
+
#
|
42
|
+
# p data # -> <OpenStruct country="Australia" population=20000000>
|
43
|
+
#
|
44
|
+
# By default, the resulting OpenStruct object will have no attributes.
|
45
|
+
#
|
46
|
+
def initialize(hash=nil)
|
47
|
+
@table = {}
|
48
|
+
if hash
|
49
|
+
for k,v in hash
|
50
|
+
@table[k.to_sym] = v
|
51
|
+
new_ostruct_member(k)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Duplicate an OpenStruct object members.
|
57
|
+
def initialize_copy(orig)
|
58
|
+
super
|
59
|
+
@table = @table.dup
|
60
|
+
end
|
61
|
+
|
62
|
+
def marshal_dump
|
63
|
+
@table
|
64
|
+
end
|
65
|
+
def marshal_load(x)
|
66
|
+
@table = x
|
67
|
+
@table.each_key{|key| new_ostruct_member(key)}
|
68
|
+
end
|
69
|
+
|
70
|
+
def new_ostruct_member(name)
|
71
|
+
name = name.to_sym
|
72
|
+
unless self.respond_to?(name)
|
73
|
+
meta = class << self; self; end
|
74
|
+
meta.send(:define_method, name) { @table[name] }
|
75
|
+
meta.send(:define_method, :"#{name}=") { |x| @table[name] = x }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def method_missing(mid, *args) # :nodoc:
|
80
|
+
mname = mid.id2name
|
81
|
+
len = args.length
|
82
|
+
if mname =~ /=$/
|
83
|
+
if len != 1
|
84
|
+
raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
|
85
|
+
end
|
86
|
+
if self.frozen?
|
87
|
+
raise TypeError, "can't modify frozen #{self.class}", caller(1)
|
88
|
+
end
|
89
|
+
mname.chop!
|
90
|
+
self.new_ostruct_member(mname)
|
91
|
+
@table[mname.intern] = args[0]
|
92
|
+
elsif len == 0
|
93
|
+
@table[mid]
|
94
|
+
else
|
95
|
+
raise NoMethodError, "undefined method `#{mname}' for #{self}", caller(1)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Remove the named field from the object.
|
101
|
+
#
|
102
|
+
def delete_field(name)
|
103
|
+
@table.delete name.to_sym
|
104
|
+
end
|
105
|
+
|
106
|
+
InspectKey = :__inspect_key__ # :nodoc:
|
107
|
+
|
108
|
+
#
|
109
|
+
# Returns a string containing a detailed summary of the keys and values.
|
110
|
+
#
|
111
|
+
def inspect
|
112
|
+
str = "#<#{self.class}"
|
113
|
+
|
114
|
+
Thread.current[InspectKey] ||= []
|
115
|
+
if Thread.current[InspectKey].include?(self) then
|
116
|
+
str << " ..."
|
117
|
+
else
|
118
|
+
first = true
|
119
|
+
for k,v in @table
|
120
|
+
str << "," unless first
|
121
|
+
first = false
|
122
|
+
|
123
|
+
Thread.current[InspectKey] << v
|
124
|
+
begin
|
125
|
+
str << " #{k}=#{v.inspect}"
|
126
|
+
ensure
|
127
|
+
Thread.current[InspectKey].pop
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
str << ">"
|
133
|
+
end
|
134
|
+
alias :to_s :inspect
|
135
|
+
|
136
|
+
attr_reader :table # :nodoc:
|
137
|
+
protected :table
|
138
|
+
|
139
|
+
#
|
140
|
+
# Compare this object and +other+ for equality.
|
141
|
+
#
|
142
|
+
def ==(other)
|
143
|
+
return false unless(other.kind_of?(OpenStruct))
|
144
|
+
return @table == other.table
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#
|
2
|
+
# parsearg.rb - parse arguments
|
3
|
+
# $Release Version: $
|
4
|
+
# $Revision: 11708 $
|
5
|
+
# $Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
|
6
|
+
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: parsearg is deprecated after Ruby 1.8.1; use optparse instead"
|
14
|
+
|
15
|
+
$RCS_ID=%q$Header$
|
16
|
+
|
17
|
+
require "getopts"
|
18
|
+
|
19
|
+
def printUsageAndExit()
|
20
|
+
if $USAGE
|
21
|
+
eval($USAGE)
|
22
|
+
end
|
23
|
+
exit()
|
24
|
+
end
|
25
|
+
|
26
|
+
def setParenthesis(ex, opt, c)
|
27
|
+
if opt != ""
|
28
|
+
ex = sprintf("%s$OPT_%s%s", ex, opt, c)
|
29
|
+
else
|
30
|
+
ex = sprintf("%s%s", ex, c)
|
31
|
+
end
|
32
|
+
return ex
|
33
|
+
end
|
34
|
+
|
35
|
+
def setOrAnd(ex, opt, c)
|
36
|
+
if opt != ""
|
37
|
+
ex = sprintf("%s$OPT_%s %s%s ", ex, opt, c, c)
|
38
|
+
else
|
39
|
+
ex = sprintf("%s %s%s ", ex, c, c)
|
40
|
+
end
|
41
|
+
return ex
|
42
|
+
end
|
43
|
+
|
44
|
+
def setExpression(ex, opt, op)
|
45
|
+
if !op
|
46
|
+
ex = sprintf("%s$OPT_%s", ex, opt)
|
47
|
+
return ex
|
48
|
+
end
|
49
|
+
case op.chr
|
50
|
+
when "(", ")"
|
51
|
+
ex = setParenthesis(ex, opt, op.chr)
|
52
|
+
when "|", "&"
|
53
|
+
ex = setOrAnd(ex, opt, op.chr)
|
54
|
+
else
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
return ex
|
58
|
+
end
|
59
|
+
|
60
|
+
# parseArgs is obsolete. Use OptionParser instead.
|
61
|
+
|
62
|
+
def parseArgs(argc, nopt, single_opts, *opts)
|
63
|
+
if (noOptions = getopts(single_opts, *opts)) == nil
|
64
|
+
printUsageAndExit()
|
65
|
+
end
|
66
|
+
if nopt
|
67
|
+
ex = nil
|
68
|
+
pos = 0
|
69
|
+
for o in nopt.split(/[()|&]/)
|
70
|
+
pos += o.length
|
71
|
+
ex = setExpression(ex, o, nopt[pos])
|
72
|
+
pos += 1
|
73
|
+
end
|
74
|
+
begin
|
75
|
+
if !eval(ex)
|
76
|
+
printUsageAndExit()
|
77
|
+
end
|
78
|
+
rescue
|
79
|
+
print "Format Error!! : \"" + nopt + "\"\t[parseArgs]\n"
|
80
|
+
exit!(-1)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
if ARGV.length < argc
|
84
|
+
printUsageAndExit()
|
85
|
+
end
|
86
|
+
return noOptions
|
87
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# = parsedate.rb: Parses dates
|
3
|
+
#
|
4
|
+
# Author:: Tadayoshi Funaba
|
5
|
+
# Documentation:: Konrad Meyer
|
6
|
+
#
|
7
|
+
# ParseDate munches on a date and turns it into an array of values.
|
8
|
+
#
|
9
|
+
|
10
|
+
#
|
11
|
+
# ParseDate converts a date into an array of values.
|
12
|
+
# For example:
|
13
|
+
#
|
14
|
+
# require 'parsedate'
|
15
|
+
#
|
16
|
+
# ParseDate.parsedate "Tuesday, July 6th, 2007, 18:35:20 UTC"
|
17
|
+
# # => [2007, 7, 6, 18, 35, 20, "UTC", 2]
|
18
|
+
#
|
19
|
+
# The order is of the form [year, month, day of month, hour, minute, second,
|
20
|
+
# timezone, day of the week].
|
21
|
+
|
22
|
+
require 'date/format'
|
23
|
+
|
24
|
+
module ParseDate
|
25
|
+
#
|
26
|
+
# Parse a string representation of a date into values.
|
27
|
+
# For example:
|
28
|
+
#
|
29
|
+
# require 'parsedate'
|
30
|
+
#
|
31
|
+
# ParseDate.parsedate "Tuesday, July 5th, 2007, 18:35:20 UTC"
|
32
|
+
# # => [2007, 7, 5, 18, 35, 20, "UTC", 2]
|
33
|
+
#
|
34
|
+
# The order is of the form [year, month, day of month, hour, minute,
|
35
|
+
# second, timezone, day of week].
|
36
|
+
#
|
37
|
+
# ParseDate.parsedate can also take a second argument, +comp+, which
|
38
|
+
# is a boolean telling the method to compensate for dates with years
|
39
|
+
# expressed as two digits. Example:
|
40
|
+
#
|
41
|
+
# require 'parsedate'
|
42
|
+
#
|
43
|
+
# ParseDate.parsedate "Mon Dec 25 00 06:53:24 UTC", true
|
44
|
+
# # => [2000, 12, 25, 6, 53, 24, "UTC", 1]
|
45
|
+
#
|
46
|
+
def parsedate(str, comp=false)
|
47
|
+
Date._parse(str, comp).
|
48
|
+
values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
|
49
|
+
end
|
50
|
+
|
51
|
+
module_function :parsedate
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,1062 @@
|
|
1
|
+
#
|
2
|
+
# = pathname.rb
|
3
|
+
#
|
4
|
+
# Object-Oriented Pathname Class
|
5
|
+
#
|
6
|
+
# Author:: Tanaka Akira <akr@m17n.org>
|
7
|
+
# Documentation:: Author and Gavin Sinclair
|
8
|
+
#
|
9
|
+
# For documentation, see class Pathname.
|
10
|
+
#
|
11
|
+
# <tt>pathname.rb</tt> is distributed with Ruby since 1.8.0.
|
12
|
+
#
|
13
|
+
|
14
|
+
#
|
15
|
+
# == Pathname
|
16
|
+
#
|
17
|
+
# Pathname represents a pathname which locates a file in a filesystem.
|
18
|
+
# The pathname depends on OS: Unix, Windows, etc.
|
19
|
+
# Pathname library works with pathnames of local OS.
|
20
|
+
# However non-Unix pathnames are supported experimentally.
|
21
|
+
#
|
22
|
+
# It does not represent the file itself.
|
23
|
+
# A Pathname can be relative or absolute. It's not until you try to
|
24
|
+
# reference the file that it even matters whether the file exists or not.
|
25
|
+
#
|
26
|
+
# Pathname is immutable. It has no method for destructive update.
|
27
|
+
#
|
28
|
+
# The value of this class is to manipulate file path information in a neater
|
29
|
+
# way than standard Ruby provides. The examples below demonstrate the
|
30
|
+
# difference. *All* functionality from File, FileTest, and some from Dir and
|
31
|
+
# FileUtils is included, in an unsurprising way. It is essentially a facade for
|
32
|
+
# all of these, and more.
|
33
|
+
#
|
34
|
+
# == Examples
|
35
|
+
#
|
36
|
+
# === Example 1: Using Pathname
|
37
|
+
#
|
38
|
+
# require 'pathname'
|
39
|
+
# p = Pathname.new("/usr/bin/ruby")
|
40
|
+
# size = p.size # 27662
|
41
|
+
# isdir = p.directory? # false
|
42
|
+
# dir = p.dirname # Pathname:/usr/bin
|
43
|
+
# base = p.basename # Pathname:ruby
|
44
|
+
# dir, base = p.split # [Pathname:/usr/bin, Pathname:ruby]
|
45
|
+
# data = p.read
|
46
|
+
# p.open { |f| _ }
|
47
|
+
# p.each_line { |line| _ }
|
48
|
+
#
|
49
|
+
# === Example 2: Using standard Ruby
|
50
|
+
#
|
51
|
+
# p = "/usr/bin/ruby"
|
52
|
+
# size = File.size(p) # 27662
|
53
|
+
# isdir = File.directory?(p) # false
|
54
|
+
# dir = File.dirname(p) # "/usr/bin"
|
55
|
+
# base = File.basename(p) # "ruby"
|
56
|
+
# dir, base = File.split(p) # ["/usr/bin", "ruby"]
|
57
|
+
# data = File.read(p)
|
58
|
+
# File.open(p) { |f| _ }
|
59
|
+
# File.foreach(p) { |line| _ }
|
60
|
+
#
|
61
|
+
# === Example 3: Special features
|
62
|
+
#
|
63
|
+
# p1 = Pathname.new("/usr/lib") # Pathname:/usr/lib
|
64
|
+
# p2 = p1 + "ruby/1.8" # Pathname:/usr/lib/ruby/1.8
|
65
|
+
# p3 = p1.parent # Pathname:/usr
|
66
|
+
# p4 = p2.relative_path_from(p3) # Pathname:lib/ruby/1.8
|
67
|
+
# pwd = Pathname.pwd # Pathname:/home/gavin
|
68
|
+
# pwd.absolute? # true
|
69
|
+
# p5 = Pathname.new "." # Pathname:.
|
70
|
+
# p5 = p5 + "music/../articles" # Pathname:music/../articles
|
71
|
+
# p5.cleanpath # Pathname:articles
|
72
|
+
# p5.realpath # Pathname:/home/gavin/articles
|
73
|
+
# p5.children # [Pathname:/home/gavin/articles/linux, ...]
|
74
|
+
#
|
75
|
+
# == Breakdown of functionality
|
76
|
+
#
|
77
|
+
# === Core methods
|
78
|
+
#
|
79
|
+
# These methods are effectively manipulating a String, because that's all a path
|
80
|
+
# is. Except for #mountpoint?, #children, and #realpath, they don't access the
|
81
|
+
# filesystem.
|
82
|
+
#
|
83
|
+
# - +
|
84
|
+
# - #join
|
85
|
+
# - #parent
|
86
|
+
# - #root?
|
87
|
+
# - #absolute?
|
88
|
+
# - #relative?
|
89
|
+
# - #relative_path_from
|
90
|
+
# - #each_filename
|
91
|
+
# - #cleanpath
|
92
|
+
# - #realpath
|
93
|
+
# - #children
|
94
|
+
# - #mountpoint?
|
95
|
+
#
|
96
|
+
# === File status predicate methods
|
97
|
+
#
|
98
|
+
# These methods are a facade for FileTest:
|
99
|
+
# - #blockdev?
|
100
|
+
# - #chardev?
|
101
|
+
# - #directory?
|
102
|
+
# - #executable?
|
103
|
+
# - #executable_real?
|
104
|
+
# - #exist?
|
105
|
+
# - #file?
|
106
|
+
# - #grpowned?
|
107
|
+
# - #owned?
|
108
|
+
# - #pipe?
|
109
|
+
# - #readable?
|
110
|
+
# - #world_readable?
|
111
|
+
# - #readable_real?
|
112
|
+
# - #setgid?
|
113
|
+
# - #setuid?
|
114
|
+
# - #size
|
115
|
+
# - #size?
|
116
|
+
# - #socket?
|
117
|
+
# - #sticky?
|
118
|
+
# - #symlink?
|
119
|
+
# - #writable?
|
120
|
+
# - #world_writable?
|
121
|
+
# - #writable_real?
|
122
|
+
# - #zero?
|
123
|
+
#
|
124
|
+
# === File property and manipulation methods
|
125
|
+
#
|
126
|
+
# These methods are a facade for File:
|
127
|
+
# - #atime
|
128
|
+
# - #ctime
|
129
|
+
# - #mtime
|
130
|
+
# - #chmod(mode)
|
131
|
+
# - #lchmod(mode)
|
132
|
+
# - #chown(owner, group)
|
133
|
+
# - #lchown(owner, group)
|
134
|
+
# - #fnmatch(pattern, *args)
|
135
|
+
# - #fnmatch?(pattern, *args)
|
136
|
+
# - #ftype
|
137
|
+
# - #make_link(old)
|
138
|
+
# - #open(*args, &block)
|
139
|
+
# - #readlink
|
140
|
+
# - #rename(to)
|
141
|
+
# - #stat
|
142
|
+
# - #lstat
|
143
|
+
# - #make_symlink(old)
|
144
|
+
# - #truncate(length)
|
145
|
+
# - #utime(atime, mtime)
|
146
|
+
# - #basename(*args)
|
147
|
+
# - #dirname
|
148
|
+
# - #extname
|
149
|
+
# - #expand_path(*args)
|
150
|
+
# - #split
|
151
|
+
#
|
152
|
+
# === Directory methods
|
153
|
+
#
|
154
|
+
# These methods are a facade for Dir:
|
155
|
+
# - Pathname.glob(*args)
|
156
|
+
# - Pathname.getwd / Pathname.pwd
|
157
|
+
# - #rmdir
|
158
|
+
# - #entries
|
159
|
+
# - #each_entry(&block)
|
160
|
+
# - #mkdir(*args)
|
161
|
+
# - #opendir(*args)
|
162
|
+
#
|
163
|
+
# === IO
|
164
|
+
#
|
165
|
+
# These methods are a facade for IO:
|
166
|
+
# - #each_line(*args, &block)
|
167
|
+
# - #read(*args)
|
168
|
+
# - #readlines(*args)
|
169
|
+
# - #sysopen(*args)
|
170
|
+
#
|
171
|
+
# === Utilities
|
172
|
+
#
|
173
|
+
# These methods are a mixture of Find, FileUtils, and others:
|
174
|
+
# - #find(&block)
|
175
|
+
# - #mkpath
|
176
|
+
# - #rmtree
|
177
|
+
# - #unlink / #delete
|
178
|
+
#
|
179
|
+
#
|
180
|
+
# == Method documentation
|
181
|
+
#
|
182
|
+
# As the above section shows, most of the methods in Pathname are facades. The
|
183
|
+
# documentation for these methods generally just says, for instance, "See
|
184
|
+
# FileTest.writable?", as you should be familiar with the original method
|
185
|
+
# anyway, and its documentation (e.g. through +ri+) will contain more
|
186
|
+
# information. In some cases, a brief description will follow.
|
187
|
+
#
|
188
|
+
class Pathname
|
189
|
+
|
190
|
+
# :stopdoc:
|
191
|
+
if RUBY_VERSION < "1.9"
|
192
|
+
TO_PATH = :to_str
|
193
|
+
else
|
194
|
+
# to_path is implemented so Pathname objects are usable with File.open, etc.
|
195
|
+
TO_PATH = :to_path
|
196
|
+
end
|
197
|
+
# :startdoc:
|
198
|
+
|
199
|
+
#
|
200
|
+
# Create a Pathname object from the given String (or String-like object).
|
201
|
+
# If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
|
202
|
+
#
|
203
|
+
def initialize(path)
|
204
|
+
path = path.__send__(TO_PATH) if path.respond_to? TO_PATH
|
205
|
+
@path = path.dup
|
206
|
+
|
207
|
+
if /\0/ =~ @path
|
208
|
+
raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
|
209
|
+
end
|
210
|
+
|
211
|
+
self.taint if @path.tainted?
|
212
|
+
end
|
213
|
+
|
214
|
+
def freeze() super; @path.freeze; self end
|
215
|
+
def taint() super; @path.taint; self end
|
216
|
+
def untaint() super; @path.untaint; self end
|
217
|
+
|
218
|
+
#
|
219
|
+
# Compare this pathname with +other+. The comparison is string-based.
|
220
|
+
# Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>)
|
221
|
+
# can refer to the same file.
|
222
|
+
#
|
223
|
+
def ==(other)
|
224
|
+
return false unless Pathname === other
|
225
|
+
other.to_s == @path
|
226
|
+
end
|
227
|
+
alias === ==
|
228
|
+
alias eql? ==
|
229
|
+
|
230
|
+
# Provides for comparing pathnames, case-sensitively.
|
231
|
+
def <=>(other)
|
232
|
+
return nil unless Pathname === other
|
233
|
+
@path.tr('/', "\0") <=> other.to_s.tr('/', "\0")
|
234
|
+
end
|
235
|
+
|
236
|
+
def hash # :nodoc:
|
237
|
+
@path.hash
|
238
|
+
end
|
239
|
+
|
240
|
+
# Return the path as a String.
|
241
|
+
def to_s
|
242
|
+
@path.dup
|
243
|
+
end
|
244
|
+
|
245
|
+
# to_path is implemented so Pathname objects are usable with File.open, etc.
|
246
|
+
alias_method TO_PATH, :to_s
|
247
|
+
|
248
|
+
def inspect # :nodoc:
|
249
|
+
"#<#{self.class}:#{@path}>"
|
250
|
+
end
|
251
|
+
|
252
|
+
# Return a pathname which is substituted by String#sub.
|
253
|
+
def sub(pattern, *rest, &block)
|
254
|
+
self.class.new(@path.sub(pattern, *rest, &block))
|
255
|
+
end
|
256
|
+
|
257
|
+
if File::ALT_SEPARATOR
|
258
|
+
SEPARATOR_PAT = /[#{Regexp.quote File::ALT_SEPARATOR}#{Regexp.quote File::SEPARATOR}]/
|
259
|
+
else
|
260
|
+
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
|
261
|
+
end
|
262
|
+
|
263
|
+
# chop_basename(path) -> [pre-basename, basename] or nil
|
264
|
+
def chop_basename(path)
|
265
|
+
base = File.basename(path)
|
266
|
+
if /\A#{SEPARATOR_PAT}?\z/ =~ base
|
267
|
+
return nil
|
268
|
+
else
|
269
|
+
return path[0, path.rindex(base)], base
|
270
|
+
end
|
271
|
+
end
|
272
|
+
private :chop_basename
|
273
|
+
|
274
|
+
# split_names(path) -> prefix, [name, ...]
|
275
|
+
def split_names(path)
|
276
|
+
names = []
|
277
|
+
while r = chop_basename(path)
|
278
|
+
path, basename = r
|
279
|
+
names.unshift basename
|
280
|
+
end
|
281
|
+
return path, names
|
282
|
+
end
|
283
|
+
private :split_names
|
284
|
+
|
285
|
+
def prepend_prefix(prefix, relpath)
|
286
|
+
if relpath.empty?
|
287
|
+
File.dirname(prefix)
|
288
|
+
elsif /#{SEPARATOR_PAT}/ =~ prefix
|
289
|
+
prefix = File.dirname(prefix)
|
290
|
+
prefix = File.join(prefix, "") if File.basename(prefix + 'a') != 'a'
|
291
|
+
prefix + relpath
|
292
|
+
else
|
293
|
+
prefix + relpath
|
294
|
+
end
|
295
|
+
end
|
296
|
+
private :prepend_prefix
|
297
|
+
|
298
|
+
# Returns clean pathname of +self+ with consecutive slashes and useless dots
|
299
|
+
# removed. The filesystem is not accessed.
|
300
|
+
#
|
301
|
+
# If +consider_symlink+ is +true+, then a more conservative algorithm is used
|
302
|
+
# to avoid breaking symbolic linkages. This may retain more <tt>..</tt>
|
303
|
+
# entries than absolutely necessary, but without accessing the filesystem,
|
304
|
+
# this can't be avoided. See #realpath.
|
305
|
+
#
|
306
|
+
def cleanpath(consider_symlink=false)
|
307
|
+
if consider_symlink
|
308
|
+
cleanpath_conservative
|
309
|
+
else
|
310
|
+
cleanpath_aggressive
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
#
|
315
|
+
# Clean the path simply by resolving and removing excess "." and ".." entries.
|
316
|
+
# Nothing more, nothing less.
|
317
|
+
#
|
318
|
+
def cleanpath_aggressive
|
319
|
+
path = @path
|
320
|
+
names = []
|
321
|
+
pre = path
|
322
|
+
while r = chop_basename(pre)
|
323
|
+
pre, base = r
|
324
|
+
case base
|
325
|
+
when '.'
|
326
|
+
when '..'
|
327
|
+
names.unshift base
|
328
|
+
else
|
329
|
+
if names[0] == '..'
|
330
|
+
names.shift
|
331
|
+
else
|
332
|
+
names.unshift base
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
|
337
|
+
names.shift while names[0] == '..'
|
338
|
+
end
|
339
|
+
self.class.new(prepend_prefix(pre, File.join(*names)))
|
340
|
+
end
|
341
|
+
private :cleanpath_aggressive
|
342
|
+
|
343
|
+
# has_trailing_separator?(path) -> bool
|
344
|
+
def has_trailing_separator?(path)
|
345
|
+
if r = chop_basename(path)
|
346
|
+
pre, basename = r
|
347
|
+
pre.length + basename.length < path.length
|
348
|
+
else
|
349
|
+
false
|
350
|
+
end
|
351
|
+
end
|
352
|
+
private :has_trailing_separator?
|
353
|
+
|
354
|
+
# add_trailing_separator(path) -> path
|
355
|
+
def add_trailing_separator(path)
|
356
|
+
if File.basename(path + 'a') == 'a'
|
357
|
+
path
|
358
|
+
else
|
359
|
+
File.join(path, "") # xxx: Is File.join is appropriate to add separator?
|
360
|
+
end
|
361
|
+
end
|
362
|
+
private :add_trailing_separator
|
363
|
+
|
364
|
+
def del_trailing_separator(path)
|
365
|
+
if r = chop_basename(path)
|
366
|
+
pre, basename = r
|
367
|
+
pre + basename
|
368
|
+
elsif /#{SEPARATOR_PAT}+\z/o =~ path
|
369
|
+
$` + File.dirname(path)[/#{SEPARATOR_PAT}*\z/o]
|
370
|
+
else
|
371
|
+
path
|
372
|
+
end
|
373
|
+
end
|
374
|
+
private :del_trailing_separator
|
375
|
+
|
376
|
+
def cleanpath_conservative
|
377
|
+
path = @path
|
378
|
+
names = []
|
379
|
+
pre = path
|
380
|
+
while r = chop_basename(pre)
|
381
|
+
pre, base = r
|
382
|
+
names.unshift base if base != '.'
|
383
|
+
end
|
384
|
+
if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
|
385
|
+
names.shift while names[0] == '..'
|
386
|
+
end
|
387
|
+
if names.empty?
|
388
|
+
self.class.new(File.dirname(pre))
|
389
|
+
else
|
390
|
+
if names.last != '..' && File.basename(path) == '.'
|
391
|
+
names << '.'
|
392
|
+
end
|
393
|
+
result = prepend_prefix(pre, File.join(*names))
|
394
|
+
if /\A(?:\.|\.\.)\z/ !~ names.last && has_trailing_separator?(path)
|
395
|
+
self.class.new(add_trailing_separator(result))
|
396
|
+
else
|
397
|
+
self.class.new(result)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
private :cleanpath_conservative
|
402
|
+
|
403
|
+
def realpath_rec(prefix, unresolved, h)
|
404
|
+
resolved = []
|
405
|
+
until unresolved.empty?
|
406
|
+
n = unresolved.shift
|
407
|
+
if n == '.'
|
408
|
+
next
|
409
|
+
elsif n == '..'
|
410
|
+
resolved.pop
|
411
|
+
else
|
412
|
+
path = prepend_prefix(prefix, File.join(*(resolved + [n])))
|
413
|
+
if h.include? path
|
414
|
+
if h[path] == :resolving
|
415
|
+
raise Errno::ELOOP.new(path)
|
416
|
+
else
|
417
|
+
prefix, *resolved = h[path]
|
418
|
+
end
|
419
|
+
else
|
420
|
+
s = File.lstat(path)
|
421
|
+
if s.symlink?
|
422
|
+
h[path] = :resolving
|
423
|
+
link_prefix, link_names = split_names(File.readlink(path))
|
424
|
+
if link_prefix == ''
|
425
|
+
prefix, *resolved = h[path] = realpath_rec(prefix, resolved + link_names, h)
|
426
|
+
else
|
427
|
+
prefix, *resolved = h[path] = realpath_rec(link_prefix, link_names, h)
|
428
|
+
end
|
429
|
+
else
|
430
|
+
resolved << n
|
431
|
+
h[path] = [prefix, *resolved]
|
432
|
+
end
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
return prefix, *resolved
|
437
|
+
end
|
438
|
+
private :realpath_rec
|
439
|
+
|
440
|
+
#
|
441
|
+
# Returns a real (absolute) pathname of +self+ in the actual filesystem.
|
442
|
+
# The real pathname doesn't contain symlinks or useless dots.
|
443
|
+
#
|
444
|
+
# No arguments should be given; the old behaviour is *obsoleted*.
|
445
|
+
#
|
446
|
+
def realpath
|
447
|
+
path = @path
|
448
|
+
prefix, names = split_names(path)
|
449
|
+
if prefix == ''
|
450
|
+
prefix, names2 = split_names(Dir.pwd)
|
451
|
+
names = names2 + names
|
452
|
+
end
|
453
|
+
prefix, *names = realpath_rec(prefix, names, {})
|
454
|
+
self.class.new(prepend_prefix(prefix, File.join(*names)))
|
455
|
+
end
|
456
|
+
|
457
|
+
# #parent returns the parent directory.
|
458
|
+
#
|
459
|
+
# This is same as <tt>self + '..'</tt>.
|
460
|
+
def parent
|
461
|
+
self + '..'
|
462
|
+
end
|
463
|
+
|
464
|
+
# #mountpoint? returns +true+ if <tt>self</tt> points to a mountpoint.
|
465
|
+
def mountpoint?
|
466
|
+
begin
|
467
|
+
stat1 = self.lstat
|
468
|
+
stat2 = self.parent.lstat
|
469
|
+
stat1.dev == stat2.dev && stat1.ino == stat2.ino ||
|
470
|
+
stat1.dev != stat2.dev
|
471
|
+
rescue Errno::ENOENT
|
472
|
+
false
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
#
|
477
|
+
# #root? is a predicate for root directories. I.e. it returns +true+ if the
|
478
|
+
# pathname consists of consecutive slashes.
|
479
|
+
#
|
480
|
+
# It doesn't access actual filesystem. So it may return +false+ for some
|
481
|
+
# pathnames which points to roots such as <tt>/usr/..</tt>.
|
482
|
+
#
|
483
|
+
def root?
|
484
|
+
!!(chop_basename(@path) == nil && /#{SEPARATOR_PAT}/o =~ @path)
|
485
|
+
end
|
486
|
+
|
487
|
+
# Predicate method for testing whether a path is absolute.
|
488
|
+
# It returns +true+ if the pathname begins with a slash.
|
489
|
+
def absolute?
|
490
|
+
!relative?
|
491
|
+
end
|
492
|
+
|
493
|
+
# The opposite of #absolute?
|
494
|
+
def relative?
|
495
|
+
path = @path
|
496
|
+
while r = chop_basename(path)
|
497
|
+
path, basename = r
|
498
|
+
end
|
499
|
+
path == ''
|
500
|
+
end
|
501
|
+
|
502
|
+
#
|
503
|
+
# Iterates over each component of the path.
|
504
|
+
#
|
505
|
+
# Pathname.new("/usr/bin/ruby").each_filename {|filename| ... }
|
506
|
+
# # yields "usr", "bin", and "ruby".
|
507
|
+
#
|
508
|
+
def each_filename # :yield: filename
|
509
|
+
prefix, names = split_names(@path)
|
510
|
+
names.each {|filename| yield filename }
|
511
|
+
nil
|
512
|
+
end
|
513
|
+
|
514
|
+
# Iterates over and yields a new Pathname object
|
515
|
+
# for each element in the given path in descending order.
|
516
|
+
#
|
517
|
+
# Pathname.new('/path/to/some/file.rb').descend {|v| p v}
|
518
|
+
# #<Pathname:/>
|
519
|
+
# #<Pathname:/path>
|
520
|
+
# #<Pathname:/path/to>
|
521
|
+
# #<Pathname:/path/to/some>
|
522
|
+
# #<Pathname:/path/to/some/file.rb>
|
523
|
+
#
|
524
|
+
# Pathname.new('path/to/some/file.rb').descend {|v| p v}
|
525
|
+
# #<Pathname:path>
|
526
|
+
# #<Pathname:path/to>
|
527
|
+
# #<Pathname:path/to/some>
|
528
|
+
# #<Pathname:path/to/some/file.rb>
|
529
|
+
#
|
530
|
+
# It doesn't access actual filesystem.
|
531
|
+
#
|
532
|
+
# This method is available since 1.8.5.
|
533
|
+
#
|
534
|
+
def descend
|
535
|
+
vs = []
|
536
|
+
ascend {|v| vs << v }
|
537
|
+
vs.reverse_each {|v| yield v }
|
538
|
+
nil
|
539
|
+
end
|
540
|
+
|
541
|
+
# Iterates over and yields a new Pathname object
|
542
|
+
# for each element in the given path in ascending order.
|
543
|
+
#
|
544
|
+
# Pathname.new('/path/to/some/file.rb').ascend {|v| p v}
|
545
|
+
# #<Pathname:/path/to/some/file.rb>
|
546
|
+
# #<Pathname:/path/to/some>
|
547
|
+
# #<Pathname:/path/to>
|
548
|
+
# #<Pathname:/path>
|
549
|
+
# #<Pathname:/>
|
550
|
+
#
|
551
|
+
# Pathname.new('path/to/some/file.rb').ascend {|v| p v}
|
552
|
+
# #<Pathname:path/to/some/file.rb>
|
553
|
+
# #<Pathname:path/to/some>
|
554
|
+
# #<Pathname:path/to>
|
555
|
+
# #<Pathname:path>
|
556
|
+
#
|
557
|
+
# It doesn't access actual filesystem.
|
558
|
+
#
|
559
|
+
# This method is available since 1.8.5.
|
560
|
+
#
|
561
|
+
def ascend
|
562
|
+
path = @path
|
563
|
+
yield self
|
564
|
+
while r = chop_basename(path)
|
565
|
+
path, name = r
|
566
|
+
break if path.empty?
|
567
|
+
yield self.class.new(del_trailing_separator(path))
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
#
|
572
|
+
# Pathname#+ appends a pathname fragment to this one to produce a new Pathname
|
573
|
+
# object.
|
574
|
+
#
|
575
|
+
# p1 = Pathname.new("/usr") # Pathname:/usr
|
576
|
+
# p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
|
577
|
+
# p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
|
578
|
+
#
|
579
|
+
# This method doesn't access the file system; it is pure string manipulation.
|
580
|
+
#
|
581
|
+
def +(other)
|
582
|
+
other = Pathname.new(other) unless Pathname === other
|
583
|
+
Pathname.new(plus(@path, other.to_s))
|
584
|
+
end
|
585
|
+
|
586
|
+
def plus(path1, path2) # -> path
|
587
|
+
prefix2 = path2
|
588
|
+
index_list2 = []
|
589
|
+
basename_list2 = []
|
590
|
+
while r2 = chop_basename(prefix2)
|
591
|
+
prefix2, basename2 = r2
|
592
|
+
index_list2.unshift prefix2.length
|
593
|
+
basename_list2.unshift basename2
|
594
|
+
end
|
595
|
+
return path2 if prefix2 != ''
|
596
|
+
prefix1 = path1
|
597
|
+
while true
|
598
|
+
while !basename_list2.empty? && basename_list2.first == '.'
|
599
|
+
index_list2.shift
|
600
|
+
basename_list2.shift
|
601
|
+
end
|
602
|
+
break unless r1 = chop_basename(prefix1)
|
603
|
+
prefix1, basename1 = r1
|
604
|
+
next if basename1 == '.'
|
605
|
+
if basename1 == '..' || basename_list2.empty? || basename_list2.first != '..'
|
606
|
+
prefix1 = prefix1 + basename1
|
607
|
+
break
|
608
|
+
end
|
609
|
+
index_list2.shift
|
610
|
+
basename_list2.shift
|
611
|
+
end
|
612
|
+
r1 = chop_basename(prefix1)
|
613
|
+
if !r1 && /#{SEPARATOR_PAT}/o =~ File.basename(prefix1)
|
614
|
+
while !basename_list2.empty? && basename_list2.first == '..'
|
615
|
+
index_list2.shift
|
616
|
+
basename_list2.shift
|
617
|
+
end
|
618
|
+
end
|
619
|
+
if !basename_list2.empty?
|
620
|
+
suffix2 = path2[index_list2.first..-1]
|
621
|
+
r1 ? File.join(prefix1, suffix2) : prefix1 + suffix2
|
622
|
+
else
|
623
|
+
r1 ? prefix1 : File.dirname(prefix1)
|
624
|
+
end
|
625
|
+
end
|
626
|
+
private :plus
|
627
|
+
|
628
|
+
#
|
629
|
+
# Pathname#join joins pathnames.
|
630
|
+
#
|
631
|
+
# <tt>path0.join(path1, ..., pathN)</tt> is the same as
|
632
|
+
# <tt>path0 + path1 + ... + pathN</tt>.
|
633
|
+
#
|
634
|
+
def join(*args)
|
635
|
+
args.unshift self
|
636
|
+
result = args.pop
|
637
|
+
result = Pathname.new(result) unless Pathname === result
|
638
|
+
return result if result.absolute?
|
639
|
+
args.reverse_each {|arg|
|
640
|
+
arg = Pathname.new(arg) unless Pathname === arg
|
641
|
+
result = arg + result
|
642
|
+
return result if result.absolute?
|
643
|
+
}
|
644
|
+
result
|
645
|
+
end
|
646
|
+
|
647
|
+
#
|
648
|
+
# Returns the children of the directory (files and subdirectories, not
|
649
|
+
# recursive) as an array of Pathname objects. By default, the returned
|
650
|
+
# pathnames will have enough information to access the files. If you set
|
651
|
+
# +with_directory+ to +false+, then the returned pathnames will contain the
|
652
|
+
# filename only.
|
653
|
+
#
|
654
|
+
# For example:
|
655
|
+
# p = Pathname("/usr/lib/ruby/1.8")
|
656
|
+
# p.children
|
657
|
+
# # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
|
658
|
+
# Pathname:/usr/lib/ruby/1.8/Env.rb,
|
659
|
+
# Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
|
660
|
+
# p.children(false)
|
661
|
+
# # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
|
662
|
+
#
|
663
|
+
# Note that the result never contain the entries <tt>.</tt> and <tt>..</tt> in
|
664
|
+
# the directory because they are not children.
|
665
|
+
#
|
666
|
+
# This method has existed since 1.8.1.
|
667
|
+
#
|
668
|
+
def children(with_directory=true)
|
669
|
+
with_directory = false if @path == '.'
|
670
|
+
result = []
|
671
|
+
Dir.foreach(@path) {|e|
|
672
|
+
next if e == '.' || e == '..'
|
673
|
+
if with_directory
|
674
|
+
result << self.class.new(File.join(@path, e))
|
675
|
+
else
|
676
|
+
result << self.class.new(e)
|
677
|
+
end
|
678
|
+
}
|
679
|
+
result
|
680
|
+
end
|
681
|
+
|
682
|
+
#
|
683
|
+
# #relative_path_from returns a relative path from the argument to the
|
684
|
+
# receiver. If +self+ is absolute, the argument must be absolute too. If
|
685
|
+
# +self+ is relative, the argument must be relative too.
|
686
|
+
#
|
687
|
+
# #relative_path_from doesn't access the filesystem. It assumes no symlinks.
|
688
|
+
#
|
689
|
+
# ArgumentError is raised when it cannot find a relative path.
|
690
|
+
#
|
691
|
+
# This method has existed since 1.8.1.
|
692
|
+
#
|
693
|
+
def relative_path_from(base_directory)
|
694
|
+
dest_directory = self.cleanpath.to_s
|
695
|
+
base_directory = base_directory.cleanpath.to_s
|
696
|
+
dest_prefix = dest_directory
|
697
|
+
dest_names = []
|
698
|
+
while r = chop_basename(dest_prefix)
|
699
|
+
dest_prefix, basename = r
|
700
|
+
dest_names.unshift basename if basename != '.'
|
701
|
+
end
|
702
|
+
base_prefix = base_directory
|
703
|
+
base_names = []
|
704
|
+
while r = chop_basename(base_prefix)
|
705
|
+
base_prefix, basename = r
|
706
|
+
base_names.unshift basename if basename != '.'
|
707
|
+
end
|
708
|
+
if dest_prefix != base_prefix
|
709
|
+
raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}"
|
710
|
+
end
|
711
|
+
while !dest_names.empty? &&
|
712
|
+
!base_names.empty? &&
|
713
|
+
dest_names.first == base_names.first
|
714
|
+
dest_names.shift
|
715
|
+
base_names.shift
|
716
|
+
end
|
717
|
+
if base_names.include? '..'
|
718
|
+
raise ArgumentError, "base_directory has ..: #{base_directory.inspect}"
|
719
|
+
end
|
720
|
+
base_names.fill('..')
|
721
|
+
relpath_names = base_names + dest_names
|
722
|
+
if relpath_names.empty?
|
723
|
+
Pathname.new('.')
|
724
|
+
else
|
725
|
+
Pathname.new(File.join(*relpath_names))
|
726
|
+
end
|
727
|
+
end
|
728
|
+
end
|
729
|
+
|
730
|
+
class Pathname # * IO *
|
731
|
+
#
|
732
|
+
# #each_line iterates over the line in the file. It yields a String object
|
733
|
+
# for each line.
|
734
|
+
#
|
735
|
+
# This method has existed since 1.8.1.
|
736
|
+
#
|
737
|
+
def each_line(*args, &block) # :yield: line
|
738
|
+
IO.foreach(@path, *args, &block)
|
739
|
+
end
|
740
|
+
|
741
|
+
# Pathname#foreachline is *obsoleted* at 1.8.1. Use #each_line.
|
742
|
+
def foreachline(*args, &block)
|
743
|
+
warn "Pathname#foreachline is obsoleted. Use Pathname#each_line."
|
744
|
+
each_line(*args, &block)
|
745
|
+
end
|
746
|
+
|
747
|
+
# See <tt>IO.read</tt>. Returns all the bytes from the file, or the first +N+
|
748
|
+
# if specified.
|
749
|
+
def read(*args) IO.read(@path, *args) end
|
750
|
+
|
751
|
+
# See <tt>IO.readlines</tt>. Returns all the lines from the file.
|
752
|
+
def readlines(*args) IO.readlines(@path, *args) end
|
753
|
+
|
754
|
+
# See <tt>IO.sysopen</tt>.
|
755
|
+
def sysopen(*args) IO.sysopen(@path, *args) end
|
756
|
+
end
|
757
|
+
|
758
|
+
|
759
|
+
class Pathname # * File *
|
760
|
+
|
761
|
+
# See <tt>File.atime</tt>. Returns last access time.
|
762
|
+
def atime() File.atime(@path) end
|
763
|
+
|
764
|
+
# See <tt>File.ctime</tt>. Returns last (directory entry, not file) change time.
|
765
|
+
def ctime() File.ctime(@path) end
|
766
|
+
|
767
|
+
# See <tt>File.mtime</tt>. Returns last modification time.
|
768
|
+
def mtime() File.mtime(@path) end
|
769
|
+
|
770
|
+
# See <tt>File.chmod</tt>. Changes permissions.
|
771
|
+
def chmod(mode) File.chmod(mode, @path) end
|
772
|
+
|
773
|
+
# See <tt>File.lchmod</tt>.
|
774
|
+
def lchmod(mode) File.lchmod(mode, @path) end
|
775
|
+
|
776
|
+
# See <tt>File.chown</tt>. Change owner and group of file.
|
777
|
+
def chown(owner, group) File.chown(owner, group, @path) end
|
778
|
+
|
779
|
+
# See <tt>File.lchown</tt>.
|
780
|
+
def lchown(owner, group) File.lchown(owner, group, @path) end
|
781
|
+
|
782
|
+
# See <tt>File.fnmatch</tt>. Return +true+ if the receiver matches the given
|
783
|
+
# pattern.
|
784
|
+
def fnmatch(pattern, *args) File.fnmatch(pattern, @path, *args) end
|
785
|
+
|
786
|
+
# See <tt>File.fnmatch?</tt> (same as #fnmatch).
|
787
|
+
def fnmatch?(pattern, *args) File.fnmatch?(pattern, @path, *args) end
|
788
|
+
|
789
|
+
# See <tt>File.ftype</tt>. Returns "type" of file ("file", "directory",
|
790
|
+
# etc).
|
791
|
+
def ftype() File.ftype(@path) end
|
792
|
+
|
793
|
+
# See <tt>File.link</tt>. Creates a hard link.
|
794
|
+
def make_link(old) File.link(old, @path) end
|
795
|
+
|
796
|
+
# See <tt>File.open</tt>. Opens the file for reading or writing.
|
797
|
+
def open(*args, &block) # :yield: file
|
798
|
+
File.open(@path, *args, &block)
|
799
|
+
end
|
800
|
+
|
801
|
+
# See <tt>File.readlink</tt>. Read symbolic link.
|
802
|
+
def readlink() self.class.new(File.readlink(@path)) end
|
803
|
+
|
804
|
+
# See <tt>File.rename</tt>. Rename the file.
|
805
|
+
def rename(to) File.rename(@path, to) end
|
806
|
+
|
807
|
+
# See <tt>File.stat</tt>. Returns a <tt>File::Stat</tt> object.
|
808
|
+
def stat() File.stat(@path) end
|
809
|
+
|
810
|
+
# See <tt>File.lstat</tt>.
|
811
|
+
def lstat() File.lstat(@path) end
|
812
|
+
|
813
|
+
# See <tt>File.symlink</tt>. Creates a symbolic link.
|
814
|
+
def make_symlink(old) File.symlink(old, @path) end
|
815
|
+
|
816
|
+
# See <tt>File.truncate</tt>. Truncate the file to +length+ bytes.
|
817
|
+
def truncate(length) File.truncate(@path, length) end
|
818
|
+
|
819
|
+
# See <tt>File.utime</tt>. Update the access and modification times.
|
820
|
+
def utime(atime, mtime) File.utime(atime, mtime, @path) end
|
821
|
+
|
822
|
+
# See <tt>File.basename</tt>. Returns the last component of the path.
|
823
|
+
def basename(*args) self.class.new(File.basename(@path, *args)) end
|
824
|
+
|
825
|
+
# See <tt>File.dirname</tt>. Returns all but the last component of the path.
|
826
|
+
def dirname() self.class.new(File.dirname(@path)) end
|
827
|
+
|
828
|
+
# See <tt>File.extname</tt>. Returns the file's extension.
|
829
|
+
def extname() File.extname(@path) end
|
830
|
+
|
831
|
+
# See <tt>File.expand_path</tt>.
|
832
|
+
def expand_path(*args) self.class.new(File.expand_path(@path, *args)) end
|
833
|
+
|
834
|
+
# See <tt>File.split</tt>. Returns the #dirname and the #basename in an
|
835
|
+
# Array.
|
836
|
+
def split() File.split(@path).map {|f| self.class.new(f) } end
|
837
|
+
|
838
|
+
# Pathname#link is confusing and *obsoleted* because the receiver/argument
|
839
|
+
# order is inverted to corresponding system call.
|
840
|
+
def link(old)
|
841
|
+
warn 'Pathname#link is obsoleted. Use Pathname#make_link.'
|
842
|
+
File.link(old, @path)
|
843
|
+
end
|
844
|
+
|
845
|
+
# Pathname#symlink is confusing and *obsoleted* because the receiver/argument
|
846
|
+
# order is inverted to corresponding system call.
|
847
|
+
def symlink(old)
|
848
|
+
warn 'Pathname#symlink is obsoleted. Use Pathname#make_symlink.'
|
849
|
+
File.symlink(old, @path)
|
850
|
+
end
|
851
|
+
end
|
852
|
+
|
853
|
+
|
854
|
+
class Pathname # * FileTest *
|
855
|
+
|
856
|
+
# See <tt>FileTest.blockdev?</tt>.
|
857
|
+
def blockdev?() FileTest.blockdev?(@path) end
|
858
|
+
|
859
|
+
# See <tt>FileTest.chardev?</tt>.
|
860
|
+
def chardev?() FileTest.chardev?(@path) end
|
861
|
+
|
862
|
+
# See <tt>FileTest.executable?</tt>.
|
863
|
+
def executable?() FileTest.executable?(@path) end
|
864
|
+
|
865
|
+
# See <tt>FileTest.executable_real?</tt>.
|
866
|
+
def executable_real?() FileTest.executable_real?(@path) end
|
867
|
+
|
868
|
+
# See <tt>FileTest.exist?</tt>.
|
869
|
+
def exist?() FileTest.exist?(@path) end
|
870
|
+
|
871
|
+
# See <tt>FileTest.grpowned?</tt>.
|
872
|
+
def grpowned?() FileTest.grpowned?(@path) end
|
873
|
+
|
874
|
+
# See <tt>FileTest.directory?</tt>.
|
875
|
+
def directory?() FileTest.directory?(@path) end
|
876
|
+
|
877
|
+
# See <tt>FileTest.file?</tt>.
|
878
|
+
def file?() FileTest.file?(@path) end
|
879
|
+
|
880
|
+
# See <tt>FileTest.pipe?</tt>.
|
881
|
+
def pipe?() FileTest.pipe?(@path) end
|
882
|
+
|
883
|
+
# See <tt>FileTest.socket?</tt>.
|
884
|
+
def socket?() FileTest.socket?(@path) end
|
885
|
+
|
886
|
+
# See <tt>FileTest.owned?</tt>.
|
887
|
+
def owned?() FileTest.owned?(@path) end
|
888
|
+
|
889
|
+
# See <tt>FileTest.readable?</tt>.
|
890
|
+
def readable?() FileTest.readable?(@path) end
|
891
|
+
|
892
|
+
# See <tt>FileTest.world_readable?</tt>.
|
893
|
+
def world_readable?() FileTest.world_readable?(@path) end
|
894
|
+
|
895
|
+
# See <tt>FileTest.readable_real?</tt>.
|
896
|
+
def readable_real?() FileTest.readable_real?(@path) end
|
897
|
+
|
898
|
+
# See <tt>FileTest.setuid?</tt>.
|
899
|
+
def setuid?() FileTest.setuid?(@path) end
|
900
|
+
|
901
|
+
# See <tt>FileTest.setgid?</tt>.
|
902
|
+
def setgid?() FileTest.setgid?(@path) end
|
903
|
+
|
904
|
+
# See <tt>FileTest.size</tt>.
|
905
|
+
def size() FileTest.size(@path) end
|
906
|
+
|
907
|
+
# See <tt>FileTest.size?</tt>.
|
908
|
+
def size?() FileTest.size?(@path) end
|
909
|
+
|
910
|
+
# See <tt>FileTest.sticky?</tt>.
|
911
|
+
def sticky?() FileTest.sticky?(@path) end
|
912
|
+
|
913
|
+
# See <tt>FileTest.symlink?</tt>.
|
914
|
+
def symlink?() FileTest.symlink?(@path) end
|
915
|
+
|
916
|
+
# See <tt>FileTest.writable?</tt>.
|
917
|
+
def writable?() FileTest.writable?(@path) end
|
918
|
+
|
919
|
+
# See <tt>FileTest.world_writable?</tt>.
|
920
|
+
def world_writable?() FileTest.world_writable?(@path) end
|
921
|
+
|
922
|
+
# See <tt>FileTest.writable_real?</tt>.
|
923
|
+
def writable_real?() FileTest.writable_real?(@path) end
|
924
|
+
|
925
|
+
# See <tt>FileTest.zero?</tt>.
|
926
|
+
def zero?() FileTest.zero?(@path) end
|
927
|
+
end
|
928
|
+
|
929
|
+
|
930
|
+
class Pathname # * Dir *
|
931
|
+
# See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
|
932
|
+
def Pathname.glob(*args) # :yield: p
|
933
|
+
if block_given?
|
934
|
+
Dir.glob(*args) {|f| yield self.new(f) }
|
935
|
+
else
|
936
|
+
Dir.glob(*args).map {|f| self.new(f) }
|
937
|
+
end
|
938
|
+
end
|
939
|
+
|
940
|
+
# See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname.
|
941
|
+
def Pathname.getwd() self.new(Dir.getwd) end
|
942
|
+
class << self; alias pwd getwd end
|
943
|
+
|
944
|
+
# Pathname#chdir is *obsoleted* at 1.8.1.
|
945
|
+
def chdir(&block)
|
946
|
+
warn "Pathname#chdir is obsoleted. Use Dir.chdir."
|
947
|
+
Dir.chdir(@path, &block)
|
948
|
+
end
|
949
|
+
|
950
|
+
# Pathname#chroot is *obsoleted* at 1.8.1.
|
951
|
+
def chroot
|
952
|
+
warn "Pathname#chroot is obsoleted. Use Dir.chroot."
|
953
|
+
Dir.chroot(@path)
|
954
|
+
end
|
955
|
+
|
956
|
+
# Return the entries (files and subdirectories) in the directory, each as a
|
957
|
+
# Pathname object.
|
958
|
+
def entries() Dir.entries(@path).map {|f| self.class.new(f) } end
|
959
|
+
|
960
|
+
# Iterates over the entries (files and subdirectories) in the directory. It
|
961
|
+
# yields a Pathname object for each entry.
|
962
|
+
#
|
963
|
+
# This method has existed since 1.8.1.
|
964
|
+
def each_entry(&block) # :yield: p
|
965
|
+
Dir.foreach(@path) {|f| yield self.class.new(f) }
|
966
|
+
end
|
967
|
+
|
968
|
+
# Pathname#dir_foreach is *obsoleted* at 1.8.1.
|
969
|
+
def dir_foreach(*args, &block)
|
970
|
+
warn "Pathname#dir_foreach is obsoleted. Use Pathname#each_entry."
|
971
|
+
each_entry(*args, &block)
|
972
|
+
end
|
973
|
+
|
974
|
+
# See <tt>Dir.mkdir</tt>. Create the referenced directory.
|
975
|
+
def mkdir(*args) Dir.mkdir(@path, *args) end
|
976
|
+
|
977
|
+
# See <tt>Dir.rmdir</tt>. Remove the referenced directory.
|
978
|
+
def rmdir() Dir.rmdir(@path) end
|
979
|
+
|
980
|
+
# See <tt>Dir.open</tt>.
|
981
|
+
def opendir(&block) # :yield: dir
|
982
|
+
Dir.open(@path, &block)
|
983
|
+
end
|
984
|
+
end
|
985
|
+
|
986
|
+
|
987
|
+
class Pathname # * Find *
|
988
|
+
#
|
989
|
+
# Pathname#find is an iterator to traverse a directory tree in a depth first
|
990
|
+
# manner. It yields a Pathname for each file under "this" directory.
|
991
|
+
#
|
992
|
+
# Since it is implemented by <tt>find.rb</tt>, <tt>Find.prune</tt> can be used
|
993
|
+
# to control the traverse.
|
994
|
+
#
|
995
|
+
# If +self+ is <tt>.</tt>, yielded pathnames begin with a filename in the
|
996
|
+
# current directory, not <tt>./</tt>.
|
997
|
+
#
|
998
|
+
def find(&block) # :yield: p
|
999
|
+
require 'find'
|
1000
|
+
if @path == '.'
|
1001
|
+
Find.find(@path) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
|
1002
|
+
else
|
1003
|
+
Find.find(@path) {|f| yield self.class.new(f) }
|
1004
|
+
end
|
1005
|
+
end
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
|
1009
|
+
class Pathname # * FileUtils *
|
1010
|
+
# See <tt>FileUtils.mkpath</tt>. Creates a full path, including any
|
1011
|
+
# intermediate directories that don't yet exist.
|
1012
|
+
def mkpath
|
1013
|
+
require 'fileutils'
|
1014
|
+
FileUtils.mkpath(@path)
|
1015
|
+
nil
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
# See <tt>FileUtils.rm_r</tt>. Deletes a directory and all beneath it.
|
1019
|
+
def rmtree
|
1020
|
+
# The name "rmtree" is borrowed from File::Path of Perl.
|
1021
|
+
# File::Path provides "mkpath" and "rmtree".
|
1022
|
+
require 'fileutils'
|
1023
|
+
FileUtils.rm_r(@path)
|
1024
|
+
nil
|
1025
|
+
end
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
|
1029
|
+
class Pathname # * mixed *
|
1030
|
+
# Removes a file or directory, using <tt>File.unlink</tt> or
|
1031
|
+
# <tt>Dir.unlink</tt> as necessary.
|
1032
|
+
def unlink()
|
1033
|
+
begin
|
1034
|
+
Dir.unlink @path
|
1035
|
+
rescue Errno::ENOTDIR
|
1036
|
+
File.unlink @path
|
1037
|
+
end
|
1038
|
+
end
|
1039
|
+
alias delete unlink
|
1040
|
+
|
1041
|
+
# This method is *obsoleted* at 1.8.1. Use #each_line or #each_entry.
|
1042
|
+
def foreach(*args, &block)
|
1043
|
+
warn "Pathname#foreach is obsoleted. Use each_line or each_entry."
|
1044
|
+
if FileTest.directory? @path
|
1045
|
+
# For polymorphism between Dir.foreach and IO.foreach,
|
1046
|
+
# Pathname#foreach doesn't yield Pathname object.
|
1047
|
+
Dir.foreach(@path, *args, &block)
|
1048
|
+
else
|
1049
|
+
IO.foreach(@path, *args, &block)
|
1050
|
+
end
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
module Kernel
|
1055
|
+
# create a pathname object.
|
1056
|
+
#
|
1057
|
+
# This method is available since 1.8.5.
|
1058
|
+
def Pathname(path) # :doc:
|
1059
|
+
Pathname.new(path)
|
1060
|
+
end
|
1061
|
+
private :Pathname
|
1062
|
+
end
|