carats 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (422) hide show
  1. data/ChangeLog +2 -0
  2. data/LICENSE +5 -0
  3. data/README +67 -0
  4. data/Reapfile +72 -0
  5. data/ToDo +24 -0
  6. data/bench/b_harray.rb +49 -0
  7. data/bench/b_range.rb +64 -0
  8. data/demo/ansicolor/cdiff.rb +20 -0
  9. data/demo/ansicolor/example.rb +82 -0
  10. data/demo/io-reactor/chatserver.rb +347 -0
  11. data/doc/classes/Array.html +172 -0
  12. data/doc/classes/BBCode.html +638 -0
  13. data/doc/classes/BinaryReader.html +675 -0
  14. data/doc/classes/Binding.html +223 -0
  15. data/doc/classes/ByteOrder.html +284 -0
  16. data/doc/classes/Class.html +189 -0
  17. data/doc/classes/Constant.html +785 -0
  18. data/doc/classes/Constant/CGS.html +609 -0
  19. data/doc/classes/Continuation.html +113 -0
  20. data/doc/classes/Coroutine.html +387 -0
  21. data/doc/classes/CountingSemaphore.html +337 -0
  22. data/doc/classes/CrossCase.html +561 -0
  23. data/doc/classes/DynamicMixin.html +185 -0
  24. data/doc/classes/EnumerableWithArgs.html +550 -0
  25. data/doc/classes/Expect.html +428 -0
  26. data/doc/classes/Expect/DefaultChain.html +113 -0
  27. data/doc/classes/Expect/SeparatedPattern.html +223 -0
  28. data/doc/classes/Expect/Timeout.html +167 -0
  29. data/doc/classes/Expect/UnmatchedMessage.html +160 -0
  30. data/doc/classes/FileList.html +833 -0
  31. data/doc/classes/FloatString.html +534 -0
  32. data/doc/classes/Functor.html +211 -0
  33. data/doc/classes/HArray.html +1872 -0
  34. data/doc/classes/HTML.html +328 -0
  35. data/doc/classes/Heap.html +683 -0
  36. data/doc/classes/Heap/EmptyHeapException.html +111 -0
  37. data/doc/classes/Heap/Max.html +176 -0
  38. data/doc/classes/Heap/Min.html +176 -0
  39. data/doc/classes/IO.html +108 -0
  40. data/doc/classes/IO/Reactor.html +790 -0
  41. data/doc/classes/IO/Redirect.html +289 -0
  42. data/doc/classes/Infinity.html +320 -0
  43. data/doc/classes/Interval.html +1014 -0
  44. data/doc/classes/InvalidNackError.html +161 -0
  45. data/doc/classes/Kernel.html +204 -0
  46. data/doc/classes/Lisp.html +1132 -0
  47. data/doc/classes/Lisp/DottedPair.html +379 -0
  48. data/doc/classes/Lisp/Format.html +178 -0
  49. data/doc/classes/Lisp/Format/ArgumentError.html +126 -0
  50. data/doc/classes/Lisp/Format/Directives.html +155 -0
  51. data/doc/classes/Lisp/Format/Directives/ArgJump.html +178 -0
  52. data/doc/classes/Lisp/Format/Directives/Ascii.html +119 -0
  53. data/doc/classes/Lisp/Format/Directives/BeginCaseConversion.html +185 -0
  54. data/doc/classes/Lisp/Format/Directives/BeginConditional.html +307 -0
  55. data/doc/classes/Lisp/Format/Directives/BeginIteration.html +338 -0
  56. data/doc/classes/Lisp/Format/Directives/Binary.html +157 -0
  57. data/doc/classes/Lisp/Format/Directives/Character.html +228 -0
  58. data/doc/classes/Lisp/Format/Directives/CharacterDirective.html +203 -0
  59. data/doc/classes/Lisp/Format/Directives/ClauseSeparator.html +166 -0
  60. data/doc/classes/Lisp/Format/Directives/Decimal.html +119 -0
  61. data/doc/classes/Lisp/Format/Directives/Directive.html +397 -0
  62. data/doc/classes/Lisp/Format/Directives/DollarFP.html +205 -0
  63. data/doc/classes/Lisp/Format/Directives/EndCaseConversion.html +174 -0
  64. data/doc/classes/Lisp/Format/Directives/EndConditional.html +159 -0
  65. data/doc/classes/Lisp/Format/Directives/EndIteration.html +163 -0
  66. data/doc/classes/Lisp/Format/Directives/ExpFP.html +252 -0
  67. data/doc/classes/Lisp/Format/Directives/FFFP.html +224 -0
  68. data/doc/classes/Lisp/Format/Directives/Factory.html +180 -0
  69. data/doc/classes/Lisp/Format/Directives/FreshLine.html +175 -0
  70. data/doc/classes/Lisp/Format/Directives/GeneralFP.html +265 -0
  71. data/doc/classes/Lisp/Format/Directives/Hexadecimal.html +157 -0
  72. data/doc/classes/Lisp/Format/Directives/Indirection.html +183 -0
  73. data/doc/classes/Lisp/Format/Directives/Literal.html +187 -0
  74. data/doc/classes/Lisp/Format/Directives/NewLine.html +158 -0
  75. data/doc/classes/Lisp/Format/Directives/NewPage.html +158 -0
  76. data/doc/classes/Lisp/Format/Directives/Number.html +243 -0
  77. data/doc/classes/Lisp/Format/Directives/Octal.html +157 -0
  78. data/doc/classes/Lisp/Format/Directives/Plural.html +177 -0
  79. data/doc/classes/Lisp/Format/Directives/Print.html +237 -0
  80. data/doc/classes/Lisp/Format/Directives/Radix.html +432 -0
  81. data/doc/classes/Lisp/Format/Directives/SExpression.html +157 -0
  82. data/doc/classes/Lisp/Format/Directives/SkipWhitespace.html +165 -0
  83. data/doc/classes/Lisp/Format/Directives/Tabulate.html +198 -0
  84. data/doc/classes/Lisp/Format/Directives/Tilde.html +158 -0
  85. data/doc/classes/Lisp/Format/Directives/UnknownDirectiveError.html +117 -0
  86. data/doc/classes/Lisp/Format/Formatter.html +193 -0
  87. data/doc/classes/Lisp/Format/IncompleteParameterError.html +119 -0
  88. data/doc/classes/Lisp/Format/IndexError.html +126 -0
  89. data/doc/classes/Lisp/Format/Lexer.html +479 -0
  90. data/doc/classes/Lisp/Format/MalformedError.html +119 -0
  91. data/doc/classes/Lisp/Format/MissingParameterError.html +119 -0
  92. data/doc/classes/Lisp/Format/ModifierError.html +119 -0
  93. data/doc/classes/Lisp/Format/Output.html +239 -0
  94. data/doc/classes/Lisp/Format/ParameterError.html +126 -0
  95. data/doc/classes/Lisp/Format/Parameters.html +123 -0
  96. data/doc/classes/Lisp/Format/Parameters/Argument.html +172 -0
  97. data/doc/classes/Lisp/Format/Parameters/ArgumentCount.html +159 -0
  98. data/doc/classes/Lisp/Format/Parameters/Character.html +119 -0
  99. data/doc/classes/Lisp/Format/Parameters/Default.html +120 -0
  100. data/doc/classes/Lisp/Format/Parameters/Integer.html +119 -0
  101. data/doc/classes/Lisp/Format/Parameters/Parameter.html +206 -0
  102. data/doc/classes/Lisp/Format/Parser.html +212 -0
  103. data/doc/classes/Lisp/Format/Positioned.html +166 -0
  104. data/doc/classes/Lisp/Format/State.html +455 -0
  105. data/doc/classes/Lisp/Format/SyntaxError.html +126 -0
  106. data/doc/classes/Method.html +274 -0
  107. data/doc/classes/Method/DuckHunter.html +281 -0
  108. data/doc/classes/Module.html +709 -0
  109. data/doc/classes/Multiton.html +284 -0
  110. data/doc/classes/Multiton/New.html +164 -0
  111. data/doc/classes/Multiton/Semi.html +155 -0
  112. data/doc/classes/NackClass.html +322 -0
  113. data/doc/classes/NilClass.html +231 -0
  114. data/doc/classes/NilComparable.html +179 -0
  115. data/doc/classes/NotCopyable.html +273 -0
  116. data/doc/classes/Object.html +261 -0
  117. data/doc/classes/OpenStructable.html +346 -0
  118. data/doc/classes/OrderedHash.html +939 -0
  119. data/doc/classes/Parser.html +515 -0
  120. data/doc/classes/Parser/Main.html +178 -0
  121. data/doc/classes/Parser/Marker.html +475 -0
  122. data/doc/classes/Parser/Registry.html +354 -0
  123. data/doc/classes/Parser/Token.html +399 -0
  124. data/doc/classes/Parser/UnitToken.html +222 -0
  125. data/doc/classes/Ref.html +230 -0
  126. data/doc/classes/SimpleStringIO.html +183 -0
  127. data/doc/classes/StaticHash.html +202 -0
  128. data/doc/classes/String.html +172 -0
  129. data/doc/classes/Struct.html +181 -0
  130. data/doc/classes/SuperStruct.html +382 -0
  131. data/doc/classes/Term.html +156 -0
  132. data/doc/classes/Term/ANSIColor.html +185 -0
  133. data/doc/classes/Text.html +138 -0
  134. data/doc/classes/Text/Soundex.html +222 -0
  135. data/doc/classes/TextTagIterator.html +911 -0
  136. data/doc/classes/Time.html +119 -0
  137. data/doc/classes/Time/Limit.html +303 -0
  138. data/doc/classes/Time/Limit/Dummy.html +181 -0
  139. data/doc/classes/Timer.html +351 -0
  140. data/doc/classes/TracePoint.html +532 -0
  141. data/doc/classes/Tuple.html +178 -0
  142. data/doc/classes/Uninheritable.html +213 -0
  143. data/doc/classes/Version.html +783 -0
  144. data/doc/created.rid +1 -0
  145. data/doc/files/LICENSE.html +113 -0
  146. data/doc/files/README.html +201 -0
  147. data/doc/files/lib/carat/1st_rb.html +107 -0
  148. data/doc/files/lib/carat/ansicolor_rb.html +146 -0
  149. data/doc/files/lib/carat/attr_rb.html +101 -0
  150. data/doc/files/lib/carat/bbcode_rb.html +152 -0
  151. data/doc/files/lib/carat/binaryreader_rb.html +114 -0
  152. data/doc/files/lib/carat/binding-of-caller_rb.html +108 -0
  153. data/doc/files/lib/carat/byteorder_rb.html +107 -0
  154. data/doc/files/lib/carat/constant_rb.html +167 -0
  155. data/doc/files/lib/carat/coroutine_rb.html +156 -0
  156. data/doc/files/lib/carat/crosscase_rb.html +224 -0
  157. data/doc/files/lib/carat/duckhunter_rb.html +165 -0
  158. data/doc/files/lib/carat/dynamic-mixin_rb.html +101 -0
  159. data/doc/files/lib/carat/enumerable-args_rb.html +140 -0
  160. data/doc/files/lib/carat/expect_rb.html +137 -0
  161. data/doc/files/lib/carat/filelist_rb.html +130 -0
  162. data/doc/files/lib/carat/floatstring_rb.html +126 -0
  163. data/doc/files/lib/carat/functor_rb.html +140 -0
  164. data/doc/files/lib/carat/harray_rb.html +128 -0
  165. data/doc/files/lib/carat/heap_rb.html +154 -0
  166. data/doc/files/lib/carat/html-helpers_rb.html +116 -0
  167. data/doc/files/lib/carat/infinity_rb.html +142 -0
  168. data/doc/files/lib/carat/init_rb.html +127 -0
  169. data/doc/files/lib/carat/interval_rb.html +162 -0
  170. data/doc/files/lib/carat/io-reactor_rb.html +211 -0
  171. data/doc/files/lib/carat/io-redirect_rb.html +132 -0
  172. data/doc/files/lib/carat/lisp-format_rb.html +187 -0
  173. data/doc/files/lib/carat/lisp_rb.html +152 -0
  174. data/doc/files/lib/carat/macro_rb.html +129 -0
  175. data/doc/files/lib/carat/multiton_rb.html +178 -0
  176. data/doc/files/lib/carat/nack_rb.html +193 -0
  177. data/doc/files/lib/carat/nil-comparable_rb.html +126 -0
  178. data/doc/files/lib/carat/nil-missing_rb.html +101 -0
  179. data/doc/files/lib/carat/notcopyable_rb.html +166 -0
  180. data/doc/files/lib/carat/orderedhash_rb.html +107 -0
  181. data/doc/files/lib/carat/ostructable_rb.html +157 -0
  182. data/doc/files/lib/carat/parser-old_rb.html +239 -0
  183. data/doc/files/lib/carat/parser_rb.html +244 -0
  184. data/doc/files/lib/carat/ref_rb.html +107 -0
  185. data/doc/files/lib/carat/semaphore_rb.html +132 -0
  186. data/doc/files/lib/carat/snapshot_rb.html +152 -0
  187. data/doc/files/lib/carat/soundex_rb.html +128 -0
  188. data/doc/files/lib/carat/sstruct_rb.html +142 -0
  189. data/doc/files/lib/carat/statichash_rb.html +150 -0
  190. data/doc/files/lib/carat/tagiter_rb.html +236 -0
  191. data/doc/files/lib/carat/timelimit_rb.html +136 -0
  192. data/doc/files/lib/carat/timer_rb.html +153 -0
  193. data/doc/files/lib/carat/tracepoint_rb.html +160 -0
  194. data/doc/files/lib/carat/tuple_rb.html +123 -0
  195. data/doc/files/lib/carat/uninheritable_rb.html +101 -0
  196. data/doc/files/lib/carat/version_rb.html +141 -0
  197. data/doc/fr_class_index.html +159 -0
  198. data/doc/fr_file_index.html +78 -0
  199. data/doc/fr_method_index.html +663 -0
  200. data/doc/index.html +24 -0
  201. data/doc/rdoc-style.css +208 -0
  202. data/lib/carat-dev/README +11 -0
  203. data/lib/carat-dev/access-blocks/access_blocks.rb +42 -0
  204. data/lib/carat-dev/association/association.rb +70 -0
  205. data/lib/carat-dev/blankslate/blankslate.rb +51 -0
  206. data/lib/carat-dev/breakpoint.rb +518 -0
  207. data/lib/carat-dev/class-constructor/constructor_methods.rb +78 -0
  208. data/lib/carat-dev/class-constructor/tc_constructor.rb +35 -0
  209. data/lib/carat-dev/closecall/closecall-test.rb +39 -0
  210. data/lib/carat-dev/closecall/closecall.rb +101 -0
  211. data/lib/carat-dev/commandrunner/commandrunner.rb +100 -0
  212. data/lib/carat-dev/conditional/conditionals.rb +106 -0
  213. data/lib/carat-dev/daemon/daemon.rb +70 -0
  214. data/lib/carat-dev/detach/detach.rb +363 -0
  215. data/lib/carat-dev/detach/tc_detach.rb +57 -0
  216. data/lib/carat-dev/import-module/import-module-0.81.tar.gz +0 -0
  217. data/lib/carat-dev/import-module/import-module-0.81/LICENSE +1 -0
  218. data/lib/carat-dev/import-module/import-module-0.81/Makefile +11 -0
  219. data/lib/carat-dev/import-module/import-module-0.81/README +4 -0
  220. data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-hash.rb +49 -0
  221. data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-pip.rb +71 -0
  222. data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-unbound-method.rb +36 -0
  223. data/lib/carat-dev/import-module/import-module-0.81/doc/README-ja.html +293 -0
  224. data/lib/carat-dev/import-module/import-module-0.81/doc/README-ja.rd +306 -0
  225. data/lib/carat-dev/import-module/import-module-0.81/doc/README.html +290 -0
  226. data/lib/carat-dev/import-module/import-module-0.81/doc/README.rd +303 -0
  227. data/lib/carat-dev/import-module/import-module-0.81/doc/style.css +85 -0
  228. data/lib/carat-dev/import-module/import-module-0.81/install.rb +99 -0
  229. data/lib/carat-dev/import-module/import-module-0.81/lib/import-module-single-thread.rb +84 -0
  230. data/lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb +493 -0
  231. data/lib/carat-dev/import-module/import-module-0.81/test/Makefile +2 -0
  232. data/lib/carat-dev/import-module/import-module-0.81/test/test +91 -0
  233. data/lib/carat-dev/import-module/import-module-0.81/test/test-import-module.rb +936 -0
  234. data/lib/carat-dev/import-module/import-module-0.81/test/test-import_scope.rb +33 -0
  235. data/lib/carat-dev/import-module/import-module-0.81/test/test-scope_import.rb +33 -0
  236. data/lib/carat-dev/import-module/import-module-0.81/test/test-time.rb +184 -0
  237. data/lib/carat-dev/import-module/import-module-0.81/test/test.sh +91 -0
  238. data/lib/carat-dev/import-module/import-module-0.81/test/time.rb +135 -0
  239. data/lib/carat-dev/import-module/import-module-0.81/test/times-do.sh +10 -0
  240. data/lib/carat-dev/interface_work/SCRAP/i-contracts.rb +37 -0
  241. data/lib/carat-dev/interface_work/SCRAP/interface.rb +105 -0
  242. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0.zip +0 -0
  243. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/CHANGES +3 -0
  244. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/MANIFEST +15 -0
  245. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/README +32 -0
  246. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/doc/interface.rd +73 -0
  247. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/doc/interface.txt +94 -0
  248. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/install.rb +16 -0
  249. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb +50 -0
  250. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/tc_interface.rb +51 -0
  251. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test.rb +29 -0
  252. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_instance.rb +24 -0
  253. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_sub.rb +29 -0
  254. data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_unrequire.rb +28 -0
  255. data/lib/carat-dev/interface_work/contracts/contract.zip +0 -0
  256. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.html +376 -0
  257. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000001.html +23 -0
  258. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000002.html +18 -0
  259. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000003.html +19 -0
  260. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000004.html +29 -0
  261. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000005.html +18 -0
  262. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000006.html +18 -0
  263. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractError.html +142 -0
  264. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractException.html +153 -0
  265. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractMismatch.html +125 -0
  266. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Module.html +157 -0
  267. data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Module.src/M000007.html +112 -0
  268. data/lib/carat-dev/interface_work/contracts/contract/doc/created.rid +1 -0
  269. data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/assertions_rb.html +109 -0
  270. data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/exception_rb.html +108 -0
  271. data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/integration_rb.html +108 -0
  272. data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/overrides_rb.html +109 -0
  273. data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract_rb.html +114 -0
  274. data/lib/carat-dev/interface_work/contracts/contract/doc/fr_class_index.html +31 -0
  275. data/lib/carat-dev/interface_work/contracts/contract/doc/fr_file_index.html +31 -0
  276. data/lib/carat-dev/interface_work/contracts/contract/doc/fr_method_index.html +33 -0
  277. data/lib/carat-dev/interface_work/contracts/contract/doc/index.html +24 -0
  278. data/lib/carat-dev/interface_work/contracts/contract/doc/rdoc-style.css +208 -0
  279. data/lib/carat-dev/interface_work/contracts/contract/lib/contract.rb +88 -0
  280. data/lib/carat-dev/interface_work/contracts/contract/lib/contract/assertions.rb +37 -0
  281. data/lib/carat-dev/interface_work/contracts/contract/lib/contract/exception.rb +92 -0
  282. data/lib/carat-dev/interface_work/contracts/contract/lib/contract/integration.rb +132 -0
  283. data/lib/carat-dev/interface_work/contracts/contract/lib/contract/overrides.rb +32 -0
  284. data/lib/carat-dev/interface_work/must.rb +37 -0
  285. data/lib/carat-dev/interface_work/type.rb +232 -0
  286. data/lib/carat-dev/main/tc_toplevel.rb +23 -0
  287. data/lib/carat-dev/main/toplevel.rb +33 -0
  288. data/lib/carat-dev/main/toplevel_test.rb +24 -0
  289. data/lib/carat-dev/misc/1.rb +40 -0
  290. data/lib/carat-dev/misc/misc.rb +44 -0
  291. data/lib/carat-dev/misc/sys.rb +186 -0
  292. data/lib/carat-dev/misc/temp.rb +1 -0
  293. data/lib/carat-dev/misc/utils.rb +518 -0
  294. data/lib/carat-dev/predicate/predicate.rb +109 -0
  295. data/lib/carat-dev/predicate/predicate_test.rb +67 -0
  296. data/lib/carat-dev/premshree.rb +40 -0
  297. data/lib/carat-dev/priority-queue/pqueue.rb +183 -0
  298. data/lib/carat-dev/priority-queue/priorityqueue.rb +84 -0
  299. data/lib/carat-dev/quaternion/quaternion.rb +529 -0
  300. data/lib/carat-dev/range.rb +259 -0
  301. data/lib/carat-dev/system/rubyinfo.rb +75 -0
  302. data/lib/carat-dev/system/system.rb +105 -0
  303. data/lib/carat-dev/tc_range.rb +118 -0
  304. data/lib/carat-dev/timer/timer-doc/classes/Timer.html +291 -0
  305. data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000001.html +26 -0
  306. data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000002.html +19 -0
  307. data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000003.html +18 -0
  308. data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000004.html +18 -0
  309. data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000005.html +21 -0
  310. data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000006.html +23 -0
  311. data/lib/carat-dev/timer/timer-doc/created.rid +1 -0
  312. data/lib/carat-dev/timer/timer-doc/files/timer_rb.html +144 -0
  313. data/lib/carat-dev/timer/timer-doc/fr_class_index.html +27 -0
  314. data/lib/carat-dev/timer/timer-doc/fr_file_index.html +27 -0
  315. data/lib/carat-dev/timer/timer-doc/fr_method_index.html +32 -0
  316. data/lib/carat-dev/timer/timer-doc/index.html +24 -0
  317. data/lib/carat-dev/timer/timer-doc/rdoc-style.css +208 -0
  318. data/lib/carat-dev/timer/timer.rb +160 -0
  319. data/lib/carat-dev/vars/vars.rb +62 -0
  320. data/lib/carat/1st.rb +58 -0
  321. data/lib/carat/ansicolor.rb +122 -0
  322. data/lib/carat/attr.rb +342 -0
  323. data/lib/carat/bbcode.rb +352 -0
  324. data/lib/carat/binaryreader.rb +170 -0
  325. data/lib/carat/binding-of-caller.rb +83 -0
  326. data/lib/carat/byteorder.rb +34 -0
  327. data/lib/carat/constant.rb +287 -0
  328. data/lib/carat/coroutine.rb +102 -0
  329. data/lib/carat/crosscase.rb +309 -0
  330. data/lib/carat/duckhunter.rb +158 -0
  331. data/lib/carat/dynamic-mixin.rb +71 -0
  332. data/lib/carat/enumerable-args.rb +125 -0
  333. data/lib/carat/expect.rb +192 -0
  334. data/lib/carat/filelist.rb +277 -0
  335. data/lib/carat/floatstring.rb +153 -0
  336. data/lib/carat/functor.rb +41 -0
  337. data/lib/carat/harray.rb +507 -0
  338. data/lib/carat/heap.rb +193 -0
  339. data/lib/carat/html-helpers.rb +82 -0
  340. data/lib/carat/infinity.rb +61 -0
  341. data/lib/carat/init.rb +33 -0
  342. data/lib/carat/interval.rb +248 -0
  343. data/lib/carat/io-reactor.rb +657 -0
  344. data/lib/carat/io-redirect.rb +99 -0
  345. data/lib/carat/lisp-format.rb +1832 -0
  346. data/lib/carat/lisp.rb +336 -0
  347. data/lib/carat/macro.rb +68 -0
  348. data/lib/carat/multiton.rb +153 -0
  349. data/lib/carat/nack.rb +115 -0
  350. data/lib/carat/nil-comparable.rb +67 -0
  351. data/lib/carat/nil-missing.rb +12 -0
  352. data/lib/carat/notcopyable.rb +68 -0
  353. data/lib/carat/orderedhash.rb +249 -0
  354. data/lib/carat/ostructable.rb +138 -0
  355. data/lib/carat/parser-old.rb +350 -0
  356. data/lib/carat/parser.rb +393 -0
  357. data/lib/carat/ref.rb +31 -0
  358. data/lib/carat/semaphore.rb +69 -0
  359. data/lib/carat/snapshot.rb +94 -0
  360. data/lib/carat/soundex.rb +104 -0
  361. data/lib/carat/sstruct.rb +223 -0
  362. data/lib/carat/statichash.rb +49 -0
  363. data/lib/carat/tagiter.rb +345 -0
  364. data/lib/carat/timelimit.rb +114 -0
  365. data/lib/carat/timer.rb +99 -0
  366. data/lib/carat/tracepoint.rb +154 -0
  367. data/lib/carat/tuple.rb +31 -0
  368. data/lib/carat/uninheritable.rb +68 -0
  369. data/lib/carat/version.rb +147 -0
  370. data/pub/doc/sstruct.txt +204 -0
  371. data/pub/doc/tagiter.html +145 -0
  372. data/setup.rb +1361 -0
  373. data/test/fixtures/filelist/testfile.txt +1 -0
  374. data/test/fixtures/filelist/testfile2.txt +1 -0
  375. data/test/tc_1st.rb +16 -0
  376. data/test/tc_ansicolor.rb +23 -0
  377. data/test/tc_attr.rb +46 -0
  378. data/test/tc_bbcode.rb +20 -0
  379. data/test/tc_binaryreader.rb +14 -0
  380. data/test/tc_binding_of_caller.rb +2 -0
  381. data/test/tc_byteorder.rb +41 -0
  382. data/test/tc_constant.rb +12 -0
  383. data/test/tc_coroutine.rb +50 -0
  384. data/test/tc_crosscase.rb +33 -0
  385. data/test/tc_duckhunter.rb +37 -0
  386. data/test/tc_dynamic-mixin.rb +66 -0
  387. data/test/tc_enumerable-args.rb +66 -0
  388. data/test/tc_expect.rb +83 -0
  389. data/test/tc_filelist.rb +17 -0
  390. data/test/tc_floatstring.rb +22 -0
  391. data/test/tc_functor.rb +18 -0
  392. data/test/tc_harray.rb +280 -0
  393. data/test/tc_heap.rb +6 -0
  394. data/test/tc_infinity.rb +23 -0
  395. data/test/tc_init.rb +29 -0
  396. data/test/tc_interval.rb +153 -0
  397. data/test/tc_io-reactor.rb +5 -0
  398. data/test/tc_io-redirect.rb +5 -0
  399. data/test/tc_lisp-format.rb +24 -0
  400. data/test/tc_lisp.rb +32 -0
  401. data/test/tc_macro.rb +48 -0
  402. data/test/tc_multiton.rb +188 -0
  403. data/test/tc_nack.rb +31 -0
  404. data/test/tc_nil-as-emptiness.rb +19 -0
  405. data/test/tc_nil-comparable.rb +29 -0
  406. data/test/tc_nil-missing.rb +0 -0
  407. data/test/tc_notcopyable.rb +64 -0
  408. data/test/tc_orderedhash.rb +36 -0
  409. data/test/tc_ostructable.rb +31 -0
  410. data/test/tc_semaphore.rb +5 -0
  411. data/test/tc_snapshot.rb +20 -0
  412. data/test/tc_soundex.rb +19 -0
  413. data/test/tc_sstruct.rb +313 -0
  414. data/test/tc_statichash.rb +24 -0
  415. data/test/tc_tagiter.rb +80 -0
  416. data/test/tc_timelimit.rb +47 -0
  417. data/test/tc_timer.rb +35 -0
  418. data/test/tc_tracepoint.rb +10 -0
  419. data/test/tc_tuple.rb +25 -0
  420. data/test/tc_uninheritable.rb +33 -0
  421. data/test/tc_version.rb +90 -0
  422. metadata +531 -0
