mack-facets 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (492) hide show
  1. data/lib/gems.rb +25 -0
  2. data/lib/gems/english-0.3.1/VERSION +1 -0
  3. data/lib/gems/english-0.3.1/lib/english/array.rb +48 -0
  4. data/lib/gems/english-0.3.1/lib/english/censor.rb +76 -0
  5. data/lib/gems/english-0.3.1/lib/english/double_metaphone.rb +353 -0
  6. data/lib/gems/english-0.3.1/lib/english/dresner.rb +47 -0
  7. data/lib/gems/english-0.3.1/lib/english/inflect.rb +299 -0
  8. data/lib/gems/english-0.3.1/lib/english/jumble.rb +37 -0
  9. data/lib/gems/english-0.3.1/lib/english/levenshtein.rb +78 -0
  10. data/lib/gems/english-0.3.1/lib/english/metaphone.rb +110 -0
  11. data/lib/gems/english-0.3.1/lib/english/numerals.rb +71 -0
  12. data/lib/gems/english-0.3.1/lib/english/patterns.rb +49 -0
  13. data/lib/gems/english-0.3.1/lib/english/porter_stemming.rb +188 -0
  14. data/lib/gems/english-0.3.1/lib/english/roman.rb +174 -0
  15. data/lib/gems/english-0.3.1/lib/english/similarity.rb +103 -0
  16. data/lib/gems/english-0.3.1/lib/english/soundex.rb +70 -0
  17. data/lib/gems/english-0.3.1/lib/english/string.rb +210 -0
  18. data/lib/gems/english-0.3.1/lib/english/style.rb +294 -0
  19. data/lib/gems/english-0.3.1/lib/english/style_orm.rb +143 -0
  20. data/lib/gems/english-0.3.1/lib/english/textfilter.rb +91 -0
  21. data/lib/gems/extlib-0.9.8/lib/extlib.rb +56 -0
  22. data/lib/gems/extlib-0.9.8/lib/extlib/assertions.rb +8 -0
  23. data/lib/gems/extlib-0.9.8/lib/extlib/blank.rb +59 -0
  24. data/lib/gems/extlib-0.9.8/lib/extlib/boolean.rb +11 -0
  25. data/lib/gems/extlib-0.9.8/lib/extlib/class.rb +175 -0
  26. data/lib/gems/extlib-0.9.8/lib/extlib/datetime.rb +9 -0
  27. data/lib/gems/extlib-0.9.8/lib/extlib/dictionary.rb +433 -0
  28. data/lib/gems/extlib-0.9.8/lib/extlib/hash.rb +419 -0
  29. data/lib/gems/extlib-0.9.8/lib/extlib/hook.rb +366 -0
  30. data/lib/gems/extlib-0.9.8/lib/extlib/inflection.rb +435 -0
  31. data/lib/gems/extlib-0.9.8/lib/extlib/lazy_array.rb +106 -0
  32. data/lib/gems/extlib-0.9.8/lib/extlib/logger.rb +202 -0
  33. data/lib/gems/extlib-0.9.8/lib/extlib/mash.rb +148 -0
  34. data/lib/gems/extlib-0.9.8/lib/extlib/module.rb +41 -0
  35. data/lib/gems/extlib-0.9.8/lib/extlib/nil.rb +5 -0
  36. data/lib/gems/extlib-0.9.8/lib/extlib/numeric.rb +5 -0
  37. data/lib/gems/extlib-0.9.8/lib/extlib/object.rb +175 -0
  38. data/lib/gems/extlib-0.9.8/lib/extlib/object_space.rb +13 -0
  39. data/lib/gems/extlib-0.9.8/lib/extlib/pathname.rb +5 -0
  40. data/lib/gems/extlib-0.9.8/lib/extlib/pooling.rb +239 -0
  41. data/lib/gems/extlib-0.9.8/lib/extlib/rubygems.rb +38 -0
  42. data/lib/gems/extlib-0.9.8/lib/extlib/simple_set.rb +39 -0
  43. data/lib/gems/extlib-0.9.8/lib/extlib/string.rb +132 -0
  44. data/lib/gems/extlib-0.9.8/lib/extlib/struct.rb +8 -0
  45. data/lib/gems/extlib-0.9.8/lib/extlib/symbol.rb +17 -0
  46. data/lib/gems/extlib-0.9.8/lib/extlib/tasks/release.rb +15 -0
  47. data/lib/gems/extlib-0.9.8/lib/extlib/time.rb +19 -0
  48. data/lib/gems/extlib-0.9.8/lib/extlib/version.rb +3 -0
  49. data/lib/gems/extlib-0.9.8/lib/extlib/virtual_file.rb +10 -0
  50. data/lib/gems/facets-2.4.5/VERSION +1 -0
  51. data/lib/gems/facets-2.4.5/lib/core/facets-live.rb +17 -0
  52. data/lib/gems/facets-2.4.5/lib/core/facets-load.rb +12 -0
  53. data/lib/gems/facets-2.4.5/lib/core/facets.rb +11 -0
  54. data/lib/gems/facets-2.4.5/lib/core/facets/array.rb +6 -0
  55. data/lib/gems/facets-2.4.5/lib/core/facets/array/combination.rb +59 -0
  56. data/lib/gems/facets-2.4.5/lib/core/facets/array/conjoin.rb +58 -0
  57. data/lib/gems/facets-2.4.5/lib/core/facets/array/delete.rb +61 -0
  58. data/lib/gems/facets-2.4.5/lib/core/facets/array/index.rb +48 -0
  59. data/lib/gems/facets-2.4.5/lib/core/facets/array/indexable.rb +73 -0
  60. data/lib/gems/facets-2.4.5/lib/core/facets/array/merge.rb +21 -0
  61. data/lib/gems/facets-2.4.5/lib/core/facets/array/not_empty.rb +13 -0
  62. data/lib/gems/facets-2.4.5/lib/core/facets/array/only.rb +21 -0
  63. data/lib/gems/facets-2.4.5/lib/core/facets/array/pad.rb +41 -0
  64. data/lib/gems/facets-2.4.5/lib/core/facets/array/permutation.rb +30 -0
  65. data/lib/gems/facets-2.4.5/lib/core/facets/array/product.rb +57 -0
  66. data/lib/gems/facets-2.4.5/lib/core/facets/array/recursively.rb +30 -0
  67. data/lib/gems/facets-2.4.5/lib/core/facets/array/rotate.rb +42 -0
  68. data/lib/gems/facets-2.4.5/lib/core/facets/array/select.rb +16 -0
  69. data/lib/gems/facets-2.4.5/lib/core/facets/array/splice.rb +30 -0
  70. data/lib/gems/facets-2.4.5/lib/core/facets/array/stackable.rb +33 -0
  71. data/lib/gems/facets-2.4.5/lib/core/facets/array/traverse.rb +22 -0
  72. data/lib/gems/facets-2.4.5/lib/core/facets/binding.rb +6 -0
  73. data/lib/gems/facets-2.4.5/lib/core/facets/binding/caller.rb +54 -0
  74. data/lib/gems/facets-2.4.5/lib/core/facets/binding/defined.rb +13 -0
  75. data/lib/gems/facets-2.4.5/lib/core/facets/binding/eval.rb +18 -0
  76. data/lib/gems/facets-2.4.5/lib/core/facets/binding/local_variables.rb +15 -0
  77. data/lib/gems/facets-2.4.5/lib/core/facets/binding/self.rb +12 -0
  78. data/lib/gems/facets-2.4.5/lib/core/facets/bitmask.rb +104 -0
  79. data/lib/gems/facets-2.4.5/lib/core/facets/blank.rb +60 -0
  80. data/lib/gems/facets-2.4.5/lib/core/facets/boolean.rb +156 -0
  81. data/lib/gems/facets-2.4.5/lib/core/facets/callstack.rb +52 -0
  82. data/lib/gems/facets-2.4.5/lib/core/facets/cattr.rb +2 -0
  83. data/lib/gems/facets-2.4.5/lib/core/facets/class.rb +6 -0
  84. data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr.rb +115 -0
  85. data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_accessor.rb +1 -0
  86. data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_reader.rb +1 -0
  87. data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_writer.rb +1 -0
  88. data/lib/gems/facets-2.4.5/lib/core/facets/class/descendents.rb +36 -0
  89. data/lib/gems/facets-2.4.5/lib/core/facets/class/methodize.rb +14 -0
  90. data/lib/gems/facets-2.4.5/lib/core/facets/class/pathize.rb +14 -0
  91. data/lib/gems/facets-2.4.5/lib/core/facets/class/prepend.rb +50 -0
  92. data/lib/gems/facets-2.4.5/lib/core/facets/class/subclasses.rb +2 -0
  93. data/lib/gems/facets-2.4.5/lib/core/facets/class/to_proc.rb +42 -0
  94. data/lib/gems/facets-2.4.5/lib/core/facets/comparable.rb +6 -0
  95. data/lib/gems/facets-2.4.5/lib/core/facets/comparable/bound.rb +65 -0
  96. data/lib/gems/facets-2.4.5/lib/core/facets/comparable/cmp.rb +38 -0
  97. data/lib/gems/facets-2.4.5/lib/core/facets/comparable/comparable.rb +42 -0
  98. data/lib/gems/facets-2.4.5/lib/core/facets/dir.rb +6 -0
  99. data/lib/gems/facets-2.4.5/lib/core/facets/dir/ascend.rb +59 -0
  100. data/lib/gems/facets-2.4.5/lib/core/facets/dir/descend.rb +1 -0
  101. data/lib/gems/facets-2.4.5/lib/core/facets/dir/multiglob.rb +92 -0
  102. data/lib/gems/facets-2.4.5/lib/core/facets/dir/parent.rb +13 -0
  103. data/lib/gems/facets-2.4.5/lib/core/facets/dir/recurse.rb +29 -0
  104. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable.rb +6 -0
  105. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/accumulate.rb +21 -0
  106. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/cluster_by.rb +21 -0
  107. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/collect.rb +54 -0
  108. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/commonality.rb +33 -0
  109. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/count.rb +26 -0
  110. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/divide.rb +33 -0
  111. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/duplicates.rb +38 -0
  112. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/each_by.rb +33 -0
  113. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/entropy.rb +37 -0
  114. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/frequency.rb +18 -0
  115. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/group_by.rb +27 -0
  116. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/inject.rb +31 -0
  117. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/map_send.rb +12 -0
  118. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/mash.rb +32 -0
  119. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/mode.rb +16 -0
  120. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/modulate.rb +22 -0
  121. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/none.rb +31 -0
  122. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/occur.rb +38 -0
  123. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/one.rb +38 -0
  124. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/probability.rb +36 -0
  125. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/split.rb +27 -0
  126. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/sum.rb +16 -0
  127. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/uniq_by.rb +18 -0
  128. data/lib/gems/facets-2.4.5/lib/core/facets/exception.rb +6 -0
  129. data/lib/gems/facets-2.4.5/lib/core/facets/exception/detail.rb +19 -0
  130. data/lib/gems/facets-2.4.5/lib/core/facets/exception/suppress.rb +21 -0
  131. data/lib/gems/facets-2.4.5/lib/core/facets/file.rb +6 -0
  132. data/lib/gems/facets-2.4.5/lib/core/facets/file/append.rb +14 -0
  133. data/lib/gems/facets-2.4.5/lib/core/facets/file/create.rb +21 -0
  134. data/lib/gems/facets-2.4.5/lib/core/facets/file/null.rb +21 -0
  135. data/lib/gems/facets-2.4.5/lib/core/facets/file/read.rb +41 -0
  136. data/lib/gems/facets-2.4.5/lib/core/facets/file/rewrite.rb +88 -0
  137. data/lib/gems/facets-2.4.5/lib/core/facets/file/rootname.rb +33 -0
  138. data/lib/gems/facets-2.4.5/lib/core/facets/file/split_root.rb +10 -0
  139. data/lib/gems/facets-2.4.5/lib/core/facets/file/write.rb +22 -0
  140. data/lib/gems/facets-2.4.5/lib/core/facets/file/writelines.rb +24 -0
  141. data/lib/gems/facets-2.4.5/lib/core/facets/filetest.rb +6 -0
  142. data/lib/gems/facets-2.4.5/lib/core/facets/filetest/root.rb +17 -0
  143. data/lib/gems/facets-2.4.5/lib/core/facets/float.rb +6 -0
  144. data/lib/gems/facets-2.4.5/lib/core/facets/float/round.rb +2 -0
  145. data/lib/gems/facets-2.4.5/lib/core/facets/functor.rb +77 -0
  146. data/lib/gems/facets-2.4.5/lib/core/facets/hash.rb +6 -0
  147. data/lib/gems/facets-2.4.5/lib/core/facets/hash/alias.rb +31 -0
  148. data/lib/gems/facets-2.4.5/lib/core/facets/hash/argumentize.rb +22 -0
  149. data/lib/gems/facets-2.4.5/lib/core/facets/hash/at.rb +8 -0
  150. data/lib/gems/facets-2.4.5/lib/core/facets/hash/autonew.rb +42 -0
  151. data/lib/gems/facets-2.4.5/lib/core/facets/hash/collate.rb +45 -0
  152. data/lib/gems/facets-2.4.5/lib/core/facets/hash/delete.rb +47 -0
  153. data/lib/gems/facets-2.4.5/lib/core/facets/hash/diff.rb +11 -0
  154. data/lib/gems/facets-2.4.5/lib/core/facets/hash/except.rb +27 -0
  155. data/lib/gems/facets-2.4.5/lib/core/facets/hash/insert.rb +19 -0
  156. data/lib/gems/facets-2.4.5/lib/core/facets/hash/inverse.rb +27 -0
  157. data/lib/gems/facets-2.4.5/lib/core/facets/hash/join.rb +14 -0
  158. data/lib/gems/facets-2.4.5/lib/core/facets/hash/keys.rb +45 -0
  159. data/lib/gems/facets-2.4.5/lib/core/facets/hash/mash.rb +18 -0
  160. data/lib/gems/facets-2.4.5/lib/core/facets/hash/merge.rb +30 -0
  161. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op.rb +7 -0
  162. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_add.rb +12 -0
  163. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_and.rb +33 -0
  164. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_mul.rb +18 -0
  165. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_or.rb +12 -0
  166. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_push.rb +17 -0
  167. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_sub.rb +26 -0
  168. data/lib/gems/facets-2.4.5/lib/core/facets/hash/recursive_merge.rb +33 -0
  169. data/lib/gems/facets-2.4.5/lib/core/facets/hash/recursively.rb +29 -0
  170. data/lib/gems/facets-2.4.5/lib/core/facets/hash/rekey.rb +59 -0
  171. data/lib/gems/facets-2.4.5/lib/core/facets/hash/select.rb +14 -0
  172. data/lib/gems/facets-2.4.5/lib/core/facets/hash/slice.rb +33 -0
  173. data/lib/gems/facets-2.4.5/lib/core/facets/hash/swap.rb +17 -0
  174. data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_h.rb +1 -0
  175. data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_proc.rb +41 -0
  176. data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_struct.rb +17 -0
  177. data/lib/gems/facets-2.4.5/lib/core/facets/hash/traverse.rb +41 -0
  178. data/lib/gems/facets-2.4.5/lib/core/facets/hash/update.rb +81 -0
  179. data/lib/gems/facets-2.4.5/lib/core/facets/hash/weave.rb +81 -0
  180. data/lib/gems/facets-2.4.5/lib/core/facets/hash/zipnew.rb +2 -0
  181. data/lib/gems/facets-2.4.5/lib/core/facets/indexable.rb +251 -0
  182. data/lib/gems/facets-2.4.5/lib/core/facets/integer.rb +6 -0
  183. data/lib/gems/facets-2.4.5/lib/core/facets/integer/even.rb +1 -0
  184. data/lib/gems/facets-2.4.5/lib/core/facets/integer/factorial.rb +30 -0
  185. data/lib/gems/facets-2.4.5/lib/core/facets/integer/multiple.rb +15 -0
  186. data/lib/gems/facets-2.4.5/lib/core/facets/integer/odd.rb +35 -0
  187. data/lib/gems/facets-2.4.5/lib/core/facets/integer/of.rb +18 -0
  188. data/lib/gems/facets-2.4.5/lib/core/facets/integer/ordinal.rb +24 -0
  189. data/lib/gems/facets-2.4.5/lib/core/facets/kernel.rb +6 -0
  190. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__callee__.rb +1 -0
  191. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__class__.rb +9 -0
  192. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__dir__.rb +12 -0
  193. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__get__.rb +10 -0
  194. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__method__.rb +36 -0
  195. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__set__.rb +1 -0
  196. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/as.rb +100 -0
  197. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/ask.rb +27 -0
  198. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/attr_singleton.rb +62 -0
  199. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/complete.rb +18 -0
  200. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/constant.rb +24 -0
  201. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/d.rb +26 -0
  202. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/deep_copy.rb +13 -0
  203. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/demo.rb +23 -0
  204. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/ergo.rb +42 -0
  205. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/here.rb +12 -0
  206. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/in.rb +13 -0
  207. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance.rb +19 -0
  208. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_assign.rb +41 -0
  209. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_class.rb +24 -0
  210. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_exec.rb +40 -0
  211. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_send.rb +7 -0
  212. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_variables.rb +99 -0
  213. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/maybe.rb +18 -0
  214. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/not_nil.rb +17 -0
  215. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_class.rb +10 -0
  216. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_hexid.rb +12 -0
  217. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_send.rb +32 -0
  218. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/p.rb +24 -0
  219. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/populate.rb +73 -0
  220. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/qua_class.rb +19 -0
  221. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/require_all.rb +21 -0
  222. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/require_local.rb +24 -0
  223. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/resc.rb +16 -0
  224. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/respond.rb +23 -0
  225. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/returning.rb +23 -0
  226. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/silence.rb +75 -0
  227. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/singleton_class.rb +19 -0
  228. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/tap.rb +32 -0
  229. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/try.rb +23 -0
  230. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/val.rb +19 -0
  231. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/with.rb +20 -0
  232. data/lib/gems/facets-2.4.5/lib/core/facets/lazy.rb +238 -0
  233. data/lib/gems/facets-2.4.5/lib/core/facets/matchdata.rb +6 -0
  234. data/lib/gems/facets-2.4.5/lib/core/facets/matchdata/match.rb +15 -0
  235. data/lib/gems/facets-2.4.5/lib/core/facets/matchdata/matchset.rb +44 -0
  236. data/lib/gems/facets-2.4.5/lib/core/facets/metaid.rb +94 -0
  237. data/lib/gems/facets-2.4.5/lib/core/facets/module.rb +6 -0
  238. data/lib/gems/facets-2.4.5/lib/core/facets/module/abstract.rb +21 -0
  239. data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_accessor.rb +45 -0
  240. data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_method_chain.rb +50 -0
  241. data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_module_function.rb +30 -0
  242. data/lib/gems/facets-2.4.5/lib/core/facets/module/ancestor.rb +16 -0
  243. data/lib/gems/facets-2.4.5/lib/core/facets/module/basename.rb +31 -0
  244. data/lib/gems/facets-2.4.5/lib/core/facets/module/can.rb +14 -0
  245. data/lib/gems/facets-2.4.5/lib/core/facets/module/class.rb +12 -0
  246. data/lib/gems/facets-2.4.5/lib/core/facets/module/conflict.rb +63 -0
  247. data/lib/gems/facets-2.4.5/lib/core/facets/module/include_function_module.rb +25 -0
  248. data/lib/gems/facets-2.4.5/lib/core/facets/module/instance_methods.rb +40 -0
  249. data/lib/gems/facets-2.4.5/lib/core/facets/module/integrate.rb +2 -0
  250. data/lib/gems/facets-2.4.5/lib/core/facets/module/is.rb +57 -0
  251. data/lib/gems/facets-2.4.5/lib/core/facets/module/methodize.rb +14 -0
  252. data/lib/gems/facets-2.4.5/lib/core/facets/module/modspace.rb +22 -0
  253. data/lib/gems/facets-2.4.5/lib/core/facets/module/module_load.rb +56 -0
  254. data/lib/gems/facets-2.4.5/lib/core/facets/module/nesting.rb +18 -0
  255. data/lib/gems/facets-2.4.5/lib/core/facets/module/op.rb +95 -0
  256. data/lib/gems/facets-2.4.5/lib/core/facets/module/pathize.rb +22 -0
  257. data/lib/gems/facets-2.4.5/lib/core/facets/module/prepend.rb +26 -0
  258. data/lib/gems/facets-2.4.5/lib/core/facets/module/redefine_method.rb +35 -0
  259. data/lib/gems/facets-2.4.5/lib/core/facets/module/redirect_method.rb +45 -0
  260. data/lib/gems/facets-2.4.5/lib/core/facets/module/rename_method.rb +20 -0
  261. data/lib/gems/facets-2.4.5/lib/core/facets/module/revise.rb +62 -0
  262. data/lib/gems/facets-2.4.5/lib/core/facets/module/spacename.rb +25 -0
  263. data/lib/gems/facets-2.4.5/lib/core/facets/module/wrap_method.rb +28 -0
  264. data/lib/gems/facets-2.4.5/lib/core/facets/nilclass.rb +6 -0
  265. data/lib/gems/facets-2.4.5/lib/core/facets/nilclass/ergo.rb +1 -0
  266. data/lib/gems/facets-2.4.5/lib/core/facets/nilclass/to_f.rb +17 -0
  267. data/lib/gems/facets-2.4.5/lib/core/facets/numeric.rb +6 -0
  268. data/lib/gems/facets-2.4.5/lib/core/facets/numeric/approx.rb +15 -0
  269. data/lib/gems/facets-2.4.5/lib/core/facets/numeric/distance.rb +14 -0
  270. data/lib/gems/facets-2.4.5/lib/core/facets/numeric/round.rb +72 -0
  271. data/lib/gems/facets-2.4.5/lib/core/facets/proc.rb +6 -0
  272. data/lib/gems/facets-2.4.5/lib/core/facets/proc/bind.rb +22 -0
  273. data/lib/gems/facets-2.4.5/lib/core/facets/proc/compose.rb +42 -0
  274. data/lib/gems/facets-2.4.5/lib/core/facets/proc/curry.rb +31 -0
  275. data/lib/gems/facets-2.4.5/lib/core/facets/proc/to_method.rb +33 -0
  276. data/lib/gems/facets-2.4.5/lib/core/facets/proc/update.rb +9 -0
  277. data/lib/gems/facets-2.4.5/lib/core/facets/range.rb +6 -0
  278. data/lib/gems/facets-2.4.5/lib/core/facets/range/combine.rb +47 -0
  279. data/lib/gems/facets-2.4.5/lib/core/facets/range/overlap.rb +13 -0
  280. data/lib/gems/facets-2.4.5/lib/core/facets/range/to_r.rb +26 -0
  281. data/lib/gems/facets-2.4.5/lib/core/facets/range/umbrella.rb +1 -0
  282. data/lib/gems/facets-2.4.5/lib/core/facets/range/within.rb +66 -0
  283. data/lib/gems/facets-2.4.5/lib/core/facets/regexp.rb +6 -0
  284. data/lib/gems/facets-2.4.5/lib/core/facets/regexp/arity.rb +17 -0
  285. data/lib/gems/facets-2.4.5/lib/core/facets/regexp/to_re.rb +28 -0
  286. data/lib/gems/facets-2.4.5/lib/core/facets/stackable.rb +86 -0
  287. data/lib/gems/facets-2.4.5/lib/core/facets/string.rb +6 -0
  288. data/lib/gems/facets-2.4.5/lib/core/facets/string/align.rb +106 -0
  289. data/lib/gems/facets-2.4.5/lib/core/facets/string/bracket.rb +105 -0
  290. data/lib/gems/facets-2.4.5/lib/core/facets/string/bytes.rb +15 -0
  291. data/lib/gems/facets-2.4.5/lib/core/facets/string/camelcase.rb +26 -0
  292. data/lib/gems/facets-2.4.5/lib/core/facets/string/capitalized.rb +46 -0
  293. data/lib/gems/facets-2.4.5/lib/core/facets/string/chars.rb +16 -0
  294. data/lib/gems/facets-2.4.5/lib/core/facets/string/chomp.rb +33 -0
  295. data/lib/gems/facets-2.4.5/lib/core/facets/string/cleave.rb +36 -0
  296. data/lib/gems/facets-2.4.5/lib/core/facets/string/divide.rb +21 -0
  297. data/lib/gems/facets-2.4.5/lib/core/facets/string/each_char.rb +29 -0
  298. data/lib/gems/facets-2.4.5/lib/core/facets/string/each_word.rb +13 -0
  299. data/lib/gems/facets-2.4.5/lib/core/facets/string/end_with.rb +1 -0
  300. data/lib/gems/facets-2.4.5/lib/core/facets/string/fold.rb +39 -0
  301. data/lib/gems/facets-2.4.5/lib/core/facets/string/interpolate.rb +20 -0
  302. data/lib/gems/facets-2.4.5/lib/core/facets/string/line_wrap.rb +21 -0
  303. data/lib/gems/facets-2.4.5/lib/core/facets/string/lines.rb +16 -0
  304. data/lib/gems/facets-2.4.5/lib/core/facets/string/methodize.rb +17 -0
  305. data/lib/gems/facets-2.4.5/lib/core/facets/string/modulize.rb +21 -0
  306. data/lib/gems/facets-2.4.5/lib/core/facets/string/mscan.rb +19 -0
  307. data/lib/gems/facets-2.4.5/lib/core/facets/string/natcmp.rb +88 -0
  308. data/lib/gems/facets-2.4.5/lib/core/facets/string/nchar.rb +28 -0
  309. data/lib/gems/facets-2.4.5/lib/core/facets/string/op_sub.rb +14 -0
  310. data/lib/gems/facets-2.4.5/lib/core/facets/string/pathize.rb +16 -0
  311. data/lib/gems/facets-2.4.5/lib/core/facets/string/range.rb +77 -0
  312. data/lib/gems/facets-2.4.5/lib/core/facets/string/rewrite.rb +28 -0
  313. data/lib/gems/facets-2.4.5/lib/core/facets/string/shatter.rb +22 -0
  314. data/lib/gems/facets-2.4.5/lib/core/facets/string/snakecase.rb +21 -0
  315. data/lib/gems/facets-2.4.5/lib/core/facets/string/splice.rb +37 -0
  316. data/lib/gems/facets-2.4.5/lib/core/facets/string/start_with.rb +32 -0
  317. data/lib/gems/facets-2.4.5/lib/core/facets/string/subtract.rb +4 -0
  318. data/lib/gems/facets-2.4.5/lib/core/facets/string/tab.rb +103 -0
  319. data/lib/gems/facets-2.4.5/lib/core/facets/string/titlecase.rb +15 -0
  320. data/lib/gems/facets-2.4.5/lib/core/facets/string/to_re.rb +26 -0
  321. data/lib/gems/facets-2.4.5/lib/core/facets/string/variablize.rb +13 -0
  322. data/lib/gems/facets-2.4.5/lib/core/facets/string/word_wrap.rb +34 -0
  323. data/lib/gems/facets-2.4.5/lib/core/facets/string/words.rb +12 -0
  324. data/lib/gems/facets-2.4.5/lib/core/facets/string/xor.rb +22 -0
  325. data/lib/gems/facets-2.4.5/lib/core/facets/symbol.rb +6 -0
  326. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/chomp.rb +24 -0
  327. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/generate.rb +24 -0
  328. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/not.rb +29 -0
  329. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/plain.rb +17 -0
  330. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/query.rb +1 -0
  331. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/re_s.rb +18 -0
  332. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/setter.rb +1 -0
  333. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/succ.rb +19 -0
  334. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/to_proc.rb +38 -0
  335. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/variablize.rb +12 -0
  336. data/lib/gems/facets-2.4.5/lib/core/facets/time.rb +6 -0
  337. data/lib/gems/facets-2.4.5/lib/core/facets/time/advance.rb +17 -0
  338. data/lib/gems/facets-2.4.5/lib/core/facets/time/ago.rb +1 -0
  339. data/lib/gems/facets-2.4.5/lib/core/facets/time/change.rb +41 -0
  340. data/lib/gems/facets-2.4.5/lib/core/facets/time/elapse.rb +16 -0
  341. data/lib/gems/facets-2.4.5/lib/core/facets/time/hence.rb +94 -0
  342. data/lib/gems/facets-2.4.5/lib/core/facets/time/round.rb +17 -0
  343. data/lib/gems/facets-2.4.5/lib/core/facets/time/set.rb +21 -0
  344. data/lib/gems/facets-2.4.5/lib/core/facets/time/stamp.rb +44 -0
  345. data/lib/gems/facets-2.4.5/lib/core/facets/time/to_time.rb +21 -0
  346. data/lib/gems/facets-2.4.5/lib/core/facets/time/trunc.rb +15 -0
  347. data/lib/gems/facets-2.4.5/lib/core/facets/to_hash.rb +87 -0
  348. data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod.rb +6 -0
  349. data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod/arguments.rb +44 -0
  350. data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod/name.rb +25 -0
  351. data/lib/gems/facets-2.4.5/lib/lore/facets/basicobject.rb +14 -0
  352. data/lib/gems/facets-2.4.5/lib/lore/facets/cgi.rb +50 -0
  353. data/lib/gems/facets-2.4.5/lib/lore/facets/continuation.rb +57 -0
  354. data/lib/gems/facets-2.4.5/lib/lore/facets/date.rb +396 -0
  355. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils.rb +27 -0
  356. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/head.rb +1 -0
  357. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/safe_ln.rb +28 -0
  358. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/slice.rb +141 -0
  359. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/tail.rb +1 -0
  360. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/wc.rb +114 -0
  361. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/whereis.rb +64 -0
  362. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/which.rb +101 -0
  363. data/lib/gems/facets-2.4.5/lib/lore/facets/getoptlong.rb +71 -0
  364. data/lib/gems/facets-2.4.5/lib/lore/facets/logger.rb +291 -0
  365. data/lib/gems/facets-2.4.5/lib/lore/facets/ostruct.rb +238 -0
  366. data/lib/gems/facets-2.4.5/lib/lore/facets/pathname.rb +172 -0
  367. data/lib/gems/facets-2.4.5/lib/lore/facets/rbconfig.rb +45 -0
  368. data/lib/gems/facets-2.4.5/lib/lore/facets/set.rb +27 -0
  369. data/lib/gems/facets-2.4.5/lib/lore/facets/shellwords.rb +89 -0
  370. data/lib/gems/facets-2.4.5/lib/lore/facets/uri.rb +249 -0
  371. data/lib/gems/facets-2.4.5/lib/lore/facets/yaml.rb +75 -0
  372. data/lib/gems/facets-2.4.5/lib/lore/facets/zlib.rb +38 -0
  373. data/lib/gems/facets-2.4.5/lib/more/facets/1stclassmethod.rb +140 -0
  374. data/lib/gems/facets-2.4.5/lib/more/facets/advisable.rb +162 -0
  375. data/lib/gems/facets-2.4.5/lib/more/facets/annotations.rb +302 -0
  376. data/lib/gems/facets-2.4.5/lib/more/facets/ansicode.rb +315 -0
  377. data/lib/gems/facets-2.4.5/lib/more/facets/arguments.rb +365 -0
  378. data/lib/gems/facets-2.4.5/lib/more/facets/argvector.rb +353 -0
  379. data/lib/gems/facets-2.4.5/lib/more/facets/association.rb +194 -0
  380. data/lib/gems/facets-2.4.5/lib/more/facets/attr.rb +208 -0
  381. data/lib/gems/facets-2.4.5/lib/more/facets/autoarray.rb +62 -0
  382. data/lib/gems/facets-2.4.5/lib/more/facets/autoreload.rb +150 -0
  383. data/lib/gems/facets-2.4.5/lib/more/facets/basex.rb +37 -0
  384. data/lib/gems/facets-2.4.5/lib/more/facets/bbcode.rb +397 -0
  385. data/lib/gems/facets-2.4.5/lib/more/facets/bicrypt.rb +265 -0
  386. data/lib/gems/facets-2.4.5/lib/more/facets/binding/opvars.rb +24 -0
  387. data/lib/gems/facets-2.4.5/lib/more/facets/binreadable.rb +221 -0
  388. data/lib/gems/facets-2.4.5/lib/more/facets/blankslate.rb +66 -0
  389. data/lib/gems/facets-2.4.5/lib/more/facets/buildable.rb +344 -0
  390. data/lib/gems/facets-2.4.5/lib/more/facets/bytes.rb +175 -0
  391. data/lib/gems/facets-2.4.5/lib/more/facets/cachedecorator.rb +117 -0
  392. data/lib/gems/facets-2.4.5/lib/more/facets/capsule.rb +258 -0
  393. data/lib/gems/facets-2.4.5/lib/more/facets/chain.rb +58 -0
  394. data/lib/gems/facets-2.4.5/lib/more/facets/class_extension.rb +114 -0
  395. data/lib/gems/facets-2.4.5/lib/more/facets/classmethods.rb +199 -0
  396. data/lib/gems/facets-2.4.5/lib/more/facets/cloneable.rb +76 -0
  397. data/lib/gems/facets-2.4.5/lib/more/facets/command.rb +439 -0
  398. data/lib/gems/facets-2.4.5/lib/more/facets/consoleutils.rb +113 -0
  399. data/lib/gems/facets-2.4.5/lib/more/facets/coroutine.rb +159 -0
  400. data/lib/gems/facets-2.4.5/lib/more/facets/crypt.rb +166 -0
  401. data/lib/gems/facets-2.4.5/lib/more/facets/cssfilter.rb +254 -0
  402. data/lib/gems/facets-2.4.5/lib/more/facets/daemonize.rb +44 -0
  403. data/lib/gems/facets-2.4.5/lib/more/facets/dependency.rb +151 -0
  404. data/lib/gems/facets-2.4.5/lib/more/facets/dictionary.rb +478 -0
  405. data/lib/gems/facets-2.4.5/lib/more/facets/dictionarymatcher.rb +136 -0
  406. data/lib/gems/facets-2.4.5/lib/more/facets/downloader.rb +281 -0
  407. data/lib/gems/facets-2.4.5/lib/more/facets/duplicable.rb +43 -0
  408. data/lib/gems/facets-2.4.5/lib/more/facets/duration.rb +540 -0
  409. data/lib/gems/facets-2.4.5/lib/more/facets/elementor.rb +133 -0
  410. data/lib/gems/facets-2.4.5/lib/more/facets/elementwise.rb +61 -0
  411. data/lib/gems/facets-2.4.5/lib/more/facets/enumerablepass.rb +217 -0
  412. data/lib/gems/facets-2.4.5/lib/more/facets/equatable.rb +120 -0
  413. data/lib/gems/facets-2.4.5/lib/more/facets/eventhook.rb +132 -0
  414. data/lib/gems/facets-2.4.5/lib/more/facets/expirable.rb +82 -0
  415. data/lib/gems/facets-2.4.5/lib/more/facets/fileable.rb +162 -0
  416. data/lib/gems/facets-2.4.5/lib/more/facets/filelist.rb +497 -0
  417. data/lib/gems/facets-2.4.5/lib/more/facets/fileshell.rb +202 -0
  418. data/lib/gems/facets-2.4.5/lib/more/facets/hash/stringify_keys.rb +1 -0
  419. data/lib/gems/facets-2.4.5/lib/more/facets/hash/symbolize_keys.rb +94 -0
  420. data/lib/gems/facets-2.4.5/lib/more/facets/heap.rb +22 -0
  421. data/lib/gems/facets-2.4.5/lib/more/facets/htmlfilter.rb +595 -0
  422. data/lib/gems/facets-2.4.5/lib/more/facets/infinity.rb +193 -0
  423. data/lib/gems/facets-2.4.5/lib/more/facets/inheritor.rb +130 -0
  424. data/lib/gems/facets-2.4.5/lib/more/facets/ini.rb +264 -0
  425. data/lib/gems/facets-2.4.5/lib/more/facets/instantiable.rb +47 -0
  426. data/lib/gems/facets-2.4.5/lib/more/facets/instantise.rb +1 -0
  427. data/lib/gems/facets-2.4.5/lib/more/facets/instantize.rb +95 -0
  428. data/lib/gems/facets-2.4.5/lib/more/facets/interval.rb +282 -0
  429. data/lib/gems/facets-2.4.5/lib/more/facets/ioredirect.rb +130 -0
  430. data/lib/gems/facets-2.4.5/lib/more/facets/iteration.rb +65 -0
  431. data/lib/gems/facets-2.4.5/lib/more/facets/kernel/meta.rb +32 -0
  432. data/lib/gems/facets-2.4.5/lib/more/facets/linkedlist.rb +222 -0
  433. data/lib/gems/facets-2.4.5/lib/more/facets/lrucache.rb +157 -0
  434. data/lib/gems/facets-2.4.5/lib/more/facets/main.rb +70 -0
  435. data/lib/gems/facets-2.4.5/lib/more/facets/memoize.rb +116 -0
  436. data/lib/gems/facets-2.4.5/lib/more/facets/methodspace.rb +141 -0
  437. data/lib/gems/facets-2.4.5/lib/more/facets/minitar.rb +1063 -0
  438. data/lib/gems/facets-2.4.5/lib/more/facets/multipliers.rb +109 -0
  439. data/lib/gems/facets-2.4.5/lib/more/facets/multiton.rb +386 -0
  440. data/lib/gems/facets-2.4.5/lib/more/facets/nackclass.rb +41 -0
  441. data/lib/gems/facets-2.4.5/lib/more/facets/net/smtp_tls.rb +131 -0
  442. data/lib/gems/facets-2.4.5/lib/more/facets/nilstatus.rb +47 -0
  443. data/lib/gems/facets-2.4.5/lib/more/facets/nullclass.rb +74 -0
  444. data/lib/gems/facets-2.4.5/lib/more/facets/opencascade.rb +94 -0
  445. data/lib/gems/facets-2.4.5/lib/more/facets/opencollection.rb +43 -0
  446. data/lib/gems/facets-2.4.5/lib/more/facets/openhash.rb +39 -0
  447. data/lib/gems/facets-2.4.5/lib/more/facets/openobject.rb +267 -0
  448. data/lib/gems/facets-2.4.5/lib/more/facets/opesc.rb +60 -0
  449. data/lib/gems/facets-2.4.5/lib/more/facets/orderedhash.rb +37 -0
  450. data/lib/gems/facets-2.4.5/lib/more/facets/overload.rb +94 -0
  451. data/lib/gems/facets-2.4.5/lib/more/facets/paramix.rb +202 -0
  452. data/lib/gems/facets-2.4.5/lib/more/facets/partial.rb +37 -0
  453. data/lib/gems/facets-2.4.5/lib/more/facets/pathlist.rb +112 -0
  454. data/lib/gems/facets-2.4.5/lib/more/facets/platform.rb +192 -0
  455. data/lib/gems/facets-2.4.5/lib/more/facets/pool.rb +91 -0
  456. data/lib/gems/facets-2.4.5/lib/more/facets/pqueue.rb +449 -0
  457. data/lib/gems/facets-2.4.5/lib/more/facets/progressbar.rb +253 -0
  458. data/lib/gems/facets-2.4.5/lib/more/facets/prototype.rb +88 -0
  459. data/lib/gems/facets-2.4.5/lib/more/facets/random.rb +451 -0
  460. data/lib/gems/facets-2.4.5/lib/more/facets/rbsystem.rb +222 -0
  461. data/lib/gems/facets-2.4.5/lib/more/facets/recorder.rb +109 -0
  462. data/lib/gems/facets-2.4.5/lib/more/facets/reference.rb +99 -0
  463. data/lib/gems/facets-2.4.5/lib/more/facets/reflection.rb +145 -0
  464. data/lib/gems/facets-2.4.5/lib/more/facets/registerable.rb +35 -0
  465. data/lib/gems/facets-2.4.5/lib/more/facets/rwdelegator.rb +74 -0
  466. data/lib/gems/facets-2.4.5/lib/more/facets/semaphore.rb +92 -0
  467. data/lib/gems/facets-2.4.5/lib/more/facets/settings.rb +248 -0
  468. data/lib/gems/facets-2.4.5/lib/more/facets/snapshot.rb +209 -0
  469. data/lib/gems/facets-2.4.5/lib/more/facets/string/mask.rb +278 -0
  470. data/lib/gems/facets-2.4.5/lib/more/facets/string/words.rb +173 -0
  471. data/lib/gems/facets-2.4.5/lib/more/facets/succ.rb +44 -0
  472. data/lib/gems/facets-2.4.5/lib/more/facets/syncarray.rb +114 -0
  473. data/lib/gems/facets-2.4.5/lib/more/facets/synchash.rb +157 -0
  474. data/lib/gems/facets-2.4.5/lib/more/facets/tagiter.rb +366 -0
  475. data/lib/gems/facets-2.4.5/lib/more/facets/thread.rb +51 -0
  476. data/lib/gems/facets-2.4.5/lib/more/facets/timer.rb +274 -0
  477. data/lib/gems/facets-2.4.5/lib/more/facets/times.rb +431 -0
  478. data/lib/gems/facets-2.4.5/lib/more/facets/tracepoint.rb +209 -0
  479. data/lib/gems/facets-2.4.5/lib/more/facets/tuple.rb +325 -0
  480. data/lib/gems/facets-2.4.5/lib/more/facets/typecast.rb +261 -0
  481. data/lib/gems/facets-2.4.5/lib/more/facets/uninheritable.rb +50 -0
  482. data/lib/gems/facets-2.4.5/lib/more/facets/uploadutils.rb +464 -0
  483. data/lib/gems/facets-2.4.5/lib/more/facets/version.rb +136 -0
  484. data/lib/gems/facets-2.4.5/lib/more/facets/xmlhash.rb +112 -0
  485. data/lib/gems/facets-2.4.5/lib/more/facets/xoxo.rb +259 -0
  486. data/lib/gems/facets-2.4.5/lib/more/facets/ziputils.rb +349 -0
  487. data/lib/mack-facets.rb +4 -2
  488. data/lib/mack-facets/english_extensions/inflect.rb +50 -50
  489. data/lib/mack-facets/extensions/string.rb +10 -1
  490. data/lib/mack-facets/utils/inflections.rb +50 -47
  491. data/lib/mack-facets/utils/inflector.rb +19 -19
  492. metadata +547 -36
