carats 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2 -0
- data/LICENSE +5 -0
- data/README +67 -0
- data/Reapfile +72 -0
- data/ToDo +24 -0
- data/bench/b_harray.rb +49 -0
- data/bench/b_range.rb +64 -0
- data/demo/ansicolor/cdiff.rb +20 -0
- data/demo/ansicolor/example.rb +82 -0
- data/demo/io-reactor/chatserver.rb +347 -0
- data/doc/classes/Array.html +172 -0
- data/doc/classes/BBCode.html +638 -0
- data/doc/classes/BinaryReader.html +675 -0
- data/doc/classes/Binding.html +223 -0
- data/doc/classes/ByteOrder.html +284 -0
- data/doc/classes/Class.html +189 -0
- data/doc/classes/Constant.html +785 -0
- data/doc/classes/Constant/CGS.html +609 -0
- data/doc/classes/Continuation.html +113 -0
- data/doc/classes/Coroutine.html +387 -0
- data/doc/classes/CountingSemaphore.html +337 -0
- data/doc/classes/CrossCase.html +561 -0
- data/doc/classes/DynamicMixin.html +185 -0
- data/doc/classes/EnumerableWithArgs.html +550 -0
- data/doc/classes/Expect.html +428 -0
- data/doc/classes/Expect/DefaultChain.html +113 -0
- data/doc/classes/Expect/SeparatedPattern.html +223 -0
- data/doc/classes/Expect/Timeout.html +167 -0
- data/doc/classes/Expect/UnmatchedMessage.html +160 -0
- data/doc/classes/FileList.html +833 -0
- data/doc/classes/FloatString.html +534 -0
- data/doc/classes/Functor.html +211 -0
- data/doc/classes/HArray.html +1872 -0
- data/doc/classes/HTML.html +328 -0
- data/doc/classes/Heap.html +683 -0
- data/doc/classes/Heap/EmptyHeapException.html +111 -0
- data/doc/classes/Heap/Max.html +176 -0
- data/doc/classes/Heap/Min.html +176 -0
- data/doc/classes/IO.html +108 -0
- data/doc/classes/IO/Reactor.html +790 -0
- data/doc/classes/IO/Redirect.html +289 -0
- data/doc/classes/Infinity.html +320 -0
- data/doc/classes/Interval.html +1014 -0
- data/doc/classes/InvalidNackError.html +161 -0
- data/doc/classes/Kernel.html +204 -0
- data/doc/classes/Lisp.html +1132 -0
- data/doc/classes/Lisp/DottedPair.html +379 -0
- data/doc/classes/Lisp/Format.html +178 -0
- data/doc/classes/Lisp/Format/ArgumentError.html +126 -0
- data/doc/classes/Lisp/Format/Directives.html +155 -0
- data/doc/classes/Lisp/Format/Directives/ArgJump.html +178 -0
- data/doc/classes/Lisp/Format/Directives/Ascii.html +119 -0
- data/doc/classes/Lisp/Format/Directives/BeginCaseConversion.html +185 -0
- data/doc/classes/Lisp/Format/Directives/BeginConditional.html +307 -0
- data/doc/classes/Lisp/Format/Directives/BeginIteration.html +338 -0
- data/doc/classes/Lisp/Format/Directives/Binary.html +157 -0
- data/doc/classes/Lisp/Format/Directives/Character.html +228 -0
- data/doc/classes/Lisp/Format/Directives/CharacterDirective.html +203 -0
- data/doc/classes/Lisp/Format/Directives/ClauseSeparator.html +166 -0
- data/doc/classes/Lisp/Format/Directives/Decimal.html +119 -0
- data/doc/classes/Lisp/Format/Directives/Directive.html +397 -0
- data/doc/classes/Lisp/Format/Directives/DollarFP.html +205 -0
- data/doc/classes/Lisp/Format/Directives/EndCaseConversion.html +174 -0
- data/doc/classes/Lisp/Format/Directives/EndConditional.html +159 -0
- data/doc/classes/Lisp/Format/Directives/EndIteration.html +163 -0
- data/doc/classes/Lisp/Format/Directives/ExpFP.html +252 -0
- data/doc/classes/Lisp/Format/Directives/FFFP.html +224 -0
- data/doc/classes/Lisp/Format/Directives/Factory.html +180 -0
- data/doc/classes/Lisp/Format/Directives/FreshLine.html +175 -0
- data/doc/classes/Lisp/Format/Directives/GeneralFP.html +265 -0
- data/doc/classes/Lisp/Format/Directives/Hexadecimal.html +157 -0
- data/doc/classes/Lisp/Format/Directives/Indirection.html +183 -0
- data/doc/classes/Lisp/Format/Directives/Literal.html +187 -0
- data/doc/classes/Lisp/Format/Directives/NewLine.html +158 -0
- data/doc/classes/Lisp/Format/Directives/NewPage.html +158 -0
- data/doc/classes/Lisp/Format/Directives/Number.html +243 -0
- data/doc/classes/Lisp/Format/Directives/Octal.html +157 -0
- data/doc/classes/Lisp/Format/Directives/Plural.html +177 -0
- data/doc/classes/Lisp/Format/Directives/Print.html +237 -0
- data/doc/classes/Lisp/Format/Directives/Radix.html +432 -0
- data/doc/classes/Lisp/Format/Directives/SExpression.html +157 -0
- data/doc/classes/Lisp/Format/Directives/SkipWhitespace.html +165 -0
- data/doc/classes/Lisp/Format/Directives/Tabulate.html +198 -0
- data/doc/classes/Lisp/Format/Directives/Tilde.html +158 -0
- data/doc/classes/Lisp/Format/Directives/UnknownDirectiveError.html +117 -0
- data/doc/classes/Lisp/Format/Formatter.html +193 -0
- data/doc/classes/Lisp/Format/IncompleteParameterError.html +119 -0
- data/doc/classes/Lisp/Format/IndexError.html +126 -0
- data/doc/classes/Lisp/Format/Lexer.html +479 -0
- data/doc/classes/Lisp/Format/MalformedError.html +119 -0
- data/doc/classes/Lisp/Format/MissingParameterError.html +119 -0
- data/doc/classes/Lisp/Format/ModifierError.html +119 -0
- data/doc/classes/Lisp/Format/Output.html +239 -0
- data/doc/classes/Lisp/Format/ParameterError.html +126 -0
- data/doc/classes/Lisp/Format/Parameters.html +123 -0
- data/doc/classes/Lisp/Format/Parameters/Argument.html +172 -0
- data/doc/classes/Lisp/Format/Parameters/ArgumentCount.html +159 -0
- data/doc/classes/Lisp/Format/Parameters/Character.html +119 -0
- data/doc/classes/Lisp/Format/Parameters/Default.html +120 -0
- data/doc/classes/Lisp/Format/Parameters/Integer.html +119 -0
- data/doc/classes/Lisp/Format/Parameters/Parameter.html +206 -0
- data/doc/classes/Lisp/Format/Parser.html +212 -0
- data/doc/classes/Lisp/Format/Positioned.html +166 -0
- data/doc/classes/Lisp/Format/State.html +455 -0
- data/doc/classes/Lisp/Format/SyntaxError.html +126 -0
- data/doc/classes/Method.html +274 -0
- data/doc/classes/Method/DuckHunter.html +281 -0
- data/doc/classes/Module.html +709 -0
- data/doc/classes/Multiton.html +284 -0
- data/doc/classes/Multiton/New.html +164 -0
- data/doc/classes/Multiton/Semi.html +155 -0
- data/doc/classes/NackClass.html +322 -0
- data/doc/classes/NilClass.html +231 -0
- data/doc/classes/NilComparable.html +179 -0
- data/doc/classes/NotCopyable.html +273 -0
- data/doc/classes/Object.html +261 -0
- data/doc/classes/OpenStructable.html +346 -0
- data/doc/classes/OrderedHash.html +939 -0
- data/doc/classes/Parser.html +515 -0
- data/doc/classes/Parser/Main.html +178 -0
- data/doc/classes/Parser/Marker.html +475 -0
- data/doc/classes/Parser/Registry.html +354 -0
- data/doc/classes/Parser/Token.html +399 -0
- data/doc/classes/Parser/UnitToken.html +222 -0
- data/doc/classes/Ref.html +230 -0
- data/doc/classes/SimpleStringIO.html +183 -0
- data/doc/classes/StaticHash.html +202 -0
- data/doc/classes/String.html +172 -0
- data/doc/classes/Struct.html +181 -0
- data/doc/classes/SuperStruct.html +382 -0
- data/doc/classes/Term.html +156 -0
- data/doc/classes/Term/ANSIColor.html +185 -0
- data/doc/classes/Text.html +138 -0
- data/doc/classes/Text/Soundex.html +222 -0
- data/doc/classes/TextTagIterator.html +911 -0
- data/doc/classes/Time.html +119 -0
- data/doc/classes/Time/Limit.html +303 -0
- data/doc/classes/Time/Limit/Dummy.html +181 -0
- data/doc/classes/Timer.html +351 -0
- data/doc/classes/TracePoint.html +532 -0
- data/doc/classes/Tuple.html +178 -0
- data/doc/classes/Uninheritable.html +213 -0
- data/doc/classes/Version.html +783 -0
- data/doc/created.rid +1 -0
- data/doc/files/LICENSE.html +113 -0
- data/doc/files/README.html +201 -0
- data/doc/files/lib/carat/1st_rb.html +107 -0
- data/doc/files/lib/carat/ansicolor_rb.html +146 -0
- data/doc/files/lib/carat/attr_rb.html +101 -0
- data/doc/files/lib/carat/bbcode_rb.html +152 -0
- data/doc/files/lib/carat/binaryreader_rb.html +114 -0
- data/doc/files/lib/carat/binding-of-caller_rb.html +108 -0
- data/doc/files/lib/carat/byteorder_rb.html +107 -0
- data/doc/files/lib/carat/constant_rb.html +167 -0
- data/doc/files/lib/carat/coroutine_rb.html +156 -0
- data/doc/files/lib/carat/crosscase_rb.html +224 -0
- data/doc/files/lib/carat/duckhunter_rb.html +165 -0
- data/doc/files/lib/carat/dynamic-mixin_rb.html +101 -0
- data/doc/files/lib/carat/enumerable-args_rb.html +140 -0
- data/doc/files/lib/carat/expect_rb.html +137 -0
- data/doc/files/lib/carat/filelist_rb.html +130 -0
- data/doc/files/lib/carat/floatstring_rb.html +126 -0
- data/doc/files/lib/carat/functor_rb.html +140 -0
- data/doc/files/lib/carat/harray_rb.html +128 -0
- data/doc/files/lib/carat/heap_rb.html +154 -0
- data/doc/files/lib/carat/html-helpers_rb.html +116 -0
- data/doc/files/lib/carat/infinity_rb.html +142 -0
- data/doc/files/lib/carat/init_rb.html +127 -0
- data/doc/files/lib/carat/interval_rb.html +162 -0
- data/doc/files/lib/carat/io-reactor_rb.html +211 -0
- data/doc/files/lib/carat/io-redirect_rb.html +132 -0
- data/doc/files/lib/carat/lisp-format_rb.html +187 -0
- data/doc/files/lib/carat/lisp_rb.html +152 -0
- data/doc/files/lib/carat/macro_rb.html +129 -0
- data/doc/files/lib/carat/multiton_rb.html +178 -0
- data/doc/files/lib/carat/nack_rb.html +193 -0
- data/doc/files/lib/carat/nil-comparable_rb.html +126 -0
- data/doc/files/lib/carat/nil-missing_rb.html +101 -0
- data/doc/files/lib/carat/notcopyable_rb.html +166 -0
- data/doc/files/lib/carat/orderedhash_rb.html +107 -0
- data/doc/files/lib/carat/ostructable_rb.html +157 -0
- data/doc/files/lib/carat/parser-old_rb.html +239 -0
- data/doc/files/lib/carat/parser_rb.html +244 -0
- data/doc/files/lib/carat/ref_rb.html +107 -0
- data/doc/files/lib/carat/semaphore_rb.html +132 -0
- data/doc/files/lib/carat/snapshot_rb.html +152 -0
- data/doc/files/lib/carat/soundex_rb.html +128 -0
- data/doc/files/lib/carat/sstruct_rb.html +142 -0
- data/doc/files/lib/carat/statichash_rb.html +150 -0
- data/doc/files/lib/carat/tagiter_rb.html +236 -0
- data/doc/files/lib/carat/timelimit_rb.html +136 -0
- data/doc/files/lib/carat/timer_rb.html +153 -0
- data/doc/files/lib/carat/tracepoint_rb.html +160 -0
- data/doc/files/lib/carat/tuple_rb.html +123 -0
- data/doc/files/lib/carat/uninheritable_rb.html +101 -0
- data/doc/files/lib/carat/version_rb.html +141 -0
- data/doc/fr_class_index.html +159 -0
- data/doc/fr_file_index.html +78 -0
- data/doc/fr_method_index.html +663 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/carat-dev/README +11 -0
- data/lib/carat-dev/access-blocks/access_blocks.rb +42 -0
- data/lib/carat-dev/association/association.rb +70 -0
- data/lib/carat-dev/blankslate/blankslate.rb +51 -0
- data/lib/carat-dev/breakpoint.rb +518 -0
- data/lib/carat-dev/class-constructor/constructor_methods.rb +78 -0
- data/lib/carat-dev/class-constructor/tc_constructor.rb +35 -0
- data/lib/carat-dev/closecall/closecall-test.rb +39 -0
- data/lib/carat-dev/closecall/closecall.rb +101 -0
- data/lib/carat-dev/commandrunner/commandrunner.rb +100 -0
- data/lib/carat-dev/conditional/conditionals.rb +106 -0
- data/lib/carat-dev/daemon/daemon.rb +70 -0
- data/lib/carat-dev/detach/detach.rb +363 -0
- data/lib/carat-dev/detach/tc_detach.rb +57 -0
- data/lib/carat-dev/import-module/import-module-0.81.tar.gz +0 -0
- data/lib/carat-dev/import-module/import-module-0.81/LICENSE +1 -0
- data/lib/carat-dev/import-module/import-module-0.81/Makefile +11 -0
- data/lib/carat-dev/import-module/import-module-0.81/README +4 -0
- data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-hash.rb +49 -0
- data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-pip.rb +71 -0
- data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-unbound-method.rb +36 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/README-ja.html +293 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/README-ja.rd +306 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/README.html +290 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/README.rd +303 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/style.css +85 -0
- data/lib/carat-dev/import-module/import-module-0.81/install.rb +99 -0
- data/lib/carat-dev/import-module/import-module-0.81/lib/import-module-single-thread.rb +84 -0
- data/lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb +493 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/Makefile +2 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test +91 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test-import-module.rb +936 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test-import_scope.rb +33 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test-scope_import.rb +33 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test-time.rb +184 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test.sh +91 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/time.rb +135 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/times-do.sh +10 -0
- data/lib/carat-dev/interface_work/SCRAP/i-contracts.rb +37 -0
- data/lib/carat-dev/interface_work/SCRAP/interface.rb +105 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0.zip +0 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/CHANGES +3 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/MANIFEST +15 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/README +32 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/doc/interface.rd +73 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/doc/interface.txt +94 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/install.rb +16 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb +50 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/tc_interface.rb +51 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test.rb +29 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_instance.rb +24 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_sub.rb +29 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_unrequire.rb +28 -0
- data/lib/carat-dev/interface_work/contracts/contract.zip +0 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.html +376 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000001.html +23 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000002.html +18 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000003.html +19 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000004.html +29 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000005.html +18 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000006.html +18 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractError.html +142 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractException.html +153 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractMismatch.html +125 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Module.html +157 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Module.src/M000007.html +112 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/created.rid +1 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/assertions_rb.html +109 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/exception_rb.html +108 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/integration_rb.html +108 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/overrides_rb.html +109 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract_rb.html +114 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/fr_class_index.html +31 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/fr_file_index.html +31 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/fr_method_index.html +33 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/index.html +24 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/rdoc-style.css +208 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract.rb +88 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract/assertions.rb +37 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract/exception.rb +92 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract/integration.rb +132 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract/overrides.rb +32 -0
- data/lib/carat-dev/interface_work/must.rb +37 -0
- data/lib/carat-dev/interface_work/type.rb +232 -0
- data/lib/carat-dev/main/tc_toplevel.rb +23 -0
- data/lib/carat-dev/main/toplevel.rb +33 -0
- data/lib/carat-dev/main/toplevel_test.rb +24 -0
- data/lib/carat-dev/misc/1.rb +40 -0
- data/lib/carat-dev/misc/misc.rb +44 -0
- data/lib/carat-dev/misc/sys.rb +186 -0
- data/lib/carat-dev/misc/temp.rb +1 -0
- data/lib/carat-dev/misc/utils.rb +518 -0
- data/lib/carat-dev/predicate/predicate.rb +109 -0
- data/lib/carat-dev/predicate/predicate_test.rb +67 -0
- data/lib/carat-dev/premshree.rb +40 -0
- data/lib/carat-dev/priority-queue/pqueue.rb +183 -0
- data/lib/carat-dev/priority-queue/priorityqueue.rb +84 -0
- data/lib/carat-dev/quaternion/quaternion.rb +529 -0
- data/lib/carat-dev/range.rb +259 -0
- data/lib/carat-dev/system/rubyinfo.rb +75 -0
- data/lib/carat-dev/system/system.rb +105 -0
- data/lib/carat-dev/tc_range.rb +118 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.html +291 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000001.html +26 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000002.html +19 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000003.html +18 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000004.html +18 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000005.html +21 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000006.html +23 -0
- data/lib/carat-dev/timer/timer-doc/created.rid +1 -0
- data/lib/carat-dev/timer/timer-doc/files/timer_rb.html +144 -0
- data/lib/carat-dev/timer/timer-doc/fr_class_index.html +27 -0
- data/lib/carat-dev/timer/timer-doc/fr_file_index.html +27 -0
- data/lib/carat-dev/timer/timer-doc/fr_method_index.html +32 -0
- data/lib/carat-dev/timer/timer-doc/index.html +24 -0
- data/lib/carat-dev/timer/timer-doc/rdoc-style.css +208 -0
- data/lib/carat-dev/timer/timer.rb +160 -0
- data/lib/carat-dev/vars/vars.rb +62 -0
- data/lib/carat/1st.rb +58 -0
- data/lib/carat/ansicolor.rb +122 -0
- data/lib/carat/attr.rb +342 -0
- data/lib/carat/bbcode.rb +352 -0
- data/lib/carat/binaryreader.rb +170 -0
- data/lib/carat/binding-of-caller.rb +83 -0
- data/lib/carat/byteorder.rb +34 -0
- data/lib/carat/constant.rb +287 -0
- data/lib/carat/coroutine.rb +102 -0
- data/lib/carat/crosscase.rb +309 -0
- data/lib/carat/duckhunter.rb +158 -0
- data/lib/carat/dynamic-mixin.rb +71 -0
- data/lib/carat/enumerable-args.rb +125 -0
- data/lib/carat/expect.rb +192 -0
- data/lib/carat/filelist.rb +277 -0
- data/lib/carat/floatstring.rb +153 -0
- data/lib/carat/functor.rb +41 -0
- data/lib/carat/harray.rb +507 -0
- data/lib/carat/heap.rb +193 -0
- data/lib/carat/html-helpers.rb +82 -0
- data/lib/carat/infinity.rb +61 -0
- data/lib/carat/init.rb +33 -0
- data/lib/carat/interval.rb +248 -0
- data/lib/carat/io-reactor.rb +657 -0
- data/lib/carat/io-redirect.rb +99 -0
- data/lib/carat/lisp-format.rb +1832 -0
- data/lib/carat/lisp.rb +336 -0
- data/lib/carat/macro.rb +68 -0
- data/lib/carat/multiton.rb +153 -0
- data/lib/carat/nack.rb +115 -0
- data/lib/carat/nil-comparable.rb +67 -0
- data/lib/carat/nil-missing.rb +12 -0
- data/lib/carat/notcopyable.rb +68 -0
- data/lib/carat/orderedhash.rb +249 -0
- data/lib/carat/ostructable.rb +138 -0
- data/lib/carat/parser-old.rb +350 -0
- data/lib/carat/parser.rb +393 -0
- data/lib/carat/ref.rb +31 -0
- data/lib/carat/semaphore.rb +69 -0
- data/lib/carat/snapshot.rb +94 -0
- data/lib/carat/soundex.rb +104 -0
- data/lib/carat/sstruct.rb +223 -0
- data/lib/carat/statichash.rb +49 -0
- data/lib/carat/tagiter.rb +345 -0
- data/lib/carat/timelimit.rb +114 -0
- data/lib/carat/timer.rb +99 -0
- data/lib/carat/tracepoint.rb +154 -0
- data/lib/carat/tuple.rb +31 -0
- data/lib/carat/uninheritable.rb +68 -0
- data/lib/carat/version.rb +147 -0
- data/pub/doc/sstruct.txt +204 -0
- data/pub/doc/tagiter.html +145 -0
- data/setup.rb +1361 -0
- data/test/fixtures/filelist/testfile.txt +1 -0
- data/test/fixtures/filelist/testfile2.txt +1 -0
- data/test/tc_1st.rb +16 -0
- data/test/tc_ansicolor.rb +23 -0
- data/test/tc_attr.rb +46 -0
- data/test/tc_bbcode.rb +20 -0
- data/test/tc_binaryreader.rb +14 -0
- data/test/tc_binding_of_caller.rb +2 -0
- data/test/tc_byteorder.rb +41 -0
- data/test/tc_constant.rb +12 -0
- data/test/tc_coroutine.rb +50 -0
- data/test/tc_crosscase.rb +33 -0
- data/test/tc_duckhunter.rb +37 -0
- data/test/tc_dynamic-mixin.rb +66 -0
- data/test/tc_enumerable-args.rb +66 -0
- data/test/tc_expect.rb +83 -0
- data/test/tc_filelist.rb +17 -0
- data/test/tc_floatstring.rb +22 -0
- data/test/tc_functor.rb +18 -0
- data/test/tc_harray.rb +280 -0
- data/test/tc_heap.rb +6 -0
- data/test/tc_infinity.rb +23 -0
- data/test/tc_init.rb +29 -0
- data/test/tc_interval.rb +153 -0
- data/test/tc_io-reactor.rb +5 -0
- data/test/tc_io-redirect.rb +5 -0
- data/test/tc_lisp-format.rb +24 -0
- data/test/tc_lisp.rb +32 -0
- data/test/tc_macro.rb +48 -0
- data/test/tc_multiton.rb +188 -0
- data/test/tc_nack.rb +31 -0
- data/test/tc_nil-as-emptiness.rb +19 -0
- data/test/tc_nil-comparable.rb +29 -0
- data/test/tc_nil-missing.rb +0 -0
- data/test/tc_notcopyable.rb +64 -0
- data/test/tc_orderedhash.rb +36 -0
- data/test/tc_ostructable.rb +31 -0
- data/test/tc_semaphore.rb +5 -0
- data/test/tc_snapshot.rb +20 -0
- data/test/tc_soundex.rb +19 -0
- data/test/tc_sstruct.rb +313 -0
- data/test/tc_statichash.rb +24 -0
- data/test/tc_tagiter.rb +80 -0
- data/test/tc_timelimit.rb +47 -0
- data/test/tc_timer.rb +35 -0
- data/test/tc_tracepoint.rb +10 -0
- data/test/tc_tuple.rb +25 -0
- data/test/tc_uninheritable.rb +33 -0
- data/test/tc_version.rb +90 -0
- metadata +531 -0
data/doc/index.html
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
5
|
+
|
6
|
+
<!--
|
7
|
+
|
8
|
+
Ruby Carats
|
9
|
+
|
10
|
+
-->
|
11
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
12
|
+
<head>
|
13
|
+
<title>Ruby Carats</title>
|
14
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
15
|
+
</head>
|
16
|
+
<frameset rows="20%, 80%">
|
17
|
+
<frameset cols="25%,35%,45%">
|
18
|
+
<frame src="fr_file_index.html" title="Files" name="Files" />
|
19
|
+
<frame src="fr_class_index.html" name="Classes" />
|
20
|
+
<frame src="fr_method_index.html" name="Methods" />
|
21
|
+
</frameset>
|
22
|
+
<frame src="files/README.html" name="docwin" />
|
23
|
+
</frameset>
|
24
|
+
</html>
|
data/doc/rdoc-style.css
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
|
2
|
+
body {
|
3
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
+
font-size: 90%;
|
5
|
+
margin: 0;
|
6
|
+
margin-left: 40px;
|
7
|
+
padding: 0;
|
8
|
+
background: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
+
h1 { font-size: 150%; }
|
13
|
+
h2,h3,h4 { margin-top: 1em; }
|
14
|
+
|
15
|
+
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
+
a:hover { background: #039; color: #eef; }
|
17
|
+
|
18
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
+
td > a {
|
20
|
+
background: transparent;
|
21
|
+
color: #039;
|
22
|
+
text-decoration: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* and inside a section title */
|
26
|
+
.section-title > a {
|
27
|
+
background: transparent;
|
28
|
+
color: #eee;
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* === Structural elements =================================== */
|
33
|
+
|
34
|
+
div#index {
|
35
|
+
margin: 0;
|
36
|
+
margin-left: -40px;
|
37
|
+
padding: 0;
|
38
|
+
font-size: 90%;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
div#index a {
|
43
|
+
margin-left: 0.7em;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#index .section-bar {
|
47
|
+
margin-left: 0px;
|
48
|
+
padding-left: 0.7em;
|
49
|
+
background: #ccc;
|
50
|
+
font-size: small;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
div#classHeader, div#fileHeader {
|
55
|
+
width: auto;
|
56
|
+
color: white;
|
57
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
+
margin: 0;
|
59
|
+
margin-left: -40px;
|
60
|
+
border-bottom: 3px solid #006;
|
61
|
+
}
|
62
|
+
|
63
|
+
div#classHeader a, div#fileHeader a {
|
64
|
+
background: inherit;
|
65
|
+
color: white;
|
66
|
+
}
|
67
|
+
|
68
|
+
div#classHeader td, div#fileHeader td {
|
69
|
+
background: inherit;
|
70
|
+
color: white;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
div#fileHeader {
|
75
|
+
background: #057;
|
76
|
+
}
|
77
|
+
|
78
|
+
div#classHeader {
|
79
|
+
background: #048;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
.class-name-in-header {
|
84
|
+
font-size: 180%;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
div#bodyContent {
|
90
|
+
padding: 0 1.5em 0 1.5em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#description {
|
94
|
+
padding: 0.5em 1.5em;
|
95
|
+
background: #efefef;
|
96
|
+
border: 1px dotted #999;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
+
color: #125;;
|
101
|
+
background: transparent;
|
102
|
+
}
|
103
|
+
|
104
|
+
div#validator-badges {
|
105
|
+
text-align: center;
|
106
|
+
}
|
107
|
+
div#validator-badges img { border: 0; }
|
108
|
+
|
109
|
+
div#copyright {
|
110
|
+
color: #333;
|
111
|
+
background: #efefef;
|
112
|
+
font: 0.75em sans-serif;
|
113
|
+
margin-top: 5em;
|
114
|
+
margin-bottom: 0;
|
115
|
+
padding: 0.5em 2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* === Classes =================================== */
|
120
|
+
|
121
|
+
table.header-table {
|
122
|
+
color: white;
|
123
|
+
font-size: small;
|
124
|
+
}
|
125
|
+
|
126
|
+
.type-note {
|
127
|
+
font-size: small;
|
128
|
+
color: #DEDEDE;
|
129
|
+
}
|
130
|
+
|
131
|
+
.xxsection-bar {
|
132
|
+
background: #eee;
|
133
|
+
color: #333;
|
134
|
+
padding: 3px;
|
135
|
+
}
|
136
|
+
|
137
|
+
.section-bar {
|
138
|
+
color: #333;
|
139
|
+
border-bottom: 1px solid #999;
|
140
|
+
margin-left: -20px;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
.section-title {
|
145
|
+
background: #79a;
|
146
|
+
color: #eee;
|
147
|
+
padding: 3px;
|
148
|
+
margin-top: 2em;
|
149
|
+
margin-left: -30px;
|
150
|
+
border: 1px solid #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.top-aligned-row { vertical-align: top }
|
154
|
+
.bottom-aligned-row { vertical-align: bottom }
|
155
|
+
|
156
|
+
/* --- Context section classes ----------------------- */
|
157
|
+
|
158
|
+
.context-row { }
|
159
|
+
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
+
.context-item-value { font-size: small; color: #448; }
|
161
|
+
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
+
|
163
|
+
/* --- Method classes -------------------------- */
|
164
|
+
.method-detail {
|
165
|
+
background: #efefef;
|
166
|
+
padding: 0;
|
167
|
+
margin-top: 0.5em;
|
168
|
+
margin-bottom: 1em;
|
169
|
+
border: 1px dotted #ccc;
|
170
|
+
}
|
171
|
+
.method-heading {
|
172
|
+
color: black;
|
173
|
+
background: #ccc;
|
174
|
+
border-bottom: 1px solid #666;
|
175
|
+
padding: 0.2em 0.5em 0 0.5em;
|
176
|
+
}
|
177
|
+
.method-signature { color: black; background: inherit; }
|
178
|
+
.method-name { font-weight: bold; }
|
179
|
+
.method-args { font-style: italic; }
|
180
|
+
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
+
|
182
|
+
/* --- Source code sections -------------------- */
|
183
|
+
|
184
|
+
a.source-toggle { font-size: 90%; }
|
185
|
+
div.method-source-code {
|
186
|
+
background: #262626;
|
187
|
+
color: #ffdead;
|
188
|
+
margin: 1em;
|
189
|
+
padding: 0.5em;
|
190
|
+
border: 1px dashed #999;
|
191
|
+
overflow: hidden;
|
192
|
+
}
|
193
|
+
|
194
|
+
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
+
|
196
|
+
/* --- Ruby keyword styles --------------------- */
|
197
|
+
|
198
|
+
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
+
|
200
|
+
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
+
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
+
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
+
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
+
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
+
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
+
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
+
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
+
.ruby-value { color: #7fffd4; background: transparent; }
|
@@ -0,0 +1,11 @@
|
|
1
|
+
*** IMPORTANT!!! ***
|
2
|
+
|
3
|
+
This directory contains alpha code and is generally considered
|
4
|
+
expiremental. It is provided as a means for conmmon development
|
5
|
+
and potential inspiration.
|
6
|
+
|
7
|
+
Some of these, or variations there-of, will find eventually become
|
8
|
+
part of the main lib.
|
9
|
+
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Ruby Treasures 0.4
|
2
|
+
# Copyright (C) 2002 Paul Brannan <paul@atdesk.com>
|
3
|
+
#
|
4
|
+
# You may distribute this software under the same terms as Ruby (see the file
|
5
|
+
# COPYING that was distributed with this library).
|
6
|
+
#
|
7
|
+
requirelocal 'secret'
|
8
|
+
|
9
|
+
##
|
10
|
+
# A hack to allow specifying public/private/protected using a block. Based on
|
11
|
+
# an idea proposed by David Alan Black.
|
12
|
+
#
|
13
|
+
# E.g.:
|
14
|
+
# <pre>
|
15
|
+
# class Thing
|
16
|
+
# private do
|
17
|
+
# def hidden
|
18
|
+
# puts 'hi'
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# def visible
|
23
|
+
# hidden
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# </pre>
|
27
|
+
class Module
|
28
|
+
PUBLIC = 0
|
29
|
+
PROTECTED = 1
|
30
|
+
PRIVATE = 2
|
31
|
+
SECRET = 3
|
32
|
+
|
33
|
+
[ 'public', 'protected', 'private', 'secret'].each do |access_level|
|
34
|
+
eval "alias_method :__old_access_blocks_#{access_level}__, :#{access_level}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def private(*args, &block)
|
38
|
+
__old_access_blocks_private__(args)
|
39
|
+
block.call
|
40
|
+
__old_access_blocks_private__(args)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
= Association
|
4
|
+
|
5
|
+
=end
|
6
|
+
|
7
|
+
class Association < Array
|
8
|
+
def initialize( key, value )
|
9
|
+
self.replace [ key, value ]
|
10
|
+
end
|
11
|
+
def key
|
12
|
+
self[0]
|
13
|
+
end
|
14
|
+
def value
|
15
|
+
self[1]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Kernel
|
20
|
+
def >>( associate )
|
21
|
+
Association.new( self, associate )
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# of course we need to teach array about working with associations
|
26
|
+
class Array
|
27
|
+
|
28
|
+
alias_method(:_get, :"[]")
|
29
|
+
private :_get
|
30
|
+
def [](i)
|
31
|
+
r = self._get(i)
|
32
|
+
return r.value if r.is_a? Association
|
33
|
+
return r
|
34
|
+
end
|
35
|
+
|
36
|
+
alias_method(:_at, :at)
|
37
|
+
private :_at
|
38
|
+
def at(i)
|
39
|
+
r = self._at(i)
|
40
|
+
return r.value if r.is_a? Association
|
41
|
+
return r
|
42
|
+
end
|
43
|
+
|
44
|
+
alias_method( :_values_at, :values_at)
|
45
|
+
private :_values_at
|
46
|
+
def values_at(*args)
|
47
|
+
r = self.values_at(i)
|
48
|
+
if r
|
49
|
+
return r.collect{ |e| e.is_a?(Association) ? e.value : e }
|
50
|
+
end
|
51
|
+
return r
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# --- development testing ---
|
58
|
+
|
59
|
+
if $0 == __FILE__
|
60
|
+
|
61
|
+
omap = [ :a >> 1, :b >> 2 ]
|
62
|
+
|
63
|
+
p omap[0]
|
64
|
+
|
65
|
+
omap.each { |a| p a }
|
66
|
+
|
67
|
+
puts "---"
|
68
|
+
omap.each { |k,v| p k,v }
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
|
4
|
+
# All rights reserved.
|
5
|
+
|
6
|
+
# Permission is granted for use, copying, modification, distribution,
|
7
|
+
# and distribution of modified versions of this work as long as the
|
8
|
+
# above copyright notice is included.
|
9
|
+
#++
|
10
|
+
|
11
|
+
# Adapted from BlankSlate.
|
12
|
+
# BlankSlate provides an abstract base class with no predefined
|
13
|
+
# methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>).
|
14
|
+
# BlankSlate is useful as a base class when writing classes that
|
15
|
+
# depend upon <tt>method_missing</tt> (e.g. dynamic proxies).
|
16
|
+
class BlankSlate
|
17
|
+
class << self
|
18
|
+
def hide(name)
|
19
|
+
undef_method name if
|
20
|
+
instance_methods.include?(name.to_s) and
|
21
|
+
name !~ /^(__|instance_eval)/
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
instance_methods.each { |m| hide(m) }
|
26
|
+
end
|
27
|
+
|
28
|
+
# Since Ruby is very dynamic, methods added to the ancestors of
|
29
|
+
# BlankSlate <em>after BlankSlate is defined</em> will show up in the
|
30
|
+
# list of available BlankSlate methods. We handle this by defining a hook in the Object and Kernel classes that will hide any defined
|
31
|
+
module Kernel
|
32
|
+
class << self
|
33
|
+
alias_method :blank_slate_method_added, :method_added
|
34
|
+
def method_added(name)
|
35
|
+
blank_slate_method_added(name)
|
36
|
+
return if self != Kernel
|
37
|
+
Builder::BlankSlate.hide(name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Object
|
43
|
+
class << self
|
44
|
+
alias_method :blank_slate_method_added, :method_added
|
45
|
+
def method_added(name)
|
46
|
+
blank_slate_method_added(name)
|
47
|
+
return if self != Object
|
48
|
+
Builder::BlankSlate.hide(name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,518 @@
|
|
1
|
+
# The Breakpoint library provides the convenience of
|
2
|
+
# being able to inspect and modify state, diagnose
|
3
|
+
# bugs all via IRB by simply setting breakpoints in
|
4
|
+
# your applications by the call of a method.
|
5
|
+
#
|
6
|
+
# This library was written and is supported by me,
|
7
|
+
# Florian Gross. I can be reached at flgr@ccan.de
|
8
|
+
# and enjoy getting feedback about my libraries.
|
9
|
+
#
|
10
|
+
# The whole library (including breakpoint_client.rb
|
11
|
+
# and binding_of_caller.rb) is licensed under the
|
12
|
+
# same license that Ruby uses. (Which is currently
|
13
|
+
# either the GNU General Public License or a custom
|
14
|
+
# one that allows for commercial usage.) If you for
|
15
|
+
# some good reason need to use this under another
|
16
|
+
# license please contact me.
|
17
|
+
|
18
|
+
require 'irb'
|
19
|
+
require File.dirname(__FILE__) + '/binding_of_caller'
|
20
|
+
require 'drb'
|
21
|
+
require 'drb/acl'
|
22
|
+
|
23
|
+
module Breakpoint
|
24
|
+
id = %q$Id: breakpoint.rb 41 2005-01-22 20:22:10Z flgr $
|
25
|
+
Version = id.split(" ")[2].to_i
|
26
|
+
|
27
|
+
extend self
|
28
|
+
|
29
|
+
# This will pop up an interactive ruby session at a
|
30
|
+
# pre-defined break point in a Ruby application. In
|
31
|
+
# this session you can examine the environment of
|
32
|
+
# the break point.
|
33
|
+
#
|
34
|
+
# You can get a list of variables in the context using
|
35
|
+
# local_variables via +local_variables+. You can then
|
36
|
+
# examine their values by typing their names.
|
37
|
+
#
|
38
|
+
# You can have a look at the call stack via +caller+.
|
39
|
+
#
|
40
|
+
# The source code around the location where the breakpoint
|
41
|
+
# was executed can be examined via +source_lines+. Its
|
42
|
+
# argument specifies how much lines of context to display.
|
43
|
+
# The default amount of context is 5 lines. Note that
|
44
|
+
# the call to +source_lines+ can raise an exception when
|
45
|
+
# it isn't able to read in the source code.
|
46
|
+
#
|
47
|
+
# breakpoints can also return a value. They will execute
|
48
|
+
# a supplied block for getting a default return value.
|
49
|
+
# A custom value can be returned from the session by doing
|
50
|
+
# +throw(:debug_return, value)+.
|
51
|
+
#
|
52
|
+
# You can also give names to break points which will be
|
53
|
+
# used in the message that is displayed upon execution
|
54
|
+
# of them.
|
55
|
+
#
|
56
|
+
# Here's a sample of how breakpoints should be placed:
|
57
|
+
#
|
58
|
+
# class Person
|
59
|
+
# def initialize(name, age)
|
60
|
+
# @name, @age = name, age
|
61
|
+
# breakpoint("Person#initialize")
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# attr_reader :age
|
65
|
+
# def name
|
66
|
+
# breakpoint("Person#name") { @name }
|
67
|
+
# end
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# person = Person.new("Random Person", 23)
|
71
|
+
# puts "Name: #{person.name}"
|
72
|
+
#
|
73
|
+
# And here is a sample debug session:
|
74
|
+
#
|
75
|
+
# Executing break point "Person#initialize" at file.rb:4 in `initialize'
|
76
|
+
# irb(#<Person:0x292fbe8>):001:0> local_variables
|
77
|
+
# => ["name", "age", "_", "__"]
|
78
|
+
# irb(#<Person:0x292fbe8>):002:0> [name, age]
|
79
|
+
# => ["Random Person", 23]
|
80
|
+
# irb(#<Person:0x292fbe8>):003:0> [@name, @age]
|
81
|
+
# => ["Random Person", 23]
|
82
|
+
# irb(#<Person:0x292fbe8>):004:0> self
|
83
|
+
# => #<Person:0x292fbe8 @age=23, @name="Random Person">
|
84
|
+
# irb(#<Person:0x292fbe8>):005:0> @age += 1; self
|
85
|
+
# => #<Person:0x292fbe8 @age=24, @name="Random Person">
|
86
|
+
# irb(#<Person:0x292fbe8>):006:0> exit
|
87
|
+
# Executing break point "Person#name" at file.rb:9 in `name'
|
88
|
+
# irb(#<Person:0x292fbe8>):001:0> throw(:debug_return, "Overriden name")
|
89
|
+
# Name: Overriden name
|
90
|
+
#
|
91
|
+
# Breakpoint sessions will automatically have a few
|
92
|
+
# convenience methods available. See Breakpoint::CommandBundle
|
93
|
+
# for a list of them.
|
94
|
+
#
|
95
|
+
# Breakpoints can also be used remotely over sockets.
|
96
|
+
# This is implemented by running part of the IRB session
|
97
|
+
# in the application and part of it in a special client.
|
98
|
+
# You have to call Breakpoint.activate_drb to enable
|
99
|
+
# support for remote breakpoints and then run
|
100
|
+
# breakpoint_client.rb which is distributed with this
|
101
|
+
# library. See the documentation of Breakpoint.activate_drb
|
102
|
+
# for details.
|
103
|
+
def breakpoint(id = nil, context = nil, &block)
|
104
|
+
callstack = caller
|
105
|
+
callstack.slice!(0, 3) if callstack.first["breakpoint"]
|
106
|
+
file, line, method = *callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/).captures
|
107
|
+
|
108
|
+
message = "Executing break point " + (id ? "#{id.inspect} " : "") +
|
109
|
+
"at #{file}:#{line}" + (method ? " in `#{method}'" : "")
|
110
|
+
|
111
|
+
if context then
|
112
|
+
return handle_breakpoint(context, message, file, line, &block)
|
113
|
+
end
|
114
|
+
|
115
|
+
Binding.of_caller do |binding_context|
|
116
|
+
handle_breakpoint(binding_context, message, file, line, &block)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
module CommandBundle
|
121
|
+
# Proxy to a Breakpoint client. Lets you directly execute code
|
122
|
+
# in the context of the client.
|
123
|
+
class Client
|
124
|
+
def initialize(eval_handler) # :nodoc:
|
125
|
+
@eval_handler = eval_handler
|
126
|
+
end
|
127
|
+
|
128
|
+
instance_methods.each do |method|
|
129
|
+
next if method[/^__.+__$/]
|
130
|
+
undef_method method
|
131
|
+
end
|
132
|
+
|
133
|
+
# Executes the specified code at the client.
|
134
|
+
def eval(code)
|
135
|
+
@eval_handler.call(code)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Will execute the specified statement at the client.
|
139
|
+
def method_missing(method, *args, &block)
|
140
|
+
if args.empty? and not block
|
141
|
+
result = eval "#{method}"
|
142
|
+
else
|
143
|
+
# This is a bit ugly. The alternative would be using an
|
144
|
+
# eval context instead of an eval handler for executing
|
145
|
+
# the code at the client. The problem with that approach
|
146
|
+
# is that we would have to handle special expressions
|
147
|
+
# like "self", "nil" or constants ourself which is hard.
|
148
|
+
remote = eval %{
|
149
|
+
result = lambda { |block, *args| #{method}(*args, &block) }
|
150
|
+
def result.call_with_block(*args, &block)
|
151
|
+
call(block, *args)
|
152
|
+
end
|
153
|
+
result
|
154
|
+
}
|
155
|
+
remote.call_with_block(*args, &block)
|
156
|
+
end
|
157
|
+
|
158
|
+
return result
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the source code surrounding the location where the
|
163
|
+
# breakpoint was issued.
|
164
|
+
def source_lines(context = 5, return_line_numbers = false)
|
165
|
+
lines = File.readlines(@__bp_file).map { |line| line.chomp }
|
166
|
+
|
167
|
+
break_line = @__bp_line
|
168
|
+
start_line = [break_line - context, 1].max
|
169
|
+
end_line = break_line + context
|
170
|
+
|
171
|
+
result = lines[(start_line - 1) .. (end_line - 1)]
|
172
|
+
|
173
|
+
if return_line_numbers then
|
174
|
+
return [start_line, break_line, result]
|
175
|
+
else
|
176
|
+
return result
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
# Lets an object that will forward method calls to the breakpoint
|
181
|
+
# client. This is useful for outputting longer things at the client
|
182
|
+
# and so on. You can for example do these things:
|
183
|
+
#
|
184
|
+
# client.puts "Hello" # outputs "Hello" at client console
|
185
|
+
# # outputs "Hello" into the file temp.txt at the client
|
186
|
+
# client.File.open("temp.txt", "w") { |f| f.puts "Hello" }
|
187
|
+
def client()
|
188
|
+
if Breakpoint.use_drb? then
|
189
|
+
sleep(0.5) until Breakpoint.drb_service.eval_handler
|
190
|
+
Client.new(Breakpoint.drb_service.eval_handler)
|
191
|
+
else
|
192
|
+
Client.new(lambda { |code| eval(code, TOPLEVEL_BINDING) })
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def handle_breakpoint(context, message, file = "", line = "", &block) # :nodoc:
|
198
|
+
catch(:debug_return) do |value|
|
199
|
+
eval(%{
|
200
|
+
@__bp_file = #{file.inspect}
|
201
|
+
@__bp_line = #{line}
|
202
|
+
extend Breakpoint::CommandBundle
|
203
|
+
extend DRbUndumped if self
|
204
|
+
}, context) rescue nil
|
205
|
+
|
206
|
+
if not use_drb? then
|
207
|
+
puts message
|
208
|
+
IRB.start(nil, IRB::WorkSpace.new(context))
|
209
|
+
else
|
210
|
+
@drb_service.add_breakpoint(context, message)
|
211
|
+
end
|
212
|
+
|
213
|
+
block.call if block
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
# These exceptions will be raised on failed asserts
|
218
|
+
# if Breakpoint.asserts_cause_exceptions is set to
|
219
|
+
# true.
|
220
|
+
class FailedAssertError < RuntimeError
|
221
|
+
end
|
222
|
+
|
223
|
+
# This asserts that the block evaluates to true.
|
224
|
+
# If it doesn't evaluate to true a breakpoint will
|
225
|
+
# automatically be created at that execution point.
|
226
|
+
#
|
227
|
+
# You can disable assert checking in production
|
228
|
+
# code by setting Breakpoint.optimize_asserts to
|
229
|
+
# true. (It will still be enabled when Ruby is run
|
230
|
+
# via the -d argument.)
|
231
|
+
#
|
232
|
+
# Example:
|
233
|
+
# person_name = "Foobar"
|
234
|
+
# assert { not person_name.nil? }
|
235
|
+
#
|
236
|
+
# Note: If you want to use this method from an
|
237
|
+
# unit test, you will have to call it by its full
|
238
|
+
# name, Breakpoint.assert.
|
239
|
+
def assert(context = nil, &condition)
|
240
|
+
return if Breakpoint.optimize_asserts and not $DEBUG
|
241
|
+
return if yield
|
242
|
+
|
243
|
+
callstack = caller
|
244
|
+
callstack.slice!(0, 3) if callstack.first["assert"]
|
245
|
+
file, line, method = *callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/).captures
|
246
|
+
|
247
|
+
message = "Assert failed at #{file}:#{line}#{" in `#{method}'" if method}."
|
248
|
+
|
249
|
+
if Breakpoint.asserts_cause_exceptions and not $DEBUG then
|
250
|
+
raise(Breakpoint::FailedAssertError, message)
|
251
|
+
end
|
252
|
+
|
253
|
+
message += " Executing implicit breakpoint."
|
254
|
+
|
255
|
+
if context then
|
256
|
+
return handle_breakpoint(context, message, file, line)
|
257
|
+
end
|
258
|
+
|
259
|
+
Binding.of_caller do |context|
|
260
|
+
handle_breakpoint(context, message, file, line)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Whether asserts should be ignored if not in debug mode.
|
265
|
+
# Debug mode can be enabled by running ruby with the -d
|
266
|
+
# switch or by setting $DEBUG to true.
|
267
|
+
attr_accessor :optimize_asserts
|
268
|
+
self.optimize_asserts = false
|
269
|
+
|
270
|
+
# Whether an Exception should be raised on failed asserts
|
271
|
+
# in non-$DEBUG code or not. By default this is disabled.
|
272
|
+
attr_accessor :asserts_cause_exceptions
|
273
|
+
self.asserts_cause_exceptions = false
|
274
|
+
@use_drb = false
|
275
|
+
|
276
|
+
attr_reader :drb_service # :nodoc:
|
277
|
+
|
278
|
+
class DRbService # :nodoc:
|
279
|
+
include DRbUndumped
|
280
|
+
|
281
|
+
def initialize
|
282
|
+
@handler = @eval_handler = @collision_handler = nil
|
283
|
+
|
284
|
+
IRB.instance_eval { @CONF[:RC] = true }
|
285
|
+
IRB.run_config
|
286
|
+
end
|
287
|
+
|
288
|
+
def collision
|
289
|
+
sleep(0.5) until @collision_handler
|
290
|
+
|
291
|
+
@collision_handler.call
|
292
|
+
end
|
293
|
+
|
294
|
+
def ping() end
|
295
|
+
|
296
|
+
def add_breakpoint(context, message)
|
297
|
+
workspace = IRB::WorkSpace.new(context)
|
298
|
+
workspace.extend(DRbUndumped)
|
299
|
+
|
300
|
+
sleep(0.5) until @handler
|
301
|
+
|
302
|
+
@handler.call(workspace, message)
|
303
|
+
end
|
304
|
+
|
305
|
+
attr_accessor :handler, :eval_handler, :collision_handler
|
306
|
+
end
|
307
|
+
|
308
|
+
# Will run Breakpoint in DRb mode. This will spawn a server
|
309
|
+
# that can be attached to via the breakpoint-client command
|
310
|
+
# whenever a breakpoint is executed. This is useful when you
|
311
|
+
# are debugging CGI applications or other applications where
|
312
|
+
# you can't access debug sessions via the standard input and
|
313
|
+
# output of your application.
|
314
|
+
#
|
315
|
+
# You can specify an URI where the DRb server will run at.
|
316
|
+
# This way you can specify the port the server runs on. The
|
317
|
+
# default URI is druby://localhost:42531.
|
318
|
+
#
|
319
|
+
# Please note that breakpoints will be skipped silently in
|
320
|
+
# case the DRb server can not spawned. (This can happen if
|
321
|
+
# the port is already used by another instance of your
|
322
|
+
# application on CGI or another application.)
|
323
|
+
#
|
324
|
+
# Also note that by default this will only allow access
|
325
|
+
# from localhost. You can however specify a list of
|
326
|
+
# allowed hosts or nil (to allow access from everywhere).
|
327
|
+
# But that will still not protect you from somebody
|
328
|
+
# reading the data as it goes through the net.
|
329
|
+
#
|
330
|
+
# A good approach for getting security and remote access
|
331
|
+
# is setting up an SSH tunnel between the DRb service
|
332
|
+
# and the client. This is usually done like this:
|
333
|
+
#
|
334
|
+
# $ ssh -L20000:127.0.0.1:20000 -R10000:127.0.0.1:10000 example.com
|
335
|
+
# (This will connect port 20000 at the client side to port
|
336
|
+
# 20000 at the server side, and port 10000 at the server
|
337
|
+
# side to port 10000 at the client side.)
|
338
|
+
#
|
339
|
+
# After that do this on the server side: (the code being debugged)
|
340
|
+
# Breakpoint.activate_drb("druby://127.0.0.1:20000", "localhost")
|
341
|
+
#
|
342
|
+
# And at the client side:
|
343
|
+
# ruby breakpoint_client.rb -c druby://127.0.0.1:10000 -s druby://127.0.0.1:20000
|
344
|
+
#
|
345
|
+
# Running through such a SSH proxy will also let you use
|
346
|
+
# breakpoint.rb in case you are behind a firewall.
|
347
|
+
#
|
348
|
+
# Detailed information about running DRb through firewalls is
|
349
|
+
# available at http://www.rubygarden.org/ruby?DrbTutorial
|
350
|
+
def activate_drb(uri = nil, allowed_hosts = ['localhost', '127.0.0.1', '::1'],
|
351
|
+
ignore_collisions = false)
|
352
|
+
|
353
|
+
return false if @use_drb
|
354
|
+
|
355
|
+
uri ||= 'druby://localhost:42531'
|
356
|
+
|
357
|
+
if allowed_hosts then
|
358
|
+
acl = ["deny", "all"]
|
359
|
+
|
360
|
+
Array(allowed_hosts).each do |host|
|
361
|
+
acl += ["allow", host]
|
362
|
+
end
|
363
|
+
|
364
|
+
DRb.install_acl(ACL.new(acl))
|
365
|
+
end
|
366
|
+
|
367
|
+
@use_drb = true
|
368
|
+
@drb_service = DRbService.new
|
369
|
+
did_collision = false
|
370
|
+
begin
|
371
|
+
@service = DRb.start_service(uri, @drb_service)
|
372
|
+
rescue Errno::EADDRINUSE
|
373
|
+
if ignore_collisions then
|
374
|
+
nil
|
375
|
+
else
|
376
|
+
# The port is already occupied by another
|
377
|
+
# Breakpoint service. We will try to tell
|
378
|
+
# the old service that we want its port.
|
379
|
+
# It will then forward that request to the
|
380
|
+
# user and retry.
|
381
|
+
unless did_collision then
|
382
|
+
DRbObject.new(nil, uri).collision
|
383
|
+
did_collision = true
|
384
|
+
end
|
385
|
+
sleep(10)
|
386
|
+
retry
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
return true
|
391
|
+
end
|
392
|
+
|
393
|
+
# Deactivates a running Breakpoint service.
|
394
|
+
def deactivate_drb
|
395
|
+
@service.stop_service unless @service.nil?
|
396
|
+
@service = nil
|
397
|
+
@use_drb = false
|
398
|
+
@drb_service = nil
|
399
|
+
end
|
400
|
+
|
401
|
+
# Returns true when Breakpoints are used over DRb.
|
402
|
+
# Breakpoint.activate_drb causes this to be true.
|
403
|
+
def use_drb?
|
404
|
+
@use_drb == true
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
module IRB # :nodoc:
|
409
|
+
class << self; remove_method :start; end
|
410
|
+
def self.start(ap_path = nil, main_context = nil, workspace = nil)
|
411
|
+
$0 = File::basename(ap_path, ".rb") if ap_path
|
412
|
+
|
413
|
+
# suppress some warnings about redefined constants
|
414
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
415
|
+
IRB.setup(ap_path)
|
416
|
+
$VERBOSE = old_verbose
|
417
|
+
|
418
|
+
if @CONF[:SCRIPT] then
|
419
|
+
irb = Irb.new(main_context, @CONF[:SCRIPT])
|
420
|
+
else
|
421
|
+
irb = Irb.new(main_context)
|
422
|
+
end
|
423
|
+
|
424
|
+
if workspace then
|
425
|
+
irb.context.workspace = workspace
|
426
|
+
end
|
427
|
+
|
428
|
+
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
|
429
|
+
@CONF[:MAIN_CONTEXT] = irb.context
|
430
|
+
|
431
|
+
old_sigint = trap("SIGINT") do
|
432
|
+
begin
|
433
|
+
irb.signal_handle
|
434
|
+
rescue RubyLex::TerminateLineInput
|
435
|
+
# ignored
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
catch(:IRB_EXIT) do
|
440
|
+
irb.eval_input
|
441
|
+
end
|
442
|
+
ensure
|
443
|
+
trap("SIGINT", old_sigint)
|
444
|
+
end
|
445
|
+
|
446
|
+
class << self
|
447
|
+
alias :old_CurrentContext :CurrentContext
|
448
|
+
remove_method :CurrentContext
|
449
|
+
end
|
450
|
+
def IRB.CurrentContext
|
451
|
+
if old_CurrentContext.nil? and Breakpoint.use_drb? then
|
452
|
+
result = Object.new
|
453
|
+
def result.last_value; end
|
454
|
+
return result
|
455
|
+
else
|
456
|
+
old_CurrentContext
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
class Context
|
461
|
+
alias :old_evaluate :evaluate
|
462
|
+
def evaluate(line, line_no)
|
463
|
+
if line.chomp == "exit" then
|
464
|
+
exit
|
465
|
+
else
|
466
|
+
old_evaluate(line, line_no)
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
class WorkSpace
|
472
|
+
alias :old_evaluate :evaluate
|
473
|
+
|
474
|
+
def evaluate(*args)
|
475
|
+
if Breakpoint.use_drb? then
|
476
|
+
result = old_evaluate(*args)
|
477
|
+
if args[0] != :no_proxy and
|
478
|
+
not [true, false, nil].include?(result)
|
479
|
+
then
|
480
|
+
result.extend(DRbUndumped) rescue nil
|
481
|
+
end
|
482
|
+
return result
|
483
|
+
else
|
484
|
+
old_evaluate(*args)
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
module InputCompletor
|
490
|
+
def self.eval(code, context, *more)
|
491
|
+
# Big hack, this assumes that InputCompletor
|
492
|
+
# will only call eval() when it wants code
|
493
|
+
# to be executed in the IRB context.
|
494
|
+
IRB.conf[:MAIN_CONTEXT].workspace.evaluate(:no_proxy, code, *more)
|
495
|
+
end
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
module DRb # :nodoc:
|
500
|
+
class DRbObject
|
501
|
+
undef :inspect if method_defined?(:inspect)
|
502
|
+
undef :clone if method_defined?(:clone)
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
# See Breakpoint.breakpoint
|
507
|
+
def breakpoint(id = nil, &block)
|
508
|
+
Binding.of_caller do |context|
|
509
|
+
Breakpoint.breakpoint(id, context, &block)
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
513
|
+
# See Breakpoint.assert
|
514
|
+
def assert(&block)
|
515
|
+
Binding.of_caller do |context|
|
516
|
+
Breakpoint.assert(context, &block)
|
517
|
+
end
|
518
|
+
end
|