@@ -0,0 +1,204 @@
1
+
2
+ SuperStruct
3
+ Hal Fulton
4
+ Version 1.0
5
+ License: The Ruby License
6
+
7
+ This is an easy way to create Struct-like classes; it converts easily
8
+ between hashes and arrays, and it allows OpenStruct-like dynamic naming
9
+ of members.
10
+
11
+ Unlike Struct, it creates a "real" class, and it has real instance variables
12
+ with predictable names.
13
+
14
+ A basic limitation is that the hash keys must be legal method names (unless
15
+ used with send()).
16
+
17
+ Basically, ss["alpha"], ss[:alpha], and ss.alpha all mean the same.
18
+
19
+
20
+ NOTES:
21
+
22
+
23
+ It's like a Struct...
24
+ - you can pass in a list of symbols for accessors
25
+ - it will create a class for you
26
+ but...
27
+ - you don't have to pass in the class name
28
+ - it returns a "real" class
29
+ . instance variables have the expected names
30
+ . you can reopen and add methods
31
+ - it doesn't go into the Struct:: namespace
32
+ - it preserves the order of the fields
33
+ - you can use Strings instead of Symbols for the names
34
+
35
+ It's like an Array...
36
+ - you can access the items by [number] and [number]=
37
+ but...
38
+ - you can also access the items by ["name"] and ["name"]=
39
+ - you can access the items by accessors
40
+
41
+ It's like an OpenStruct...
42
+ - (if you use .open instead of .new) you can add fields
43
+ automatically with x.field or x.field=val
44
+ but...
45
+ - you can initialize it like a Struct
46
+ - it preserves the order of the fields
47
+
48
+ It's like a Hash...
49
+ - data can be accessed by ["name"]
50
+ but...
51
+ - order (of entry or creation) is preserved
52
+ - arbitrary objects are not allowed (it does obj.to_str or obj.to_s)
53
+ - strings must be valid method names
54
+
55
+ It's like Ara Howard's Named Array...
56
+ - we can access elements by ["name"] or ["name"]=
57
+ but...
58
+ - you can access the items by accessors
59
+ - strings must be valid method names
60
+
61
+ It's like Florian Gross's Keyed List...
62
+ (to be done)
63
+ but...
64
+ - it preserves the order of the fields
65
+
66
+
67
+ Some examples: (see test cases)
68
+ --------------
69
+
70
+ # Need not assign to existing fields (default to nil)
71
+ myStruct = SuperStruct.new(:alpha)
72
+ x = myStruct.new
73
+ x.alpha # nil
74
+
75
+ # A value assigned at construction may be retrieved
76
+ myStruct = SuperStruct.new(:alpha)
77
+ x = myStruct.new(234)
78
+ x.alpha # 234
79
+
80
+ # Unassigned fields are nil
81
+ myStruct = SuperStruct.new(:alpha,:beta)
82
+ x = myStruct.new(234)
83
+ x.beta # nil
84
+
85
+ # An open structure may not construct with nonexistent fields
86
+ myStruct = SuperStruct.open
87
+ x = myStruct.new(234) # error
88
+
89
+ # An open structure may assign fields not previously existing
90
+ myStruct = SuperStruct.open
91
+ x = myStruct.new
92
+ x.foo = 123
93
+ x.bar = 456
94
+
95
+ # The act of retrieving a nonexistent field from an open struct will
96
+ # create that field
97
+ myStruct = SuperStruct.open
98
+ x = myStruct.new
99
+ x.foo # nil
100
+
101
+ # A field (in an open struct) that is unassigned will be nil
102
+ myStruct = SuperStruct.open
103
+ x = myStruct.new
104
+ y = x.foobar
105
+
106
+ # A struct created with new rather than open cannot reference nonexistent
107
+ # fields
108
+ myStruct = SuperStruct.new
109
+ x = myStruct.new
110
+ x.foo # error
111
+
112
+ # Adding a field to a struct will create a writer and reader for that field
113
+
114
+ # An open struct will also create a writer and a reader together
115
+
116
+ # A field has a real writer and reader corresponding to it
117
+
118
+ # A string will work as well as a symbol
119
+ myStruct = SuperStruct.new("alpha")
120
+
121
+ # to_a will return an array of values
122
+ myStruct = SuperStruct.new("alpha","beta","gamma")
123
+ x = myStruct.new(7,8,9)
124
+ assert(x.to_a == [7,8,9])
125
+
126
+ # Instance method 'members' will return a list of members (as strings)
127
+ myStruct = SuperStruct.new(:alpha,"beta")
128
+ x = myStruct.new
129
+ assert_equal(["alpha","beta"],x.members)
130
+
131
+ # Class method 'members' will return a list of members (as strings)
132
+ myStruct = SuperStruct.new(:alpha,"beta")
133
+ assert_equal(["alpha","beta"],myStruct.members)
134
+
135
+ # to_ary will allow a struct to be treated like an array in
136
+ # multiple assignment
137
+ myStruct = SuperStruct.new("alpha","beta","gamma")
138
+ x = myStruct.new(7,8,9)
139
+ a,b,c = x
140
+ assert(b == 8)
141
+
142
+ # to_ary will allow a struct to be treated like an array in
143
+ # passed parameters
144
+ myStruct = SuperStruct.new("alpha","beta","gamma")
145
+ x = myStruct.new(7,8,9)
146
+ b = meth(*x)
147
+
148
+ # to_hash will return a hash with fields as keys
149
+ myStruct = SuperStruct.new("alpha","beta","gamma")
150
+ x = myStruct.new(7,8,9)
151
+ h = x.to_hash
152
+ assert_equal({"alpha"=>7,"beta"=>8,"gamma"=>9},h)
153
+
154
+ # A field name (String) may be used in a hash-like notation
155
+ myStruct = SuperStruct.new("alpha","beta","gamma")
156
+ x = myStruct.new(7,8,9)
157
+ y = x["beta"]
158
+
159
+ # A field name (Symbol) may be used in a hash-like notation
160
+ myStruct = SuperStruct.new("alpha","beta","gamma")
161
+ x = myStruct.new(7,8,9)
162
+ y = x[:beta]
163
+
164
+ # [offset,length] may be used as for arrays
165
+ myStruct = SuperStruct.new("alpha","beta","gamma")
166
+ x = myStruct.new(7,8,9)
167
+ y = x[0,2]
168
+
169
+ # Ranges may be used as for arrays
170
+ myStruct = SuperStruct.new("alpha","beta","gamma")
171
+ x = myStruct.new(7,8,9)
172
+ y = x[1..2]
173
+
174
+ # Adding a field to an open struct adds it to the instance
175
+ myStruct = SuperStruct.open(:alpha)
176
+ x = myStruct.new
177
+ x.beta = 5
178
+
179
+ # Adding a field to an open struct adds it to the class also
180
+ myStruct = SuperStruct.open(:alpha)
181
+ x = myStruct.new
182
+ x.beta = 5
183
+
184
+ # An array passed to SuperStruct.new need not be starred
185
+ myStruct = SuperStruct.new(%w[alpha beta gamma])
186
+ x = myStruct.new
187
+
188
+ # A hash passed to #set will set multiple values at once
189
+ myStruct = SuperStruct.new(%w[alpha beta gamma])
190
+ x = myStruct.new
191
+ hash = {"alpha"=>234,"beta"=>345,"gamma"=>456}
192
+ x.set(hash)
193
+
194
+ # ||= works properly
195
+ x = SuperStruct.open.new
196
+ x.foo ||= 333
197
+ x.bar = x.bar || 444
198
+
199
+ # attr_tester will create a ?-method
200
+ myStruct = SuperStruct.new(:alive)
201
+ myStruct.attr_tester :alive
202
+ x = myStruct.new(true)
203
+ x.alive? # true
204
+
@@ -0,0 +1,145 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
+ <HTML>
3
+ <HEAD>
4
+ <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Shift-JIS">
5
+
6
+ <TITLE>tagiter.rb�̐���</TITLE>
7
+ </HEAD>
8
+
9
+ <BODY>
10
+ <H1>tagiter.rb�̐���</H1>
11
+ <H3>�T�v</H3>
12
+ <P>������������������͌�g�p�����T���������B</P>
13
+ <P>
14
+ �e�L�X�g���̃^�O�Ɉ͂܂ꂽ�͈͂�yield���邽�߂̃N���X�ł��B<BR>
15
+ String�ł͂Ȃ��A�������g�̃N���X�̃C���X�^���X��yield���܂��B�e�L�X�g��
16
+ ����text���g���Ď��o���܂��B
17
+ </P>
18
+ <P>
19
+ �S���C�e���[�^�ɂ�����Ă̂��{���̎p�Ȃ̂ł��傤���A�߂�ǂ��������Ƃ������̂Œl�ŕԂ����\�b�h�����܂����B�K�V�K�V�ƃ��\�b�h���J�X�P�[�h�����Ďg���̂��{���̎g������������܂��񂪁A��҂ɂ��悭�킩���Ă܂���B
20
+ </P>
21
+
22
+ <P>
23
+ �Ȃ񂾂���̕�����Ȃ��\����html�t�@�C���Ȃǂł����񎎍s���낷��ΕK�v�ȏ��ɃA�N�Z�X�ł��܂��B�i�ق�Ƃ��H�j
24
+ </P>
25
+
26
+ <P>�����R�[�h�͊e���ł��܂����Ƃ���ĉ������B
27
+ </P>
28
+
29
+ <HR>
30
+ <H2>TextTagIterator</H2>
31
+ <H3>����</H3>
32
+ <DL>
33
+ <DT>text
34
+ <DD>�ێ����Ă���e�L�X�g�ł�
35
+ <DT>option
36
+ <DD>�^�O���ʗp���K�\���̃I�v�V�����ł��B�f�t�H���g��"pi"
37
+ <DT>tag
38
+ <DD>�ێ����Ă���e�L�X�g���������Ă����^�O�i�J�n�^�O�j
39
+ <DT>attributes
40
+ <DD>tag�ɂ����‚��Ă����������n�b�V���ɂ������́B�������͂��ׂď������ɕϊ�����Ă��܂��B<NOBR>(��case ignored�ɂȂ�܂���)</NOBR>
41
+ </DL>
42
+ <H3>���ك��\�b�h</H3>
43
+ <DL>
44
+ <DT>new(text,tag=nil,attributes={})
45
+ <DD>���ʂ̓t�@�C���̓��e��ǂݍ��݁A�����text�Ƃ��ēn���܂��B��Q�����ȍ~�͓����I�ɗ��p�������̂ł��B�C�ɂ��Ȃ��ʼn������B
46
+ </DL>
47
+ <H3>���\�b�h</H3>
48
+ <DL>
49
+ <DT>nth(opentag,n,closetag=nil) |tagiter|
50
+ <DD>opentag����closetag�܂ł�����ꂽ�e�L�X�g��n�Ԗڂ̂��̂�yield���܂��B�‚܂�P�x����yield����܂��B
51
+ <DD>opentag��"BODY"��"DL"�Ȃǂ̂悤��&lt;��&gt;�͏ȗ����Ďw�肵�܂��Bclosetag���ȗ�����ƁA"/"+opentag�i���ۂ͂�����ƈႢ�܂����j���ݒ肳��܂��B���ʂ�closetag�͏ȗ����邱�Ƃł��傤�B
52
+ <DD>�^�O�����̐��K�\����'<(\s|\n)*'+element+'(\s|\n|>)'�ł��B���ʂȉ��s��X�y�[�X�������Ă����v�Ȃ͂��B
53
+ <DD>�w�肵���^�O�̓���q�͂����ƔF�����܂��B�ł��̂ŁA<NOBR>&lt;t&gt; &lt;t&gt;test&lt;/t&gt;&lt;/t&gt; &lt;t&gt;OK&lt;/t&gt;</NOBR>�ɑ΂���nth("t",2)�Ƃ���ƁA"OK"��TextTagIterator�ɂ������̂�Ԃ��܂��B
54
+ <DD>�Ԃ�l�Ƃ��āA�‚��^�O�̌�둤�̃e�L�X�g�S�̂�TextTagIterator�i�܂��͂��̃T�u�N���X�j�ɂ�������Ԃ��܂��B
55
+ <DT>first(opentag,closetag=nil) |tagiter|
56
+ <DD>nth(opentag,1,closetag)���̂܂�܂ł��B
57
+ <DD>����next�Ƃ������낢�땴��킵���ʖ��������Ă��܂��B�J�X�P�[�h���鎞�p�B
58
+ <DT>each_block(opentag,closetag=nil) |tagiter|
59
+ <DD>nth()��first()�͎w�肵��n�Ԗڂ̃e�L�X�g����x��������yield���܂��񂪁A����͊J�n�^�O�ƏI���^�O�Ō��‚������e�L�X�g�͂��ׂ�yield���܂��B
60
+ <DD>������^�O�̃l�X�g�͔F�����܂��̂Œ��ӁB
61
+ <DD>�Ԃ�l�͍Ō��yield�����e�L�X�g����둤�̃e�L�X�g��TextTagIterator�i�܂��͂��̃T�u�N���X�j�ɂ�������
62
+ <DT>enumtag(tag) |tagiter|
63
+ <DD>DT��LI�Ȃǂ̃^�O�͏I���^�O������܂���B������tag�����ڂƂ��ăe�L�X�g�𕪊����A���ꂼ���yield���܂��B
64
+ <DD>�������A�ŏ���yield�����̂́A�ŏ���tag�̌�둤����ł��B����ȑO�̕����͖�������܂��B
65
+ <DD>�Ԃ�l�͓��ɂ���܂���B
66
+ <DT>for_this() |tagiter|
67
+ <DD>�������g��yield���܂��B
68
+ <DT>get_nth(*arg)
69
+ <DD>*arg��nth�Ɠ����ł��Bnth��yield�������̂�Ԃ�l�Ƃ��ĕԂ��܂��B
70
+ <DT>get_first(*arg)
71
+ <DD>*arg��first�Ɠ����ł��Bfirst��yield�������̂�Ԃ�l�Ƃ��ĕԂ��܂��B
72
+ <DT>collect(*arg)
73
+ <DD>*arg��each_block�Ɠ����ł��Beach_block��yield�������̂�z��ɓ���ĕԂ��܂��B
74
+ <DT>enumcollect(*arg)
75
+ <DD>*arg��enumtag�Ɠ����ł��Benumtag��yield�������̂�z��ɓ���ĕԂ��܂��B
76
+ <DT>tagexist?(tag,st=0)
77
+ <DD>�ێ����Ă���e�L�X�g��tag�Ŏ������^�O�����݂��Ă��邩�ǂ����̃`�F�b�N�B
78
+ st�͌����J�n�����ʒu�B
79
+ <DT>tagnext
80
+ <DD>�ێ����Ă���e�L�X�g���ň�ԍŏ��ɂ���^�O��Ԃ�
81
+ <DT>nth_trailer(tag,n)
82
+ <DD>n�Ԗڂ�tag�̃u���b�N�̌�둤�̃e�L�X�g��Ԃ��܂��B
83
+ <DD>���g��<CODE> nth(tag,n) do end </CODE> (��`)
84
+ </DL>
85
+
86
+ <HR>
87
+ <H3>��Ȃ�</H3>
88
+ <P>
89
+ �C�e���[�^�Ƃ��Ďg���ăJ�X�P�[�h���Ă���Ⴊtagiter.rb�̍Ō�ɏ����Ă���܂��B
90
+ </P>
91
+ <P>
92
+ ���x���x�C�e���[�g�����Ă��̒��g���E���̂��߂�ǂ������̂ŁA�K�Xget_nth()��get_first()�����g���������B
93
+ </P>
94
+ <P>
95
+ closetag�������Ŏw�肷��ƁA���낢�돬�׍H���o���܂��B<BR>
96
+ ���Ƃ���infoseek.co.jp�Ȃǂ̌������ʂ͂��ꂼ��A
97
+ &lt;!-- START ResURL_Search_JW&gt;��
98
+ &lt;!-- END ResURL_Search_JW&gt; �ł������Ă��܂����A�����́A<BR>
99
+
100
+ <CODE>
101
+ each_block("!-- START ResURL_Search_JW","!-- END ResURL_Search_JW") do |ser|
102
+ </CODE>
103
+ �Ƃ��邱�Ƃł��ꂼ���yield�o���܂��B<BR>
104
+ ���l�ɁA&lt;/TITLE&gt;����&lt;/HEAD&gt;�܂ł̃e�L�X�g���擾����Ȃ�ĕςȂ��Ƃ��ł��܂��B
105
+ </P>
106
+ <P>
107
+ goo��infoseek.co.jp��quote.yahoo.co.jp(d=v1)�̌������ʂ�yield������̂�
108
+ <A HREF="sengine.rb">sengine.rb</A>�ł��B<BR>
109
+ ���ɂ��ꂼ��̃T�C�g�p�̃N���X����`���Ă���܂����A�e�X�Aeach���\�b�h����`����Ă��܂��Byield������e�́A|url,title,desc|�B�Ԃ�l�͎��̌��ʃy�[�W�ւ�URL�ł��B
110
+ ������t�@�C���̍Ō�ɊȒP�Ȏg�p�Ⴊ����̂Ō��ĉ������B
111
+ </P>
112
+
113
+ <P>tcup�f���‚�sengine.rb�Ɠ����������镨��<A HREF="tcup.rb">tcup.rb</A>�ł��B
114
+ title�ɑ薼���̑��̏�񂪓���Aurl�ɂ͔����҂�����܂��Bdesc�͏������ݓ��e�B
115
+ �P���ɉ��������邽�тɐ�؂��Ă���̂ŁA��������&lt;HR&gt;������Ƃ��������Ȃ�܂��B�Ԃ�l�͎��̃y�[�W�ւ�URL�B
116
+ </P>
117
+ <HR>
118
+
119
+ <H3>���ӂȂ�</H3>
120
+ <P>
121
+ �‚��Y��̂���^�O�ɑ΂���each_block��������ƌ��ʂ��ςɂȂ邱�Ƃ�����܂�
122
+ �i�‚��Y�ꂽ�^�O����悪�܂邲�ƈ�‚̈����ɂȂ邱�Ƃ�����j�B
123
+ ���������ꍇ�͓K�X�A��ʂ̃^�O�Ńe�L�X�g���������������Ă��炨�g���������B
124
+ </P>
125
+
126
+ <HR>
127
+ <H3>�X�V����</H3>
128
+ <UL>
129
+ <LI>00/09/18�ɍX�V����܂����BTextTagIterator#attributes[]�̈�����case-ignored�ɁB
130
+ <LI>00/06/06�ɍX�V����܂����Bnth_trailer(tag,n)�lj��Btagnext�ύX�B
131
+ <LI>00/06/05�ɍX�V����܂����Btagnext��tagexist?(tag)���\�b�h�lj��ƁA�C�̕t�����o�O�C���B
132
+ <LI>00/06/01�ɍX�V����܂����B�Ō�ɋ�s�������Ȃǂ̃e�L�X�g�ɑ΂��čŊO�s�̃^�O��yield�����悤�Ƃ���ƃG���[�Ŏ~�܂��Ă܂����BString#index()��nil��Ԃ��ꍇ�̏����Y��B����l�A���񍐂��肪�Ƃ��������܂��B
133
+ <LI>00/05/08�ɍX�V����܂����B<CODE>&lt;TAG attr=1&gt;&lt;TAG attr=2&gt;...</CODE>�̂悤�ɉ��s���Ȃ��A������tag��Ώۂ�enumtag�𑖂点���ꍇ�A��‚�����yield���Ă��܂��i�����̌�����yield����Ȃ��j�̂��C���B
134
+ <LI>00/04/26�ɍX�V����܂����Btagiter.rb�̃^�O�������߂̃o�O�C���Ǝd�l�C������сAsengine.rb���ꕔ�����Ȃ��Ȃ��Ă��̂Ńo�[�W�����A�b�v�Btcup�f���‚̃X�N���v�g�lj�
135
+ <LI>�ŏ��͉������������Y��܂����B
136
+ </UL>
137
+
138
+ <HR>
139
+ �Ƃ������Ƃ�
140
+ <A HREF="http://www.threeweb.ad.jp/~nyasu/software/ruby.html">�߂�</A>
141
+ <HR>
142
+ <A HREF="mailto:nyasu@osk.3web.ne.jp"><ADDRESS>
143
+ Email: nyasu@osk.3web.ne.jp
144
+ </ADDRESS></A>
145
+ </BODY>
@@ -0,0 +1,1361 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # setup.rb
4
+ #
5
+ # Copyright (c) 2000-2004 Minero Aoki
6
+ #
7
+ # This program is free software.
8
+ # You can distribute/modify this program under the terms of
9
+ # the GNU LGPL, Lesser General Public License version 2.1.
10
+ #
11
+
12
+ unless Enumerable.method_defined?(:map) # Ruby 1.4.6
13
+ module Enumerable
14
+ alias map collect
15
+ end
16
+ end
17
+
18
+ unless File.respond_to?(:read) # Ruby 1.6
19
+ def File.read(fname)
20
+ open(fname) {|f|
21
+ return f.read
22
+ }
23
+ end
24
+ end
25
+
26
+ def File.binread(fname)
27
+ open(fname, 'rb') {|f|
28
+ return f.read
29
+ }
30
+ end
31
+
32
+ # for corrupted windows stat(2)
33
+ def File.dir?(path)
34
+ File.directory?((path[-1,1] == '/') ? path : path + '/')
35
+ end
36
+
37
+
38
+ class SetupError < StandardError; end
39
+
40
+ def setup_rb_error(msg)
41
+ raise SetupError, msg
42
+ end
43
+
44
+ #
45
+ # Config
46
+ #
47
+
48
+ if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg }
49
+ ARGV.delete(arg)
50
+ require arg.split(/=/, 2)[1]
51
+ $".push 'rbconfig.rb'
52
+ else
53
+ require 'rbconfig'
54
+ end
55
+
56
+ def multipackage_install?
57
+ FileTest.directory?(File.dirname($0) + '/packages')
58
+ end
59
+
60
+
61
+ class ConfigItem
62
+ def initialize(name, template, default, desc)
63
+ @name = name.freeze
64
+ @template = template
65
+ @value = default
66
+ @default = default.dup.freeze
67
+ @description = desc
68
+ end
69
+
70
+ attr_reader :name
71
+ attr_reader :description
72
+
73
+ attr_accessor :default
74
+ alias help_default default
75
+
76
+ def help_opt
77
+ "--#{@name}=#{@template}"
78
+ end
79
+
80
+ def value
81
+ @value
82
+ end
83
+
84
+ def eval(table)
85
+ @value.gsub(%r<\$([^/]+)>) { table[$1] }
86
+ end
87
+
88
+ def set(val)
89
+ @value = check(val)
90
+ end
91
+
92
+ private
93
+
94
+ def check(val)
95
+ setup_rb_error "config: --#{name} requires argument" unless val
96
+ val
97
+ end
98
+ end
99
+
100
+ class BoolItem < ConfigItem
101
+ def config_type
102
+ 'bool'
103
+ end
104
+
105
+ def help_opt
106
+ "--#{@name}"
107
+ end
108
+
109
+ private
110
+
111
+ def check(val)
112
+ return 'yes' unless val
113
+ unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val
114
+ setup_rb_error "config: --#{@name} accepts only yes/no for argument"
115
+ end
116
+ (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no'
117
+ end
118
+ end
119
+
120
+ class PathItem < ConfigItem
121
+ def config_type
122
+ 'path'
123
+ end
124
+
125
+ private
126
+
127
+ def check(path)
128
+ setup_rb_error "config: --#{@name} requires argument" unless path
129
+ path[0,1] == '$' ? path : File.expand_path(path)
130
+ end
131
+ end
132
+
133
+ class ProgramItem < ConfigItem
134
+ def config_type
135
+ 'program'
136
+ end
137
+ end
138
+
139
+ class SelectItem < ConfigItem
140
+ def initialize(name, template, default, desc)
141
+ super
142
+ @ok = template.split('/')
143
+ end
144
+
145
+ def config_type
146
+ 'select'
147
+ end
148
+
149
+ private
150
+
151
+ def check(val)
152
+ unless @ok.include?(val.strip)
153
+ setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
154
+ end
155
+ val.strip
156
+ end
157
+ end
158
+
159
+ class PackageSelectionItem < ConfigItem
160
+ def initialize(name, template, default, help_default, desc)
161
+ super name, template, default, desc
162
+ @help_default = help_default
163
+ end
164
+
165
+ attr_reader :help_default
166
+
167
+ def config_type
168
+ 'package'
169
+ end
170
+
171
+ private
172
+
173
+ def check(val)
174
+ unless File.dir?("packages/#{val}")
175
+ setup_rb_error "config: no such package: #{val}"
176
+ end
177
+ val
178
+ end
179
+ end
180
+
181
+ class ConfigTable_class
182
+
183
+ def initialize(items)
184
+ @items = items
185
+ @table = {}
186
+ items.each do |i|
187
+ @table[i.name] = i
188
+ end
189
+ ALIASES.each do |ali, name|
190
+ @table[ali] = @table[name]
191
+ end
192
+ end
193
+
194
+ include Enumerable
195
+
196
+ def each(&block)
197
+ @items.each(&block)
198
+ end
199
+
200
+ def key?(name)
201
+ @table.key?(name)
202
+ end
203
+
204
+ def lookup(name)
205
+ @table[name] or raise ArgumentError, "no such config item: #{name}"
206
+ end
207
+
208
+ def add(item)
209
+ @items.push item
210
+ @table[item.name] = item
211
+ end
212
+
213
+ def remove(name)
214
+ item = lookup(name)
215
+ @items.delete_if {|i| i.name == name }
216
+ @table.delete_if {|name, i| i.name == name }
217
+ item
218
+ end
219
+
220
+ def new
221
+ dup()
222
+ end
223
+
224
+ def savefile
225
+ '.config'
226
+ end
227
+
228
+ def load
229
+ begin
230
+ t = dup()
231
+ File.foreach(savefile()) do |line|
232
+ k, v = *line.split(/=/, 2)
233
+ t[k] = v.strip
234
+ end
235
+ t
236
+ rescue Errno::ENOENT
237
+ setup_rb_error $!.message + "#{File.basename($0)} config first"
238
+ end
239
+ end
240
+
241
+ def save
242
+ @items.each {|i| i.value }
243
+ File.open(savefile(), 'w') {|f|
244
+ @items.each do |i|
245
+ f.printf "%s=%s\n", i.name, i.value if i.value
246
+ end
247
+ }
248
+ end
249
+
250
+ def [](key)
251
+ lookup(key).eval(self)
252
+ end
253
+
254
+ def []=(key, val)
255
+ lookup(key).set val
256
+ end
257
+
258
+ end
259
+
260
+ c = ::Config::CONFIG
261
+
262
+ rubypath = c['bindir'] + '/' + c['ruby_install_name']
263
+
264
+ major = c['MAJOR'].to_i
265
+ minor = c['MINOR'].to_i
266
+ teeny = c['TEENY'].to_i
267
+ version = "#{major}.#{minor}"
268
+
269
+ # ruby ver. >= 1.4.4?
270
+ newpath_p = ((major >= 2) or
271
+ ((major == 1) and
272
+ ((minor >= 5) or
273
+ ((minor == 4) and (teeny >= 4)))))
274
+
275
+ if c['rubylibdir']
276
+ # V < 1.6.3
277
+ _stdruby = c['rubylibdir']
278
+ _siteruby = c['sitedir']
279
+ _siterubyver = c['sitelibdir']
280
+ _siterubyverarch = c['sitearchdir']
281
+ elsif newpath_p
282
+ # 1.4.4 <= V <= 1.6.3
283
+ _stdruby = "$prefix/lib/ruby/#{version}"
284
+ _siteruby = c['sitedir']
285
+ _siterubyver = "$siteruby/#{version}"
286
+ _siterubyverarch = "$siterubyver/#{c['arch']}"
287
+ else
288
+ # V < 1.4.4
289
+ _stdruby = "$prefix/lib/ruby/#{version}"
290
+ _siteruby = "$prefix/lib/ruby/#{version}/site_ruby"
291
+ _siterubyver = _siteruby
292
+ _siterubyverarch = "$siterubyver/#{c['arch']}"
293
+ end
294
+ libdir = '-* dummy libdir *-'
295
+ stdruby = '-* dummy rubylibdir *-'
296
+ siteruby = '-* dummy site_ruby *-'
297
+ siterubyver = '-* dummy site_ruby version *-'
298
+ parameterize = lambda {|path|
299
+ path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')\
300
+ .sub(/\A#{Regexp.quote(libdir)}/, '$libdir')\
301
+ .sub(/\A#{Regexp.quote(stdruby)}/, '$stdruby')\
302
+ .sub(/\A#{Regexp.quote(siteruby)}/, '$siteruby')\
303
+ .sub(/\A#{Regexp.quote(siterubyver)}/, '$siterubyver')
304
+ }
305
+ libdir = parameterize.call(c['libdir'])
306
+ stdruby = parameterize.call(_stdruby)
307
+ siteruby = parameterize.call(_siteruby)
308
+ siterubyver = parameterize.call(_siterubyver)
309
+ siterubyverarch = parameterize.call(_siterubyverarch)
310
+
311
+ if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
312
+ makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
313
+ else
314
+ makeprog = 'make'
315
+ end
316
+
317
+ common_conf = [
318
+ PathItem.new('prefix', 'path', c['prefix'],
319
+ 'path prefix of target environment'),
320
+ PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
321
+ 'the directory for commands'),
322
+ PathItem.new('libdir', 'path', libdir,
323
+ 'the directory for libraries'),
324
+ PathItem.new('datadir', 'path', parameterize.call(c['datadir']),
325
+ 'the directory for shared data'),
326
+ PathItem.new('mandir', 'path', parameterize.call(c['mandir']),
327
+ 'the directory for man pages'),
328
+ PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']),
329
+ 'the directory for man pages'),
330
+ PathItem.new('stdruby', 'path', stdruby,
331
+ 'the directory for standard ruby libraries'),
332
+ PathItem.new('siteruby', 'path', siteruby,
333
+ 'the directory for version-independent aux ruby libraries'),
334
+ PathItem.new('siterubyver', 'path', siterubyver,
335
+ 'the directory for aux ruby libraries'),
336
+ PathItem.new('siterubyverarch', 'path', siterubyverarch,
337
+ 'the directory for aux ruby binaries'),
338
+ PathItem.new('rbdir', 'path', '$siterubyver',
339
+ 'the directory for ruby scripts'),
340
+ PathItem.new('sodir', 'path', '$siterubyverarch',
341
+ 'the directory for ruby extentions'),
342
+ PathItem.new('rubypath', 'path', rubypath,
343
+ 'the path to set to #! line'),
344
+ ProgramItem.new('rubyprog', 'name', rubypath,
345
+ 'the ruby program using for installation'),
346
+ ProgramItem.new('makeprog', 'name', makeprog,
347
+ 'the make program to compile ruby extentions'),
348
+ SelectItem.new('shebang', 'all/ruby/never', 'ruby',
349
+ 'shebang line (#!) editing mode'),
350
+ BoolItem.new('without-ext', 'yes/no', 'no',
351
+ 'does not compile/install ruby extentions')
352
+ ]
353
+ class ConfigTable_class # open again
354
+ ALIASES = {
355
+ 'std-ruby' => 'stdruby',
356
+ 'site-ruby-common' => 'siteruby', # For backward compatibility
357
+ 'site-ruby' => 'siterubyver', # For backward compatibility
358
+ 'bin-dir' => 'bindir',
359
+ 'bin-dir' => 'bindir',
360
+ 'rb-dir' => 'rbdir',
361
+ 'so-dir' => 'sodir',
362
+ 'data-dir' => 'datadir',
363
+ 'ruby-path' => 'rubypath',
364
+ 'ruby-prog' => 'rubyprog',
365
+ 'ruby' => 'rubyprog',
366
+ 'make-prog' => 'makeprog',
367
+ 'make' => 'makeprog'
368
+ }
369
+ end
370
+ multipackage_conf = [
371
+ PackageSelectionItem.new('with', 'name,name...', '', 'ALL',
372
+ 'package names that you want to install'),
373
+ PackageSelectionItem.new('without', 'name,name...', '', 'NONE',
374
+ 'package names that you do not want to install')
375
+ ]
376
+ if multipackage_install?
377
+ ConfigTable = ConfigTable_class.new(common_conf + multipackage_conf)
378
+ else
379
+ ConfigTable = ConfigTable_class.new(common_conf)
380
+ end
381
+
382
+
383
+ module MetaConfigAPI
384
+
385
+ def eval_file_ifexist(fname)
386
+ instance_eval File.read(fname), fname, 1 if File.file?(fname)
387
+ end
388
+
389
+ def config_names
390
+ ConfigTable.map {|i| i.name }
391
+ end
392
+
393
+ def config?(name)
394
+ ConfigTable.key?(name)
395
+ end
396
+
397
+ def bool_config?(name)
398
+ ConfigTable.lookup(name).config_type == 'bool'
399
+ end
400
+
401
+ def path_config?(name)
402
+ ConfigTable.lookup(name).config_type == 'path'
403
+ end
404
+
405
+ def value_config?(name)
406
+ case ConfigTable.lookup(name).config_type
407
+ when 'bool', 'path'
408
+ true
409
+ else
410
+ false
411
+ end
412
+ end
413
+
414
+ def add_config(item)
415
+ ConfigTable.add item
416
+ end
417
+
418
+ def add_bool_config(name, default, desc)
419
+ ConfigTable.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc)
420
+ end
421
+
422
+ def add_path_config(name, default, desc)
423
+ ConfigTable.add PathItem.new(name, 'path', default, desc)
424
+ end
425
+
426
+ def set_config_default(name, default)
427
+ ConfigTable.lookup(name).default = default
428
+ end
429
+
430
+ def remove_config(name)
431
+ ConfigTable.remove(name)
432
+ end
433
+
434
+ end
435
+
436
+
437
+ #
438
+ # File Operations
439
+ #
440
+
441
+ module FileOperations
442
+
443
+ def mkdir_p(dirname, prefix = nil)
444
+ dirname = prefix + File.expand_path(dirname) if prefix
445
+ $stderr.puts "mkdir -p #{dirname}" if verbose?
446
+ return if no_harm?
447
+
448
+ # does not check '/'... it's too abnormal case
449
+ dirs = File.expand_path(dirname).split(%r<(?=/)>)
450
+ if /\A[a-z]:\z/i =~ dirs[0]
451
+ disk = dirs.shift
452
+ dirs[0] = disk + dirs[0]
453
+ end
454
+ dirs.each_index do |idx|
455
+ path = dirs[0..idx].join('')
456
+ Dir.mkdir path unless File.dir?(path)
457
+ end
458
+ end
459
+
460
+ def rm_f(fname)
461
+ $stderr.puts "rm -f #{fname}" if verbose?
462
+ return if no_harm?
463
+
464
+ if File.exist?(fname) or File.symlink?(fname)
465
+ File.chmod 0777, fname
466
+ File.unlink fname
467
+ end
468
+ end
469
+
470
+ def rm_rf(dn)
471
+ $stderr.puts "rm -rf #{dn}" if verbose?
472
+ return if no_harm?
473
+
474
+ Dir.chdir dn
475
+ Dir.foreach('.') do |fn|
476
+ next if fn == '.'
477
+ next if fn == '..'
478
+ if File.dir?(fn)
479
+ verbose_off {
480
+ rm_rf fn
481
+ }
482
+ else
483
+ verbose_off {
484
+ rm_f fn
485
+ }
486
+ end
487
+ end
488
+ Dir.chdir '..'
489
+ Dir.rmdir dn
490
+ end
491
+
492
+ def move_file(src, dest)
493
+ File.unlink dest if File.exist?(dest)
494
+ begin
495
+ File.rename src, dest
496
+ rescue
497
+ File.open(dest, 'wb') {|f| f.write File.binread(src) }
498
+ File.chmod File.stat(src).mode, dest
499
+ File.unlink src
500
+ end
501
+ end
502
+
503
+ def install(from, dest, mode, prefix = nil)
504
+ $stderr.puts "install #{from} #{dest}" if verbose?
505
+ return if no_harm?
506
+
507
+ realdest = prefix ? prefix + File.expand_path(dest) : dest
508
+ realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest)
509
+ str = File.binread(from)
510
+ if diff?(str, realdest)
511
+ verbose_off {
512
+ rm_f realdest if File.exist?(realdest)
513
+ }
514
+ File.open(realdest, 'wb') {|f|
515
+ f.write str
516
+ }
517
+ File.chmod mode, realdest
518
+
519
+ File.open("#{objdir_root()}/InstalledFiles", 'a') {|f|
520
+ if prefix
521
+ f.puts realdest.sub(prefix, '')
522
+ else
523
+ f.puts realdest
524
+ end
525
+ }
526
+ end
527
+ end
528
+
529
+ def diff?(new_content, path)
530
+ return true unless File.exist?(path)
531
+ new_content != File.binread(path)
532
+ end
533
+
534
+ def command(str)
535
+ $stderr.puts str if verbose?
536
+ system str or raise RuntimeError, "'system #{str}' failed"
537
+ end
538
+
539
+ def ruby(str)
540
+ command config('rubyprog') + ' ' + str
541
+ end
542
+
543
+ def make(task = '')
544
+ command config('makeprog') + ' ' + task
545
+ end
546
+
547
+ def extdir?(dir)
548
+ File.exist?(dir + '/MANIFEST')
549
+ end
550
+
551
+ def all_files_in(dirname)
552
+ Dir.open(dirname) {|d|
553
+ return d.select {|ent| File.file?("#{dirname}/#{ent}") }
554
+ }
555
+ end
556
+
557
+ REJECT_DIRS = %w(
558
+ CVS SCCS RCS CVS.adm .svn
559
+ )
560
+
561
+ def all_dirs_in(dirname)
562
+ Dir.open(dirname) {|d|
563
+ return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS
564
+ }
565
+ end
566
+
567
+ end
568
+
569
+
570
+ #
571
+ # Main Installer
572
+ #
573
+
574
+ module HookUtils
575
+
576
+ def run_hook(name)
577
+ try_run_hook "#{curr_srcdir()}/#{name}" or
578
+ try_run_hook "#{curr_srcdir()}/#{name}.rb"
579
+ end
580
+
581
+ def try_run_hook(fname)
582
+ return false unless File.file?(fname)
583
+ begin
584
+ instance_eval File.read(fname), fname, 1
585
+ rescue
586
+ setup_rb_error "hook #{fname} failed:\n" + $!.message
587
+ end
588
+ true
589
+ end
590
+
591
+ end
592
+
593
+
594
+ module HookScriptAPI
595
+
596
+ def get_config(key)
597
+ @config[key]
598
+ end
599
+
600
+ alias config get_config
601
+
602
+ def set_config(key, val)
603
+ @config[key] = val
604
+ end
605
+
606
+ #
607
+ # srcdir/objdir (works only in the package directory)
608
+ #
609
+
610
+ #abstract srcdir_root
611
+ #abstract objdir_root
612
+ #abstract relpath
613
+
614
+ def curr_srcdir
615
+ "#{srcdir_root()}/#{relpath()}"
616
+ end
617
+
618
+ def curr_objdir
619
+ "#{objdir_root()}/#{relpath()}"
620
+ end
621
+
622
+ def srcfile(path)
623
+ "#{curr_srcdir()}/#{path}"
624
+ end
625
+
626
+ def srcexist?(path)
627
+ File.exist?(srcfile(path))
628
+ end
629
+
630
+ def srcdirectory?(path)
631
+ File.dir?(srcfile(path))
632
+ end
633
+
634
+ def srcfile?(path)
635
+ File.file? srcfile(path)
636
+ end
637
+
638
+ def srcentries(path = '.')
639
+ Dir.open("#{curr_srcdir()}/#{path}") {|d|
640
+ return d.to_a - %w(. ..)
641
+ }
642
+ end
643
+
644
+ def srcfiles(path = '.')
645
+ srcentries(path).select {|fname|
646
+ File.file?(File.join(curr_srcdir(), path, fname))
647
+ }
648
+ end
649
+
650
+ def srcdirectories(path = '.')
651
+ srcentries(path).select {|fname|
652
+ File.dir?(File.join(curr_srcdir(), path, fname))
653
+ }
654
+ end
655
+
656
+ end
657
+
658
+
659
+ class ToplevelInstaller
660
+
661
+ Version = '3.3.1'
662
+ Copyright = 'Copyright (c) 2000-2004 Minero Aoki'
663
+
664
+ TASKS = [
665
+ [ 'all', 'do config, setup, then install' ],
666
+ [ 'config', 'saves your configurations' ],
667
+ [ 'show', 'shows current configuration' ],
668
+ [ 'setup', 'compiles ruby extentions and others' ],
669
+ [ 'install', 'installs files' ],
670
+ [ 'clean', "does `make clean' for each extention" ],
671
+ [ 'distclean',"does `make distclean' for each extention" ]
672
+ ]
673
+
674
+ def ToplevelInstaller.invoke
675
+ instance().invoke
676
+ end
677
+
678
+ @singleton = nil
679
+
680
+ def ToplevelInstaller.instance
681
+ @singleton ||= new(File.dirname($0))
682
+ @singleton
683
+ end
684
+
685
+ include MetaConfigAPI
686
+
687
+ def initialize(ardir_root)
688
+ @config = nil
689
+ @options = { 'verbose' => true }
690
+ @ardir = File.expand_path(ardir_root)
691
+ end
692
+
693
+ def inspect
694
+ "#<#{self.class} #{__id__()}>"
695
+ end
696
+
697
+ def invoke
698
+ run_metaconfigs
699
+ case task = parsearg_global()
700
+ when nil, 'all'
701
+ @config = load_config('config')
702
+ parsearg_config
703
+ init_installers
704
+ exec_config
705
+ exec_setup
706
+ exec_install
707
+ else
708
+ @config = load_config(task)
709
+ __send__ "parsearg_#{task}"
710
+ init_installers
711
+ __send__ "exec_#{task}"
712
+ end
713
+ end
714
+
715
+ def run_metaconfigs
716
+ eval_file_ifexist "#{@ardir}/metaconfig"
717
+ end
718
+
719
+ def load_config(task)
720
+ case task
721
+ when 'config'
722
+ ConfigTable.new
723
+ when 'clean', 'distclean'
724
+ if File.exist?(ConfigTable.savefile)
725
+ then ConfigTable.load
726
+ else ConfigTable.new
727
+ end
728
+ else
729
+ ConfigTable.load
730
+ end
731
+ end
732
+
733
+ def init_installers
734
+ @installer = Installer.new(@config, @options, @ardir, File.expand_path('.'))
735
+ end
736
+
737
+ #
738
+ # Hook Script API bases
739
+ #
740
+
741
+ def srcdir_root
742
+ @ardir
743
+ end
744
+
745
+ def objdir_root
746
+ '.'
747
+ end
748
+
749
+ def relpath
750
+ '.'
751
+ end
752
+
753
+ #
754
+ # Option Parsing
755
+ #
756
+
757
+ def parsearg_global
758
+ valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/
759
+
760
+ while arg = ARGV.shift
761
+ case arg
762
+ when /\A\w+\z/
763
+ setup_rb_error "invalid task: #{arg}" unless valid_task =~ arg
764
+ return arg
765
+
766
+ when '-q', '--quiet'
767
+ @options['verbose'] = false
768
+
769
+ when '--verbose'
770
+ @options['verbose'] = true
771
+
772
+ when '-h', '--help'
773
+ print_usage $stdout
774
+ exit 0
775
+
776
+ when '-v', '--version'
777
+ puts "#{File.basename($0)} version #{Version}"
778
+ exit 0
779
+
780
+ when '--copyright'
781
+ puts Copyright
782
+ exit 0
783
+
784
+ else
785
+ setup_rb_error "unknown global option '#{arg}'"
786
+ end
787
+ end
788
+
789
+ nil
790
+ end
791
+
792
+
793
+ def parsearg_no_options
794
+ unless ARGV.empty?
795
+ setup_rb_error "#{task}: unknown options: #{ARGV.join ' '}"
796
+ end
797
+ end
798
+
799
+ alias parsearg_show parsearg_no_options
800
+ alias parsearg_setup parsearg_no_options
801
+ alias parsearg_clean parsearg_no_options
802
+ alias parsearg_distclean parsearg_no_options
803
+
804
+ def parsearg_config
805
+ re = /\A--(#{ConfigTable.map {|i| i.name }.join('|')})(?:=(.*))?\z/
806
+ @options['config-opt'] = []
807
+
808
+ while i = ARGV.shift
809
+ if /\A--?\z/ =~ i
810
+ @options['config-opt'] = ARGV.dup
811
+ break
812
+ end
813
+ m = re.match(i) or setup_rb_error "config: unknown option #{i}"
814
+ name, value = *m.to_a[1,2]
815
+ @config[name] = value
816
+ end
817
+ end
818
+
819
+ def parsearg_install
820
+ @options['no-harm'] = false
821
+ @options['install-prefix'] = ''
822
+ while a = ARGV.shift
823
+ case a
824
+ when /\A--no-harm\z/
825
+ @options['no-harm'] = true
826
+ when /\A--prefix=(.*)\z/
827
+ path = $1
828
+ path = File.expand_path(path) unless path[0,1] == '/'
829
+ @options['install-prefix'] = path
830
+ else
831
+ setup_rb_error "install: unknown option #{a}"
832
+ end
833
+ end
834
+ end
835
+
836
+ def print_usage(out)
837
+ out.puts 'Typical Installation Procedure:'
838
+ out.puts " $ ruby #{File.basename $0} config"
839
+ out.puts " $ ruby #{File.basename $0} setup"
840
+ out.puts " # ruby #{File.basename $0} install (may require root privilege)"
841
+ out.puts
842
+ out.puts 'Detailed Usage:'
843
+ out.puts " ruby #{File.basename $0} <global option>"
844
+ out.puts " ruby #{File.basename $0} [<global options>] <task> [<task options>]"
845
+
846
+ fmt = " %-24s %s\n"
847
+ out.puts
848
+ out.puts 'Global options:'
849
+ out.printf fmt, '-q,--quiet', 'suppress message outputs'
850
+ out.printf fmt, ' --verbose', 'output messages verbosely'
851
+ out.printf fmt, '-h,--help', 'print this message'
852
+ out.printf fmt, '-v,--version', 'print version and quit'
853
+ out.printf fmt, ' --copyright', 'print copyright and quit'
854
+ out.puts
855
+ out.puts 'Tasks:'
856
+ TASKS.each do |name, desc|
857
+ out.printf fmt, name, desc
858
+ end
859
+
860
+ fmt = " %-24s %s [%s]\n"
861
+ out.puts
862
+ out.puts 'Options for CONFIG or ALL:'
863
+ ConfigTable.each do |item|
864
+ out.printf fmt, item.help_opt, item.description, item.help_default
865
+ end
866
+ out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's"
867
+ out.puts
868
+ out.puts 'Options for INSTALL:'
869
+ out.printf fmt, '--no-harm', 'only display what to do if given', 'off'
870
+ out.printf fmt, '--prefix=path', 'install path prefix', '$prefix'
871
+ out.puts
872
+ end
873
+
874
+ #
875
+ # Task Handlers
876
+ #
877
+
878
+ def exec_config
879
+ @installer.exec_config
880
+ @config.save # must be final
881
+ end
882
+
883
+ def exec_setup
884
+ @installer.exec_setup
885
+ end
886
+
887
+ def exec_install
888
+ @installer.exec_install
889
+ end
890
+
891
+ def exec_show
892
+ ConfigTable.each do |i|
893
+ printf "%-20s %s\n", i.name, i.value
894
+ end
895
+ end
896
+
897
+ def exec_clean
898
+ @installer.exec_clean
899
+ end
900
+
901
+ def exec_distclean
902
+ @installer.exec_distclean
903
+ end
904
+
905
+ end
906
+
907
+
908
+ class ToplevelInstallerMulti < ToplevelInstaller
909
+
910
+ include HookUtils
911
+ include HookScriptAPI
912
+ include FileOperations
913
+
914
+ def initialize(ardir)
915
+ super
916
+ @packages = all_dirs_in("#{@ardir}/packages")
917
+ raise 'no package exists' if @packages.empty?
918
+ end
919
+
920
+ def run_metaconfigs
921
+ eval_file_ifexist "#{@ardir}/metaconfig"
922
+ @packages.each do |name|
923
+ eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig"
924
+ end
925
+ end
926
+
927
+ def init_installers
928
+ @installers = {}
929
+ @packages.each do |pack|
930
+ @installers[pack] = Installer.new(@config, @options,
931
+ "#{@ardir}/packages/#{pack}",
932
+ "packages/#{pack}")
933
+ end
934
+
935
+ with = extract_selection(config('with'))
936
+ without = extract_selection(config('without'))
937
+ @selected = @installers.keys.select {|name|
938
+ (with.empty? or with.include?(name)) \
939
+ and not without.include?(name)
940
+ }
941
+ end
942
+
943
+ def extract_selection(list)
944
+ a = list.split(/,/)
945
+ a.each do |name|
946
+ setup_rb_error "no such package: #{name}" unless @installers.key?(name)
947
+ end
948
+ a
949
+ end
950
+
951
+ def print_usage(f)
952
+ super
953
+ f.puts 'Inluded packages:'
954
+ f.puts ' ' + @packages.sort.join(' ')
955
+ f.puts
956
+ end
957
+
958
+ #
959
+ # multi-package metaconfig API
960
+ #
961
+
962
+ attr_reader :packages
963
+
964
+ def declare_packages(list)
965
+ raise 'package list is empty' if list.empty?
966
+ list.each do |name|
967
+ raise "directory packages/#{name} does not exist"\
968
+ unless File.dir?("#{@ardir}/packages/#{name}")
969
+ end
970
+ @packages = list
971
+ end
972
+
973
+ #
974
+ # Task Handlers
975
+ #
976
+
977
+ def exec_config
978
+ run_hook 'pre-config'
979
+ each_selected_installers {|inst| inst.exec_config }
980
+ run_hook 'post-config'
981
+ @config.save # must be final
982
+ end
983
+
984
+ def exec_setup
985
+ run_hook 'pre-setup'
986
+ each_selected_installers {|inst| inst.exec_setup }
987
+ run_hook 'post-setup'
988
+ end
989
+
990
+ def exec_install
991
+ run_hook 'pre-install'
992
+ each_selected_installers {|inst| inst.exec_install }
993
+ run_hook 'post-install'
994
+ end
995
+
996
+ def exec_clean
997
+ rm_f ConfigTable.savefile
998
+ run_hook 'pre-clean'
999
+ each_selected_installers {|inst| inst.exec_clean }
1000
+ run_hook 'post-clean'
1001
+ end
1002
+
1003
+ def exec_distclean
1004
+ rm_f ConfigTable.savefile
1005
+ run_hook 'pre-distclean'
1006
+ each_selected_installers {|inst| inst.exec_distclean }
1007
+ run_hook 'post-distclean'
1008
+ end
1009
+
1010
+ #
1011
+ # lib
1012
+ #
1013
+
1014
+ def each_selected_installers
1015
+ Dir.mkdir 'packages' unless File.dir?('packages')
1016
+ @selected.each do |pack|
1017
+ $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose']
1018
+ Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}")
1019
+ Dir.chdir "packages/#{pack}"
1020
+ yield @installers[pack]
1021
+ Dir.chdir '../..'
1022
+ end
1023
+ end
1024
+
1025
+ def verbose?
1026
+ @options['verbose']
1027
+ end
1028
+
1029
+ def no_harm?
1030
+ @options['no-harm']
1031
+ end
1032
+
1033
+ end
1034
+
1035
+
1036
+ class Installer
1037
+
1038
+ FILETYPES = %w( bin lib ext data )
1039
+
1040
+ include HookScriptAPI
1041
+ include HookUtils
1042
+ include FileOperations
1043
+
1044
+ def initialize(config, opt, srcroot, objroot)
1045
+ @config = config
1046
+ @options = opt
1047
+ @srcdir = File.expand_path(srcroot)
1048
+ @objdir = File.expand_path(objroot)
1049
+ @currdir = '.'
1050
+ end
1051
+
1052
+ def inspect
1053
+ "#<#{self.class} #{File.basename(@srcdir)}>"
1054
+ end
1055
+
1056
+ #
1057
+ # Hook Script API base methods
1058
+ #
1059
+
1060
+ def srcdir_root
1061
+ @srcdir
1062
+ end
1063
+
1064
+ def objdir_root
1065
+ @objdir
1066
+ end
1067
+
1068
+ def relpath
1069
+ @currdir
1070
+ end
1071
+
1072
+ #
1073
+ # configs/options
1074
+ #
1075
+
1076
+ def no_harm?
1077
+ @options['no-harm']
1078
+ end
1079
+
1080
+ def verbose?
1081
+ @options['verbose']
1082
+ end
1083
+
1084
+ def verbose_off
1085
+ begin
1086
+ save, @options['verbose'] = @options['verbose'], false
1087
+ yield
1088
+ ensure
1089
+ @options['verbose'] = save
1090
+ end
1091
+ end
1092
+
1093
+ #
1094
+ # TASK config
1095
+ #
1096
+
1097
+ def exec_config
1098
+ exec_task_traverse 'config'
1099
+ end
1100
+
1101
+ def config_dir_bin(rel)
1102
+ end
1103
+
1104
+ def config_dir_lib(rel)
1105
+ end
1106
+
1107
+ def config_dir_ext(rel)
1108
+ extconf if extdir?(curr_srcdir())
1109
+ end
1110
+
1111
+ def extconf
1112
+ opt = @options['config-opt'].join(' ')
1113
+ command "#{config('rubyprog')} #{curr_srcdir()}/extconf.rb #{opt}"
1114
+ end
1115
+
1116
+ def config_dir_data(rel)
1117
+ end
1118
+
1119
+ #
1120
+ # TASK setup
1121
+ #
1122
+
1123
+ def exec_setup
1124
+ exec_task_traverse 'setup'
1125
+ end
1126
+
1127
+ def setup_dir_bin(rel)
1128
+ all_files_in(curr_srcdir()).each do |fname|
1129
+ adjust_shebang "#{curr_srcdir()}/#{fname}"
1130
+ end
1131
+ end
1132
+
1133
+ def adjust_shebang(path)
1134
+ return if no_harm?
1135
+ tmpfile = File.basename(path) + '.tmp'
1136
+ begin
1137
+ File.open(path, 'rb') {|r|
1138
+ first = r.gets
1139
+ return unless File.basename(config('rubypath')) == 'ruby'
1140
+ return unless File.basename(first.sub(/\A\#!/, '').split[0]) == 'ruby'
1141
+ $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose?
1142
+ File.open(tmpfile, 'wb') {|w|
1143
+ w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath'))
1144
+ w.write r.read
1145
+ }
1146
+ move_file tmpfile, File.basename(path)
1147
+ }
1148
+ ensure
1149
+ File.unlink tmpfile if File.exist?(tmpfile)
1150
+ end
1151
+ end
1152
+
1153
+ def setup_dir_lib(rel)
1154
+ end
1155
+
1156
+ def setup_dir_ext(rel)
1157
+ make if extdir?(curr_srcdir())
1158
+ end
1159
+
1160
+ def setup_dir_data(rel)
1161
+ end
1162
+
1163
+ #
1164
+ # TASK install
1165
+ #
1166
+
1167
+ def exec_install
1168
+ rm_f 'InstalledFiles'
1169
+ exec_task_traverse 'install'
1170
+ end
1171
+
1172
+ def install_dir_bin(rel)
1173
+ install_files collect_filenames_auto(), "#{config('bindir')}/#{rel}", 0755
1174
+ end
1175
+
1176
+ def install_dir_lib(rel)
1177
+ install_files ruby_scripts(), "#{config('rbdir')}/#{rel}", 0644
1178
+ end
1179
+
1180
+ def install_dir_ext(rel)
1181
+ return unless extdir?(curr_srcdir())
1182
+ install_files ruby_extentions('.'),
1183
+ "#{config('sodir')}/#{File.dirname(rel)}",
1184
+ 0555
1185
+ end
1186
+
1187
+ def install_dir_data(rel)
1188
+ install_files collect_filenames_auto(), "#{config('datadir')}/#{rel}", 0644
1189
+ end
1190
+
1191
+ def install_files(list, dest, mode)
1192
+ mkdir_p dest, @options['install-prefix']
1193
+ list.each do |fname|
1194
+ install fname, dest, mode, @options['install-prefix']
1195
+ end
1196
+ end
1197
+
1198
+ def ruby_scripts
1199
+ collect_filenames_auto().select {|n| /\.rb\z/ =~ n }
1200
+ end
1201
+
1202
+ # picked up many entries from cvs-1.11.1/src/ignore.c
1203
+ reject_patterns = %w(
1204
+ core RCSLOG tags TAGS .make.state
1205
+ .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
1206
+ *~ *.old *.bak *.BAK *.orig *.rej _$* *$
1207
+
1208
+ *.org *.in .*
1209
+ )
1210
+ mapping = {
1211
+ '.' => '\.',
1212
+ '$' => '\$',
1213
+ '#' => '\#',
1214
+ '*' => '.*'
1215
+ }
1216
+ REJECT_PATTERNS = Regexp.new('\A(?:' +
1217
+ reject_patterns.map {|pat|
1218
+ pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] }
1219
+ }.join('|') +
1220
+ ')\z')
1221
+
1222
+ def collect_filenames_auto
1223
+ mapdir((existfiles() - hookfiles()).reject {|fname|
1224
+ REJECT_PATTERNS =~ fname
1225
+ })
1226
+ end
1227
+
1228
+ def existfiles
1229
+ all_files_in(curr_srcdir()) | all_files_in('.')
1230
+ end
1231
+
1232
+ def hookfiles
1233
+ %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt|
1234
+ %w( config setup install clean ).map {|t| sprintf(fmt, t) }
1235
+ }.flatten
1236
+ end
1237
+
1238
+ def mapdir(filelist)
1239
+ filelist.map {|fname|
1240
+ if File.exist?(fname) # objdir
1241
+ fname
1242
+ else # srcdir
1243
+ File.join(curr_srcdir(), fname)
1244
+ end
1245
+ }
1246
+ end
1247
+
1248
+ def ruby_extentions(dir)
1249
+ Dir.open(dir) {|d|
1250
+ ents = d.select {|fname| /\.#{::Config::CONFIG['DLEXT']}\z/ =~ fname }
1251
+ if ents.empty?
1252
+ setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first"
1253
+ end
1254
+ return ents
1255
+ }
1256
+ end
1257
+
1258
+ #
1259
+ # TASK clean
1260
+ #
1261
+
1262
+ def exec_clean
1263
+ exec_task_traverse 'clean'
1264
+ rm_f ConfigTable.savefile
1265
+ rm_f 'InstalledFiles'
1266
+ end
1267
+
1268
+ def clean_dir_bin(rel)
1269
+ end
1270
+
1271
+ def clean_dir_lib(rel)
1272
+ end
1273
+
1274
+ def clean_dir_ext(rel)
1275
+ return unless extdir?(curr_srcdir())
1276
+ make 'clean' if File.file?('Makefile')
1277
+ end
1278
+
1279
+ def clean_dir_data(rel)
1280
+ end
1281
+
1282
+ #
1283
+ # TASK distclean
1284
+ #
1285
+
1286
+ def exec_distclean
1287
+ exec_task_traverse 'distclean'
1288
+ rm_f ConfigTable.savefile
1289
+ rm_f 'InstalledFiles'
1290
+ end
1291
+
1292
+ def distclean_dir_bin(rel)
1293
+ end
1294
+
1295
+ def distclean_dir_lib(rel)
1296
+ end
1297
+
1298
+ def distclean_dir_ext(rel)
1299
+ return unless extdir?(curr_srcdir())
1300
+ make 'distclean' if File.file?('Makefile')
1301
+ end
1302
+
1303
+ #
1304
+ # lib
1305
+ #
1306
+
1307
+ def exec_task_traverse(task)
1308
+ run_hook "pre-#{task}"
1309
+ FILETYPES.each do |type|
1310
+ if config('without-ext') == 'yes' and type == 'ext'
1311
+ $stderr.puts 'skipping ext/* by user option' if verbose?
1312
+ next
1313
+ end
1314
+ traverse task, type, "#{task}_dir_#{type}"
1315
+ end
1316
+ run_hook "post-#{task}"
1317
+ end
1318
+
1319
+ def traverse(task, rel, mid)
1320
+ dive_into(rel) {
1321
+ run_hook "pre-#{task}"
1322
+ __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '')
1323
+ all_dirs_in(curr_srcdir()).each do |d|
1324
+ traverse task, "#{rel}/#{d}", mid
1325
+ end
1326
+ run_hook "post-#{task}"
1327
+ }
1328
+ end
1329
+
1330
+ def dive_into(rel)
1331
+ return unless File.dir?("#{@srcdir}/#{rel}")
1332
+
1333
+ dir = File.basename(rel)
1334
+ Dir.mkdir dir unless File.dir?(dir)
1335
+ prevdir = Dir.pwd
1336
+ Dir.chdir dir
1337
+ $stderr.puts '---> ' + rel if verbose?
1338
+ @currdir = rel
1339
+ yield
1340
+ Dir.chdir prevdir
1341
+ $stderr.puts '<--- ' + rel if verbose?
1342
+ @currdir = File.dirname(rel)
1343
+ end
1344
+
1345
+ end
1346
+
1347
+
1348
+ if $0 == __FILE__
1349
+ begin
1350
+ if multipackage_install?
1351
+ ToplevelInstallerMulti.invoke
1352
+ else
1353
+ ToplevelInstaller.invoke
1354
+ end
1355
+ rescue SetupError
1356
+ raise if $DEBUG
1357
+ $stderr.puts $!.message
1358
+ $stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
1359
+ exit 1
1360
+ end
1361
+ end