@@ -0,0 +1,70 @@
1
+ # = Main as Module
2
+ #
3
+ # Main, ie. the top-level object, is not fully in-sync with
4
+ # Module. So, certain methods like #define_method do not work.
5
+ # This library fixes this.
6
+ #
7
+ # Techinally it is this authors opinion that the top-level object
8
+ # most likely be better-off as a self-extended module, and
9
+ # method defined in it do not automatically get added to the
10
+ # Object class.
11
+ #
12
+ # == Copying
13
+ #
14
+ # Copyright (c) 2006 Thomas Sawyer
15
+ #
16
+ # Ruby License
17
+ #
18
+ # This module is free software. You may use, modify, and/or redistribute this
19
+ # software under the same terms as Ruby.
20
+ #
21
+ # This program is distributed in the hope that it will be useful, but WITHOUT
22
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23
+ # FOR A PARTICULAR PURPOSE.
24
+ #
25
+ # == Authors
26
+ #
27
+ # * Thomas Sawyer
28
+
29
+ public
30
+
31
+ (Module.public_instance_methods - public_methods).each do |m|
32
+ next if m == "initialize"
33
+ next if m =~ /^\W+$/
34
+ eval <<-END
35
+ def self.#{m}( *args, &block )
36
+ Object.class_eval do
37
+ #{m}( *args, &block )
38
+ end
39
+ end
40
+ END
41
+ end
42
+
43
+ private
44
+
45
+ (Module.private_instance_methods - private_methods).each do |m|
46
+ next if m == "initialize"
47
+ next if m =~ /^\W+$/
48
+ eval <<-END
49
+ def self.#{m}( *args, &block )
50
+ Object.class_eval do
51
+ #{m}( *args, &block )
52
+ end
53
+ end
54
+ END
55
+ end
56
+
57
+ protected
58
+
59
+ (Module.protected_instance_methods - protected_methods).each do |m|
60
+ next if m == "initialize"
61
+ next if m =~ /^\W+$/
62
+ eval <<-END
63
+ def self.#{m}( *args, &block )
64
+ Object.class_eval do
65
+ #{m}( *args, &block )
66
+ end
67
+ end
68
+ END
69
+ end
70
+
@@ -0,0 +1,116 @@
1
+ # = Memoize
2
+ #
3
+ # Directive for making your functions faster by trading
4
+ # space for time. When you "memoize" a method/function
5
+ # its results are cached so that later calls with the
6
+ # same arguments returns results in the cache instead
7
+ # of recalculating them.
8
+ #
9
+ # class T
10
+ # def initialize(a)
11
+ # @a = a
12
+ # end
13
+ # def a
14
+ # "#{@a ^ 3 + 4}"
15
+ # end
16
+ # memoize :a
17
+ # end
18
+ #
19
+ # t = T.new
20
+ # t.a.__id__ == t.a.__id__ #=> true
21
+ #
22
+ # == Authors
23
+ #
24
+ # * Trans
25
+ #
26
+ # == Copying
27
+ #
28
+ # Copyright (c) 2005 Robert Feldt
29
+ #
30
+ # Ruby License
31
+ #
32
+ # This module is free software. You may use, modify, and/or redistribute this
33
+ # software under the same terms as Ruby.
34
+ #
35
+ # This program is distributed in the hope that it will be useful, but WITHOUT
36
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
37
+ # FOR A PARTICULAR PURPOSE.
38
+
39
+ #
40
+ class Module
41
+
42
+ # Directive for making your functions faster by trading
43
+ # space for time. When you "memoize" a method/function
44
+ # its results are cached so that later calls with the
45
+ # same arguments returns results in the cache instead
46
+ # of recalculating them.
47
+ #
48
+ # class T
49
+ # def initialize(a)
50
+ # @a = a
51
+ # end
52
+ # def a
53
+ # "#{@a ^ 3 + 4}"
54
+ # end
55
+ # memoize :a
56
+ # end
57
+ #
58
+ # t = T.new
59
+ # t.a.__id__ == t.a.__id__ #=> true
60
+ #
61
+ def memoize(*meths)
62
+ @_MEMOIZE_CACHE ||= Hash.new
63
+ meths.each do |meth|
64
+ mc = @_MEMOIZE_CACHE[meth] = Hash.new
65
+ old = instance_method(meth)
66
+ new = proc do |*args|
67
+ if mc.has_key? args
68
+ mc[args]
69
+ else
70
+ mc[args] = old.bind(self).call(*args)
71
+ end
72
+ end
73
+ send(:define_method, meth, &new)
74
+ end
75
+ end
76
+
77
+ end
78
+
79
+ # This allows memoize to work in main and instance scope too.
80
+ #--
81
+ # Would this be good to have? Will need to modify for instance level, if so.
82
+ #++
83
+
84
+ def memoize(*args)
85
+ Object.memoize(*args)
86
+ end
87
+
88
+ #
89
+ module Kernel
90
+
91
+ # Object#cache is essentially like Module#memoize except
92
+ # it can also be used on singleton/eigen methods.
93
+ # OTOH, memoize's implementation is arguably better for it's
94
+ # use of #bind instead of #alias. Eventually the two implmenations
95
+ # will be reconciled with a single implmentation.
96
+
97
+ def cache m = nil
98
+ if m
99
+ (Module === self ? self : (class << self; self; end)).module_eval <<-code
100
+ alias_method '__#{ m }__', '#{ m }'
101
+ def #{ m }(*__a__,&__b__)
102
+ c = cache['#{ m }']
103
+ k = [__a__,__b__]
104
+ if c.has_key? k
105
+ c[k]
106
+ else
107
+ c[k] = __#{ m }__(*__a__,&__b__)
108
+ end
109
+ end
110
+ code
111
+ end
112
+ @cache ||= Hash::new{|h,k| h[k]={}}
113
+ end
114
+
115
+ end
116
+
@@ -0,0 +1,141 @@
1
+ # = Method Namespaces
2
+ #
3
+ # Create method namespaces, allowing for method
4
+ # chains but still accessing the object's instance.
5
+ #
6
+ # == Todo
7
+ #
8
+ # * May need to cahnge name, to avoid conflict with Rake's method by the same name.
9
+ # * Maybe can become part of core once name is changed.
10
+ #
11
+ # == Authors
12
+ #
13
+ # * Thomas Sawyer
14
+ # * Pit Captain
15
+ #
16
+ # == Copying
17
+ #
18
+ # Copyright (c) 2006 Thomas Sawyer, Pit Captain
19
+ #
20
+ # Ruby License
21
+ #
22
+ # This module is free software. You may use, modify, and/or redistribute this
23
+ # software under the same terms as Ruby.
24
+ #
25
+ # This program is distributed in the hope that it will be useful, but WITHOUT
26
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
27
+ # FOR A PARTICULAR PURPOSE.
28
+
29
+ require 'facets/functor'
30
+ require 'facets/module' # for Module#basename
31
+
32
+ class Module
33
+
34
+ # Define a simple method namespace.
35
+ #
36
+ # class A
37
+ # attr_writer :x
38
+ # method_space :inside do
39
+ # def x; @x; end
40
+ # end
41
+ # end
42
+ #
43
+ # a = A.new
44
+ # a.x = 10
45
+ # a.inside.x #=> 10
46
+ # a.x # no method error
47
+
48
+ def method_space(name, mod=nil, &blk)
49
+
50
+ # If block is given then create a module, otherwise
51
+ # get the name of the module.
52
+ if block_given?
53
+ name = name.to_s
54
+ raise ArgumentError if mod
55
+ mod = Module.new(&blk)
56
+ else
57
+ if Module === name
58
+ mod = name
59
+ name = mod.basename.downcase
60
+ end
61
+ mod = mod.dup
62
+ end
63
+
64
+ # Include the module. This is neccessary, otherwise
65
+ # Ruby won't let us bind the instance methods.
66
+ include mod
67
+
68
+ # Save the instance methods of the module and
69
+ # replace them with a "transparent" version.
70
+ methods = {}
71
+ mod.instance_methods(false).each do |m|
72
+ methods[m.to_sym] = mod.instance_method(m)
73
+ mod.instance_eval do
74
+ define_method(m) do
75
+ super
76
+ end
77
+ end
78
+ end
79
+
80
+ # Add a method for the namespace that delegates
81
+ # via the Functor to the saved instance methods.
82
+ define_method(name) do
83
+ mtab = methods
84
+ Functor.new do |op, *args|
85
+ mtab[op].bind(self).call(*args)
86
+ end
87
+ end
88
+ end
89
+
90
+ # Include a module via a specified space.
91
+ #
92
+ # module T
93
+ # def t ; "HERE" ; end
94
+ # end
95
+ #
96
+ # class X
97
+ # include_as :test => T
98
+ # def t ; test.t ; end
99
+ # end
100
+ #
101
+ # X.new.t #=> "HERE"
102
+ #
103
+ def include_as(h)
104
+ h.each{ |name, mod| method_space(name, mod) }
105
+ end
106
+
107
+ end
108
+
109
+
110
+
111
+
112
+ # demonstration
113
+
114
+ =begin demo
115
+
116
+ module T
117
+ def t ; p self ; end
118
+ def r ; p self ; end
119
+ def q ; super ; end
120
+ end
121
+
122
+ class N
123
+ def q ; puts "ho" ; end
124
+ end
125
+
126
+ class X < N
127
+ include_as :test => T
128
+
129
+ def n ; p test ; end
130
+ def m ; test.t ; end
131
+ def o ; test.r ; end
132
+ end
133
+
134
+ x = X.new
135
+ x.n
136
+ x.m
137
+ x.o
138
+ x.q
139
+
140
+ =end
141
+
@@ -0,0 +1,1063 @@
1
+ # = Archive::Tar::Minitar
2
+ #
3
+ # = Synopsis
4
+ #
5
+ # Archive::Tar::Minitar is a pure-Ruby library and command-line
6
+ # utility that provides the ability to deal with POSIX tar(1) archive
7
+ # files. The implementation is based heavily on Mauricio Fern�dez's
8
+ # implementation in rpa-base, but has been reorganised to promote
9
+ # reuse in other projects.
10
+ #
11
+ # This tar class performs a subset of all tar (POSIX tape archive)
12
+ # operations. We can only deal with typeflags 0, 1, 2, and 5 (see
13
+ # Archive::Tar::PosixHeader). All other typeflags will be treated as
14
+ # normal files.
15
+ #
16
+ # NOTE::: support for typeflags 1 and 2 is not yet implemented in this
17
+ # version.
18
+ #
19
+ # This release is version 0.5.1. The library can only handle files and
20
+ # directories at this point. A future version will be expanded to
21
+ # handle symbolic links and hard links in a portable manner. The
22
+ # command line utility, minitar, can only create archives, extract
23
+ # from archives, and list archive contents.
24
+ #
25
+ # == Synopsis
26
+ #
27
+ # Using this library is easy. The simplest case is:
28
+ #
29
+ # require 'zlib'
30
+ # require 'archive/tar/minitar'
31
+ # include Archive::Tar
32
+ #
33
+ # # Packs everything that matches Find.find('tests')
34
+ # File.open('test.tar', 'wb') { |tar| Minitar.pack('tests', tar) }
35
+ # # Unpacks 'test.tar' to 'x', creating 'x' if necessary.
36
+ # Minitar.unpack('test.tar', 'x')
37
+ #
38
+ # A gzipped tar can be written with:
39
+ #
40
+ # tgz = Zlib::GzipWriter.new(File.open('test.tgz', 'wb'))
41
+ # # Warning: tgz will be closed!
42
+ # Minitar.pack('tests', tgz)
43
+ #
44
+ # tgz = Zlib::GzipReader.new(File.open('test.tgz', 'rb'))
45
+ # # Warning: tgz will be closed!
46
+ # Minitar.unpack(tgz, 'x')
47
+ #
48
+ # As the case above shows, one need not write to a file. However, it
49
+ # will sometimes require that one dive a little deeper into the API,
50
+ # as in the case of StringIO objects. Note that I'm not providing a
51
+ # block with Minitar::Output, as Minitar::Output#close automatically
52
+ # closes both the Output object and the wrapped data stream object.
53
+ #
54
+ # begin
55
+ # sgz = Zlib::GzipWriter.new(StringIO.new(""))
56
+ # tar = Output.new(sgz)
57
+ # Find.find('tests') do |entry|
58
+ # Minitar.pack_file(entry, tar)
59
+ # end
60
+ # ensure
61
+ # # Closes both tar and sgz.
62
+ # tar.close
63
+ # end
64
+ #
65
+ # == Version
66
+ #
67
+ # 0.5.1
68
+ #
69
+ # == Authors
70
+ #
71
+ # * Mauricio Julio Fern�dez Pradier
72
+ # * Austin Ziegler
73
+ #
74
+ # == Copying
75
+ #
76
+ # Copyright 2004 Mauricio Julio Fern�dez Pradier and Austin Ziegler
77
+ #
78
+ # This program is based on and incorporates parts of RPA::Package from
79
+ # rpa-base (lib/rpa/package.rb and lib/rpa/util.rb) by Mauricio and
80
+ # has been adapted to be more generic by Austin.
81
+ #
82
+ # 'minitar' contains an adaptation of Ruby/ProgressBar by Satoru
83
+ # Takabayashi <satoru@namazu.org>, copyright 2001 - 2004.
84
+ #
85
+ # This program is free software. It may be redistributed and/or
86
+ # modified under the terms of the GPL version 2 (or later) or Ruby's
87
+ # licence.
88
+
89
+
90
+ #
91
+ module Archive; end
92
+ module Archive::Tar; end
93
+
94
+ # = Archive::Tar::PosixHeader
95
+ # Implements the POSIX tar header as a Ruby class. The structure of
96
+ # the POSIX tar header is:
97
+ #
98
+ # struct tarfile_entry_posix
99
+ # { // pack/unpack
100
+ # char name[100]; // ASCII (+ Z unless filled) a100/Z100
101
+ # char mode[8]; // 0 padded, octal, null a8 /A8
102
+ # char uid[8]; // ditto a8 /A8
103
+ # char gid[8]; // ditto a8 /A8
104
+ # char size[12]; // 0 padded, octal, null a12 /A12
105
+ # char mtime[12]; // 0 padded, octal, null a12 /A12
106
+ # char checksum[8]; // 0 padded, octal, null, space a8 /A8
107
+ # char typeflag[1]; // see below a /a
108
+ # char linkname[100]; // ASCII + (Z unless filled) a100/Z100
109
+ # char magic[6]; // "ustar\0" a6 /A6
110
+ # char version[2]; // "00" a2 /A2
111
+ # char uname[32]; // ASCIIZ a32 /Z32
112
+ # char gname[32]; // ASCIIZ a32 /Z32
113
+ # char devmajor[8]; // 0 padded, octal, null a8 /A8
114
+ # char devminor[8]; // 0 padded, octal, null a8 /A8
115
+ # char prefix[155]; // ASCII (+ Z unless filled) a155/Z155
116
+ # };
117
+ #
118
+ # The +typeflag+ may be one of the following known values:
119
+ #
120
+ # <tt>"0"</tt>:: Regular file. NULL should be treated as a synonym, for
121
+ # compatibility purposes.
122
+ # <tt>"1"</tt>:: Hard link.
123
+ # <tt>"2"</tt>:: Symbolic link.
124
+ # <tt>"3"</tt>:: Character device node.
125
+ # <tt>"4"</tt>:: Block device node.
126
+ # <tt>"5"</tt>:: Directory.
127
+ # <tt>"6"</tt>:: FIFO node.
128
+ # <tt>"7"</tt>:: Reserved.
129
+ #
130
+ # POSIX indicates that "A POSIX-compliant implementation must treat any
131
+ # unrecognized typeflag value as a regular file."
132
+ class Archive::Tar::PosixHeader #:nodoc:
133
+ FIELDS = %w(name mode uid gid size mtime checksum typeflag linkname) +
134
+ %w(magic version uname gname devmajor devminor prefix)
135
+
136
+ FIELDS.each { |field| attr_reader field.intern }
137
+
138
+ HEADER_PACK_FORMAT = "a100a8a8a8a12a12a7aaa100a6a2a32a32a8a8a155"
139
+ HEADER_UNPACK_FORMAT = "Z100A8A8A8A12A12A8aZ100A6A2Z32Z32A8A8Z155"
140
+
141
+ # Creates a new PosixHeader from a data stream.
142
+ def self.new_from_stream(stream)
143
+ data = stream.read(512)
144
+ fields = data.unpack(HEADER_UNPACK_FORMAT)
145
+ name = fields.shift
146
+ mode = fields.shift.oct
147
+ uid = fields.shift.oct
148
+ gid = fields.shift.oct
149
+ size = fields.shift.oct
150
+ mtime = fields.shift.oct
151
+ checksum = fields.shift.oct
152
+ typeflag = fields.shift
153
+ linkname = fields.shift
154
+ magic = fields.shift
155
+ version = fields.shift.oct
156
+ uname = fields.shift
157
+ gname = fields.shift
158
+ devmajor = fields.shift.oct
159
+ devminor = fields.shift.oct
160
+ prefix = fields.shift
161
+
162
+ empty = (data == "\0" * 512)
163
+
164
+ new(:name => name, :mode => mode, :uid => uid, :gid => gid,
165
+ :size => size, :mtime => mtime, :checksum => checksum,
166
+ :typeflag => typeflag, :magic => magic, :version => version,
167
+ :uname => uname, :gname => gname, :devmajor => devmajor,
168
+ :devminor => devminor, :prefix => prefix, :empty => empty)
169
+ end
170
+
171
+ # Creates a new PosixHeader. A PosixHeader cannot be created unless the
172
+ # #name, #size, #prefix, and #mode are provided.
173
+ def initialize(vals)
174
+ unless vals[:name] && vals[:size] && vals[:prefix] && vals[:mode]
175
+ raise ArgumentError
176
+ end
177
+
178
+ vals[:mtime] ||= 0
179
+ vals[:checksum] ||= ""
180
+ vals[:typeflag] ||= "0"
181
+ vals[:magic] ||= "ustar"
182
+ vals[:version] ||= "00"
183
+
184
+ FIELDS.each do |field|
185
+ instance_variable_set("@#{field}", vals[field.intern])
186
+ end
187
+ @empty = vals[:empty]
188
+ end
189
+
190
+ def empty?
191
+ @empty
192
+ end
193
+
194
+ def to_s
195
+ update_checksum
196
+ header(@checksum)
197
+ end
198
+
199
+ # Update the checksum field.
200
+ def update_checksum
201
+ hh = header(" " * 8)
202
+ @checksum = oct(calculate_checksum(hh), 6)
203
+ end
204
+
205
+ private
206
+ def oct(num, len)
207
+ if num.nil?
208
+ "\0" * (len + 1)
209
+ else
210
+ "%0#{len}o" % num
211
+ end
212
+ end
213
+
214
+ def calculate_checksum(hdr)
215
+ hdr.unpack("C*").inject { |aa, bb| aa + bb }
216
+ end
217
+
218
+ def header(chksum)
219
+ arr = [name, oct(mode, 7), oct(uid, 7), oct(gid, 7), oct(size, 11),
220
+ oct(mtime, 11), chksum, " ", typeflag, linkname, magic, version,
221
+ uname, gname, oct(devmajor, 7), oct(devminor, 7), prefix]
222
+ str = arr.pack(HEADER_PACK_FORMAT)
223
+ str + "\0" * ((512 - str.size) % 512)
224
+ end
225
+ end
226
+
227
+ require 'fileutils'
228
+ require 'find'
229
+
230
+ # = Archive::Tar::Minitar 0.5.1
231
+ # Archive::Tar::Minitar is a pure-Ruby library and command-line
232
+ # utility that provides the ability to deal with POSIX tar(1) archive
233
+ # files. The implementation is based heavily on Mauricio Fern�dez's
234
+ # implementation in rpa-base, but has been reorganised to promote
235
+ # reuse in other projects.
236
+ #
237
+ # This tar class performs a subset of all tar (POSIX tape archive)
238
+ # operations. We can only deal with typeflags 0, 1, 2, and 5 (see
239
+ # Archive::Tar::PosixHeader). All other typeflags will be treated as
240
+ # normal files.
241
+ #
242
+ # NOTE::: support for typeflags 1 and 2 is not yet implemented in this
243
+ # version.
244
+ #
245
+ # This release is version 0.5.1. The library can only handle files and
246
+ # directories at this point. A future version will be expanded to
247
+ # handle symbolic links and hard links in a portable manner. The
248
+ # command line utility, minitar, can only create archives, extract
249
+ # from archives, and list archive contents.
250
+ #
251
+ # == Synopsis
252
+ # Using this library is easy. The simplest case is:
253
+ #
254
+ # require 'zlib'
255
+ # require 'archive/tar/minitar'
256
+ # include Archive::Tar
257
+ #
258
+ # # Packs everything that matches Find.find('tests')
259
+ # File.open('test.tar', 'wb') { |tar| Minitar.pack('tests', tar) }
260
+ # # Unpacks 'test.tar' to 'x', creating 'x' if necessary.
261
+ # Minitar.unpack('test.tar', 'x')
262
+ #
263
+ # A gzipped tar can be written with:
264
+ #
265
+ # tgz = Zlib::GzipWriter.new(File.open('test.tgz', 'wb'))
266
+ # # Warning: tgz will be closed!
267
+ # Minitar.pack('tests', tgz)
268
+ #
269
+ # tgz = Zlib::GzipReader.new(File.open('test.tgz', 'rb'))
270
+ # # Warning: tgz will be closed!
271
+ # Minitar.unpack(tgz, 'x')
272
+ #
273
+ # As the case above shows, one need not write to a file. However, it
274
+ # will sometimes require that one dive a little deeper into the API,
275
+ # as in the case of StringIO objects. Note that I'm not providing a
276
+ # block with Minitar::Output, as Minitar::Output#close automatically
277
+ # closes both the Output object and the wrapped data stream object.
278
+ #
279
+ # begin
280
+ # sgz = Zlib::GzipWriter.new(StringIO.new(""))
281
+ # tar = Output.new(sgz)
282
+ # Find.find('tests') do |entry|
283
+ # Minitar.pack_file(entry, tar)
284
+ # end
285
+ # ensure
286
+ # # Closes both tar and sgz.
287
+ # tar.close
288
+ # end
289
+ #
290
+ # == Copyright
291
+ # Copyright 2004 Mauricio Julio Fern�dez Pradier and Austin Ziegler
292
+ #
293
+ # This program is based on and incorporates parts of RPA::Package from
294
+ # rpa-base (lib/rpa/package.rb and lib/rpa/util.rb) by Mauricio and
295
+ # has been adapted to be more generic by Austin.
296
+ #
297
+ # 'minitar' contains an adaptation of Ruby/ProgressBar by Satoru
298
+ # Takabayashi <satoru@namazu.org>, copyright 2001 - 2004.
299
+ #
300
+ # This program is free software. It may be redistributed and/or
301
+ # modified under the terms of the GPL version 2 (or later) or Ruby's
302
+ # licence.
303
+ module Archive::Tar::Minitar
304
+ VERSION = "0.5.1"
305
+
306
+ # The exception raised when a wrapped data stream class is expected to
307
+ # respond to #rewind or #pos but does not.
308
+ class NonSeekableStream < StandardError #:nodoc:
309
+ end
310
+ # The exception raised when a block is required for proper operation of
311
+ # the method.
312
+ class BlockRequired < ArgumentError #:nodoc:
313
+ end
314
+ # The exception raised when operations are performed on a stream that has
315
+ # previously been closed.
316
+ class ClosedStream < StandardError #:nodoc:
317
+ end
318
+ # The exception raised when a filename exceeds 256 bytes in length,
319
+ # the maximum supported by the standard Tar format.
320
+ class FileNameTooLong < StandardError #:nodoc:
321
+ end
322
+ # The exception raised when a data stream ends before the amount of data
323
+ # expected in the archive's PosixHeader.
324
+ class UnexpectedEOF < StandardError #:nodoc:
325
+ end
326
+
327
+ # The class that writes a tar format archive to a data stream.
328
+ class Writer
329
+ # A stream wrapper that can only be written to. Any attempt to read
330
+ # from this restricted stream will result in a NameError being thrown.
331
+ class RestrictedStream #:nodoc:
332
+ def initialize(anIO)
333
+ @io = anIO
334
+ end
335
+
336
+ def write(data)
337
+ @io.write(data)
338
+ end
339
+ end
340
+
341
+ # A RestrictedStream that also has a size limit.
342
+ class BoundedStream < Archive::Tar::Minitar::Writer::RestrictedStream #:nodoc:
343
+ # The exception raised when the user attempts to write more data to
344
+ # a BoundedStream than has been allocated.
345
+ class FileOverflow < RuntimeError #:nodoc:
346
+ end
347
+
348
+ # The maximum number of bytes that may be written to this data
349
+ # stream.
350
+ attr_reader :limit
351
+ # The current total number of bytes written to this data stream.
352
+ attr_reader :written
353
+
354
+ def initialize(io, limit)
355
+ @io = io
356
+ @limit = limit
357
+ @written = 0
358
+ end
359
+
360
+ def write(data)
361
+ raise FileOverflow if (data.size + @written) > @limit
362
+ @io.write(data)
363
+ @written += data.size
364
+ data.size
365
+ end
366
+ end
367
+
368
+ # With no associated block, +Writer::open+ is a synonym for
369
+ # +Writer::new+. If the optional code block is given, it will be
370
+ # passed the new _writer_ as an argument and the Writer object will
371
+ # automatically be closed when the block terminates. In this instance,
372
+ # +Writer::open+ returns the value of the block.
373
+ def self.open(anIO)
374
+ writer = Writer.new(anIO)
375
+
376
+ return writer unless block_given?
377
+
378
+ begin
379
+ res = yield writer
380
+ ensure
381
+ writer.close
382
+ end
383
+
384
+ res
385
+ end
386
+
387
+ # Creates and returns a new Writer object.
388
+ def initialize(anIO)
389
+ @io = anIO
390
+ @closed = false
391
+ end
392
+
393
+ # Adds a file to the archive as +name+. +opts+ must contain the
394
+ # following values:
395
+ #
396
+ # <tt>:mode</tt>:: The Unix file permissions mode value.
397
+ # <tt>:size</tt>:: The size, in bytes.
398
+ #
399
+ # +opts+ may contain the following values:
400
+ #
401
+ # <tt>:uid</tt>: The Unix file owner user ID number.
402
+ # <tt>:gid</tt>: The Unix file owner group ID number.
403
+ # <tt>:mtime</tt>:: The *integer* modification time value.
404
+ #
405
+ # It will not be possible to add more than <tt>opts[:size]</tt> bytes
406
+ # to the file.
407
+ def add_file_simple(name, opts = {}) # :yields BoundedStream:
408
+ raise Archive::Tar::Minitar::BlockRequired unless block_given?
409
+ raise Archive::Tar::ClosedStream if @closed
410
+
411
+ name, prefix = split_name(name)
412
+
413
+ header = { :name => name, :mode => opts[:mode], :mtime => opts[:mtime],
414
+ :size => opts[:size], :gid => opts[:gid], :uid => opts[:uid],
415
+ :prefix => prefix }
416
+ header = Archive::Tar::PosixHeader.new(header).to_s
417
+ @io.write(header)
418
+
419
+ os = BoundedStream.new(@io, opts[:size])
420
+ yield os
421
+ # FIXME: what if an exception is raised in the block?
422
+
423
+ min_padding = opts[:size] - os.written
424
+ @io.write("\0" * min_padding)
425
+ remainder = (512 - (opts[:size] % 512)) % 512
426
+ @io.write("\0" * remainder)
427
+ end
428
+
429
+ # Adds a file to the archive as +name+. +opts+ must contain the
430
+ # following value:
431
+ #
432
+ # <tt>:mode</tt>:: The Unix file permissions mode value.
433
+ #
434
+ # +opts+ may contain the following values:
435
+ #
436
+ # <tt>:uid</tt>: The Unix file owner user ID number.
437
+ # <tt>:gid</tt>: The Unix file owner group ID number.
438
+ # <tt>:mtime</tt>:: The *integer* modification time value.
439
+ #
440
+ # The file's size will be determined from the amount of data written
441
+ # to the stream.
442
+ #
443
+ # For #add_file to be used, the Archive::Tar::Minitar::Writer must be
444
+ # wrapping a stream object that is seekable (e.g., it responds to
445
+ # #pos=). Otherwise, #add_file_simple must be used.
446
+ #
447
+ # +opts+ may be modified during the writing to the stream.
448
+ def add_file(name, opts = {}) # :yields RestrictedStream, +opts+:
449
+ raise Archive::Tar::Minitar::BlockRequired unless block_given?
450
+ raise Archive::Tar::Minitar::ClosedStream if @closed
451
+ raise Archive::Tar::Minitar::NonSeekableStream unless @io.respond_to?(:pos=)
452
+
453
+ name, prefix = split_name(name)
454
+ init_pos = @io.pos
455
+ @io.write("\0" * 512) # placeholder for the header
456
+
457
+ yield RestrictedStream.new(@io), opts
458
+ # FIXME: what if an exception is raised in the block?
459
+
460
+ size = @io.pos - (init_pos + 512)
461
+ remainder = (512 - (size % 512)) % 512
462
+ @io.write("\0" * remainder)
463
+
464
+ final_pos = @io.pos
465
+ @io.pos = init_pos
466
+
467
+ header = { :name => name, :mode => opts[:mode], :mtime => opts[:mtime],
468
+ :size => size, :gid => opts[:gid], :uid => opts[:uid],
469
+ :prefix => prefix }
470
+ header = Archive::Tar::PosixHeader.new(header).to_s
471
+ @io.write(header)
472
+ @io.pos = final_pos
473
+ end
474
+
475
+ # Creates a directory in the tar.
476
+ def mkdir(name, opts = {})
477
+ raise ClosedStream if @closed
478
+ name, prefix = split_name(name)
479
+ header = { :name => name, :mode => opts[:mode], :typeflag => "5",
480
+ :size => 0, :gid => opts[:gid], :uid => opts[:uid],
481
+ :mtime => opts[:mtime], :prefix => prefix }
482
+ header = Archive::Tar::PosixHeader.new(header).to_s
483
+ @io.write(header)
484
+ nil
485
+ end
486
+
487
+ # Passes the #flush method to the wrapped stream, used for buffered
488
+ # streams.
489
+ def flush
490
+ raise ClosedStream if @closed
491
+ @io.flush if @io.respond_to?(:flush)
492
+ end
493
+
494
+ # Closes the Writer.
495
+ def close
496
+ return if @closed
497
+ @io.write("\0" * 1024)
498
+ @closed = true
499
+ end
500
+
501
+ private
502
+ def split_name(name)
503
+ raise FileNameTooLong if name.size > 256
504
+ if name.size <= 100
505
+ prefix = ""
506
+ else
507
+ parts = name.split(/\//)
508
+ newname = parts.pop
509
+
510
+ nxt = ""
511
+
512
+ loop do
513
+ nxt = parts.pop
514
+ break if newname.size + 1 + nxt.size > 100
515
+ newname = "#{nxt}/#{newname}"
516
+ end
517
+
518
+ prefix = (parts + [nxt]).join("/")
519
+
520
+ name = newname
521
+
522
+ raise FileNameTooLong if name.size > 100 || prefix.size > 155
523
+ end
524
+ return name, prefix
525
+ end
526
+ end
527
+
528
+ # The class that reads a tar format archive from a data stream. The data
529
+ # stream may be sequential or random access, but certain features only work
530
+ # with random access data streams.
531
+ class Reader
532
+ # This marks the EntryStream closed for reading without closing the
533
+ # actual data stream.
534
+ module InvalidEntryStream #:nodoc:
535
+ def read(len = nil); raise ClosedStream; end
536
+ def getc; raise ClosedStream; end
537
+ def rewind; raise ClosedStream; end
538
+ end
539
+
540
+ # EntryStreams are pseudo-streams on top of the main data stream.
541
+ class EntryStream #:nodoc:
542
+ Archive::Tar::PosixHeader::FIELDS.each do |field|
543
+ attr_reader field.intern
544
+ end
545
+
546
+ def initialize(header, anIO)
547
+ @io = anIO
548
+ @name = header.name
549
+ @mode = header.mode
550
+ @uid = header.uid
551
+ @gid = header.gid
552
+ @size = header.size
553
+ @mtime = header.mtime
554
+ @checksum = header.checksum
555
+ @typeflag = header.typeflag
556
+ @linkname = header.linkname
557
+ @magic = header.magic
558
+ @version = header.version
559
+ @uname = header.uname
560
+ @gname = header.gname
561
+ @devmajor = header.devmajor
562
+ @devminor = header.devminor
563
+ @prefix = header.prefix
564
+ @read = 0
565
+ @orig_pos = @io.pos
566
+ end
567
+
568
+ # Reads +len+ bytes (or all remaining data) from the entry. Returns
569
+ # +nil+ if there is no more data to read.
570
+ def read(len = nil)
571
+ return nil if @read >= @size
572
+ len ||= @size - @read
573
+ max_read = [len, @size - @read].min
574
+ ret = @io.read(max_read)
575
+ @read += ret.size
576
+ ret
577
+ end
578
+
579
+ # Reads one byte from the entry. Returns +nil+ if there is no more data
580
+ # to read.
581
+ def getc
582
+ return nil if @read >= @size
583
+ ret = @io.getc
584
+ @read += 1 if ret
585
+ ret
586
+ end
587
+
588
+ # Returns +true+ if the entry represents a directory.
589
+ def directory?
590
+ @typeflag == "5"
591
+ end
592
+ alias_method :directory, :directory?
593
+
594
+ # Returns +true+ if the entry represents a plain file.
595
+ def file?
596
+ @typeflag == "0"
597
+ end
598
+ alias_method :file, :file?
599
+
600
+ # Returns +true+ if the current read pointer is at the end of the
601
+ # EntryStream data.
602
+ def eof?
603
+ @read >= @size
604
+ end
605
+
606
+ # Returns the current read pointer in the EntryStream.
607
+ def pos
608
+ @read
609
+ end
610
+
611
+ # Sets the current read pointer to the beginning of the EntryStream.
612
+ def rewind
613
+ raise NonSeekableStream unless @io.respond_to?(:pos=)
614
+ @io.pos = @orig_pos
615
+ @read = 0
616
+ end
617
+
618
+ def bytes_read
619
+ @read
620
+ end
621
+
622
+ # Returns the full and proper name of the entry.
623
+ def full_name
624
+ if @prefix != ""
625
+ File.join(@prefix, @name)
626
+ else
627
+ @name
628
+ end
629
+ end
630
+
631
+ # Closes the entry.
632
+ def close
633
+ invalidate
634
+ end
635
+
636
+ private
637
+ def invalidate
638
+ extend InvalidEntryStream
639
+ end
640
+ end
641
+
642
+ # With no associated block, +Reader::open+ is a synonym for
643
+ # +Reader::new+. If the optional code block is given, it will be passed
644
+ # the new _writer_ as an argument and the Reader object will
645
+ # automatically be closed when the block terminates. In this instance,
646
+ # +Reader::open+ returns the value of the block.
647
+ def self.open(anIO)
648
+ reader = Reader.new(anIO)
649
+
650
+ return reader unless block_given?
651
+
652
+ begin
653
+ res = yield reader
654
+ ensure
655
+ reader.close
656
+ end
657
+
658
+ res
659
+ end
660
+
661
+ # Creates and returns a new Reader object.
662
+ def initialize(anIO)
663
+ @io = anIO
664
+ @init_pos = anIO.pos
665
+ end
666
+
667
+ # Iterates through each entry in the data stream.
668
+ def each(&block)
669
+ each_entry(&block)
670
+ end
671
+
672
+ # Resets the read pointer to the beginning of data stream. Do not call
673
+ # this during a #each or #each_entry iteration. This only works with
674
+ # random access data streams that respond to #rewind and #pos.
675
+ def rewind
676
+ if @init_pos == 0
677
+ raise NonSeekableStream unless @io.respond_to?(:rewind)
678
+ @io.rewind
679
+ else
680
+ raise NonSeekableStream unless @io.respond_to?(:pos=)
681
+ @io.pos = @init_pos
682
+ end
683
+ end
684
+
685
+ # Iterates through each entry in the data stream.
686
+ def each_entry
687
+ loop do
688
+ return if @io.eof?
689
+
690
+ header = Archive::Tar::PosixHeader.new_from_stream(@io)
691
+ return if header.empty?
692
+
693
+ entry = EntryStream.new(header, @io)
694
+ size = entry.size
695
+
696
+ yield entry
697
+
698
+ skip = (512 - (size % 512)) % 512
699
+
700
+ if @io.respond_to?(:seek)
701
+ # avoid reading...
702
+ @io.seek(size - entry.bytes_read, IO::SEEK_CUR)
703
+ else
704
+ pending = size - entry.bytes_read
705
+ while pending > 0
706
+ bread = @io.read([pending, 4096].min).size
707
+ raise UnexpectedEOF if @io.eof?
708
+ pending -= bread
709
+ end
710
+ end
711
+ @io.read(skip) # discard trailing zeros
712
+ # make sure nobody can use #read, #getc or #rewind anymore
713
+ entry.close
714
+ end
715
+ end
716
+
717
+ def close
718
+ end
719
+ end
720
+
721
+ # Wraps a Archive::Tar::Minitar::Reader with convenience methods and
722
+ # wrapped stream management; Input only works with random access data
723
+ # streams. See Input::new for details.
724
+ class Input
725
+ include Enumerable
726
+
727
+ # With no associated block, +Input::open+ is a synonym for
728
+ # +Input::new+. If the optional code block is given, it will be passed
729
+ # the new _writer_ as an argument and the Input object will
730
+ # automatically be closed when the block terminates. In this instance,
731
+ # +Input::open+ returns the value of the block.
732
+ def self.open(input)
733
+ stream = Input.new(input)
734
+ return stream unless block_given?
735
+
736
+ begin
737
+ res = yield stream
738
+ ensure
739
+ stream.close
740
+ end
741
+
742
+ res
743
+ end
744
+
745
+ # Creates a new Input object. If +input+ is a stream object that responds
746
+ # to #read), then it will simply be wrapped. Otherwise, one will be
747
+ # created and opened using Kernel#open. When Input#close is called, the
748
+ # stream object wrapped will be closed.
749
+ def initialize(input)
750
+ if input.respond_to?(:read)
751
+ @io = input
752
+ else
753
+ @io = open(input, "rb")
754
+ end
755
+ @tarreader = Archive::Tar::Minitar::Reader.new(@io)
756
+ end
757
+
758
+ # Iterates through each entry and rewinds to the beginning of the stream
759
+ # when finished.
760
+ def each(&block)
761
+ @tarreader.each { |entry| yield entry }
762
+ ensure
763
+ @tarreader.rewind
764
+ end
765
+
766
+ # Extracts the current +entry+ to +destdir+. If a block is provided, it
767
+ # yields an +action+ Symbol, the full name of the file being extracted
768
+ # (+name+), and a Hash of statistical information (+stats+).
769
+ #
770
+ # The +action+ will be one of:
771
+ # <tt>:dir</tt>:: The +entry+ is a directory.
772
+ # <tt>:file_start</tt>:: The +entry+ is a file; the extract of the
773
+ # file is just beginning.
774
+ # <tt>:file_progress</tt>:: Yielded every 4096 bytes during the extract
775
+ # of the +entry+.
776
+ # <tt>:file_done</tt>:: Yielded when the +entry+ is completed.
777
+ #
778
+ # The +stats+ hash contains the following keys:
779
+ # <tt>:current</tt>:: The current total number of bytes read in the
780
+ # +entry+.
781
+ # <tt>:currinc</tt>:: The current number of bytes read in this read
782
+ # cycle.
783
+ # <tt>:entry</tt>:: The entry being extracted; this is a
784
+ # Reader::EntryStream, with all methods thereof.
785
+ def extract_entry(destdir, entry) # :yields action, name, stats:
786
+ stats = {
787
+ :current => 0,
788
+ :currinc => 0,
789
+ :entry => entry
790
+ }
791
+
792
+ if entry.directory?
793
+ dest = File.join(destdir, entry.full_name)
794
+
795
+ yield :dir, entry.full_name, stats if block_given?
796
+
797
+ if Archive::Tar::Minitar.dir?(dest)
798
+ begin
799
+ FileUtils.chmod(entry.mode, dest)
800
+ rescue Exception
801
+ nil
802
+ end
803
+ else
804
+ FileUtils.mkdir_p(dest, :mode => entry.mode)
805
+ FileUtils.chmod(entry.mode, dest)
806
+ end
807
+
808
+ fsync_dir(dest)
809
+ fsync_dir(File.join(dest, ".."))
810
+ return
811
+ else # it's a file
812
+ destdir = File.join(destdir, File.dirname(entry.full_name))
813
+ FileUtils.mkdir_p(destdir, :mode => 0755)
814
+
815
+ destfile = File.join(destdir, File.basename(entry.full_name))
816
+ FileUtils.chmod(0600, destfile) rescue nil # Errno::ENOENT
817
+
818
+ yield :file_start, entry.full_name, stats if block_given?
819
+
820
+ File.open(destfile, "wb", entry.mode) do |os|
821
+ loop do
822
+ data = entry.read(4096)
823
+ break unless data
824
+
825
+ stats[:currinc] = os.write(data)
826
+ stats[:current] += stats[:currinc]
827
+
828
+ yield :file_progress, entry.full_name, stats if block_given?
829
+ end
830
+ os.fsync
831
+ end
832
+
833
+ FileUtils.chmod(entry.mode, destfile)
834
+ fsync_dir(File.dirname(destfile))
835
+ fsync_dir(File.join(File.dirname(destfile), ".."))
836
+
837
+ yield :file_done, entry.full_name, stats if block_given?
838
+ end
839
+ end
840
+
841
+ # Returns the Reader object for direct access.
842
+ def tar
843
+ @tarreader
844
+ end
845
+
846
+ # Closes the Reader object and the wrapped data stream.
847
+ def close
848
+ @io.close
849
+ @tarreader.close
850
+ end
851
+
852
+ private
853
+ def fsync_dir(dirname)
854
+ # make sure this hits the disc
855
+ dir = open(dirname, 'rb')
856
+ dir.fsync
857
+ rescue # ignore IOError if it's an unpatched (old) Ruby
858
+ nil
859
+ ensure
860
+ dir.close if dir rescue nil
861
+ end
862
+ end
863
+
864
+ # Wraps a Archive::Tar::Minitar::Writer with convenience methods and
865
+ # wrapped stream management; Output only works with random access data
866
+ # streams. See Output::new for details.
867
+ class Output
868
+ # With no associated block, +Output::open+ is a synonym for
869
+ # +Output::new+. If the optional code block is given, it will be passed
870
+ # the new _writer_ as an argument and the Output object will
871
+ # automatically be closed when the block terminates. In this instance,
872
+ # +Output::open+ returns the value of the block.
873
+ def self.open(output)
874
+ stream = Output.new(output)
875
+ return stream unless block_given?
876
+
877
+ begin
878
+ res = yield stream
879
+ ensure
880
+ stream.close
881
+ end
882
+
883
+ res
884
+ end
885
+
886
+ # Creates a new Output object. If +output+ is a stream object that
887
+ # responds to #read), then it will simply be wrapped. Otherwise, one will
888
+ # be created and opened using Kernel#open. When Output#close is called,
889
+ # the stream object wrapped will be closed.
890
+ def initialize(output)
891
+ if output.respond_to?(:write)
892
+ @io = output
893
+ else
894
+ @io = ::File.open(output, "wb")
895
+ end
896
+ @tarwriter = Archive::Tar::Minitar::Writer.new(@io)
897
+ end
898
+
899
+ # Returns the Writer object for direct access.
900
+ def tar
901
+ @tarwriter
902
+ end
903
+
904
+ # Closes the Writer object and the wrapped data stream.
905
+ def close
906
+ @tarwriter.close
907
+ @io.close
908
+ end
909
+ end
910
+
911
+ class << self
912
+ # Tests if +path+ refers to a directory. Fixes an apparently
913
+ # corrupted <tt>stat()</tt> call on Windows.
914
+ def dir?(path)
915
+ File.directory?((path[-1] == ?/) ? path : "#{path}/")
916
+ end
917
+
918
+ # A convenience method for wrapping Archive::Tar::Minitar::Input.open
919
+ # (mode +r+) and Archive::Tar::Minitar::Output.open (mode +w+). No other
920
+ # modes are currently supported.
921
+ def open(dest, mode = "r", &block)
922
+ case mode
923
+ when "r"
924
+ Input.open(dest, &block)
925
+ when "w"
926
+ Output.open(dest, &block)
927
+ else
928
+ raise "Unknown open mode for Archive::Tar::Minitar.open."
929
+ end
930
+ end
931
+
932
+ # A convenience method to packs the file provided. +entry+ may either be
933
+ # a filename (in which case various values for the file (see below) will
934
+ # be obtained from <tt>File#stat(entry)</tt> or a Hash with the fields:
935
+ #
936
+ # <tt>:name</tt>:: The filename to be packed into the tarchive.
937
+ # *REQUIRED*.
938
+ # <tt>:mode</tt>:: The mode to be applied.
939
+ # <tt>:uid</tt>:: The user owner of the file. (Ignored on Windows.)
940
+ # <tt>:gid</tt>:: The group owner of the file. (Ignored on Windows.)
941
+ # <tt>:mtime</tt>:: The modification Time of the file.
942
+ #
943
+ # During packing, if a block is provided, #pack_file yields an +action+
944
+ # Symol, the full name of the file being packed, and a Hash of
945
+ # statistical information, just as with
946
+ # Archive::Tar::Minitar::Input#extract_entry.
947
+ #
948
+ # The +action+ will be one of:
949
+ # <tt>:dir</tt>:: The +entry+ is a directory.
950
+ # <tt>:file_start</tt>:: The +entry+ is a file; the extract of the
951
+ # file is just beginning.
952
+ # <tt>:file_progress</tt>:: Yielded every 4096 bytes during the extract
953
+ # of the +entry+.
954
+ # <tt>:file_done</tt>:: Yielded when the +entry+ is completed.
955
+ #
956
+ # The +stats+ hash contains the following keys:
957
+ # <tt>:current</tt>:: The current total number of bytes read in the
958
+ # +entry+.
959
+ # <tt>:currinc</tt>:: The current number of bytes read in this read
960
+ # cycle.
961
+ # <tt>:name</tt>:: The filename to be packed into the tarchive.
962
+ # *REQUIRED*.
963
+ # <tt>:mode</tt>:: The mode to be applied.
964
+ # <tt>:uid</tt>:: The user owner of the file. (+nil+ on Windows.)
965
+ # <tt>:gid</tt>:: The group owner of the file. (+nil+ on Windows.)
966
+ # <tt>:mtime</tt>:: The modification Time of the file.
967
+ def pack_file(entry, outputter) #:yields action, name, stats:
968
+ outputter = outputter.tar if outputter.kind_of?(Archive::Tar::Minitar::Output)
969
+
970
+ stats = {}
971
+
972
+ if entry.kind_of?(Hash)
973
+ name = entry[:name]
974
+
975
+ entry.each { |kk, vv| stats[kk] = vv unless vv.nil? }
976
+ else
977
+ name = entry
978
+ end
979
+
980
+ name = name.sub(%r{\./}, '')
981
+ stat = File.stat(name)
982
+ stats[:mode] ||= stat.mode
983
+ stats[:mtime] ||= stat.mtime
984
+ stats[:size] = stat.size
985
+
986
+ if RUBY_PLATFORM =~ /win32/
987
+ stats[:uid] = nil
988
+ stats[:gid] = nil
989
+ else
990
+ stats[:uid] ||= stat.uid
991
+ stats[:gid] ||= stat.gid
992
+ end
993
+
994
+ case
995
+ when File.file?(name)
996
+ outputter.add_file_simple(name, stats) do |os|
997
+ stats[:current] = 0
998
+ yield :file_start, name, stats if block_given?
999
+ File.open(name, "rb") do |ff|
1000
+ until ff.eof?
1001
+ stats[:currinc] = os.write(ff.read(4096))
1002
+ stats[:current] += stats[:currinc]
1003
+ yield :file_progress, name, stats if block_given?
1004
+ end
1005
+ end
1006
+ yield :file_done, name, stats if block_given?
1007
+ end
1008
+ when dir?(name)
1009
+ yield :dir, name, stats if block_given?
1010
+ outputter.mkdir(name, stats)
1011
+ else
1012
+ raise "Don't yet know how to pack this type of file."
1013
+ end
1014
+ end
1015
+
1016
+ # A convenience method to pack files specified by +src+ into +dest+. If
1017
+ # +src+ is an Array, then each file detailed therein will be packed into
1018
+ # the resulting Archive::Tar::Minitar::Output stream; if +recurse_dirs+
1019
+ # is true, then directories will be recursed.
1020
+ #
1021
+ # If +src+ is an Array, it will be treated as the argument to Find.find;
1022
+ # all files matching will be packed.
1023
+ def pack(src, dest, recurse_dirs = true, &block)
1024
+ Output.open(dest) do |outp|
1025
+ if src.kind_of?(Array)
1026
+ src.each do |entry|
1027
+ pack_file(entry, outp, &block)
1028
+ if dir?(entry) and recurse_dirs
1029
+ Dir["#{entry}/**/**"].each do |ee|
1030
+ pack_file(ee, outp, &block)
1031
+ end
1032
+ end
1033
+ end
1034
+ else
1035
+ Find.find(src) do |entry|
1036
+ pack_file(entry, outp, &block)
1037
+ end
1038
+ end
1039
+ end
1040
+ end
1041
+
1042
+ # A convenience method to unpack files from +src+ into the directory
1043
+ # specified by +dest+. Only those files named explicitly in +files+
1044
+ # will be extracted.
1045
+ def unpack(src, dest, files = [], &block)
1046
+ Input.open(src) do |inp|
1047
+ if File.exist?(dest) and (not dir?(dest))
1048
+ raise "Can't unpack to a non-directory."
1049
+ elsif not File.exist?(dest)
1050
+ FileUtils.mkdir_p(dest)
1051
+ end
1052
+
1053
+ inp.each do |entry|
1054
+ if files.empty? or files.include?(entry.full_name)
1055
+ inp.extract_entry(dest, entry, &block)
1056
+ end
1057
+ end
1058
+ end
1059
+ end
1060
+ end
1061
+ end
1062
+
1063
+