zucker 8 → 9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (366) hide show
  1. data/CHANGELOG +14 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README +1 -1
  4. data/Rakefile +33 -40
  5. data/desc/alias_for.yaml +17 -0
  6. data/desc/aliases.yaml +18 -0
  7. data/desc/array.yaml +13 -0
  8. data/desc/array_to_proc.yaml +16 -0
  9. data/desc/binding.yaml +22 -0
  10. data/desc/blank.yaml +9 -0
  11. data/desc/cc.yaml +10 -0
  12. data/desc/class_to_proc.yaml +11 -0
  13. data/desc/dd.yaml +23 -0
  14. data/desc/egonil.yaml +15 -0
  15. data/desc/engine.yaml +15 -0
  16. data/desc/enumerable.yaml +10 -0
  17. data/desc/file.yaml +15 -0
  18. data/desc/hash.yaml +14 -0
  19. data/desc/hash_to_proc.yaml +10 -0
  20. data/desc/info.yaml +20 -0
  21. data/desc/iterate.yaml +16 -0
  22. data/desc/ivars.yaml +19 -0
  23. data/desc/kernel.yaml +14 -0
  24. data/desc/mcopy.yaml +11 -0
  25. data/desc/mm.yaml +15 -0
  26. data/desc/not.yaml +11 -0
  27. data/desc/oo.yaml +10 -0
  28. data/desc/os.yaml +19 -0
  29. data/desc/qq.yaml +11 -0
  30. data/desc/regexp_to_proc.yaml +12 -0
  31. data/desc/regexp_visualize.yaml +23 -0
  32. data/desc/sandbox.yaml +12 -0
  33. data/desc/square_brackets_for.yaml +22 -0
  34. data/desc/string.yaml +23 -0
  35. data/desc/tap.yaml +17 -0
  36. data/desc/unary.yaml +15 -0
  37. data/desc/union.yaml +10 -0
  38. data/desc/version.yaml +28 -0
  39. data/doc/zucker_doc.html +2688 -0
  40. data/doc/zucker_doc.rb +553 -0
  41. data/lib/zucker.rb +10 -9
  42. data/lib/zucker/array2proc.rb +2 -18
  43. data/lib/zucker/{2/array2proc.rb → array_to_proc.rb} +0 -0
  44. data/lib/zucker/binding.rb +4 -5
  45. data/lib/zucker/cc.rb +7 -2
  46. data/lib/zucker/class2proc.rb +2 -12
  47. data/lib/zucker/{1/class2proc.rb → class_to_proc.rb} +0 -0
  48. data/lib/zucker/file.rb +22 -0
  49. data/lib/zucker/hash2proc.rb +2 -16
  50. data/lib/zucker/{1/hash2proc.rb → hash_to_proc.rb} +0 -0
  51. data/lib/zucker/kernel.rb +4 -2
  52. data/lib/zucker/mm.rb +14 -8
  53. data/lib/zucker/regexp2proc.rb +2 -12
  54. data/lib/zucker/{1/regexp2proc.rb → regexp_to_proc.rb} +0 -0
  55. data/lib/zucker/regexp_visualize.rb +26 -0
  56. data/lib/zucker/sandbox.rb +1 -11
  57. data/spec/alias_for_spec.rb +117 -0
  58. data/spec/aliases_spec.rb +13 -0
  59. data/spec/array_spec.rb +23 -0
  60. data/spec/array_to_proc_spec.rb +12 -0
  61. data/spec/binding_spec.rb +6 -0
  62. data/spec/blank_spec.rb +20 -0
  63. data/spec/cc_spec.rb +6 -0
  64. data/spec/class_to_proc_spec.rb +9 -0
  65. data/spec/dd_spec.rb +37 -0
  66. data/spec/egonil_spec.rb +32 -0
  67. data/spec/engine_spec.rb +11 -0
  68. data/spec/enumerable_spec.rb +8 -0
  69. data/spec/file_spec.rb +30 -0
  70. data/spec/hash_spec.rb +25 -0
  71. data/spec/hash_to_proc_spec.rb +12 -0
  72. data/spec/info_spec.rb +8 -0
  73. data/spec/iterate_spec.rb +59 -0
  74. data/spec/ivars_spec.rb +20 -0
  75. data/spec/kernel_spec.rb +37 -0
  76. data/spec/mcopy_spec.rb +13 -0
  77. data/spec/mm_spec.rb +6 -0
  78. data/spec/not_spec.rb +12 -0
  79. data/spec/oo_spec.rb +6 -0
  80. data/spec/os_spec.rb +37 -0
  81. data/spec/qq_spec.rb +19 -0
  82. data/spec/regexp_to_proc_spec.rb +9 -0
  83. data/spec/regexp_visualize_spec.rb +38 -0
  84. data/spec/sandbox_spec.rb +12 -0
  85. data/spec/spec_helper.rb +18 -0
  86. data/spec/square_brackets_for_spec.rb +59 -0
  87. data/spec/string_spec.rb +65 -0
  88. data/spec/tap_spec.rb +18 -0
  89. data/spec/unary_spec.rb +26 -0
  90. data/spec/union_spec.rb +17 -0
  91. data/spec/version_spec.rb +55 -0
  92. data/zucker.gemspec +21 -0
  93. metadata +139 -323
  94. data/lib/zucker/1/D.rb +0 -21
  95. data/lib/zucker/1/aliases.rb +0 -30
  96. data/lib/zucker/1/all.rb +0 -8
  97. data/lib/zucker/1/array.rb +0 -19
  98. data/lib/zucker/1/array2proc.rb +0 -12
  99. data/lib/zucker/1/binding.rb +0 -27
  100. data/lib/zucker/1/blank.rb +0 -28
  101. data/lib/zucker/1/debug.rb +0 -6
  102. data/lib/zucker/1/default.rb +0 -27
  103. data/lib/zucker/1/egonil.rb +0 -16
  104. data/lib/zucker/1/enumerable.rb +0 -14
  105. data/lib/zucker/1/hash.rb +0 -21
  106. data/lib/zucker/1/iterate.rb +0 -25
  107. data/lib/zucker/1/ivars.rb +0 -28
  108. data/lib/zucker/1/kernel.rb +0 -22
  109. data/lib/zucker/1/mcopy.rb +0 -11
  110. data/lib/zucker/1/mm.rb +0 -33
  111. data/lib/zucker/1/sandbox.rb +0 -17
  112. data/lib/zucker/1/square_brackets_for.rb +0 -22
  113. data/lib/zucker/1/string.rb +0 -27
  114. data/lib/zucker/1/unary.rb +0 -24
  115. data/lib/zucker/1/union.rb +0 -16
  116. data/lib/zucker/2/D.rb +0 -21
  117. data/lib/zucker/2/aliases.rb +0 -30
  118. data/lib/zucker/2/all.rb +0 -8
  119. data/lib/zucker/2/array.rb +0 -19
  120. data/lib/zucker/2/binding.rb +0 -27
  121. data/lib/zucker/2/blank.rb +0 -28
  122. data/lib/zucker/2/class2proc.rb +0 -12
  123. data/lib/zucker/2/debug.rb +0 -6
  124. data/lib/zucker/2/default.rb +0 -27
  125. data/lib/zucker/2/egonil.rb +0 -16
  126. data/lib/zucker/2/enumerable.rb +0 -14
  127. data/lib/zucker/2/hash.rb +0 -21
  128. data/lib/zucker/2/hash2proc.rb +0 -16
  129. data/lib/zucker/2/info.rb +0 -166
  130. data/lib/zucker/2/iterate.rb +0 -25
  131. data/lib/zucker/2/ivars.rb +0 -28
  132. data/lib/zucker/2/kernel.rb +0 -20
  133. data/lib/zucker/2/mcopy.rb +0 -11
  134. data/lib/zucker/2/mm.rb +0 -33
  135. data/lib/zucker/2/regexp2proc.rb +0 -12
  136. data/lib/zucker/2/sandbox.rb +0 -21
  137. data/lib/zucker/2/square_brackets_for.rb +0 -22
  138. data/lib/zucker/2/string.rb +0 -27
  139. data/lib/zucker/2/unary.rb +0 -24
  140. data/lib/zucker/2/union.rb +0 -16
  141. data/lib/zucker/3/D.rb +0 -21
  142. data/lib/zucker/3/alias_for.rb +0 -21
  143. data/lib/zucker/3/aliases.rb +0 -30
  144. data/lib/zucker/3/all.rb +0 -8
  145. data/lib/zucker/3/array.rb +0 -25
  146. data/lib/zucker/3/array2proc.rb +0 -18
  147. data/lib/zucker/3/binding.rb +0 -27
  148. data/lib/zucker/3/blank.rb +0 -28
  149. data/lib/zucker/3/class2proc.rb +0 -12
  150. data/lib/zucker/3/debug.rb +0 -8
  151. data/lib/zucker/3/default.rb +0 -37
  152. data/lib/zucker/3/egonil.rb +0 -16
  153. data/lib/zucker/3/enumerable.rb +0 -14
  154. data/lib/zucker/3/hash.rb +0 -21
  155. data/lib/zucker/3/hash2proc.rb +0 -16
  156. data/lib/zucker/3/info.rb +0 -169
  157. data/lib/zucker/3/iterate.rb +0 -25
  158. data/lib/zucker/3/ivars.rb +0 -28
  159. data/lib/zucker/3/kernel.rb +0 -50
  160. data/lib/zucker/3/mcopy.rb +0 -10
  161. data/lib/zucker/3/mm.rb +0 -33
  162. data/lib/zucker/3/not.rb +0 -19
  163. data/lib/zucker/3/regexp2proc.rb +0 -12
  164. data/lib/zucker/3/sandbox.rb +0 -21
  165. data/lib/zucker/3/square_brackets_for.rb +0 -22
  166. data/lib/zucker/3/string.rb +0 -49
  167. data/lib/zucker/3/tap.rb +0 -11
  168. data/lib/zucker/3/unary.rb +0 -24
  169. data/lib/zucker/3/union.rb +0 -16
  170. data/lib/zucker/4/D.rb +0 -21
  171. data/lib/zucker/4/alias_for.rb +0 -21
  172. data/lib/zucker/4/aliases.rb +0 -35
  173. data/lib/zucker/4/all.rb +0 -8
  174. data/lib/zucker/4/array.rb +0 -25
  175. data/lib/zucker/4/array2proc.rb +0 -18
  176. data/lib/zucker/4/binding.rb +0 -27
  177. data/lib/zucker/4/blank.rb +0 -28
  178. data/lib/zucker/4/class2proc.rb +0 -12
  179. data/lib/zucker/4/debug.rb +0 -8
  180. data/lib/zucker/4/default.rb +0 -40
  181. data/lib/zucker/4/egonil.rb +0 -16
  182. data/lib/zucker/4/engine.rb +0 -69
  183. data/lib/zucker/4/enumerable.rb +0 -14
  184. data/lib/zucker/4/hash.rb +0 -21
  185. data/lib/zucker/4/hash2proc.rb +0 -16
  186. data/lib/zucker/4/info.rb +0 -173
  187. data/lib/zucker/4/iterate.rb +0 -25
  188. data/lib/zucker/4/ivars.rb +0 -28
  189. data/lib/zucker/4/kernel.rb +0 -27
  190. data/lib/zucker/4/mcopy.rb +0 -10
  191. data/lib/zucker/4/mm.rb +0 -33
  192. data/lib/zucker/4/not.rb +0 -19
  193. data/lib/zucker/4/os.rb +0 -50
  194. data/lib/zucker/4/q.rb +0 -7
  195. data/lib/zucker/4/regexp2proc.rb +0 -12
  196. data/lib/zucker/4/sandbox.rb +0 -23
  197. data/lib/zucker/4/square_brackets_for.rb +0 -22
  198. data/lib/zucker/4/string.rb +0 -54
  199. data/lib/zucker/4/tap.rb +0 -11
  200. data/lib/zucker/4/unary.rb +0 -24
  201. data/lib/zucker/4/union.rb +0 -16
  202. data/lib/zucker/4/version.rb +0 -115
  203. data/lib/zucker/5/alias_for.rb +0 -21
  204. data/lib/zucker/5/aliases.rb +0 -51
  205. data/lib/zucker/5/all.rb +0 -4
  206. data/lib/zucker/5/array.rb +0 -25
  207. data/lib/zucker/5/array2proc.rb +0 -18
  208. data/lib/zucker/5/binding.rb +0 -34
  209. data/lib/zucker/5/blank.rb +0 -28
  210. data/lib/zucker/5/cc.rb +0 -25
  211. data/lib/zucker/5/class2proc.rb +0 -12
  212. data/lib/zucker/5/control.rb +0 -4
  213. data/lib/zucker/5/dd.rb +0 -24
  214. data/lib/zucker/5/debug.rb +0 -4
  215. data/lib/zucker/5/default.rb +0 -4
  216. data/lib/zucker/5/egonil.rb +0 -16
  217. data/lib/zucker/5/engine.rb +0 -69
  218. data/lib/zucker/5/enumerable.rb +0 -14
  219. data/lib/zucker/5/env.rb +0 -4
  220. data/lib/zucker/5/extensions.rb +0 -4
  221. data/lib/zucker/5/hash.rb +0 -27
  222. data/lib/zucker/5/hash2proc.rb +0 -16
  223. data/lib/zucker/5/info.rb +0 -177
  224. data/lib/zucker/5/iterate.rb +0 -26
  225. data/lib/zucker/5/ivars.rb +0 -28
  226. data/lib/zucker/5/kernel.rb +0 -34
  227. data/lib/zucker/5/mcopy.rb +0 -10
  228. data/lib/zucker/5/mm.rb +0 -34
  229. data/lib/zucker/5/not.rb +0 -19
  230. data/lib/zucker/5/object.rb +0 -4
  231. data/lib/zucker/5/oo.rb +0 -17
  232. data/lib/zucker/5/os.rb +0 -49
  233. data/lib/zucker/5/qq.rb +0 -12
  234. data/lib/zucker/5/regexp2proc.rb +0 -12
  235. data/lib/zucker/5/sandbox.rb +0 -25
  236. data/lib/zucker/5/shortcuts.rb +0 -4
  237. data/lib/zucker/5/square_brackets_for.rb +0 -21
  238. data/lib/zucker/5/string.rb +0 -54
  239. data/lib/zucker/5/tap.rb +0 -11
  240. data/lib/zucker/5/to_proc.rb +0 -4
  241. data/lib/zucker/5/unary.rb +0 -24
  242. data/lib/zucker/5/union.rb +0 -16
  243. data/lib/zucker/5/version.rb +0 -118
  244. data/lib/zucker/6/alias_for.rb +0 -21
  245. data/lib/zucker/6/aliases.rb +0 -51
  246. data/lib/zucker/6/all.rb +0 -4
  247. data/lib/zucker/6/array.rb +0 -25
  248. data/lib/zucker/6/array2proc.rb +0 -18
  249. data/lib/zucker/6/binding.rb +0 -34
  250. data/lib/zucker/6/blank.rb +0 -28
  251. data/lib/zucker/6/cc.rb +0 -25
  252. data/lib/zucker/6/class2proc.rb +0 -12
  253. data/lib/zucker/6/control.rb +0 -4
  254. data/lib/zucker/6/dd.rb +0 -23
  255. data/lib/zucker/6/debug.rb +0 -4
  256. data/lib/zucker/6/default.rb +0 -4
  257. data/lib/zucker/6/egonil.rb +0 -27
  258. data/lib/zucker/6/engine.rb +0 -68
  259. data/lib/zucker/6/enumerable.rb +0 -14
  260. data/lib/zucker/6/env.rb +0 -4
  261. data/lib/zucker/6/extensions.rb +0 -4
  262. data/lib/zucker/6/hash.rb +0 -27
  263. data/lib/zucker/6/hash2proc.rb +0 -16
  264. data/lib/zucker/6/info.rb +0 -192
  265. data/lib/zucker/6/iterate.rb +0 -27
  266. data/lib/zucker/6/ivars.rb +0 -28
  267. data/lib/zucker/6/kernel.rb +0 -34
  268. data/lib/zucker/6/mcopy.rb +0 -10
  269. data/lib/zucker/6/mm.rb +0 -34
  270. data/lib/zucker/6/not.rb +0 -19
  271. data/lib/zucker/6/object.rb +0 -4
  272. data/lib/zucker/6/oo.rb +0 -17
  273. data/lib/zucker/6/os.rb +0 -54
  274. data/lib/zucker/6/qq.rb +0 -12
  275. data/lib/zucker/6/regexp2proc.rb +0 -12
  276. data/lib/zucker/6/sandbox.rb +0 -25
  277. data/lib/zucker/6/shortcuts.rb +0 -4
  278. data/lib/zucker/6/square_brackets_for.rb +0 -21
  279. data/lib/zucker/6/string.rb +0 -54
  280. data/lib/zucker/6/tap.rb +0 -11
  281. data/lib/zucker/6/to_proc.rb +0 -4
  282. data/lib/zucker/6/unary.rb +0 -24
  283. data/lib/zucker/6/union.rb +0 -16
  284. data/lib/zucker/6/version.rb +0 -118
  285. data/lib/zucker/7/alias_for.rb +0 -21
  286. data/lib/zucker/7/aliases.rb +0 -51
  287. data/lib/zucker/7/all.rb +0 -4
  288. data/lib/zucker/7/array.rb +0 -25
  289. data/lib/zucker/7/array2proc.rb +0 -18
  290. data/lib/zucker/7/binding.rb +0 -34
  291. data/lib/zucker/7/blank.rb +0 -28
  292. data/lib/zucker/7/cc.rb +0 -25
  293. data/lib/zucker/7/class2proc.rb +0 -12
  294. data/lib/zucker/7/control.rb +0 -4
  295. data/lib/zucker/7/dd.rb +0 -23
  296. data/lib/zucker/7/debug.rb +0 -4
  297. data/lib/zucker/7/default.rb +0 -4
  298. data/lib/zucker/7/egonil.rb +0 -27
  299. data/lib/zucker/7/engine.rb +0 -68
  300. data/lib/zucker/7/enumerable.rb +0 -14
  301. data/lib/zucker/7/env.rb +0 -4
  302. data/lib/zucker/7/extensions.rb +0 -4
  303. data/lib/zucker/7/hash.rb +0 -27
  304. data/lib/zucker/7/hash2proc.rb +0 -16
  305. data/lib/zucker/7/info.rb +0 -192
  306. data/lib/zucker/7/iterate.rb +0 -27
  307. data/lib/zucker/7/ivars.rb +0 -28
  308. data/lib/zucker/7/kernel.rb +0 -34
  309. data/lib/zucker/7/mcopy.rb +0 -10
  310. data/lib/zucker/7/mm.rb +0 -34
  311. data/lib/zucker/7/not.rb +0 -19
  312. data/lib/zucker/7/object.rb +0 -4
  313. data/lib/zucker/7/oo.rb +0 -17
  314. data/lib/zucker/7/os.rb +0 -54
  315. data/lib/zucker/7/qq.rb +0 -12
  316. data/lib/zucker/7/regexp2proc.rb +0 -12
  317. data/lib/zucker/7/sandbox.rb +0 -25
  318. data/lib/zucker/7/shortcuts.rb +0 -4
  319. data/lib/zucker/7/square_brackets_for.rb +0 -21
  320. data/lib/zucker/7/string.rb +0 -54
  321. data/lib/zucker/7/tap.rb +0 -11
  322. data/lib/zucker/7/to_proc.rb +0 -4
  323. data/lib/zucker/7/unary.rb +0 -24
  324. data/lib/zucker/7/union.rb +0 -16
  325. data/lib/zucker/7/version.rb +0 -118
  326. data/lib/zucker/8/alias_for.rb +0 -21
  327. data/lib/zucker/8/aliases.rb +0 -51
  328. data/lib/zucker/8/all.rb +0 -4
  329. data/lib/zucker/8/array.rb +0 -25
  330. data/lib/zucker/8/array2proc.rb +0 -18
  331. data/lib/zucker/8/binding.rb +0 -33
  332. data/lib/zucker/8/blank.rb +0 -28
  333. data/lib/zucker/8/cc.rb +0 -25
  334. data/lib/zucker/8/class2proc.rb +0 -12
  335. data/lib/zucker/8/control.rb +0 -4
  336. data/lib/zucker/8/dd.rb +0 -23
  337. data/lib/zucker/8/debug.rb +0 -4
  338. data/lib/zucker/8/default.rb +0 -4
  339. data/lib/zucker/8/egonil.rb +0 -27
  340. data/lib/zucker/8/engine.rb +0 -68
  341. data/lib/zucker/8/enumerable.rb +0 -14
  342. data/lib/zucker/8/env.rb +0 -4
  343. data/lib/zucker/8/extensions.rb +0 -4
  344. data/lib/zucker/8/hash.rb +0 -27
  345. data/lib/zucker/8/hash2proc.rb +0 -16
  346. data/lib/zucker/8/info.rb +0 -192
  347. data/lib/zucker/8/iterate.rb +0 -27
  348. data/lib/zucker/8/ivars.rb +0 -28
  349. data/lib/zucker/8/kernel.rb +0 -34
  350. data/lib/zucker/8/mcopy.rb +0 -10
  351. data/lib/zucker/8/mm.rb +0 -34
  352. data/lib/zucker/8/not.rb +0 -19
  353. data/lib/zucker/8/object.rb +0 -4
  354. data/lib/zucker/8/oo.rb +0 -17
  355. data/lib/zucker/8/os.rb +0 -54
  356. data/lib/zucker/8/qq.rb +0 -12
  357. data/lib/zucker/8/regexp2proc.rb +0 -12
  358. data/lib/zucker/8/sandbox.rb +0 -25
  359. data/lib/zucker/8/shortcuts.rb +0 -4
  360. data/lib/zucker/8/square_brackets_for.rb +0 -21
  361. data/lib/zucker/8/string.rb +0 -54
  362. data/lib/zucker/8/tap.rb +0 -11
  363. data/lib/zucker/8/to_proc.rb +0 -4
  364. data/lib/zucker/8/unary.rb +0 -24
  365. data/lib/zucker/8/union.rb +0 -16
  366. data/lib/zucker/8/version.rb +0 -118
