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,397 @@
1
+ # = BBCode
2
+ #
3
+ # = Synopsis
4
+ #
5
+ # The BBCode module helps ease the separation of core and frontend with the
6
+ # core (or submodules) being still able to say, what colors shall be used
7
+ # in it's responses. This is achieved by encoding formatting information
8
+ # using the BBCode tokens. This enables you to "pipe" layout information
9
+ # such as colors, style, fonttype, size and alignment through the core to
10
+ # the frontend.
11
+ #
12
+ # Additionally it converts markups/codes between ANSI, HTML and BBCode
13
+ # almost freely ;)
14
+ #
15
+ # == Usage
16
+ #
17
+ # # Converting a bbcode string to ANSI and XHTML
18
+ #
19
+ # str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
20
+ # print( BBCode.bbcode_to_ansi(str) )
21
+ # print( BBCode.bbcode_to_html(str) )
22
+ #
23
+ # == Authors
24
+ #
25
+ # * Thomas-Ivo Heinen
26
+ #
27
+ # == Copying
28
+ #
29
+ # Copyright (c) 2002 Thomas-Ivo Heinen
30
+ #
31
+ # Ruby License
32
+ #
33
+ # This module is free software. You may use, modify, and/or redistribute this
34
+ # software under the same terms as Ruby.
35
+ #
36
+ # This program is distributed in the hope that it will be useful, but WITHOUT
37
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
38
+ # FOR A PARTICULAR PURPOSE.
39
+
40
+ # = BBCode
41
+ #
42
+ # The BBCode module helps ease the separation of core and frontend with the
43
+ # core (or submodules) being still able to say, what colors shall be used
44
+ # in it's responses. This is achieved by encoding formatting information
45
+ # using the BBCode tokens. This enables you to "pipe" layout information
46
+ # such as colors, style, fonttype, size and alignment through the core to
47
+ # the frontend.
48
+ #
49
+ # Additionally it converts markups/codes between ANSI, HTML and BBCode
50
+ # almost freely ;)
51
+ #
52
+ # == Usage
53
+ #
54
+ # # Converting a bbcode string to ANSI and XHTML
55
+ #
56
+ # str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
57
+ # print( BBCode.bbcode_to_ansi(str) )
58
+ # print( BBCode.bbcode_to_html(str) )
59
+ #
60
+ module BBCode
61
+
62
+ ## ANSIname => ANSIcode LUT
63
+ ANSINAME2CODE= { "reset" => "\e[0m", "bold" => "\e[1m",
64
+ "underline" => "\e[4m", "blink" => "\e[5m",
65
+ "reverse" => "\e[7m", "invisible" => "\e[8m",
66
+ "black" => "\e[0;30m", "darkgrey" => "\e[1;30m",
67
+ "red" => "\e[0;31m", "lightred" => "\e[1;31m",
68
+ "green" => "\e[0;32m", "lightgreen" => "\e[1;32m",
69
+ "brown" => "\e[0;33m", "yellow" => "\e[1;33m",
70
+ "blue" => "\e[0;34m", "lightblue" => "\e[1;34m",
71
+ "purple" => "\e[0;35m", "magenta" => "\e[1;35m",
72
+ "cyan" => "\e[1;36m", "lightcyan" => "\e[1;36m",
73
+ "grey" => "\e[0;37m", "white" => "\e[1;37m",
74
+ "bgblack" => "\e[40m", "bgred" => "\e[41m",
75
+ "bggreen" => "\e[42m", "bgyellow" => "\e[43m",
76
+ "bgblue" => "\e[44m", "bgmagenta" => "\e[45m",
77
+ "bgcyan" => "\e[46m", "bgwhite" => "\e[47m"
78
+ }
79
+
80
+ ## BBColor => ANSIname LUT
81
+ BBCOLOR2ANSI = { "skyblue" => "blue", "royalblue" => "blue",
82
+ "blue" => "blue", "darkblue" => "blue",
83
+ "orange" => "red", "orangered" => "red",
84
+ "crimson" => "red", "red" => "lightred",
85
+ "firebrick" => "red", "darkred" => "red",
86
+ "green" => "green", "limegreen" => "green",
87
+ "seagreen" => "green", "darkgreen" => "green",
88
+ "deeppink" => "magenta", "tomato" => "red",
89
+ "coral" => "cyan", "purple" => "purple",
90
+ "indigo" => "blue", "burlywood" => "red",
91
+ "sandybrown"=> "red", "sierra" => "sierra",
92
+ "chocolate" => "brown", "teal" => "teal",
93
+ "silver" => "white",
94
+ "black" => "black", "yellow" => "yellow",
95
+ "magenta" => "magenta", "cyan" => "cyan",
96
+ "white" => "white"
97
+ }
98
+
99
+ ## ANSInames => BBCode LUT
100
+ ANSINAME2BBCODE = { "bold" => "B", "underline" => "U", "reverse" => "I",
101
+
102
+ "red" => "COLOR=red", "blue" => "COLOR=blue",
103
+ "green" => "COLOR=green", "cyan" => "COLOR=cyan",
104
+ "magenta"=> "COLOR=deeppink", "purple" => "COLOR=purple",
105
+ "black" => "COLOR=black", "white" => "COLOR=white",
106
+ "yellow" => "COLOR=yellow", "brown" => "COLOR=chocolate"
107
+ }
108
+
109
+ ## Needed for alignments
110
+ @@width = 80
111
+
112
+
113
+ # ---------------------------
114
+
115
+ # Returns the ANSI sequence for given color, if existant
116
+ def BBCode.ansi(colorname)
117
+ colorname.strip!
118
+ return ANSINAME2CODE[ colorname.downcase ]
119
+ end
120
+
121
+ # --- strip_bbcode( string )
122
+ # Will strip any BBCode tags from the given string.
123
+ def BBCode.strip_bbcode(string)
124
+ string.strip!
125
+ return string.gsub(/\[[A-Za-z0-9\/=]+\]/, "")
126
+ end
127
+
128
+ # Returns the string with all ansi escape sequences converted to BBCodes
129
+ def BBCode.ansi_to_bbcode(string)
130
+ return "" if string.nil? || string.to_s.strip.empty?
131
+ result = ""
132
+ tagstack = []
133
+
134
+ ## Iterate over input lines
135
+ string.split("\n").each do |line|
136
+ ansi = line.scan(/\e\[[0-9;]+m/)
137
+ continue if ansi.nil? || ansi.empty?
138
+
139
+ ## Iterate over found ansi sequences
140
+ ansi.each do |seq|
141
+ ansiname = ANSINAME2CODE.invert["#{seq}"]
142
+
143
+ ## Pop last tag and form closing tag
144
+ if ansiname == "reset"
145
+ lasttag = tagstack.pop
146
+ bbname = "/" + String.new( lasttag.split("=")[0] )
147
+
148
+ ## Get corresponding BBCode tag + Push to stack
149
+ else
150
+ bbname = ANSINAME2BBCODE[ansiname]
151
+ tagstack.push(bbname)
152
+ end
153
+
154
+ ## Replace ansi sequence by BBCode tag
155
+ replace = sprintf("[%s]", bbname)
156
+ line.sub!("#{Regexp.quote(seq)}", replace)
157
+ end
158
+
159
+ ## Append converted line
160
+ result << sprintf("%s\n", line)
161
+ end
162
+
163
+
164
+ ## Some tags are unclosed
165
+ while !tagstack.empty?
166
+ result << sprintf("[/%s]", String.new(tagstack.pop.split("=")[0]) )
167
+ end
168
+
169
+ return result
170
+ end
171
+
172
+ # Converts a BBCode string to one with ANSI sequences.
173
+ # Returns the string with all formatting instructions in BBCodes converted
174
+ # to ANSI code sequences / aligned with spaces to specified width.
175
+ def BBCode.bbcode_to_ansi(string, usecolors = true)
176
+ return "" if string.nil? || string.to_s.strip.empty?
177
+ result = ""
178
+
179
+ return BBCode.strip_bbcode(string) if !usecolors
180
+
181
+ ## Iterate over lines
182
+ string.split("\n").each do |line|
183
+
184
+ ## TODO: stacking? other styles!
185
+ ANSINAME2BBCODE.each do |key,val|
186
+ line.gsub!(/\[#{val}\]/, ANSINAME2CODE[key])
187
+ line.gsub!(/\[\/#{val}\]/, ANSINAME2CODE["reset"])
188
+ end
189
+
190
+ ## Fonttypes and sizes not available
191
+ line.gsub!(/\[SIZE=\d\]/, "")
192
+ line.gsub!(/\[\/SIZE\]/, "")
193
+ line.gsub!(/\[FONT=[^\]]*\]/, "")
194
+ line.gsub!(/\[\/FONT\]/, "")
195
+
196
+ ## Color-mapping
197
+ colors = line.scan(/\[COLOR=(.*?)\]/i)
198
+ colors = colors.collect{|s| s[0].to_s} if !colors.nil?
199
+ colors.each do |col|
200
+ name = BBCOLOR2ANSI[col.downcase]
201
+ name = BBCOLOR2ANSI["white"] if name.nil?
202
+ code = ANSINAME2CODE[name]
203
+
204
+ line.gsub!(/\[COLOR=#{col}\]/i, code)
205
+ end
206
+ line.gsub!(/\[\/COLOR\]/, ANSINAME2CODE["reset"])
207
+
208
+ ## TODO: Alignment
209
+ ## TODO: IMGs
210
+ ## TODO: EMAILs
211
+ ## TODO: URLs
212
+ ## TODO: QUOTEs
213
+ ## TODO: LISTs
214
+
215
+ result << sprintf("%s\n", line)
216
+ end
217
+
218
+ return result
219
+ end
220
+
221
+ # Converts a HTML string into one with BBCode markup (TODO)
222
+ # Returns the (X)HTML markup string as BBCode
223
+ def BBCode.html_to_bbcode(string)
224
+ return "" if string.nil? || string.to_s.strip.empty?
225
+ result = ""
226
+
227
+ ## Iterate over lines
228
+ string.split(/<br *\/?>/i).each do |line|
229
+ styles = { "strong" => "b", "b" => "b",
230
+ "em" => "i", "i" => "i",
231
+ "u" => "u" }
232
+
233
+ ## preserve B, I, U
234
+ styles.each do |html,code|
235
+ line.gsub!(/<#{html}>/i, "[#{code.upcase}]")
236
+ line.gsub!(/<\/#{html}>/i, "[/#{code.upcase}]")
237
+ end
238
+
239
+ ## TODO: COLORs
240
+ ## TODO: SIZEs
241
+ ## TODO: FONTs
242
+
243
+ ## EMAIL
244
+ line.gsub!(/<a +href *= *\"mailto:(.*?)\".*?>.*?<\/a>/i, "[EMAIL]\\1[/EMAIL]")
245
+
246
+ ## URL
247
+ line.gsub!(/<a +href *= *\"((?:https?|ftp):\/\/.*?)\".*?>(.*?)<\/a>/i, "[URL=\\1]\\2[/URL]")
248
+
249
+ ## Other refs + closing tags => throw away
250
+ line.gsub!(/<a +href *= *\".*?\".*?>/i, "")
251
+ line.gsub!(/<\/a>/i, "")
252
+
253
+ ## IMG
254
+ #line.gsub!(/<img +src *= *\"(.*?)\".*?\/?>/i, "[IMG=\\1]")
255
+ line.gsub!(/<img +src *= *\"(.*?)\".*?\/?>/i, "[IMG]\\1[/IMG]")
256
+
257
+ ## CENTER (right/left??)
258
+ line.gsub!(/<center>/i, "[ALIGN=center]")
259
+ line.gsub!(/<\/center>/i, "[/ALIGN]")
260
+
261
+ ## QUOTE
262
+ line.gsub!(/<(?:xmp|pre)>/i, "[QUOTE]")
263
+ line.gsub!(/<\/(?:xmp|pre)>/i, "[/QUOTE]")
264
+
265
+ ## LIST
266
+ line.gsub!(/<ul>/i, "\n[LIST]\n")
267
+ line.gsub!(/<\/ul>/i, "\n[/LIST]\n")
268
+ line.gsub!(/<li *\/?> */i, "\n[*] ")
269
+
270
+ ## Unkown tags => throw away
271
+ line.gsub!(/<.*? *\/?>/, "")
272
+
273
+ result << sprintf("%s<br />\n", line)
274
+ end
275
+
276
+ return result.gsub!(/<br *\/?>/i, "\n")
277
+ end
278
+
279
+ # Converts a BBCode string to one with HTML markup.
280
+ # Returns the string with all formatting instructions in
281
+ # BBCodes converted to XHTML markups.
282
+ def BBCode.bbcode_to_html(string)
283
+ return "" if string.nil? || string.to_s.strip.empty?
284
+ result = ""
285
+ quote = 0
286
+
287
+ ## Iterate over lines
288
+ string.split("\n").each do |line|
289
+ styles = { "b" => "strong", "i" => "em", "u" => "u" }
290
+
291
+ ## preserve B, I, U
292
+ styles.each do |code,html|
293
+ line.gsub!(/\[#{code}\]/i, "<#{html}>")
294
+ line.gsub!(/\[\/#{code}\]/i, "</#{html}>")
295
+ end
296
+
297
+ ## COLOR => font color=... (TODO: should be numeric!)
298
+ line.gsub!(/\[COLOR=(.*?)\]/i, "<font color=\"\\1\">")
299
+ line.gsub!(/\[\/COLOR\]/i, "</font>")
300
+
301
+ ## SIZE => font size=...
302
+ line.gsub!(/\[SIZE=(.*?)\]/i, "<font size=\"\\1\">")
303
+ line.gsub!(/\[\/SIZE\]/i, "</font>")
304
+
305
+ ## URL
306
+ line.gsub!(/\[URL\]([^\[]+?)\[\/URL\]/i, "<a href=\"\\1\">\\1</a>")
307
+ line.gsub!(/\[URL=(.*?)\](.+?)\[\/URL\]/i, "<a href=\"\\1\">\\2</a>")
308
+
309
+ ## IMG
310
+ line.gsub!(/\[IMG=(.*?)\]/i, "<img src=\"\\1\" />")
311
+
312
+ ## ALIGN=center (TODO: right, left)
313
+ line.gsub!(/\[ALIGN=center\]/i, "<center>")
314
+ line.gsub!(/\[ALIGN=right\]/i, "<center>")
315
+ line.gsub!(/\[ALIGN=left\]/i, "<center>")
316
+ line.gsub!(/\[\/ALIGN\]/i, "</center>")
317
+
318
+ ## QUOTE
319
+ quote+=1 if line =~ /\[QUOTE\]/i
320
+ quote-=1 if (line =~ /\[\/QUOTE\]/i) && (quote > -1)
321
+ line.gsub!(/\[QUOTE\]/i, "<pre>\n")
322
+ line.gsub!(/\[\/QUOTE\]/i, "</pre>\n")
323
+ line.gsub!(/^/, "&#62;"*quote) if quote > 0
324
+
325
+ ## EMAIL
326
+ line.gsub!(/\[EMAIL\](.*?)\[\/EMAIL\]/i, "<a href=\"mailto:\\1\">\\1</a>")
327
+
328
+ ## LIST (TODO: LIST=1, LIST=A)
329
+ line.gsub!(/\[LIST(?:=(.*?))?\]/i, "\n<ul>\n")
330
+ line.gsub!(/\[\/LIST\]/i, "\n</ul>\n")
331
+ line.gsub!(/\[\*\]/i, "\n<li />")
332
+
333
+ ## FONT => font ??????
334
+ ## ?BLUR?, FADE?
335
+
336
+ result << sprintf("%s<br />\n", line)
337
+ end
338
+
339
+ return result
340
+ end
341
+
342
+
343
+ # -- Transitive methods ---------------
344
+
345
+ # Converts a ANSI string to one with HTML markup.
346
+ # Returns the string with ANSI code sequences converted to XHTML markup.
347
+ def BBCode.ansi_to_html(string)
348
+ bbcoded = BBCode.ansi_to_bbcode(string )
349
+ htmled = BBCode.bbcode_to_html(bbcoded)
350
+
351
+ return htmled
352
+ end
353
+
354
+ # Returns the (X)HTML markup code as ANSI sequences
355
+ def BBCode.html_to_ansi(string)
356
+ bbcoded = BBCode.html_to_bbcode(string )
357
+ ansied = BBCode.bbcode_to_ansi(bbcoded)
358
+
359
+ return ansied
360
+ end
361
+
362
+ end #module BBCode
363
+
364
+
365
+
366
+ # _____ _
367
+ # |_ _|__ ___| |_
368
+ # | |/ _ \/ __| __|
369
+ # | | __/\__ \ |_
370
+ # |_|\___||___/\__|
371
+ #
372
+
373
+ =begin testing
374
+
375
+ require 'test/unit'
376
+
377
+ class TC_BBCode < Test::Unit::TestCase
378
+
379
+ def test_to_ansi
380
+ str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
381
+ out = "this is \e[0;31mred\e[0m, this is \e[1mbold\e[0m\n"
382
+ assert_equal( out, BBCode.bbcode_to_ansi(str) )
383
+ end
384
+
385
+ def test_to_html
386
+ str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
387
+ out = "this is <font color=\"red\">red</font>, this is <strong>bold</strong><br />\n"
388
+ assert_equal( out, BBCode.bbcode_to_html(str) )
389
+ end
390
+
391
+ end
392
+
393
+ =end
394
+
395
+
396
+ # CREDIT Thomas-Ivo Heinen
397
+
@@ -0,0 +1,265 @@
1
+ # = BiCrypt
2
+ #
3
+ # A simple two-way encryption class.
4
+ #
5
+ # == Authors
6
+ #
7
+ # * Trans
8
+ #
9
+ # == Copying
10
+ #
11
+ # Copyright (c) 2007 Trans
12
+ #
13
+ # Ruby License
14
+ #
15
+ # This module is free software. You may use, modify, and/or redistribute this
16
+ # software under the same terms as Ruby.
17
+ #
18
+ # This program is distributed in the hope that it will be useful, but WITHOUT
19
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
+ # FOR A PARTICULAR PURPOSE.
21
+
22
+ require 'stringio'
23
+ require 'facets/string/xor'
24
+
25
+ # = BiCrypt
26
+ #
27
+ # A simple two-way encryption class.
28
+ #
29
+ class BiCrypt
30
+
31
+ ULONG = 0x100000000
32
+
33
+ def block_size
34
+ return(8)
35
+ end
36
+
37
+ def initialize(userKey)
38
+
39
+ # These are the S-boxes given in Applied Cryptography 2nd Ed., p. 333
40
+ @sBox = [
41
+ [4, 10, 9, 2, 13, 8, 0, 14, 6, 11, 1, 12, 7, 15, 5, 3],
42
+ [14, 11, 4, 12, 6, 13, 15, 10, 2, 3, 8, 1, 0, 7, 5, 9],
43
+ [5, 8, 1, 13, 10, 3, 4, 2, 14, 15, 12, 7, 6, 0, 9, 11],
44
+ [7, 13, 10, 1, 0, 8, 9, 15, 14, 4, 6, 12, 11, 2, 5, 3],
45
+ [6, 12, 7, 1, 5, 15, 13, 8, 4, 10, 9, 14, 0, 3, 11, 2],
46
+ [4, 11, 10, 0, 7, 2, 1, 13, 3, 6, 8, 5, 9, 12, 15, 14],
47
+ [13, 11, 4, 1, 3, 15, 5, 9, 0, 10, 14, 7, 6, 8, 2, 12],
48
+ [1, 15, 13, 0, 5, 7, 10, 4, 9, 2, 3, 14, 6, 11, 8, 12]
49
+ ]
50
+
51
+ # These are the S-boxes given in the GOST source code listing in Applied
52
+ # Cryptography 2nd Ed., p. 644. They appear to be from the DES S-boxes
53
+ # [13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7 ],
54
+ # [ 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1 ],
55
+ # [12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11 ],
56
+ # [ 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9 ],
57
+ # [ 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15 ],
58
+ # [10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 ],
59
+ # [15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10 ],
60
+ # [14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7 ]
61
+
62
+ # precalculate the S table
63
+ @sTable = precalculate_S_table()
64
+
65
+ # derive the 32-byte key from the user-supplied key
66
+ userKeyLength = userKey.length
67
+ @key = userKey[0..31].unpack('C'*32)
68
+ if (userKeyLength < 32)
69
+ userKeyLength.upto(31) { @key << 0 }
70
+ end
71
+ end
72
+
73
+
74
+ def precalculate_S_table()
75
+ sTable = [[], [], [], []]
76
+ 0.upto(3) { |i|
77
+ 0.upto(255) { |j|
78
+ t = @sBox[2*i][j % 16] | (@sBox[2*i+1][j/16] << 4)
79
+ u = (8*i + 11) % 32
80
+ v = (t << u) | (t >> (32-u))
81
+ sTable[i][j] = (v % ULONG)
82
+ }
83
+ }
84
+ return(sTable)
85
+ end
86
+
87
+
88
+ def f(longWord)
89
+ longWord = longWord % ULONG
90
+ a, b, c, d = [longWord].pack('L').unpack('CCCC')
91
+ return(@sTable[3][d] ^ @sTable[2][c] ^ @sTable[1][b] ^ @sTable[0][a])
92
+ end
93
+
94
+ def encrypt_pair(xl, xr)
95
+ 3.times {
96
+ xr ^= f(xl+@key[0])
97
+ xl ^= f(xr+@key[1])
98
+ xr ^= f(xl+@key[2])
99
+ xl ^= f(xr+@key[3])
100
+ xr ^= f(xl+@key[4])
101
+ xl ^= f(xr+@key[5])
102
+ xr ^= f(xl+@key[6])
103
+ xl ^= f(xr+@key[7])
104
+ }
105
+ xr ^= f(xl+@key[7])
106
+ xl ^= f(xr+@key[6])
107
+ xr ^= f(xl+@key[5])
108
+ xl ^= f(xr+@key[4])
109
+ xr ^= f(xl+@key[3])
110
+ xl ^= f(xr+@key[2])
111
+ xr ^= f(xl+@key[1])
112
+ xl ^= f(xr+@key[0])
113
+ return([xr, xl])
114
+ end
115
+
116
+
117
+ def decrypt_pair(xl, xr)
118
+ xr ^= f(xl+@key[0])
119
+ xl ^= f(xr+@key[1])
120
+ xr ^= f(xl+@key[2])
121
+ xl ^= f(xr+@key[3])
122
+ xr ^= f(xl+@key[4])
123
+ xl ^= f(xr+@key[5])
124
+ xr ^= f(xl+@key[6])
125
+ xl ^= f(xr+@key[7])
126
+ 3.times {
127
+ xr ^= f(xl+@key[7])
128
+ xl ^= f(xr+@key[6])
129
+ xr ^= f(xl+@key[5])
130
+ xl ^= f(xr+@key[4])
131
+ xr ^= f(xl+@key[3])
132
+ xl ^= f(xr+@key[2])
133
+ xr ^= f(xl+@key[1])
134
+ xl ^= f(xr+@key[0])
135
+ }
136
+ return([xr, xl])
137
+ end
138
+
139
+ def encrypt_block(block)
140
+ xl, xr = block.unpack('NN')
141
+ xl, xr = encrypt_pair(xl, xr)
142
+ encrypted = [xl, xr].pack('NN')
143
+ return(encrypted)
144
+ end
145
+
146
+
147
+ def decrypt_block(block)
148
+ xl, xr = block.unpack('NN')
149
+ xl, xr = decrypt_pair(xl, xr)
150
+ decrypted = [xl, xr].pack('NN')
151
+ return(decrypted)
152
+ end
153
+
154
+ # When this module is mixed in with an encryption class, the class
155
+ # must provide three methods: encrypt_block(block) and decrypt_block(block)
156
+ # and block_size()
157
+
158
+ def generate_initialization_vector(words)
159
+ srand(Time.now.to_i)
160
+ vector = ""
161
+ words.times {
162
+ vector << [rand(ULONG)].pack('N')
163
+ }
164
+ return(vector)
165
+ end
166
+
167
+
168
+ def encrypt_stream(plainStream, cryptStream)
169
+ # Cypher-block-chain mode
170
+
171
+ initVector = generate_initialization_vector(block_size() / 4)
172
+ chain = encrypt_block(initVector)
173
+ cryptStream.write(chain)
174
+
175
+ while ((block = plainStream.read(block_size())) && (block.length == block_size()))
176
+ block = block ^ chain
177
+ encrypted = encrypt_block(block)
178
+ cryptStream.write(encrypted)
179
+ chain = encrypted
180
+ end
181
+
182
+ # write the final block
183
+ # At most block_size()-1 bytes can be part of the message.
184
+ # That means the final byte can be used to store the number of meaningful
185
+ # bytes in the final block
186
+ block = '' if block.nil?
187
+ buffer = block.split('')
188
+ remainingMessageBytes = buffer.length
189
+ # we use 7-bit characters to avoid possible strange behavior on the Mac
190
+ remainingMessageBytes.upto(block_size()-2) { buffer << rand(128).chr }
191
+ buffer << remainingMessageBytes.chr
192
+ block = buffer.join('')
193
+ block = block ^ chain
194
+ encrypted = encrypt_block(block)
195
+ cryptStream.write(encrypted)
196
+ end
197
+
198
+
199
+ def decrypt_stream(cryptStream, plainStream)
200
+ # Cypher-block-chain mode
201
+ chain = cryptStream.read(block_size())
202
+
203
+ while (block = cryptStream.read(block_size()))
204
+ decrypted = decrypt_block(block)
205
+ plainText = decrypted ^ chain
206
+ plainStream.write(plainText) unless cryptStream.eof?
207
+ chain = block
208
+ end
209
+
210
+ # write the final block, omitting the padding
211
+ buffer = plainText.split('')
212
+ remainingMessageBytes = buffer.last.unpack('C').first
213
+ remainingMessageBytes.times { plainStream.write(buffer.shift) }
214
+ end
215
+
216
+
217
+ def carefully_open_file(filename, mode)
218
+ begin
219
+ aFile = File.new(filename, mode)
220
+ rescue
221
+ puts "Sorry. There was a problem opening the file <#{filename}>."
222
+ aFile.close() unless aFile.nil?
223
+ raise
224
+ end
225
+ return(aFile)
226
+ end
227
+
228
+
229
+ def encrypt_file(plainFilename, cryptFilename)
230
+ plainFile = carefully_open_file(plainFilename, 'rb')
231
+ cryptFile = carefully_open_file(cryptFilename, 'wb+')
232
+ encrypt_stream(plainFile, cryptFile)
233
+ plainFile.close unless plainFile.closed?
234
+ cryptFile.close unless cryptFile.closed?
235
+ end
236
+
237
+
238
+ def decrypt_file(cryptFilename, plainFilename)
239
+ cryptFile = carefully_open_file(cryptFilename, 'rb')
240
+ plainFile = carefully_open_file(plainFilename, 'wb+')
241
+ decrypt_stream(cryptFile, plainFile)
242
+ cryptFile.close unless cryptFile.closed?
243
+ plainFile.close unless plainFile.closed?
244
+ end
245
+
246
+
247
+ def encrypt_string(plainText)
248
+ plainStream = StringIO.new(plainText)
249
+ cryptStream = StringIO.new('')
250
+ encrypt_stream(plainStream, cryptStream)
251
+ cryptText = cryptStream.string
252
+ return(cryptText)
253
+ end
254
+
255
+
256
+ def decrypt_string(cryptText)
257
+ cryptStream = StringIO.new(cryptText)
258
+ plainStream = StringIO.new('')
259
+ decrypt_stream(cryptStream, plainStream)
260
+ plainText = plainStream.string
261
+ return(plainText)
262
+ end
263
+
264
+ end
265
+