auser-poolparty 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/examples/monitored_cloud.rb +1 -1
- data/examples/thrift/thrift_example.rb +1 -1
- data/lib/proto/command_interface_handler.rb +1 -1
- data/vendor/gems/thrift/CHANGES +35 -0
- data/vendor/gems/thrift/CONTRIBUTORS +77 -0
- data/vendor/gems/thrift/DISCLAIMER +6 -0
- data/vendor/gems/thrift/LICENSE +202 -0
- data/vendor/gems/thrift/Makefile.am +28 -0
- data/vendor/gems/thrift/NEWS +79 -0
- data/vendor/gems/thrift/NOTICE +26 -0
- data/vendor/gems/thrift/README +137 -0
- data/vendor/gems/thrift/aclocal/ax_boost_base.m4 +198 -0
- data/vendor/gems/thrift/aclocal/ax_javac_and_java.m4 +107 -0
- data/vendor/gems/thrift/aclocal/ax_lib_event.m4 +194 -0
- data/vendor/gems/thrift/aclocal/ax_lib_zlib.m4 +173 -0
- data/vendor/gems/thrift/aclocal/ax_signed_right_shift.m4 +127 -0
- data/vendor/gems/thrift/aclocal/ax_thrift_internal.m4 +39 -0
- data/vendor/gems/thrift/bootstrap.sh +35 -0
- data/vendor/gems/thrift/cleanup.sh +58 -0
- data/vendor/gems/thrift/compiler/cpp/Makefile.am +136 -0
- data/vendor/gems/thrift/compiler/cpp/README +39 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_cocoa_generator.cc +2331 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_cpp_generator.cc +3003 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_csharp_generator.cc +1700 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_erl_generator.cc +932 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_generator.cc +173 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_generator.h +321 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_hs_generator.cc +1445 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_html_generator.cc +637 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_java_generator.cc +3069 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_ocaml_generator.cc +1673 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_oop_generator.h +77 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_perl_generator.cc +1812 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_php_generator.cc +2281 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_py_generator.cc +2310 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_rb_generator.cc +1114 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_st_generator.cc +1071 -0
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_xsd_generator.cc +354 -0
- data/vendor/gems/thrift/compiler/cpp/src/globals.h +117 -0
- data/vendor/gems/thrift/compiler/cpp/src/main.cc +1207 -0
- data/vendor/gems/thrift/compiler/cpp/src/main.h +103 -0
- data/vendor/gems/thrift/compiler/cpp/src/md5.c +381 -0
- data/vendor/gems/thrift/compiler/cpp/src/md5.h +91 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_base_type.h +137 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_const.h +59 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_const_value.h +121 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_container.h +56 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_doc.h +51 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_enum.h +59 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_enum_value.h +64 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_field.h +150 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_function.h +93 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_list.h +56 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_map.h +64 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_program.h +223 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_scope.h +86 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_service.h +68 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_set.h +55 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_struct.h +127 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_type.h +176 -0
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_typedef.h +70 -0
- data/vendor/gems/thrift/compiler/cpp/src/platform.h +36 -0
- data/vendor/gems/thrift/compiler/cpp/src/thriftl.ll +303 -0
- data/vendor/gems/thrift/compiler/cpp/src/thrifty.yy +1140 -0
- data/vendor/gems/thrift/configure.ac +255 -0
- data/vendor/gems/thrift/contrib/fb303/LICENSE +16 -0
- data/vendor/gems/thrift/contrib/fb303/Makefile.am +31 -0
- data/vendor/gems/thrift/contrib/fb303/README +37 -0
- data/vendor/gems/thrift/contrib/fb303/acinclude.m4 +258 -0
- data/vendor/gems/thrift/contrib/fb303/aclocal/ax_boost_base.m4 +198 -0
- data/vendor/gems/thrift/contrib/fb303/bootstrap.sh +26 -0
- data/vendor/gems/thrift/contrib/fb303/configure.ac +115 -0
- data/vendor/gems/thrift/contrib/fb303/cpp/FacebookBase.cpp +124 -0
- data/vendor/gems/thrift/contrib/fb303/cpp/FacebookBase.h +103 -0
- data/vendor/gems/thrift/contrib/fb303/cpp/Makefile.am +84 -0
- data/vendor/gems/thrift/contrib/fb303/cpp/ServiceTracker.cpp +481 -0
- data/vendor/gems/thrift/contrib/fb303/cpp/ServiceTracker.h +215 -0
- data/vendor/gems/thrift/contrib/fb303/global_footer.mk +21 -0
- data/vendor/gems/thrift/contrib/fb303/global_header.mk +38 -0
- data/vendor/gems/thrift/contrib/fb303/if/fb303.thrift +112 -0
- data/vendor/gems/thrift/contrib/fb303/java/FacebookBase.java +103 -0
- data/vendor/gems/thrift/contrib/fb303/java/build.xml +84 -0
- data/vendor/gems/thrift/contrib/fb303/php/FacebookBase.php +89 -0
- data/vendor/gems/thrift/contrib/fb303/py/Makefile.am +44 -0
- data/vendor/gems/thrift/contrib/fb303/py/fb303/FacebookBase.py +82 -0
- data/vendor/gems/thrift/contrib/fb303/py/fb303_scripts/__init__.py +20 -0
- data/vendor/gems/thrift/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py +195 -0
- data/vendor/gems/thrift/contrib/fb303/py/setup.py +27 -0
- data/vendor/gems/thrift/contrib/thrift.el +126 -0
- data/vendor/gems/thrift/contrib/thrift.spec +206 -0
- data/vendor/gems/thrift/contrib/thrift.vim +91 -0
- data/vendor/gems/thrift/contrib/thrift_dump.cpp +91 -0
- data/vendor/gems/thrift/doc/lgpl-2.1.txt +504 -0
- data/vendor/gems/thrift/doc/otp-base-license.txt +20 -0
- data/vendor/gems/thrift/doc/thrift.bnf +96 -0
- data/vendor/gems/thrift/doc/thrift.tex +1057 -0
- data/vendor/gems/thrift/lib/Makefile.am +55 -0
- data/vendor/gems/thrift/lib/cocoa/README +21 -0
- data/vendor/gems/thrift/lib/cocoa/src/TApplicationException.h +44 -0
- data/vendor/gems/thrift/lib/cocoa/src/TApplicationException.m +130 -0
- data/vendor/gems/thrift/lib/cocoa/src/TException.h +34 -0
- data/vendor/gems/thrift/lib/cocoa/src/TException.m +64 -0
- data/vendor/gems/thrift/lib/cocoa/src/TProcessor.h +29 -0
- data/vendor/gems/thrift/lib/cocoa/src/TProcessorFactory.h +27 -0
- data/vendor/gems/thrift/lib/cocoa/src/TSharedProcessorFactory.h +27 -0
- data/vendor/gems/thrift/lib/cocoa/src/TSharedProcessorFactory.m +51 -0
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TBinaryProtocol.h +51 -0
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TBinaryProtocol.m +477 -0
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocol.h +148 -0
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolException.h +25 -0
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolException.m +23 -0
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolFactory.h +29 -0
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolUtil.h +29 -0
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolUtil.m +104 -0
- data/vendor/gems/thrift/lib/cocoa/src/server/TSocketServer.h +50 -0
- data/vendor/gems/thrift/lib/cocoa/src/server/TSocketServer.m +153 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/THTTPClient.h +42 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/THTTPClient.m +159 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.h +35 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.m +91 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TNSStreamTransport.h +38 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TNSStreamTransport.m +89 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TSocketClient.h +32 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TSocketClient.m +58 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TTransport.h +36 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TTransportException.h +30 -0
- data/vendor/gems/thrift/lib/cocoa/src/transport/TTransportException.m +43 -0
- data/vendor/gems/thrift/lib/cpp/Makefile.am +158 -0
- data/vendor/gems/thrift/lib/cpp/README +67 -0
- data/vendor/gems/thrift/lib/cpp/src/TLogging.h +163 -0
- data/vendor/gems/thrift/lib/cpp/src/TProcessor.h +53 -0
- data/vendor/gems/thrift/lib/cpp/src/TReflectionLocal.h +96 -0
- data/vendor/gems/thrift/lib/cpp/src/Thrift.cpp +148 -0
- data/vendor/gems/thrift/lib/cpp/src/Thrift.h +191 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Exception.h +60 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/FunctionRunner.h +77 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Monitor.cpp +137 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Monitor.h +84 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Mutex.cpp +160 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Mutex.h +114 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/PosixThreadFactory.cpp +314 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/PosixThreadFactory.h +130 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Thread.h +125 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/ThreadManager.cpp +493 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/ThreadManager.h +169 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/TimerManager.cpp +284 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/TimerManager.h +122 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Util.cpp +55 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Util.h +100 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/test/Tests.cpp +155 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/test/ThreadFactoryTests.h +354 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/test/ThreadManagerTests.h +379 -0
- data/vendor/gems/thrift/lib/cpp/src/concurrency/test/TimerManagerTests.h +155 -0
- data/vendor/gems/thrift/lib/cpp/src/processor/PeekProcessor.cpp +122 -0
- data/vendor/gems/thrift/lib/cpp/src/processor/PeekProcessor.h +77 -0
- data/vendor/gems/thrift/lib/cpp/src/processor/StatsProcessor.h +264 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TBase64Utils.cpp +79 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TBase64Utils.h +42 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TBinaryProtocol.cpp +394 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TBinaryProtocol.h +254 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TCompactProtocol.cpp +736 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TCompactProtocol.h +279 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TDebugProtocol.cpp +346 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TDebugProtocol.h +225 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TDenseProtocol.cpp +762 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TDenseProtocol.h +253 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TJSONProtocol.cpp +998 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TJSONProtocol.h +340 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TOneWayProtocol.h +304 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocol.h +438 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocolException.h +104 -0
- data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocolTap.h +187 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TNonblockingServer.cpp +750 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TNonblockingServer.h +435 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TServer.cpp +38 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TServer.h +213 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TSimpleServer.cpp +118 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TSimpleServer.h +70 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TThreadPoolServer.cpp +217 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TThreadPoolServer.h +79 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TThreadedServer.cpp +243 -0
- data/vendor/gems/thrift/lib/cpp/src/server/TThreadedServer.h +74 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TBufferTransports.cpp +370 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TBufferTransports.h +667 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TFDTransport.cpp +77 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TFDTransport.h +73 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TFileTransport.cpp +953 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TFileTransport.h +442 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/THttpClient.cpp +348 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/THttpClient.h +111 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TServerSocket.cpp +368 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TServerSocket.h +76 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TServerTransport.h +92 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TShortReadTransport.h +96 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TSimpleFileTransport.cpp +54 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TSimpleFileTransport.h +41 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TSocket.cpp +591 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TSocket.h +242 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TSocketPool.cpp +235 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TSocketPool.h +191 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransport.h +224 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransportException.cpp +31 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransportException.h +117 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransportUtils.cpp +178 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransportUtils.h +287 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TZlibTransport.cpp +299 -0
- data/vendor/gems/thrift/lib/cpp/src/transport/TZlibTransport.h +219 -0
- data/vendor/gems/thrift/lib/cpp/thrift-nb.pc.in +30 -0
- data/vendor/gems/thrift/lib/cpp/thrift-z.pc.in +30 -0
- data/vendor/gems/thrift/lib/cpp/thrift.pc.in +29 -0
- data/vendor/gems/thrift/lib/csharp/Makefile.am +70 -0
- data/vendor/gems/thrift/lib/csharp/README +26 -0
- data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/Properties/AssemblyInfo.cs +55 -0
- data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/ThriftBuild.cs +242 -0
- data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/ThriftMSBuildTask.csproj +62 -0
- data/vendor/gems/thrift/lib/csharp/src/Collections/THashSet.cs +142 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TBase.cs +34 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TBinaryProtocol.cs +392 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TField.cs +58 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TList.cs +50 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TMap.cs +58 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TMessage.cs +58 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TMessageType.cs +31 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocol.cs +87 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolException.cs +61 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolFactory.cs +29 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolUtil.cs +94 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TSet.cs +50 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TStruct.cs +42 -0
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TType.cs +40 -0
- data/vendor/gems/thrift/lib/csharp/src/Server/TServer.cs +135 -0
- data/vendor/gems/thrift/lib/csharp/src/Server/TSimpleServer.cs +148 -0
- data/vendor/gems/thrift/lib/csharp/src/Server/TThreadPoolServer.cs +186 -0
- data/vendor/gems/thrift/lib/csharp/src/Server/TThreadedServer.cs +234 -0
- data/vendor/gems/thrift/lib/csharp/src/TApplicationException.cs +131 -0
- data/vendor/gems/thrift/lib/csharp/src/TProcessor.cs +29 -0
- data/vendor/gems/thrift/lib/csharp/src/Thrift.csproj +73 -0
- data/vendor/gems/thrift/lib/csharp/src/Thrift.sln +35 -0
- data/vendor/gems/thrift/lib/csharp/src/Transport/TBufferedTransport.cs +100 -0
- data/vendor/gems/thrift/lib/csharp/src/Transport/TServerSocket.cs +157 -0
- data/vendor/gems/thrift/lib/csharp/src/Transport/TServerTransport.cs +39 -0
- data/vendor/gems/thrift/lib/csharp/src/Transport/TSocket.cs +144 -0
- data/vendor/gems/thrift/lib/csharp/src/Transport/TStreamTransport.cs +103 -0
- data/vendor/gems/thrift/lib/csharp/src/Transport/TTransport.cs +66 -0
- data/vendor/gems/thrift/lib/csharp/src/Transport/TTransportException.cs +64 -0
- data/vendor/gems/thrift/lib/csharp/src/Transport/TTransportFactory.cs +38 -0
- data/vendor/gems/thrift/lib/erl/Makefile +37 -0
- data/vendor/gems/thrift/lib/erl/README +56 -0
- data/vendor/gems/thrift/lib/erl/build/beamver +59 -0
- data/vendor/gems/thrift/lib/erl/build/buildtargets.mk +15 -0
- data/vendor/gems/thrift/lib/erl/build/colors.mk +24 -0
- data/vendor/gems/thrift/lib/erl/build/docs.mk +12 -0
- data/vendor/gems/thrift/lib/erl/build/mime.types +98 -0
- data/vendor/gems/thrift/lib/erl/build/otp.mk +146 -0
- data/vendor/gems/thrift/lib/erl/build/otp_subdir.mk +85 -0
- data/vendor/gems/thrift/lib/erl/build/raw_test.mk +29 -0
- data/vendor/gems/thrift/lib/erl/include/thrift_constants.hrl +54 -0
- data/vendor/gems/thrift/lib/erl/include/thrift_protocol.hrl +31 -0
- data/vendor/gems/thrift/lib/erl/src/Makefile +116 -0
- data/vendor/gems/thrift/lib/erl/src/test_handler.erl +26 -0
- data/vendor/gems/thrift/lib/erl/src/test_service.erl +29 -0
- data/vendor/gems/thrift/lib/erl/src/thrift.app.src +44 -0
- data/vendor/gems/thrift/lib/erl/src/thrift.appup.src +1 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_base64_transport.erl +64 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_binary_protocol.erl +325 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_buffered_transport.erl +180 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_client.erl +384 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_disk_log_transport.erl +118 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_file_transport.erl +87 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_framed_transport.erl +208 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_http_transport.erl +199 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_memory_buffer.erl +164 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_processor.erl +188 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_protocol.erl +356 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_server.erl +183 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_service.erl +25 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_socket_server.erl +249 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_socket_transport.erl +119 -0
- data/vendor/gems/thrift/lib/erl/src/thrift_transport.erl +57 -0
- data/vendor/gems/thrift/lib/erl/vsn.mk +1 -0
- data/vendor/gems/thrift/lib/hs/README +82 -0
- data/vendor/gems/thrift/lib/hs/Setup.lhs +23 -0
- data/vendor/gems/thrift/lib/hs/TODO +2 -0
- data/vendor/gems/thrift/lib/hs/Thrift.cabal +20 -0
- data/vendor/gems/thrift/lib/hs/src/Thrift.hs +111 -0
- data/vendor/gems/thrift/lib/hs/src/Thrift/Protocol.hs +191 -0
- data/vendor/gems/thrift/lib/hs/src/Thrift/Protocol/Binary.hs +147 -0
- data/vendor/gems/thrift/lib/hs/src/Thrift/Server.hs +65 -0
- data/vendor/gems/thrift/lib/hs/src/Thrift/Transport.hs +60 -0
- data/vendor/gems/thrift/lib/hs/src/Thrift/Transport/Handle.hs +58 -0
- data/vendor/gems/thrift/lib/java/Makefile.am +38 -0
- data/vendor/gems/thrift/lib/java/README +43 -0
- data/vendor/gems/thrift/lib/java/build.xml +195 -0
- data/vendor/gems/thrift/lib/java/ivy.xml +8 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/IntRangeSet.java +171 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TApplicationException.java +123 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TBase.java +66 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TBaseHelper.java +102 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java +46 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TDeserializer.java +94 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TException.java +45 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TFieldRequirementType.java +30 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TProcessor.java +32 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TProcessorFactory.java +39 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TSerializer.java +110 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java +69 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/FieldValueMetaData.java +42 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/ListMetaData.java +29 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/MapMetaData.java +31 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/SetMetaData.java +29 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/StructMetaData.java +31 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TBase64Utils.java +128 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java +331 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java +741 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TField.java +48 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TJSONProtocol.java +927 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TList.java +38 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMap.java +40 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMessage.java +48 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMessageType.java +31 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocol.java +146 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolException.java +81 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolFactory.java +30 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolUtil.java +158 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TSet.java +42 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TSimpleJSONProtocol.java +384 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TStruct.java +36 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TType.java +40 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/THsHaServer.java +304 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TNonblockingServer.java +772 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TServer.java +126 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TSimpleServer.java +145 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java +271 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TFramedTransport.java +126 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/THttpClient.java +157 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TIOStreamTransport.java +159 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TMemoryBuffer.java +98 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingServerSocket.java +160 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingServerTransport.java +31 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingSocket.java +213 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingTransport.java +31 -0
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TServerSocket.java +145 -0
- metadata +348 -37
- data/vendor/gems/trollop/FAQ.txt +0 -35
- data/vendor/gems/trollop/History.txt +0 -84
- data/vendor/gems/trollop/Manifest.txt +0 -7
- data/vendor/gems/trollop/README.txt +0 -38
- data/vendor/gems/trollop/Rakefile +0 -36
- data/vendor/gems/trollop/lib/trollop.rb +0 -695
- data/vendor/gems/trollop/release-script.txt +0 -13
- data/vendor/gems/trollop/test/test_trollop.rb +0 -957
- data/vendor/gems/trollop/www/index.html +0 -167
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Just a few simple steps to make a new release.
|
|
2
|
-
|
|
3
|
-
vi lib/trollop.rb # and bump version number
|
|
4
|
-
vi History.txt # and describe changes
|
|
5
|
-
git-rank-contributors -o -h >> www/index.html
|
|
6
|
-
vi www/index.html # and integrate contributors
|
|
7
|
-
rake upload_webpage
|
|
8
|
-
rake upload_docs
|
|
9
|
-
rake release VERSION=<releasename>
|
|
10
|
-
git commit -a -m "bump to..."
|
|
11
|
-
git tag release-<releasename>
|
|
12
|
-
git push
|
|
13
|
-
git push --tags
|
|
@@ -1,957 +0,0 @@
|
|
|
1
|
-
## test/test_trollop.rb -- unit tests for trollop
|
|
2
|
-
## Author:: William Morgan (mailto: wmorgan-trollop@masanjin.net)
|
|
3
|
-
## Copyright:: Copyright 2007 William Morgan
|
|
4
|
-
## License:: GNU GPL version 2
|
|
5
|
-
|
|
6
|
-
require 'test/unit'
|
|
7
|
-
require 'stringio'
|
|
8
|
-
require 'trollop'
|
|
9
|
-
|
|
10
|
-
module Trollop
|
|
11
|
-
module Test
|
|
12
|
-
|
|
13
|
-
class Trollop < ::Test::Unit::TestCase
|
|
14
|
-
def setup
|
|
15
|
-
@p = Parser.new
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_unknown_arguments
|
|
19
|
-
assert_raise(CommandlineError) { @p.parse(%w(--arg)) }
|
|
20
|
-
@p.opt "arg"
|
|
21
|
-
assert_nothing_raised { @p.parse(%w(--arg)) }
|
|
22
|
-
assert_raise(CommandlineError) { @p.parse(%w(--arg2)) }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_syntax_check
|
|
26
|
-
@p.opt "arg"
|
|
27
|
-
|
|
28
|
-
assert_nothing_raised { @p.parse(%w(--arg)) }
|
|
29
|
-
assert_nothing_raised { @p.parse(%w(arg)) }
|
|
30
|
-
assert_raise(CommandlineError) { @p.parse(%w(---arg)) }
|
|
31
|
-
assert_raise(CommandlineError) { @p.parse(%w(-arg)) }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def test_required_flags_are_required
|
|
35
|
-
@p.opt "arg", "desc", :required => true
|
|
36
|
-
@p.opt "arg2", "desc", :required => false
|
|
37
|
-
@p.opt "arg3", "desc", :required => false
|
|
38
|
-
|
|
39
|
-
assert_nothing_raised { @p.parse(%w(--arg)) }
|
|
40
|
-
assert_nothing_raised { @p.parse(%w(--arg --arg2)) }
|
|
41
|
-
assert_raise(CommandlineError) { @p.parse(%w(--arg2)) }
|
|
42
|
-
assert_raise(CommandlineError) { @p.parse(%w(--arg2 --arg3)) }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
## flags that take an argument error unless given one
|
|
46
|
-
def test_argflags_demand_args
|
|
47
|
-
@p.opt "goodarg", "desc", :type => String
|
|
48
|
-
@p.opt "goodarg2", "desc", :type => String
|
|
49
|
-
|
|
50
|
-
assert_nothing_raised { @p.parse(%w(--goodarg goat)) }
|
|
51
|
-
assert_raise(CommandlineError) { @p.parse(%w(--goodarg --goodarg2 goat)) }
|
|
52
|
-
assert_raise(CommandlineError) { @p.parse(%w(--goodarg)) }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
## flags that don't take arguments ignore them
|
|
56
|
-
def test_arglessflags_refuse_args
|
|
57
|
-
@p.opt "goodarg"
|
|
58
|
-
@p.opt "goodarg2"
|
|
59
|
-
assert_nothing_raised { @p.parse(%w(--goodarg)) }
|
|
60
|
-
assert_nothing_raised { @p.parse(%w(--goodarg --goodarg2)) }
|
|
61
|
-
opts = @p.parse %w(--goodarg a)
|
|
62
|
-
assert_equal true, opts["goodarg"]
|
|
63
|
-
assert_equal ["a"], @p.leftovers
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
## flags that require args of a specific type refuse args of other
|
|
67
|
-
## types
|
|
68
|
-
def test_typed_args_refuse_args_of_other_types
|
|
69
|
-
assert_nothing_raised { @p.opt "goodarg", "desc", :type => :int }
|
|
70
|
-
assert_raise(ArgumentError) { @p.opt "badarg", "desc", :type => :asdf }
|
|
71
|
-
|
|
72
|
-
assert_nothing_raised { @p.parse(%w(--goodarg 3)) }
|
|
73
|
-
assert_raise(CommandlineError) { @p.parse(%w(--goodarg 4.2)) }
|
|
74
|
-
assert_raise(CommandlineError) { @p.parse(%w(--goodarg hello)) }
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
## type is correctly derived from :default
|
|
78
|
-
def test_type_correctly_derived_from_default
|
|
79
|
-
assert_raise(ArgumentError) { @p.opt "badarg", "desc", :default => [] }
|
|
80
|
-
|
|
81
|
-
opts = nil
|
|
82
|
-
|
|
83
|
-
# single arg: int
|
|
84
|
-
assert_nothing_raised { @p.opt "argsi", "desc", :default => 0 }
|
|
85
|
-
assert_nothing_raised { opts = @p.parse("--") }
|
|
86
|
-
assert_equal 0, opts["argsi"]
|
|
87
|
-
assert_nothing_raised { opts = @p.parse(%w(--argsi 4)) }
|
|
88
|
-
assert_equal 4, opts["argsi"]
|
|
89
|
-
assert_raise(CommandlineError) { @p.parse(%w(--argsi 4.2)) }
|
|
90
|
-
assert_raise(CommandlineError) { @p.parse(%w(--argsi hello)) }
|
|
91
|
-
|
|
92
|
-
# single arg: float
|
|
93
|
-
assert_nothing_raised { @p.opt "argsf", "desc", :default => 3.14 }
|
|
94
|
-
assert_nothing_raised { opts = @p.parse("--") }
|
|
95
|
-
assert_equal 3.14, opts["argsf"]
|
|
96
|
-
assert_nothing_raised { opts = @p.parse(%w(--argsf 2.41)) }
|
|
97
|
-
assert_equal 2.41, opts["argsf"]
|
|
98
|
-
assert_nothing_raised { opts = @p.parse(%w(--argsf 2)) }
|
|
99
|
-
assert_equal 2, opts["argsf"]
|
|
100
|
-
assert_raise(CommandlineError) { @p.parse(%w(--argsf hello)) }
|
|
101
|
-
|
|
102
|
-
# single arg: string
|
|
103
|
-
assert_nothing_raised { @p.opt "argss", "desc", :default => "foobar" }
|
|
104
|
-
assert_nothing_raised { opts = @p.parse("--") }
|
|
105
|
-
assert_equal "foobar", opts["argss"]
|
|
106
|
-
assert_nothing_raised { opts = @p.parse(%w(--argss 2.41)) }
|
|
107
|
-
assert_equal "2.41", opts["argss"]
|
|
108
|
-
assert_nothing_raised { opts = @p.parse(%w(--argss hello)) }
|
|
109
|
-
assert_equal "hello", opts["argss"]
|
|
110
|
-
|
|
111
|
-
# multi args: ints
|
|
112
|
-
assert_nothing_raised { @p.opt "argmi", "desc", :default => [3, 5] }
|
|
113
|
-
assert_nothing_raised { opts = @p.parse("--") }
|
|
114
|
-
assert_equal [3, 5], opts["argmi"]
|
|
115
|
-
assert_nothing_raised { opts = @p.parse(%w(--argmi 4)) }
|
|
116
|
-
assert_equal [4], opts["argmi"]
|
|
117
|
-
assert_raise(CommandlineError) { @p.parse(%w(--argmi 4.2)) }
|
|
118
|
-
assert_raise(CommandlineError) { @p.parse(%w(--argmi hello)) }
|
|
119
|
-
|
|
120
|
-
# multi args: floats
|
|
121
|
-
assert_nothing_raised { @p.opt "argmf", "desc", :default => [3.34, 5.21] }
|
|
122
|
-
assert_nothing_raised { opts = @p.parse("--") }
|
|
123
|
-
assert_equal [3.34, 5.21], opts["argmf"]
|
|
124
|
-
assert_nothing_raised { opts = @p.parse(%w(--argmf 2)) }
|
|
125
|
-
assert_equal [2], opts["argmf"]
|
|
126
|
-
assert_nothing_raised { opts = @p.parse(%w(--argmf 4.0)) }
|
|
127
|
-
assert_equal [4.0], opts["argmf"]
|
|
128
|
-
assert_raise(CommandlineError) { @p.parse(%w(--argmf hello)) }
|
|
129
|
-
|
|
130
|
-
# multi args: strings
|
|
131
|
-
assert_nothing_raised { @p.opt "argms", "desc", :default => %w(hello world) }
|
|
132
|
-
assert_nothing_raised { opts = @p.parse("--") }
|
|
133
|
-
assert_equal %w(hello world), opts["argms"]
|
|
134
|
-
assert_nothing_raised { opts = @p.parse(%w(--argms 3.4)) }
|
|
135
|
-
assert_equal ["3.4"], opts["argms"]
|
|
136
|
-
assert_nothing_raised { opts = @p.parse(%w(--argms goodbye)) }
|
|
137
|
-
assert_equal ["goodbye"], opts["argms"]
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
## :type and :default must match if both are specified
|
|
141
|
-
def test_type_and_default_must_match
|
|
142
|
-
assert_raise(ArgumentError) { @p.opt "badarg", "desc", :type => :int, :default => "hello" }
|
|
143
|
-
assert_raise(ArgumentError) { @p.opt "badarg2", "desc", :type => :String, :default => 4 }
|
|
144
|
-
assert_raise(ArgumentError) { @p.opt "badarg2", "desc", :type => :String, :default => ["hi"] }
|
|
145
|
-
assert_raise(ArgumentError) { @p.opt "badarg2", "desc", :type => :ints, :default => [3.14] }
|
|
146
|
-
|
|
147
|
-
assert_nothing_raised { @p.opt "argsi", "desc", :type => :int, :default => 4 }
|
|
148
|
-
assert_nothing_raised { @p.opt "argsf", "desc", :type => :float, :default => 3.14 }
|
|
149
|
-
assert_nothing_raised { @p.opt "argss", "desc", :type => :string, :default => "yo" }
|
|
150
|
-
assert_nothing_raised { @p.opt "argmi", "desc", :type => :ints, :default => [4] }
|
|
151
|
-
assert_nothing_raised { @p.opt "argmf", "desc", :type => :floats, :default => [3.14] }
|
|
152
|
-
assert_nothing_raised { @p.opt "argms", "desc", :type => :strings, :default => ["yo"] }
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def test_long_detects_bad_names
|
|
156
|
-
assert_nothing_raised { @p.opt "goodarg", "desc", :long => "none" }
|
|
157
|
-
assert_nothing_raised { @p.opt "goodarg2", "desc", :long => "--two" }
|
|
158
|
-
assert_raise(ArgumentError) { @p.opt "badarg", "desc", :long => "" }
|
|
159
|
-
assert_raise(ArgumentError) { @p.opt "badarg2", "desc", :long => "--" }
|
|
160
|
-
assert_raise(ArgumentError) { @p.opt "badarg3", "desc", :long => "-one" }
|
|
161
|
-
assert_raise(ArgumentError) { @p.opt "badarg4", "desc", :long => "---toomany" }
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def test_short_detects_bad_names
|
|
165
|
-
assert_nothing_raised { @p.opt "goodarg", "desc", :short => "a" }
|
|
166
|
-
assert_nothing_raised { @p.opt "goodarg2", "desc", :short => "-b" }
|
|
167
|
-
assert_raise(ArgumentError) { @p.opt "badarg", "desc", :short => "" }
|
|
168
|
-
assert_raise(ArgumentError) { @p.opt "badarg2", "desc", :short => "-ab" }
|
|
169
|
-
assert_raise(ArgumentError) { @p.opt "badarg3", "desc", :short => "--t" }
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def test_short_names_created_automatically
|
|
173
|
-
@p.opt "arg"
|
|
174
|
-
@p.opt "arg2"
|
|
175
|
-
@p.opt "arg3"
|
|
176
|
-
assert_raise(ArgumentError) { @p.opt "gra" }
|
|
177
|
-
opts = @p.parse %w(-a -g)
|
|
178
|
-
assert_equal true, opts["arg"]
|
|
179
|
-
assert_equal false, opts["arg2"]
|
|
180
|
-
assert_equal true, opts["arg3"]
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def test_short_autocreation_skips_dashes_and_numbers
|
|
184
|
-
@p.opt :arg # auto: a
|
|
185
|
-
@p.opt :arg_potato # auto: r
|
|
186
|
-
@p.opt :arg_muffin # auto: g
|
|
187
|
-
assert_nothing_raised { @p.opt :arg_daisy } # auto: d (not _)!
|
|
188
|
-
assert_nothing_raised { @p.opt :arg_r2d2f } # auto: f (not 2)!
|
|
189
|
-
|
|
190
|
-
opts = @p.parse %w(-f -d)
|
|
191
|
-
assert_equal true, opts[:arg_daisy]
|
|
192
|
-
assert_equal true, opts[:arg_r2d2f]
|
|
193
|
-
assert_equal false, opts[:arg]
|
|
194
|
-
assert_equal false, opts[:arg_potato]
|
|
195
|
-
assert_equal false, opts[:arg_muffin]
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
def test_short_autocreation_detects_running_out
|
|
199
|
-
@p.opt :arg1 # auto: a
|
|
200
|
-
@p.opt :arg2 # auto: r
|
|
201
|
-
@p.opt :arg3 # auto: g
|
|
202
|
-
assert_raises(ArgumentError) { @p.opt :arg4 }
|
|
203
|
-
assert_nothing_raised { @p.opt :argf }
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
def test_short_can_be_nothing
|
|
207
|
-
assert_nothing_raised do
|
|
208
|
-
@p.opt "arg", "desc", :short => :none
|
|
209
|
-
@p.parse []
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
sio = StringIO.new "w"
|
|
213
|
-
@p.educate sio
|
|
214
|
-
assert sio.string =~ /--arg:\s+desc/
|
|
215
|
-
|
|
216
|
-
assert_raise(CommandlineError) { @p.parse %w(-a) }
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
## two args can't have the same name
|
|
220
|
-
def test_conflicting_names_are_detected
|
|
221
|
-
assert_nothing_raised { @p.opt "goodarg" }
|
|
222
|
-
assert_raise(ArgumentError) { @p.opt "goodarg" }
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
## two args can't have the same :long
|
|
226
|
-
def test_conflicting_longs_detected
|
|
227
|
-
assert_nothing_raised { @p.opt "goodarg", "desc", :long => "--goodarg" }
|
|
228
|
-
assert_raise(ArgumentError) { @p.opt "badarg", "desc", :long => "--goodarg" }
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
## two args can't have the same :short
|
|
232
|
-
def test_conflicting_shorts_detected
|
|
233
|
-
assert_nothing_raised { @p.opt "goodarg", "desc", :short => "-g" }
|
|
234
|
-
assert_raise(ArgumentError) { @p.opt "badarg", "desc", :short => "-g" }
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
def test_flag_defaults
|
|
238
|
-
@p.opt "defaultfalse", "desc"
|
|
239
|
-
@p.opt "defaulttrue", "desc", :default => true
|
|
240
|
-
opts = @p.parse []
|
|
241
|
-
assert_equal false, opts["defaultfalse"]
|
|
242
|
-
assert_equal true, opts["defaulttrue"]
|
|
243
|
-
|
|
244
|
-
opts = @p.parse %w(--defaultfalse --defaulttrue)
|
|
245
|
-
assert_equal true, opts["defaultfalse"]
|
|
246
|
-
assert_equal false, opts["defaulttrue"]
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
def test_special_flags_work
|
|
250
|
-
@p.version "asdf fdas"
|
|
251
|
-
assert_raise(VersionNeeded) { @p.parse(%w(-v)) }
|
|
252
|
-
assert_raise(HelpNeeded) { @p.parse(%w(-h)) }
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
def test_short_options_combine
|
|
256
|
-
@p.opt :arg1, "desc", :short => "a"
|
|
257
|
-
@p.opt :arg2, "desc", :short => "b"
|
|
258
|
-
@p.opt :arg3, "desc", :short => "c", :type => :int
|
|
259
|
-
|
|
260
|
-
opts = nil
|
|
261
|
-
assert_nothing_raised { opts = @p.parse %w(-a -b) }
|
|
262
|
-
assert_equal true, opts[:arg1]
|
|
263
|
-
assert_equal true, opts[:arg2]
|
|
264
|
-
assert_equal nil, opts[:arg3]
|
|
265
|
-
|
|
266
|
-
assert_nothing_raised { opts = @p.parse %w(-ab) }
|
|
267
|
-
assert_equal true, opts[:arg1]
|
|
268
|
-
assert_equal true, opts[:arg2]
|
|
269
|
-
assert_equal nil, opts[:arg3]
|
|
270
|
-
|
|
271
|
-
assert_nothing_raised { opts = @p.parse %w(-ac 4 -b) }
|
|
272
|
-
assert_equal true, opts[:arg1]
|
|
273
|
-
assert_equal true, opts[:arg2]
|
|
274
|
-
assert_equal 4, opts[:arg3]
|
|
275
|
-
|
|
276
|
-
assert_raises(CommandlineError) { @p.parse %w(-cab 4) }
|
|
277
|
-
assert_raises(CommandlineError) { @p.parse %w(-cba 4) }
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
def test_version_only_appears_if_set
|
|
281
|
-
@p.opt "arg"
|
|
282
|
-
assert_raise(CommandlineError) { @p.parse %w(-v) }
|
|
283
|
-
@p.version "trollop 1.2.3.4"
|
|
284
|
-
assert_raise(VersionNeeded) { @p.parse %w(-v) }
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
def test_doubledash_ends_option_processing
|
|
288
|
-
@p.opt :arg1, "desc", :short => "a", :default => 0
|
|
289
|
-
@p.opt :arg2, "desc", :short => "b", :default => 0
|
|
290
|
-
opts = nil
|
|
291
|
-
assert_nothing_raised { opts = @p.parse %w(-- -a 3 -b 2) }
|
|
292
|
-
assert_equal opts[:arg1], 0
|
|
293
|
-
assert_equal opts[:arg2], 0
|
|
294
|
-
assert_equal %w(-a 3 -b 2), @p.leftovers
|
|
295
|
-
assert_nothing_raised { opts = @p.parse %w(-a 3 -- -b 2) }
|
|
296
|
-
assert_equal opts[:arg1], 3
|
|
297
|
-
assert_equal opts[:arg2], 0
|
|
298
|
-
assert_equal %w(-b 2), @p.leftovers
|
|
299
|
-
assert_nothing_raised { opts = @p.parse %w(-a 3 -b 2 --) }
|
|
300
|
-
assert_equal opts[:arg1], 3
|
|
301
|
-
assert_equal opts[:arg2], 2
|
|
302
|
-
assert_equal %w(), @p.leftovers
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
def test_wrap
|
|
306
|
-
assert_equal [""], @p.wrap("")
|
|
307
|
-
assert_equal ["a"], @p.wrap("a")
|
|
308
|
-
assert_equal ["one two", "three"], @p.wrap("one two three", :width => 8)
|
|
309
|
-
assert_equal ["one two three"], @p.wrap("one two three", :width => 80)
|
|
310
|
-
assert_equal ["one", "two", "three"], @p.wrap("one two three", :width => 3)
|
|
311
|
-
assert_equal ["onetwothree"], @p.wrap("onetwothree", :width => 3)
|
|
312
|
-
assert_equal [
|
|
313
|
-
"Test is an awesome program that does something very, very important.",
|
|
314
|
-
"",
|
|
315
|
-
"Usage:",
|
|
316
|
-
" test [options] <filenames>+",
|
|
317
|
-
"where [options] are:"], @p.wrap(<<EOM, :width => 100)
|
|
318
|
-
Test is an awesome program that does something very, very important.
|
|
319
|
-
|
|
320
|
-
Usage:
|
|
321
|
-
test [options] <filenames>+
|
|
322
|
-
where [options] are:
|
|
323
|
-
EOM
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
def test_floating_point_formatting
|
|
327
|
-
@p.opt :arg, "desc", :type => :float, :short => "f"
|
|
328
|
-
opts = nil
|
|
329
|
-
assert_nothing_raised { opts = @p.parse %w(-f 1) }
|
|
330
|
-
assert_equal 1.0, opts[:arg]
|
|
331
|
-
assert_nothing_raised { opts = @p.parse %w(-f 1.0) }
|
|
332
|
-
assert_equal 1.0, opts[:arg]
|
|
333
|
-
assert_nothing_raised { opts = @p.parse %w(-f 0.1) }
|
|
334
|
-
assert_equal 0.1, opts[:arg]
|
|
335
|
-
assert_nothing_raised { opts = @p.parse %w(-f .1) }
|
|
336
|
-
assert_equal 0.1, opts[:arg]
|
|
337
|
-
assert_nothing_raised { opts = @p.parse %w(-f .99999999999999999999) }
|
|
338
|
-
assert_equal 1.0, opts[:arg]
|
|
339
|
-
assert_nothing_raised { opts = @p.parse %w(-f -1) }
|
|
340
|
-
assert_equal(-1.0, opts[:arg])
|
|
341
|
-
assert_nothing_raised { opts = @p.parse %w(-f -1.0) }
|
|
342
|
-
assert_equal(-1.0, opts[:arg])
|
|
343
|
-
assert_nothing_raised { opts = @p.parse %w(-f -0.1) }
|
|
344
|
-
assert_equal(-0.1, opts[:arg])
|
|
345
|
-
assert_nothing_raised { opts = @p.parse %w(-f -.1) }
|
|
346
|
-
assert_equal(-0.1, opts[:arg])
|
|
347
|
-
assert_raises(CommandlineError) { @p.parse %w(-f a) }
|
|
348
|
-
assert_raises(CommandlineError) { @p.parse %w(-f 1a) }
|
|
349
|
-
assert_raises(CommandlineError) { @p.parse %w(-f 1.a) }
|
|
350
|
-
assert_raises(CommandlineError) { @p.parse %w(-f a.1) }
|
|
351
|
-
assert_raises(CommandlineError) { @p.parse %w(-f 1.0.0) }
|
|
352
|
-
assert_raises(CommandlineError) { @p.parse %w(-f .) }
|
|
353
|
-
assert_raises(CommandlineError) { @p.parse %w(-f -.) }
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
def test_short_options_cant_be_numeric
|
|
357
|
-
assert_raises(ArgumentError) { @p.opt :arg, "desc", :short => "-1" }
|
|
358
|
-
@p.opt :a1b, "desc"
|
|
359
|
-
@p.opt :a2b, "desc"
|
|
360
|
-
assert_not_equal "2", @p.specs[:a2b][:short]
|
|
361
|
-
end
|
|
362
|
-
|
|
363
|
-
def test_short_options_can_be_weird
|
|
364
|
-
assert_nothing_raised { @p.opt :arg1, "desc", :short => "#" }
|
|
365
|
-
assert_nothing_raised { @p.opt :arg2, "desc", :short => "." }
|
|
366
|
-
assert_raises(ArgumentError) { @p.opt :arg3, "desc", :short => "-" }
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
def test_options_cant_be_set_multiple_times_if_not_specified
|
|
370
|
-
@p.opt :arg, "desc", :short => "-x"
|
|
371
|
-
assert_nothing_raised { @p.parse %w(-x) }
|
|
372
|
-
assert_raises(CommandlineError) { @p.parse %w(-x -x) }
|
|
373
|
-
assert_raises(CommandlineError) { @p.parse %w(-xx) }
|
|
374
|
-
end
|
|
375
|
-
|
|
376
|
-
def test_options_can_be_set_multiple_times_if_specified
|
|
377
|
-
assert_nothing_raised do
|
|
378
|
-
@p.opt :arg, "desc", :short => "-x", :multi => true
|
|
379
|
-
end
|
|
380
|
-
assert_nothing_raised { @p.parse %w(-x) }
|
|
381
|
-
assert_nothing_raised { @p.parse %w(-x -x) }
|
|
382
|
-
assert_nothing_raised { @p.parse %w(-xx) }
|
|
383
|
-
end
|
|
384
|
-
|
|
385
|
-
def test_short_options_with_multiple_options
|
|
386
|
-
opts = nil
|
|
387
|
-
|
|
388
|
-
assert_nothing_raised do
|
|
389
|
-
@p.opt :xarg, "desc", :short => "-x", :type => String, :multi => true
|
|
390
|
-
end
|
|
391
|
-
assert_nothing_raised { opts = @p.parse %w(-x a -x b) }
|
|
392
|
-
assert_equal %w(a b), opts[:xarg]
|
|
393
|
-
assert_equal [], @p.leftovers
|
|
394
|
-
end
|
|
395
|
-
|
|
396
|
-
def short_options_with_multiple_options_does_not_affect_flags_type
|
|
397
|
-
opts = nil
|
|
398
|
-
|
|
399
|
-
assert_nothing_raised do
|
|
400
|
-
@p.opt :xarg, "desc", :short => "-x", :type => :flag, :multi => true
|
|
401
|
-
end
|
|
402
|
-
|
|
403
|
-
assert_nothing_raised { opts = @p.parse %w(-x a) }
|
|
404
|
-
assert_equal true, opts[:xarg]
|
|
405
|
-
assert_equal %w(a), @p.leftovers
|
|
406
|
-
|
|
407
|
-
assert_nothing_raised { opts = @p.parse %w(-x a -x b) }
|
|
408
|
-
assert_equal true, opts[:xarg]
|
|
409
|
-
assert_equal %w(a b), @p.leftovers
|
|
410
|
-
|
|
411
|
-
assert_nothing_raised { opts = @p.parse %w(-xx a -x b) }
|
|
412
|
-
assert_equal true, opts[:xarg]
|
|
413
|
-
assert_equal %w(a b), @p.leftovers
|
|
414
|
-
end
|
|
415
|
-
|
|
416
|
-
def test_short_options_with_multiple_arguments
|
|
417
|
-
opts = nil
|
|
418
|
-
|
|
419
|
-
@p.opt :xarg, "desc", :type => :ints
|
|
420
|
-
assert_nothing_raised { opts = @p.parse %w(-x 3 4 0) }
|
|
421
|
-
assert_equal [3, 4, 0], opts[:xarg]
|
|
422
|
-
assert_equal [], @p.leftovers
|
|
423
|
-
|
|
424
|
-
@p.opt :yarg, "desc", :type => :floats
|
|
425
|
-
assert_nothing_raised { opts = @p.parse %w(-y 3.14 4.21 0.66) }
|
|
426
|
-
assert_equal [3.14, 4.21, 0.66], opts[:yarg]
|
|
427
|
-
assert_equal [], @p.leftovers
|
|
428
|
-
|
|
429
|
-
@p.opt :zarg, "desc", :type => :strings
|
|
430
|
-
assert_nothing_raised { opts = @p.parse %w(-z a b c) }
|
|
431
|
-
assert_equal %w(a b c), opts[:zarg]
|
|
432
|
-
assert_equal [], @p.leftovers
|
|
433
|
-
end
|
|
434
|
-
|
|
435
|
-
def test_short_options_with_multiple_options_and_arguments
|
|
436
|
-
opts = nil
|
|
437
|
-
|
|
438
|
-
@p.opt :xarg, "desc", :type => :ints, :multi => true
|
|
439
|
-
assert_nothing_raised { opts = @p.parse %w(-x 3 4 5 -x 6 7) }
|
|
440
|
-
assert_equal [[3, 4, 5], [6, 7]], opts[:xarg]
|
|
441
|
-
assert_equal [], @p.leftovers
|
|
442
|
-
|
|
443
|
-
@p.opt :yarg, "desc", :type => :floats, :multi => true
|
|
444
|
-
assert_nothing_raised { opts = @p.parse %w(-y 3.14 4.21 5.66 -y 6.99 7.01) }
|
|
445
|
-
assert_equal [[3.14, 4.21, 5.66], [6.99, 7.01]], opts[:yarg]
|
|
446
|
-
assert_equal [], @p.leftovers
|
|
447
|
-
|
|
448
|
-
@p.opt :zarg, "desc", :type => :strings, :multi => true
|
|
449
|
-
assert_nothing_raised { opts = @p.parse %w(-z a b c -z d e) }
|
|
450
|
-
assert_equal [%w(a b c), %w(d e)], opts[:zarg]
|
|
451
|
-
assert_equal [], @p.leftovers
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
def test_combined_short_options_with_multiple_arguments
|
|
455
|
-
@p.opt :arg1, "desc", :short => "a"
|
|
456
|
-
@p.opt :arg2, "desc", :short => "b"
|
|
457
|
-
@p.opt :arg3, "desc", :short => "c", :type => :ints
|
|
458
|
-
@p.opt :arg4, "desc", :short => "d", :type => :floats
|
|
459
|
-
|
|
460
|
-
opts = nil
|
|
461
|
-
|
|
462
|
-
assert_nothing_raised { opts = @p.parse %w(-abc 4 6 9) }
|
|
463
|
-
assert_equal true, opts[:arg1]
|
|
464
|
-
assert_equal true, opts[:arg2]
|
|
465
|
-
assert_equal [4, 6, 9], opts[:arg3]
|
|
466
|
-
|
|
467
|
-
assert_nothing_raised { opts = @p.parse %w(-ac 4 6 9 -bd 3.14 2.41) }
|
|
468
|
-
assert_equal true, opts[:arg1]
|
|
469
|
-
assert_equal true, opts[:arg2]
|
|
470
|
-
assert_equal [4, 6, 9], opts[:arg3]
|
|
471
|
-
assert_equal [3.14, 2.41], opts[:arg4]
|
|
472
|
-
|
|
473
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(-abcd 3.14 2.41) }
|
|
474
|
-
end
|
|
475
|
-
|
|
476
|
-
def test_long_options_with_multiple_options
|
|
477
|
-
@p.opt :xarg, "desc", :type => String, :multi => true
|
|
478
|
-
opts = nil
|
|
479
|
-
assert_nothing_raised { opts = @p.parse %w(--xarg=a --xarg=b) }
|
|
480
|
-
assert_equal %w(a b), opts[:xarg]
|
|
481
|
-
assert_equal [], @p.leftovers
|
|
482
|
-
assert_nothing_raised { opts = @p.parse %w(--xarg a --xarg b) }
|
|
483
|
-
assert_equal %w(a b), opts[:xarg]
|
|
484
|
-
assert_equal [], @p.leftovers
|
|
485
|
-
end
|
|
486
|
-
|
|
487
|
-
def test_long_options_with_multiple_arguments
|
|
488
|
-
opts = nil
|
|
489
|
-
|
|
490
|
-
@p.opt :xarg, "desc", :type => :ints
|
|
491
|
-
assert_nothing_raised { opts = @p.parse %w(--xarg 3 2 5) }
|
|
492
|
-
assert_equal [3, 2, 5], opts[:xarg]
|
|
493
|
-
assert_equal [], @p.leftovers
|
|
494
|
-
assert_nothing_raised { opts = @p.parse %w(--xarg=3) }
|
|
495
|
-
assert_equal [3], opts[:xarg]
|
|
496
|
-
assert_equal [], @p.leftovers
|
|
497
|
-
|
|
498
|
-
@p.opt :yarg, "desc", :type => :floats
|
|
499
|
-
assert_nothing_raised { opts = @p.parse %w(--yarg 3.14 2.41 5.66) }
|
|
500
|
-
assert_equal [3.14, 2.41, 5.66], opts[:yarg]
|
|
501
|
-
assert_equal [], @p.leftovers
|
|
502
|
-
assert_nothing_raised { opts = @p.parse %w(--yarg=3.14) }
|
|
503
|
-
assert_equal [3.14], opts[:yarg]
|
|
504
|
-
assert_equal [], @p.leftovers
|
|
505
|
-
|
|
506
|
-
@p.opt :zarg, "desc", :type => :strings
|
|
507
|
-
assert_nothing_raised { opts = @p.parse %w(--zarg a b c) }
|
|
508
|
-
assert_equal %w(a b c), opts[:zarg]
|
|
509
|
-
assert_equal [], @p.leftovers
|
|
510
|
-
assert_nothing_raised { opts = @p.parse %w(--zarg=a) }
|
|
511
|
-
assert_equal %w(a), opts[:zarg]
|
|
512
|
-
assert_equal [], @p.leftovers
|
|
513
|
-
end
|
|
514
|
-
|
|
515
|
-
def test_long_options_with_multiple_options_and_arguments
|
|
516
|
-
opts = nil
|
|
517
|
-
|
|
518
|
-
@p.opt :xarg, "desc", :type => :ints, :multi => true
|
|
519
|
-
assert_nothing_raised { opts = @p.parse %w(--xarg 3 2 5 --xarg 2 1) }
|
|
520
|
-
assert_equal [[3, 2, 5], [2, 1]], opts[:xarg]
|
|
521
|
-
assert_equal [], @p.leftovers
|
|
522
|
-
assert_nothing_raised { opts = @p.parse %w(--xarg=3 --xarg=2) }
|
|
523
|
-
assert_equal [[3], [2]], opts[:xarg]
|
|
524
|
-
assert_equal [], @p.leftovers
|
|
525
|
-
|
|
526
|
-
@p.opt :yarg, "desc", :type => :floats, :multi => true
|
|
527
|
-
assert_nothing_raised { opts = @p.parse %w(--yarg 3.14 2.72 5 --yarg 2.41 1.41) }
|
|
528
|
-
assert_equal [[3.14, 2.72, 5], [2.41, 1.41]], opts[:yarg]
|
|
529
|
-
assert_equal [], @p.leftovers
|
|
530
|
-
assert_nothing_raised { opts = @p.parse %w(--yarg=3.14 --yarg=2.41) }
|
|
531
|
-
assert_equal [[3.14], [2.41]], opts[:yarg]
|
|
532
|
-
assert_equal [], @p.leftovers
|
|
533
|
-
|
|
534
|
-
@p.opt :zarg, "desc", :type => :strings, :multi => true
|
|
535
|
-
assert_nothing_raised { opts = @p.parse %w(--zarg a b c --zarg d e) }
|
|
536
|
-
assert_equal [%w(a b c), %w(d e)], opts[:zarg]
|
|
537
|
-
assert_equal [], @p.leftovers
|
|
538
|
-
assert_nothing_raised { opts = @p.parse %w(--zarg=a --zarg=d) }
|
|
539
|
-
assert_equal [%w(a), %w(d)], opts[:zarg]
|
|
540
|
-
assert_equal [], @p.leftovers
|
|
541
|
-
end
|
|
542
|
-
|
|
543
|
-
def test_long_options_also_take_equals
|
|
544
|
-
@p.opt :arg, "desc", :long => "arg", :type => String, :default => "hello"
|
|
545
|
-
opts = nil
|
|
546
|
-
assert_nothing_raised { opts = @p.parse %w() }
|
|
547
|
-
assert_equal "hello", opts[:arg]
|
|
548
|
-
assert_nothing_raised { opts = @p.parse %w(--arg goat) }
|
|
549
|
-
assert_equal "goat", opts[:arg]
|
|
550
|
-
assert_nothing_raised { opts = @p.parse %w(--arg=goat) }
|
|
551
|
-
assert_equal "goat", opts[:arg]
|
|
552
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--arg= goat) }
|
|
553
|
-
end
|
|
554
|
-
|
|
555
|
-
def test_auto_generated_long_names_convert_underscores_to_hyphens
|
|
556
|
-
@p.opt :hello_there
|
|
557
|
-
assert_equal "hello-there", @p.specs[:hello_there][:long]
|
|
558
|
-
end
|
|
559
|
-
|
|
560
|
-
def test_arguments_passed_through_block
|
|
561
|
-
@goat = 3
|
|
562
|
-
boat = 4
|
|
563
|
-
Parser.new(@goat) do |goat|
|
|
564
|
-
boat = goat
|
|
565
|
-
end
|
|
566
|
-
assert_equal @goat, boat
|
|
567
|
-
end
|
|
568
|
-
|
|
569
|
-
def test_help_has_default_banner
|
|
570
|
-
@p = Parser.new
|
|
571
|
-
sio = StringIO.new "w"
|
|
572
|
-
@p.parse []
|
|
573
|
-
@p.educate sio
|
|
574
|
-
help = sio.string.split "\n"
|
|
575
|
-
assert help[0] =~ /options/i
|
|
576
|
-
assert_equal 2, help.length # options, then -h
|
|
577
|
-
|
|
578
|
-
@p = Parser.new
|
|
579
|
-
@p.version "my version"
|
|
580
|
-
sio = StringIO.new "w"
|
|
581
|
-
@p.parse []
|
|
582
|
-
@p.educate sio
|
|
583
|
-
help = sio.string.split "\n"
|
|
584
|
-
assert help[0] =~ /my version/i
|
|
585
|
-
assert_equal 4, help.length # version, options, -h, -v
|
|
586
|
-
|
|
587
|
-
@p = Parser.new
|
|
588
|
-
@p.banner "my own banner"
|
|
589
|
-
sio = StringIO.new "w"
|
|
590
|
-
@p.parse []
|
|
591
|
-
@p.educate sio
|
|
592
|
-
help = sio.string.split "\n"
|
|
593
|
-
assert help[0] =~ /my own banner/i
|
|
594
|
-
assert_equal 2, help.length # banner, -h
|
|
595
|
-
end
|
|
596
|
-
|
|
597
|
-
def test_help_preserves_positions
|
|
598
|
-
@p.opt :zzz, "zzz"
|
|
599
|
-
@p.opt :aaa, "aaa"
|
|
600
|
-
sio = StringIO.new "w"
|
|
601
|
-
@p.educate sio
|
|
602
|
-
|
|
603
|
-
help = sio.string.split "\n"
|
|
604
|
-
assert help[1] =~ /zzz/
|
|
605
|
-
assert help[2] =~ /aaa/
|
|
606
|
-
end
|
|
607
|
-
|
|
608
|
-
def test_version_and_help_short_args_can_be_overridden
|
|
609
|
-
@p.opt :verbose, "desc", :short => "-v"
|
|
610
|
-
@p.opt :hello, "desc", :short => "-h"
|
|
611
|
-
@p.version "version"
|
|
612
|
-
|
|
613
|
-
assert_nothing_raised { @p.parse(%w(-v)) }
|
|
614
|
-
assert_raises(VersionNeeded) { @p.parse(%w(--version)) }
|
|
615
|
-
assert_nothing_raised { @p.parse(%w(-h)) }
|
|
616
|
-
assert_raises(HelpNeeded) { @p.parse(%w(--help)) }
|
|
617
|
-
end
|
|
618
|
-
|
|
619
|
-
def test_version_and_help_long_args_can_be_overridden
|
|
620
|
-
@p.opt :asdf, "desc", :long => "help"
|
|
621
|
-
@p.opt :asdf2, "desc2", :long => "version"
|
|
622
|
-
assert_nothing_raised { @p.parse %w() }
|
|
623
|
-
assert_nothing_raised { @p.parse %w(--help) }
|
|
624
|
-
assert_nothing_raised { @p.parse %w(--version) }
|
|
625
|
-
assert_nothing_raised { @p.parse %w(-h) }
|
|
626
|
-
assert_nothing_raised { @p.parse %w(-v) }
|
|
627
|
-
end
|
|
628
|
-
|
|
629
|
-
def test_version_and_help_override_errors
|
|
630
|
-
@p.opt :asdf, "desc", :type => String
|
|
631
|
-
@p.version "version"
|
|
632
|
-
assert_nothing_raised { @p.parse %w(--asdf goat) }
|
|
633
|
-
assert_raises(CommandlineError) { @p.parse %w(--asdf) }
|
|
634
|
-
assert_raises(HelpNeeded) { @p.parse %w(--asdf --help) }
|
|
635
|
-
assert_raises(VersionNeeded) { @p.parse %w(--asdf --version) }
|
|
636
|
-
end
|
|
637
|
-
|
|
638
|
-
def test_conflicts
|
|
639
|
-
@p.opt :one
|
|
640
|
-
assert_raises(ArgumentError) { @p.conflicts :one, :two }
|
|
641
|
-
@p.opt :two
|
|
642
|
-
assert_nothing_raised { @p.conflicts :one, :two }
|
|
643
|
-
assert_nothing_raised { @p.parse %w(--one) }
|
|
644
|
-
assert_nothing_raised { @p.parse %w(--two) }
|
|
645
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--one --two) }
|
|
646
|
-
|
|
647
|
-
@p.opt :hello
|
|
648
|
-
@p.opt :yellow
|
|
649
|
-
@p.opt :mellow
|
|
650
|
-
@p.opt :jello
|
|
651
|
-
@p.conflicts :hello, :yellow, :mellow, :jello
|
|
652
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--hello --yellow --mellow --jello) }
|
|
653
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--hello --mellow --jello) }
|
|
654
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--hello --jello) }
|
|
655
|
-
|
|
656
|
-
assert_nothing_raised { opts = @p.parse %w(--hello) }
|
|
657
|
-
assert_nothing_raised { opts = @p.parse %w(--jello) }
|
|
658
|
-
assert_nothing_raised { opts = @p.parse %w(--yellow) }
|
|
659
|
-
assert_nothing_raised { opts = @p.parse %w(--mellow) }
|
|
660
|
-
|
|
661
|
-
assert_nothing_raised { opts = @p.parse %w(--mellow --one) }
|
|
662
|
-
assert_nothing_raised { opts = @p.parse %w(--mellow --two) }
|
|
663
|
-
|
|
664
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--mellow --two --jello) }
|
|
665
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--one --mellow --two --jello) }
|
|
666
|
-
end
|
|
667
|
-
|
|
668
|
-
def test_conflict_error_messages
|
|
669
|
-
@p.opt :one
|
|
670
|
-
@p.opt "two"
|
|
671
|
-
@p.conflicts :one, "two"
|
|
672
|
-
|
|
673
|
-
begin
|
|
674
|
-
@p.parse %w(--one --two)
|
|
675
|
-
flunk "no error thrown"
|
|
676
|
-
rescue CommandlineError => e
|
|
677
|
-
assert_match(/--one/, e.message)
|
|
678
|
-
assert_match(/--two/, e.message)
|
|
679
|
-
end
|
|
680
|
-
end
|
|
681
|
-
|
|
682
|
-
def test_depends
|
|
683
|
-
@p.opt :one
|
|
684
|
-
assert_raises(ArgumentError) { @p.depends :one, :two }
|
|
685
|
-
@p.opt :two
|
|
686
|
-
assert_nothing_raised { @p.depends :one, :two }
|
|
687
|
-
assert_nothing_raised { opts = @p.parse %w(--one --two) }
|
|
688
|
-
assert_raises(CommandlineError) { @p.parse %w(--one) }
|
|
689
|
-
assert_raises(CommandlineError) { @p.parse %w(--two) }
|
|
690
|
-
|
|
691
|
-
@p.opt :hello
|
|
692
|
-
@p.opt :yellow
|
|
693
|
-
@p.opt :mellow
|
|
694
|
-
@p.opt :jello
|
|
695
|
-
@p.depends :hello, :yellow, :mellow, :jello
|
|
696
|
-
assert_nothing_raised { opts = @p.parse %w(--hello --yellow --mellow --jello) }
|
|
697
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--hello --mellow --jello) }
|
|
698
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--hello --jello) }
|
|
699
|
-
|
|
700
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--hello) }
|
|
701
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--mellow) }
|
|
702
|
-
|
|
703
|
-
assert_nothing_raised { opts = @p.parse %w(--hello --yellow --mellow --jello --one --two) }
|
|
704
|
-
assert_nothing_raised { opts = @p.parse %w(--hello --yellow --mellow --jello --one --two a b c) }
|
|
705
|
-
|
|
706
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--mellow --two --jello --one) }
|
|
707
|
-
end
|
|
708
|
-
|
|
709
|
-
def test_depend_error_messages
|
|
710
|
-
@p.opt :one
|
|
711
|
-
@p.opt "two"
|
|
712
|
-
@p.depends :one, "two"
|
|
713
|
-
|
|
714
|
-
assert_nothing_raised { @p.parse %w(--one --two) }
|
|
715
|
-
|
|
716
|
-
begin
|
|
717
|
-
@p.parse %w(--one)
|
|
718
|
-
flunk "no error thrown"
|
|
719
|
-
rescue CommandlineError => e
|
|
720
|
-
assert_match(/--one/, e.message)
|
|
721
|
-
assert_match(/--two/, e.message)
|
|
722
|
-
end
|
|
723
|
-
|
|
724
|
-
begin
|
|
725
|
-
@p.parse %w(--two)
|
|
726
|
-
flunk "no error thrown"
|
|
727
|
-
rescue CommandlineError => e
|
|
728
|
-
assert_match(/--one/, e.message)
|
|
729
|
-
assert_match(/--two/, e.message)
|
|
730
|
-
end
|
|
731
|
-
end
|
|
732
|
-
|
|
733
|
-
## courtesy neill zero
|
|
734
|
-
def test_two_required_one_missing_accuses_correctly
|
|
735
|
-
@p.opt "arg1", "desc1", :required => true
|
|
736
|
-
@p.opt "arg2", "desc2", :required => true
|
|
737
|
-
|
|
738
|
-
begin
|
|
739
|
-
@p.parse(%w(--arg1))
|
|
740
|
-
flunk "should have failed on a missing req"
|
|
741
|
-
rescue CommandlineError => e
|
|
742
|
-
assert e.message =~ /arg2/, "didn't mention arg2 in the error msg: #{e.message}"
|
|
743
|
-
end
|
|
744
|
-
|
|
745
|
-
begin
|
|
746
|
-
@p.parse(%w(--arg2))
|
|
747
|
-
flunk "should have failed on a missing req"
|
|
748
|
-
rescue CommandlineError => e
|
|
749
|
-
assert e.message =~ /arg1/, "didn't mention arg1 in the error msg: #{e.message}"
|
|
750
|
-
end
|
|
751
|
-
|
|
752
|
-
assert_nothing_raised { @p.parse(%w(--arg1 --arg2)) }
|
|
753
|
-
end
|
|
754
|
-
|
|
755
|
-
def test_stopwords_mixed
|
|
756
|
-
@p.opt "arg1", :default => false
|
|
757
|
-
@p.opt "arg2", :default => false
|
|
758
|
-
@p.stop_on %w(happy sad)
|
|
759
|
-
|
|
760
|
-
opts = @p.parse %w(--arg1 happy --arg2)
|
|
761
|
-
assert_equal true, opts["arg1"]
|
|
762
|
-
assert_equal false, opts["arg2"]
|
|
763
|
-
|
|
764
|
-
## restart parsing
|
|
765
|
-
@p.leftovers.shift
|
|
766
|
-
opts = @p.parse @p.leftovers
|
|
767
|
-
assert_equal false, opts["arg1"]
|
|
768
|
-
assert_equal true, opts["arg2"]
|
|
769
|
-
end
|
|
770
|
-
|
|
771
|
-
def test_stopwords_no_stopwords
|
|
772
|
-
@p.opt "arg1", :default => false
|
|
773
|
-
@p.opt "arg2", :default => false
|
|
774
|
-
@p.stop_on %w(happy sad)
|
|
775
|
-
|
|
776
|
-
opts = @p.parse %w(--arg1 --arg2)
|
|
777
|
-
assert_equal true, opts["arg1"]
|
|
778
|
-
assert_equal true, opts["arg2"]
|
|
779
|
-
|
|
780
|
-
## restart parsing
|
|
781
|
-
@p.leftovers.shift
|
|
782
|
-
opts = @p.parse @p.leftovers
|
|
783
|
-
assert_equal false, opts["arg1"]
|
|
784
|
-
assert_equal false, opts["arg2"]
|
|
785
|
-
end
|
|
786
|
-
|
|
787
|
-
def test_stopwords_multiple_stopwords
|
|
788
|
-
@p.opt "arg1", :default => false
|
|
789
|
-
@p.opt "arg2", :default => false
|
|
790
|
-
@p.stop_on %w(happy sad)
|
|
791
|
-
|
|
792
|
-
opts = @p.parse %w(happy sad --arg1 --arg2)
|
|
793
|
-
assert_equal false, opts["arg1"]
|
|
794
|
-
assert_equal false, opts["arg2"]
|
|
795
|
-
|
|
796
|
-
## restart parsing
|
|
797
|
-
@p.leftovers.shift
|
|
798
|
-
opts = @p.parse @p.leftovers
|
|
799
|
-
assert_equal false, opts["arg1"]
|
|
800
|
-
assert_equal false, opts["arg2"]
|
|
801
|
-
|
|
802
|
-
## restart parsing again
|
|
803
|
-
@p.leftovers.shift
|
|
804
|
-
opts = @p.parse @p.leftovers
|
|
805
|
-
assert_equal true, opts["arg1"]
|
|
806
|
-
assert_equal true, opts["arg2"]
|
|
807
|
-
end
|
|
808
|
-
|
|
809
|
-
def test_stopwords_with_short_args
|
|
810
|
-
@p.opt :global_option, "This is a global option", :short => "-g"
|
|
811
|
-
@p.stop_on %w(sub-command-1 sub-command-2)
|
|
812
|
-
|
|
813
|
-
global_opts = @p.parse %w(-g sub-command-1 -c)
|
|
814
|
-
cmd = @p.leftovers.shift
|
|
815
|
-
|
|
816
|
-
@q = Parser.new
|
|
817
|
-
@q.opt :cmd_option, "This is an option only for the subcommand", :short => "-c"
|
|
818
|
-
cmd_opts = @q.parse @p.leftovers
|
|
819
|
-
|
|
820
|
-
assert_equal true, global_opts[:global_option]
|
|
821
|
-
assert_nil global_opts[:cmd_option]
|
|
822
|
-
|
|
823
|
-
assert_equal true, cmd_opts[:cmd_option]
|
|
824
|
-
assert_nil cmd_opts[:global_option]
|
|
825
|
-
|
|
826
|
-
assert_equal cmd, "sub-command-1"
|
|
827
|
-
assert_equal @q.leftovers, []
|
|
828
|
-
end
|
|
829
|
-
|
|
830
|
-
def assert_parses_correctly(parser, commandline, expected_opts,
|
|
831
|
-
expected_leftovers)
|
|
832
|
-
opts = parser.parse commandline
|
|
833
|
-
assert_equal expected_opts, opts
|
|
834
|
-
assert_equal expected_leftovers, parser.leftovers
|
|
835
|
-
end
|
|
836
|
-
|
|
837
|
-
def test_unknown_subcommand
|
|
838
|
-
@p.opt :global_flag, "Global flag", :short => "-g", :type => :flag
|
|
839
|
-
@p.opt :global_param, "Global parameter", :short => "-p", :default => 5
|
|
840
|
-
@p.stop_on_unknown
|
|
841
|
-
|
|
842
|
-
expected_opts = { :global_flag =>true, :help =>false, :global_param =>5 }
|
|
843
|
-
expected_leftovers = [ "my_subcommand", "-c" ]
|
|
844
|
-
|
|
845
|
-
assert_parses_correctly @p, %w(--global-flag my_subcommand -c), \
|
|
846
|
-
expected_opts, expected_leftovers
|
|
847
|
-
assert_parses_correctly @p, %w(-g my_subcommand -c), \
|
|
848
|
-
expected_opts, expected_leftovers
|
|
849
|
-
|
|
850
|
-
expected_opts = { :global_flag =>false, :help =>false, :global_param =>5 }
|
|
851
|
-
expected_leftovers = [ "my_subcommand", "-c" ]
|
|
852
|
-
|
|
853
|
-
assert_parses_correctly @p, %w(-p 5 my_subcommand -c), \
|
|
854
|
-
expected_opts, expected_leftovers
|
|
855
|
-
assert_parses_correctly @p, %w(--global-param 5 my_subcommand -c), \
|
|
856
|
-
expected_opts, expected_leftovers
|
|
857
|
-
end
|
|
858
|
-
|
|
859
|
-
def test_alternate_args
|
|
860
|
-
args = %w(-a -b -c)
|
|
861
|
-
|
|
862
|
-
opts = ::Trollop.options(args) do
|
|
863
|
-
opt :alpher, "Ralph Alpher", :short => "-a"
|
|
864
|
-
opt :bethe, "Hans Bethe", :short => "-b"
|
|
865
|
-
opt :gamow, "George Gamow", :short => "-c"
|
|
866
|
-
end
|
|
867
|
-
|
|
868
|
-
physicists_with_humor = [:alpher, :bethe, :gamow]
|
|
869
|
-
physicists_with_humor.each do |physicist|
|
|
870
|
-
assert_equal true, opts[physicist]
|
|
871
|
-
end
|
|
872
|
-
end
|
|
873
|
-
|
|
874
|
-
def test_io_arg_type
|
|
875
|
-
@p.opt :arg, "desc", :type => :io
|
|
876
|
-
@p.opt :arg2, "desc", :type => IO
|
|
877
|
-
@p.opt :arg3, "desc", :default => $stdout
|
|
878
|
-
|
|
879
|
-
opts = nil
|
|
880
|
-
assert_nothing_raised { opts = @p.parse() }
|
|
881
|
-
assert_equal $stdout, opts[:arg3]
|
|
882
|
-
|
|
883
|
-
assert_nothing_raised { opts = @p.parse %w(--arg /dev/null) }
|
|
884
|
-
assert_kind_of File, opts[:arg]
|
|
885
|
-
assert_equal "/dev/null", opts[:arg].path
|
|
886
|
-
|
|
887
|
-
#TODO: move to mocks
|
|
888
|
-
#assert_nothing_raised { opts = @p.parse %w(--arg2 http://google.com/) }
|
|
889
|
-
#assert_kind_of StringIO, opts[:arg2]
|
|
890
|
-
|
|
891
|
-
assert_nothing_raised { opts = @p.parse %w(--arg3 stdin) }
|
|
892
|
-
assert_equal $stdin, opts[:arg3]
|
|
893
|
-
|
|
894
|
-
assert_raises(CommandlineError) { opts = @p.parse %w(--arg /fdasfasef/fessafef/asdfasdfa/fesasf) }
|
|
895
|
-
end
|
|
896
|
-
|
|
897
|
-
def test_openstruct_style_access
|
|
898
|
-
@p.opt "arg1", "desc", :type => :int
|
|
899
|
-
@p.opt :arg2, "desc", :type => :int
|
|
900
|
-
|
|
901
|
-
opts = @p.parse(%w(--arg1 3 --arg2 4))
|
|
902
|
-
|
|
903
|
-
assert_nothing_raised { opts.arg1 }
|
|
904
|
-
assert_nothing_raised { opts.arg2 }
|
|
905
|
-
assert_equal 3, opts.arg1
|
|
906
|
-
assert_equal 4, opts.arg2
|
|
907
|
-
end
|
|
908
|
-
|
|
909
|
-
def test_multi_args_autobox_defaults
|
|
910
|
-
@p.opt :arg1, "desc", :default => "hello", :multi => true
|
|
911
|
-
@p.opt :arg2, "desc", :default => ["hello"], :multi => true
|
|
912
|
-
|
|
913
|
-
opts = @p.parse
|
|
914
|
-
assert_equal ["hello"], opts[:arg1]
|
|
915
|
-
assert_equal ["hello"], opts[:arg2]
|
|
916
|
-
|
|
917
|
-
opts = @p.parse %w(--arg1 hello)
|
|
918
|
-
assert_equal ["hello"], opts[:arg1]
|
|
919
|
-
assert_equal ["hello"], opts[:arg2]
|
|
920
|
-
|
|
921
|
-
opts = @p.parse %w(--arg1 hello --arg1 there)
|
|
922
|
-
assert_equal ["hello", "there"], opts[:arg1]
|
|
923
|
-
end
|
|
924
|
-
|
|
925
|
-
def test_ambigious_multi_plus_array_default_resolved_as_specified_by_documentation
|
|
926
|
-
@p.opt :arg1, "desc", :default => ["potato"], :multi => true
|
|
927
|
-
@p.opt :arg2, "desc", :default => ["potato"], :multi => true, :type => :strings
|
|
928
|
-
@p.opt :arg3, "desc", :default => ["potato"]
|
|
929
|
-
@p.opt :arg4, "desc", :default => ["potato", "rhubarb"], :short => :none, :multi => true
|
|
930
|
-
|
|
931
|
-
## arg1 should be multi-occurring but not multi-valued
|
|
932
|
-
opts = @p.parse %w(--arg1 one two)
|
|
933
|
-
assert_equal ["one"], opts[:arg1]
|
|
934
|
-
assert_equal ["two"], @p.leftovers
|
|
935
|
-
|
|
936
|
-
opts = @p.parse %w(--arg1 one --arg1 two)
|
|
937
|
-
assert_equal ["one", "two"], opts[:arg1]
|
|
938
|
-
assert_equal [], @p.leftovers
|
|
939
|
-
|
|
940
|
-
## arg2 should be multi-valued and multi-occurring
|
|
941
|
-
opts = @p.parse %w(--arg2 one two)
|
|
942
|
-
assert_equal [["one", "two"]], opts[:arg2]
|
|
943
|
-
assert_equal [], @p.leftovers
|
|
944
|
-
|
|
945
|
-
## arg3 should be multi-valued but not multi-occurring
|
|
946
|
-
opts = @p.parse %w(--arg3 one two)
|
|
947
|
-
assert_equal ["one", "two"], opts[:arg3]
|
|
948
|
-
assert_equal [], @p.leftovers
|
|
949
|
-
|
|
950
|
-
## arg4 should be multi-valued but not multi-occurring
|
|
951
|
-
opts = @p.parse %w()
|
|
952
|
-
assert_equal ["potato", "rhubarb"], opts[:arg4]
|
|
953
|
-
end
|
|
954
|
-
end
|
|
955
|
-
|
|
956
|
-
end
|
|
957
|
-
end
|