@@ -1,21 +0,0 @@
1
- require 'zucker'
2
-
3
- def alias_for(m, *aliases)
4
- aliases.each{ |a|
5
- class_eval "alias #{a} #{m}"
6
- }
7
- end
8
- alias aliases_for alias_for
9
-
10
- class Module
11
- def alias_method_for(m, *alias_methods)
12
- alias_methods.each{ |a|
13
- class_eval do
14
- alias_method a.to_sym, m.to_sym
15
- end
16
- }
17
- end
18
- alias alias_methods_for alias_method_for
19
- end
20
-
21
- # J-_-L
@@ -1,51 +0,0 @@
1
- require 'zucker'
2
-
3
- class Object
4
- alias is_an? is_a? # thanks to utility_belt
5
- end
6
-
7
- module Enumerable
8
- alias with zip
9
- alias % zip
10
- end
11
-
12
- class Array
13
- alias ** product
14
- alias contains? include?
15
- end
16
-
17
- class String
18
- alias contains? include?
19
- end
20
-
21
- class Hash
22
- alias + merge
23
- end
24
-
25
- class Binding
26
- #alias [] eval
27
- def [](expr)
28
- self.eval "#{expr}"
29
- end
30
- end
31
-
32
- class << File
33
- alias filename basename # thanks rdp :)
34
- end
35
-
36
- class << Dir
37
- def join(*args)
38
- File.join(*args)
39
- end
40
-
41
- def split(*args)
42
- File.split(*args)
43
- end
44
- end
45
-
46
- # constants - who would use these in real-world code for other things?
47
- Infinity = 1.0 / 0.0 # or 2*Float::MAX or Float::INFINITY
48
- NaN = 0.0 / 0.0
49
-
50
- # J-_-L
51
-
@@ -1,4 +0,0 @@
1
- require 'zucker'
2
- Zucker.require_all
3
-
4
- # J-_-L
@@ -1,25 +0,0 @@
1
- require 'zucker'
2
-
3
- class Array
4
- def ^(other) # TODO: more efficient
5
- (self - other) +
6
- (other - self)
7
- end
8
-
9
- # can take an argument & block to be Rails compatible
10
- def sum(identity = 0, &block)
11
- # inject(:+)
12
- if block_given?
13
- map(&block).sum( identity )
14
- else
15
- inject(:+) || identity
16
- end
17
- end
18
-
19
- def chrs
20
- self.pack 'C*'
21
- end
22
- end
23
-
24
- # J-_-L
25
-
@@ -1,18 +0,0 @@
1
- require 'zucker'
2
-
3
- class Array
4
- def to_proc
5
- Proc.new{ |obj|
6
- if self.first.is_a? Array
7
- self.inject(obj){ |result, nested_array|
8
- nested_array.to_proc.call result
9
- }
10
- else
11
- obj.send *self
12
- end
13
- }
14
- end
15
- end
16
-
17
- # J-_-L
18
-
@@ -1,33 +0,0 @@
1
- require 'zucker'
2
-
3
- class Binding
4
- def variables
5
- put_vars = lambda { |array|
6
- if array.empty?
7
- ' - none'
8
- else
9
- array.map{|e|
10
- val = self.eval "#{e}"
11
- val = val.is_a?( Binding ) ? val.to_s : val.inspect
12
- " - #{e}: #{ val }"
13
- }.join "\n"
14
- end
15
- }
16
-
17
- "#{self.to_s}
18
- local vars
19
- #{ put_vars[ self.eval 'local_variables' ] }
20
- (instance vars)
21
- #{ put_vars[ self.eval 'instance_variables' ] }
22
- self
23
- - #{self.eval 'self'}
24
- block_given?
25
- - #{self.eval 'block_given?'}"
26
-
27
- end
28
-
29
- alias vars variables
30
- end
31
-
32
- # J-_-L
33
-
@@ -1,28 +0,0 @@
1
- require 'zucker'
2
-
3
- class Object
4
- def blank?
5
- if respond_to? :empty? then empty? else !self end
6
- end
7
-
8
- def present?
9
- !blank?
10
- end
11
- end
12
-
13
-
14
- { # what to do # for which classes
15
- lambda{ true } => [FalseClass, NilClass],
16
- lambda{ false } => [TrueClass, Numeric],
17
- lambda{ empty? } => [Array, Hash],
18
- lambda{ self !~ /\S/ } => [String],
19
- lambda{ self == // } => [Regexp],
20
-
21
- }.each{ |action, klass_array|
22
- klass_array.each{ |klass|
23
- klass.send :define_method, :blank?, &action
24
- }
25
- }
26
-
27
- # J-_-L
28
-
@@ -1,25 +0,0 @@
1
- require 'zucker'
2
-
3
- module Kernel
4
- private
5
-
6
- def c(show_irb = false)
7
- method_stack = caller.reverse.map{ |m|
8
- m.rindex( /:\d+(:in `(.*)')?$/ )
9
- $2
10
- }.compact
11
-
12
- if !show_irb && a = method_stack.index( 'irb_binding' )
13
- method_stack = [ method_stack[0], '(irb)', *method_stack[a+1..-1] ]
14
- end
15
-
16
- # puts method_stack.map.with_index{ |m, i|
17
- method_stack.each_with_index{ |m, i|
18
- puts " "*i + m
19
- }
20
- end
21
-
22
- alias cc c
23
- end
24
-
25
- # J-_-L
@@ -1,12 +0,0 @@
1
- require 'zucker'
2
-
3
- class Class
4
- def to_proc
5
- Proc.new do |*args|
6
- self.new *args
7
- end
8
- end
9
- end
10
-
11
- # J-_-L
12
-
@@ -1,4 +0,0 @@
1
- require 'zucker'
2
- Zucker.require_this __FILE__
3
-
4
- # J-_-L
@@ -1,23 +0,0 @@
1
- require 'zucker'
2
-
3
- module Kernel
4
- def d(*args, &block)
5
- if args.empty?
6
- tap{
7
- if block_given?
8
- puts yield self
9
- else
10
- puts self.inspect
11
- end
12
- }
13
- else
14
- raise ArgumentError, ".d - The parser thought that the code after .d are method arguments... Please don't put a space after d or use .d() or .d{} in this case!"
15
- # eval ...
16
- end
17
- end
18
-
19
- alias dd d
20
- end
21
-
22
- # J-_-L
23
-
@@ -1,4 +0,0 @@
1
- require 'zucker'
2
- Zucker.require_this __FILE__
3
-
4
- # J-_-L
@@ -1,4 +0,0 @@
1
- require 'zucker'
2
- Zucker.require_all
3
-
4
- # J-_-L
@@ -1,27 +0,0 @@
1
- require 'zucker'
2
-
3
- # code by Yohan, slightly edited and comments by me
4
- def egonil(&block)
5
- # grip methods
6
- ori_method_missing = NilClass.instance_method(:method_missing)
7
- catch_method_missing = NilClass.instance_method(:catch_method_missing)
8
- # activate ego mode
9
- NilClass.send :define_method, :method_missing, catch_method_missing
10
- # run code
11
- yield
12
- ensure
13
- # no matter what happens: restore default nil behaviour
14
- NilClass.send :define_method, :method_missing, ori_method_missing
15
- end
16
-
17
- # this is the ego nil
18
- class NilClass
19
- def catch_method_missing(m, *args, &block)
20
- nil
21
- end
22
- end
23
-
24
- alias nn egonil
25
-
26
- # J-_-L
27
-
@@ -1,68 +0,0 @@
1
- require 'zucker'
2
-
3
- module RubyEngine
4
- # try to guess the interpreter
5
- @interpreter = case
6
- when RUBY_PLATFORM == 'parrot'
7
- 'cardinal'
8
- when Object.const_defined?(:RUBY_ENGINE)
9
- if RUBY_ENGINE == 'ruby'
10
- if RUBY_DESCRIPTION =~ /Enterprise/
11
- 'ree'
12
- else
13
- 'mri'
14
- end
15
- else
16
- RUBY_ENGINE.to_s # jruby, rbx, ironruby, macruby, etc.
17
- end
18
- else # probably 1.8
19
- 'mri'
20
- end
21
-
22
- class << self
23
- def is?(what)
24
- what === @interpreter
25
- end
26
- alias is is?
27
-
28
- def to_s
29
- @interpreter.to_s
30
- end
31
-
32
- # ask methods
33
-
34
- def mri?
35
- RubyEngine.is? 'mri'
36
- end
37
- alias official_ruby? mri?
38
- alias ruby? mri?
39
-
40
- def jruby?
41
- RubyEngine.is? 'jruby'
42
- end
43
- alias java? jruby?
44
-
45
- def rubinius?
46
- RubyEngine.is? 'rbx'
47
- end
48
- alias rbx? rubinius?
49
-
50
- def ree?
51
- RubyEngine.is? 'ree'
52
- end
53
- alias enterprise? ree?
54
-
55
- def ironruby?
56
- RubyEngine.is? 'ironruby'
57
- end
58
- alias iron_ruby? ironruby?
59
-
60
- def cardinal?
61
- RubyEngine.is? 'cardinal'
62
- end
63
- alias parrot? cardinal?
64
- alias perl? cardinal?
65
- end
66
- end
67
-
68
- # J-_-L
@@ -1,14 +0,0 @@
1
- require 'zucker'
2
-
3
- module Enumerable
4
- def mash
5
- ret = {}
6
- each{ |kv|
7
- ret.store *( yield(kv)[0,2] )
8
- }
9
- ret
10
- end
11
- end
12
-
13
- # J-_-L
14
-
@@ -1,4 +0,0 @@
1
- require 'zucker'
2
- Zucker.require_this __FILE__
3
-
4
- # J-_-L
@@ -1,4 +0,0 @@
1
- require 'zucker'
2
- Zucker.require_this __FILE__
3
-
4
- # J-_-L
@@ -1,27 +0,0 @@
1
- require 'zucker'
2
-
3
- class Hash
4
- def self.zip(keys,values)
5
- Hash[ *keys.zip( values ).flatten ]
6
- end
7
-
8
- def <<(other)
9
- case
10
- when other.is_a?(Hash)
11
- merge! other
12
- when other.is_a?(Enumerable) || other.respond_to?(:to_splat)
13
- merge! Hash[*other]
14
- else
15
- raise TypeError, 'can only append other Hashs and Enumerables (or Classes that implement to_splat)'
16
- end
17
- end
18
-
19
- def &(other)
20
- Hash[ *select{ |k,v|
21
- other[k] == v
22
- }.flatten ]
23
- end
24
- end
25
-
26
- # J-_-L
27
-
@@ -1,16 +0,0 @@
1
- require 'zucker'
2
-
3
- class Hash
4
- def to_proc
5
- Proc.new{ |obj|
6
- if self.member? obj
7
- self[obj].to_proc.call obj
8
- else
9
- obj
10
- end
11
- }
12
- end
13
- end
14
-
15
- # J-_-L
16
-
@@ -1,192 +0,0 @@
1
- require 'zucker'
2
- require 'rbconfig'
3
- require 'etc'
4
-
5
- module Info
6
- class << self
7
- # hash like access
8
- def [](what)
9
- send what
10
- end
11
-
12
- # list available info methods
13
- def list
14
- singleton_methods - [:[], :list, '[]', 'list']
15
- end
16
- end
17
-
18
- module_function
19
-
20
- # input
21
- def last_input_file
22
- $FILENAME
23
- end
24
-
25
- def last_input_line_number
26
- $.
27
- end
28
-
29
- def last_input
30
- $_
31
- end
32
-
33
- # program
34
- def program_name
35
- $0
36
- end
37
-
38
- def program_arguments
39
- $:
40
- end
41
-
42
- def loaded_programs
43
- $"
44
- end
45
-
46
- def program_data
47
- ::DATA
48
- end
49
-
50
- def child_program_status
51
- $CHILD_STATUS
52
- end
53
-
54
- # system info
55
- def environment
56
- ::ENV
57
- end
58
- alias env environment
59
-
60
- def working_directory
61
- Dir.pwd
62
- end
63
-
64
- def platform
65
- ::RUBY_PLATFORM
66
- end
67
-
68
- def os
69
- RbConfig::CONFIG['host_os']
70
- end
71
-
72
- def process_id
73
- $$
74
- end
75
-
76
- def load_path
77
- $:
78
- end
79
-
80
- # user
81
- def user_login
82
- Etc.getlogin
83
- end
84
-
85
- def user_name
86
- Etc.getpwnam(user_login).gecos.split(',')[0]
87
- end
88
-
89
- # current
90
-
91
- def current_file # __FILE__
92
- return $` if caller[0].rindex(/:\d+(:in `.*')?$/)
93
- end
94
-
95
- def current_file_directory
96
- if current_file[0,1] == '(' && current_file[-1,1] == ')'
97
- current_file
98
- else
99
- File.dirname(current_file)
100
- end
101
- end
102
-
103
- def current_line # __LINE__
104
- return $1.to_i if caller[0].rindex( /:(\d+)(:in `.*')?$/ )
105
- end
106
-
107
- def current_method # __method__ (except aliases)
108
- return $1.to_sym if caller(1)[0].rindex( /\`([^\']+)\'/ )
109
- end
110
-
111
- def current_callstack
112
- caller
113
- end
114
-
115
- # dealing with strings
116
- def gets_separator
117
- $/
118
- end
119
-
120
- def join_separator
121
- $,
122
- end
123
-
124
- def print_separator
125
- $,
126
- end
127
-
128
- def split_separator
129
- $;
130
- end
131
-
132
- # misc
133
- def security_level
134
- $SAFE
135
- end
136
-
137
- def warnings_activated?
138
- $VERBOSE
139
- end
140
-
141
- def debug_activated?
142
- $DEBUG
143
- end
144
-
145
- def last_exception
146
- $!
147
- end
148
-
149
- # defined objects
150
- def global_variables
151
- Object.send :global_variables
152
- end
153
-
154
- def global_constants
155
- Object.constants
156
- end
157
-
158
- # encoding (1.9)
159
- #def source_encoding
160
- # __ENCODING__
161
- #end
162
-
163
- def external_encoding
164
- Encoding.default_external
165
- end
166
-
167
- def internal_encoding
168
- Encoding.default_internal
169
- end
170
-
171
- # ruby version info
172
- def ruby_version # also see the RubyVersion cube
173
- ::RUBY_VERSION
174
- end
175
-
176
- def ruby_patchlevel
177
- ::RUBY_PATCHLEVEL
178
- end
179
-
180
- def ruby_description
181
- ::RUBY_DESCRIPTION
182
- end
183
-
184
- def ruby_release_date
185
- ::RUBY_RELEASE_DATE
186
- end
187
-
188
- def ruby_engine # warning! not support by every implementation. It's saver to use the RubyEngine cube
189
- ::RUBY_ENGINE
190
- end
191
- end
192
-