zucker 2 → 3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. data/CHANGELOG +12 -0
  2. data/README +4 -1
  3. data/Rakefile +17 -7
  4. data/lib/zucker.rb +7 -1
  5. data/lib/zucker/2/all.rb +2 -2
  6. data/lib/zucker/2/debug.rb +3 -3
  7. data/lib/zucker/2/default.rb +1 -1
  8. data/lib/zucker/3/D.rb +19 -0
  9. data/lib/zucker/3/alias_for.rb +19 -0
  10. data/lib/zucker/3/aliases.rb +28 -0
  11. data/lib/zucker/3/all.rb +6 -0
  12. data/lib/zucker/3/array.rb +23 -0
  13. data/lib/zucker/3/array2proc.rb +16 -0
  14. data/lib/zucker/3/binding.rb +25 -0
  15. data/lib/zucker/3/blank.rb +26 -0
  16. data/lib/zucker/3/class2proc.rb +10 -0
  17. data/lib/zucker/3/debug.rb +6 -0
  18. data/lib/zucker/3/default.rb +35 -0
  19. data/lib/zucker/3/egonil.rb +14 -0
  20. data/lib/zucker/3/enumerable.rb +12 -0
  21. data/lib/zucker/3/hash.rb +19 -0
  22. data/lib/zucker/3/hash2proc.rb +14 -0
  23. data/lib/zucker/3/info.rb +167 -0
  24. data/lib/zucker/3/iterate.rb +23 -0
  25. data/lib/zucker/3/ivars.rb +26 -0
  26. data/lib/zucker/3/kernel.rb +48 -0
  27. data/lib/zucker/3/mcopy.rb +8 -0
  28. data/lib/zucker/3/mm.rb +31 -0
  29. data/lib/zucker/3/not.rb +17 -0
  30. data/lib/zucker/3/regexp2proc.rb +10 -0
  31. data/lib/zucker/3/sandbox.rb +19 -0
  32. data/lib/zucker/3/square_brackets_for.rb +20 -0
  33. data/lib/zucker/3/string.rb +47 -0
  34. data/lib/zucker/3/tap.rb +9 -0
  35. data/lib/zucker/3/unary.rb +22 -0
  36. data/lib/zucker/3/union.rb +14 -0
  37. data/lib/zucker/alias_for.rb +19 -0
  38. data/lib/zucker/array.rb +8 -2
  39. data/lib/zucker/debug.rb +2 -0
  40. data/lib/zucker/default.rb +11 -1
  41. data/lib/zucker/info.rb +5 -2
  42. data/lib/zucker/kernel.rb +41 -11
  43. data/lib/zucker/mcopy.rb +0 -1
  44. data/lib/zucker/not.rb +17 -0
  45. data/lib/zucker/string.rb +24 -2
  46. data/lib/zucker/tap.rb +9 -0
  47. metadata +41 -160
  48. data/lib/zucker/1/desc/D.yaml +0 -23
  49. data/lib/zucker/1/desc/aliases.yaml +0 -16
  50. data/lib/zucker/1/desc/array.yaml +0 -14
  51. data/lib/zucker/1/desc/array2proc.yaml +0 -13
  52. data/lib/zucker/1/desc/binding.yaml +0 -10
  53. data/lib/zucker/1/desc/blank.yaml +0 -12
  54. data/lib/zucker/1/desc/class2proc.yaml +0 -12
  55. data/lib/zucker/1/desc/egonil.yaml +0 -17
  56. data/lib/zucker/1/desc/enumerable.yaml +0 -11
  57. data/lib/zucker/1/desc/hash.yaml +0 -12
  58. data/lib/zucker/1/desc/hash2proc.yaml +0 -11
  59. data/lib/zucker/1/desc/iterate.yaml +0 -17
  60. data/lib/zucker/1/desc/ivars.yaml +0 -20
  61. data/lib/zucker/1/desc/kernel.yaml +0 -13
  62. data/lib/zucker/1/desc/mcopy.yaml +0 -12
  63. data/lib/zucker/1/desc/mm.yaml +0 -12
  64. data/lib/zucker/1/desc/regexp2proc.yaml +0 -13
  65. data/lib/zucker/1/desc/sandbox.yaml +0 -14
  66. data/lib/zucker/1/desc/square_brackets_for.yaml +0 -23
  67. data/lib/zucker/1/desc/string.yaml +0 -13
  68. data/lib/zucker/1/desc/unary.yaml +0 -15
  69. data/lib/zucker/1/desc/union.yaml +0 -11
  70. data/lib/zucker/1/doc/meta.yaml +0 -4
  71. data/lib/zucker/1/doc/zucker_doc.html +0 -1286
  72. data/lib/zucker/1/doc/zucker_doc.rb +0 -493
  73. data/lib/zucker/1/spec/D_spec.rb +0 -27
  74. data/lib/zucker/1/spec/aliases_spec.rb +0 -34
  75. data/lib/zucker/1/spec/array2proc_spec.rb +0 -8
  76. data/lib/zucker/1/spec/array_spec.rb +0 -23
  77. data/lib/zucker/1/spec/binding_spec.rb +0 -6
  78. data/lib/zucker/1/spec/blank_spec.rb +0 -20
  79. data/lib/zucker/1/spec/class2proc_spec.rb +0 -9
  80. data/lib/zucker/1/spec/egonil_spec.rb +0 -30
  81. data/lib/zucker/1/spec/enumerable_spec.rb +0 -8
  82. data/lib/zucker/1/spec/hash2proc_spec.rb +0 -12
  83. data/lib/zucker/1/spec/hash_spec.rb +0 -10
  84. data/lib/zucker/1/spec/iterate_spec.rb +0 -54
  85. data/lib/zucker/1/spec/ivars_spec.rb +0 -20
  86. data/lib/zucker/1/spec/kernel_spec.rb +0 -34
  87. data/lib/zucker/1/spec/mcopy_spec.rb +0 -13
  88. data/lib/zucker/1/spec/mm_spec.rb +0 -6
  89. data/lib/zucker/1/spec/regexp2proc_spec.rb +0 -9
  90. data/lib/zucker/1/spec/sandbox_spec.rb +0 -7
  91. data/lib/zucker/1/spec/square_brackets_for_spec.rb +0 -59
  92. data/lib/zucker/1/spec/string_spec.rb +0 -29
  93. data/lib/zucker/1/spec/unary_spec.rb +0 -26
  94. data/lib/zucker/1/spec/union_spec.rb +0 -13
  95. data/lib/zucker/2/desc/D.yaml +0 -23
  96. data/lib/zucker/2/desc/aliases.yaml +0 -16
  97. data/lib/zucker/2/desc/array.yaml +0 -14
  98. data/lib/zucker/2/desc/array2proc.yaml +0 -17
  99. data/lib/zucker/2/desc/binding.yaml +0 -10
  100. data/lib/zucker/2/desc/blank.yaml +0 -10
  101. data/lib/zucker/2/desc/class2proc.yaml +0 -12
  102. data/lib/zucker/2/desc/egonil.yaml +0 -17
  103. data/lib/zucker/2/desc/enumerable.yaml +0 -11
  104. data/lib/zucker/2/desc/hash.yaml +0 -14
  105. data/lib/zucker/2/desc/hash2proc.yaml +0 -11
  106. data/lib/zucker/2/desc/info.yaml +0 -12
  107. data/lib/zucker/2/desc/iterate.yaml +0 -17
  108. data/lib/zucker/2/desc/ivars.yaml +0 -20
  109. data/lib/zucker/2/desc/kernel.yaml +0 -13
  110. data/lib/zucker/2/desc/mcopy.yaml +0 -12
  111. data/lib/zucker/2/desc/mm.yaml +0 -12
  112. data/lib/zucker/2/desc/regexp2proc.yaml +0 -13
  113. data/lib/zucker/2/desc/sandbox.yaml +0 -19
  114. data/lib/zucker/2/desc/square_brackets_for.yaml +0 -23
  115. data/lib/zucker/2/desc/string.yaml +0 -13
  116. data/lib/zucker/2/desc/unary.yaml +0 -15
  117. data/lib/zucker/2/desc/union.yaml +0 -11
  118. data/lib/zucker/2/doc/zucker_doc.html +0 -1494
  119. data/lib/zucker/2/doc/zucker_doc.rb +0 -498
  120. data/lib/zucker/2/spec/D_spec.rb +0 -35
  121. data/lib/zucker/2/spec/aliases_spec.rb +0 -13
  122. data/lib/zucker/2/spec/array2proc_spec.rb +0 -12
  123. data/lib/zucker/2/spec/array_spec.rb +0 -23
  124. data/lib/zucker/2/spec/binding_spec.rb +0 -8
  125. data/lib/zucker/2/spec/blank_spec.rb +0 -20
  126. data/lib/zucker/2/spec/class2proc_spec.rb +0 -9
  127. data/lib/zucker/2/spec/egonil_spec.rb +0 -30
  128. data/lib/zucker/2/spec/enumerable_spec.rb +0 -8
  129. data/lib/zucker/2/spec/hash2proc_spec.rb +0 -12
  130. data/lib/zucker/2/spec/hash_spec.rb +0 -17
  131. data/lib/zucker/2/spec/info_spec.rb +0 -8
  132. data/lib/zucker/2/spec/iterate_spec.rb +0 -54
  133. data/lib/zucker/2/spec/ivars_spec.rb +0 -20
  134. data/lib/zucker/2/spec/kernel_spec.rb +0 -28
  135. data/lib/zucker/2/spec/mcopy_spec.rb +0 -13
  136. data/lib/zucker/2/spec/mm_spec.rb +0 -8
  137. data/lib/zucker/2/spec/regexp2proc_spec.rb +0 -9
  138. data/lib/zucker/2/spec/sandbox_spec.rb +0 -26
  139. data/lib/zucker/2/spec/spec_helper.rb +0 -18
  140. data/lib/zucker/2/spec/square_brackets_for_spec.rb +0 -59
  141. data/lib/zucker/2/spec/string_spec.rb +0 -29
  142. data/lib/zucker/2/spec/unary_spec.rb +0 -26
  143. data/lib/zucker/2/spec/union_spec.rb +0 -15
  144. data/lib/zucker/desc/D.yaml +0 -23
  145. data/lib/zucker/desc/aliases.yaml +0 -16
  146. data/lib/zucker/desc/array.yaml +0 -14
  147. data/lib/zucker/desc/array2proc.yaml +0 -17
  148. data/lib/zucker/desc/binding.yaml +0 -10
  149. data/lib/zucker/desc/blank.yaml +0 -10
  150. data/lib/zucker/desc/class2proc.yaml +0 -12
  151. data/lib/zucker/desc/egonil.yaml +0 -17
  152. data/lib/zucker/desc/enumerable.yaml +0 -11
  153. data/lib/zucker/desc/hash.yaml +0 -14
  154. data/lib/zucker/desc/hash2proc.yaml +0 -11
  155. data/lib/zucker/desc/info.yaml +0 -12
  156. data/lib/zucker/desc/iterate.yaml +0 -17
  157. data/lib/zucker/desc/ivars.yaml +0 -20
  158. data/lib/zucker/desc/kernel.yaml +0 -13
  159. data/lib/zucker/desc/mcopy.yaml +0 -12
  160. data/lib/zucker/desc/mm.yaml +0 -12
  161. data/lib/zucker/desc/regexp2proc.yaml +0 -13
  162. data/lib/zucker/desc/sandbox.yaml +0 -19
  163. data/lib/zucker/desc/square_brackets_for.yaml +0 -23
  164. data/lib/zucker/desc/string.yaml +0 -13
  165. data/lib/zucker/desc/unary.yaml +0 -15
  166. data/lib/zucker/desc/union.yaml +0 -11
  167. data/lib/zucker/doc/zucker_doc.html +0 -1494
  168. data/lib/zucker/doc/zucker_doc.rb +0 -498
  169. data/lib/zucker/edge/ideas/args.rb +0 -22
  170. data/lib/zucker/edge/ideas/args.yaml +0 -19
  171. data/lib/zucker/edge/ideas/args_spec.rb +0 -19
  172. data/lib/zucker/edge/ideas/clone_deep.rb +0 -21
  173. data/lib/zucker/edge/ideas/clone_deep_spec.rb +0 -12
  174. data/lib/zucker/edge/ideas/dclone.yaml +0 -12
  175. data/lib/zucker/edge/ideas/hash.rb +0 -18
  176. data/lib/zucker/edge/ideas/require_directory.rb +0 -6
  177. data/lib/zucker/spec/D_spec.rb +0 -35
  178. data/lib/zucker/spec/aliases_spec.rb +0 -13
  179. data/lib/zucker/spec/array2proc_spec.rb +0 -12
  180. data/lib/zucker/spec/array_spec.rb +0 -23
  181. data/lib/zucker/spec/binding_spec.rb +0 -8
  182. data/lib/zucker/spec/blank_spec.rb +0 -20
  183. data/lib/zucker/spec/class2proc_spec.rb +0 -9
  184. data/lib/zucker/spec/egonil_spec.rb +0 -30
  185. data/lib/zucker/spec/enumerable_spec.rb +0 -8
  186. data/lib/zucker/spec/hash2proc_spec.rb +0 -12
  187. data/lib/zucker/spec/hash_spec.rb +0 -17
  188. data/lib/zucker/spec/info_spec.rb +0 -8
  189. data/lib/zucker/spec/iterate_spec.rb +0 -54
  190. data/lib/zucker/spec/ivars_spec.rb +0 -20
  191. data/lib/zucker/spec/kernel_spec.rb +0 -28
  192. data/lib/zucker/spec/mcopy_spec.rb +0 -13
  193. data/lib/zucker/spec/mm_spec.rb +0 -8
  194. data/lib/zucker/spec/regexp2proc_spec.rb +0 -9
  195. data/lib/zucker/spec/sandbox_spec.rb +0 -26
  196. data/lib/zucker/spec/spec_helper.rb +0 -18
  197. data/lib/zucker/spec/square_brackets_for_spec.rb +0 -59
  198. data/lib/zucker/spec/string_spec.rb +0 -29
  199. data/lib/zucker/spec/unary_spec.rb +0 -26
  200. data/lib/zucker/spec/union_spec.rb +0 -15
@@ -1,29 +0,0 @@
1
- require 'zucker/string'
2
-
3
- describe 'String#^' do
4
- it 'should give C-like substring access to strings' do
5
- string = 'Theoretische Informatik ist voll geil!'
6
-
7
- (string^0).should == 'Theoretische Informatik ist voll geil!'
8
- (string^1).should == 'heoretische Informatik ist voll geil!'
9
- (string^13).should == 'Informatik ist voll geil!'
10
- (string^-1).should == 'Theoretische Informatik ist voll geil'
11
- (string^38).should == ''
12
- (string^99).should == nil
13
- end
14
- end
15
-
16
- describe 'String#lchomp' do
17
- it 'should chomp on the left side' do
18
- string = 'Theoretische Informatik ist voll geil!'
19
- string.lchomp('T').should == 'heoretische Informatik ist voll geil!'
20
- end
21
- end
22
-
23
- describe 'String#ords' do
24
- it 'should unpack characters' do
25
- string = 'Theoretische Informatik ist voll geil!'
26
- string.ords.should == [84, 104, 101, 111, 114, 101, 116, 105, 115, 99, 104, 101, 32, 73, 110, 102, 111, 114, 109, 97, 116, 105, 107, 32, 105, 115, 116, 32, 118, 111, 108, 108, 32, 103, 101, 105, 108, 33]
27
- end
28
- end
29
-
@@ -1,26 +0,0 @@
1
- require 'zucker/unary'
2
-
3
- describe Symbol, '#+@' do
4
- it 'should convert to_s' do
5
- +(:matz) == 'matz' # () 1.8 bug
6
- end
7
- end
8
-
9
- describe Symbol, '#-@' do
10
- it 'should do nothing' do
11
- -:matz == :matz
12
- end
13
- end
14
-
15
- describe String, '#+@' do
16
- it 'should do nothing' do
17
- +'matz' == 'matz'
18
- end
19
- end
20
-
21
- describe String, '#-@' do
22
- it 'should convert to_sym' do
23
- -'matz' == :matz
24
- end
25
- end
26
-
@@ -1,15 +0,0 @@
1
- require 'zucker/union'
2
-
3
- shared_examples_for "Regexp.union operator" do
4
- it "should create an Regexp.union of both operands" do
5
- end
6
- end
7
-
8
- describe 'Regexp#|' do
9
- it_should_behave_like 'Regexp.union operator'
10
- end
11
-
12
- describe 'String#|' do
13
- it_should_behave_like 'Regexp.union operator'
14
- end
15
-
@@ -1,23 +0,0 @@
1
- D:
2
- summary: Easy debug printing with the ⇧p⇧ alternative ⇧.D⇧. It outputs to stdout and returns ⇧self⇧. Accepts a block.
3
- methods:
4
- Object#D: |
5
- some.D.methods.D.noone.D.knows.D
6
- # ...outputs 4 lines with the inspected objects
7
- # => (result)
8
-
9
- 21+Math.sin(42).D
10
- # outputs -0.916521547915634
11
- # => 20.0834784520844
12
-
13
- name = 'Earth'
14
- 'Hello ' + name.D{|e| "The length is: #{e.size}"}
15
- # outputs "The length is: 5"
16
- # => 'Hello Earth'
17
- package: debug
18
- info:
19
- - "This is inspired by the funny →⇧.tap⇧ method→http://moonbase.rydia.net/mental/blog/programming/eavesdropping-on-expressions→."
20
- versions:
21
- - 1.9
22
- - 1.8
23
-
@@ -1,16 +0,0 @@
1
- aliases:
2
- summary: Some convenient aliases (and constants) for existing methods.
3
- package: default
4
- methods:
5
- Object#is_an?: Object.is_a?
6
- Enumerable#with: Enumerable#zip
7
- Enumerable#%: Enumerable#zip
8
- Array#**: Array#product
9
- Hash#+: Hash#merge
10
- Binding#[]: Binding#eval
11
- Infinity: 1.0 / 0.0
12
- NaN: 0.0 / 0.0
13
- versions:
14
- - 1.9
15
- - 1.8
16
-
@@ -1,14 +0,0 @@
1
- array:
2
- summary: Methods one could miss for ⇧Array⇧.
3
- why:
4
- - ⇧Array⇧ has ⇧&⇧ and ⇧|⇧, but why does it not have ⇧^⇧?
5
- - ⇧sum⇧ is just an alias for ⇧inject(:+)⇧, but it is needed pretty often..
6
- methods:
7
- Array#^: "[1,2,3,4] ^ [3,4,5,6] # => [1,2,5,6]"
8
- Array#sum: "[1,2,3,4,5].sum # => 15"
9
- Array#chrs: "[72, 97, 108, 108, 111].chrs # => 'Hallo'"
10
- package: default
11
- versions:
12
- - 1.9
13
- - 1.8
14
-
@@ -1,17 +0,0 @@
1
- array2proc:
2
- summary: Calls the method named by the first paramenter and passes the other elements as paramaters.
3
- why: When using ⇧Symbol#to_proc⇧, you often wish to pass parameters.
4
- methods:
5
- Array#to_proc: |
6
- [1,2,3,4].map &[:*, 5] # => [5, 10, 15, 20]
7
- # you can also chain them, if the first parameter is an Array
8
- [1,2,3,4].map &[[:to_s, 2],[:+, 'b']] # => ["1b", "10b", "11b", "100b"]
9
- info:
10
- - Inspired by →this article→http://www.sanityinc.com/articles/adding-array-to-proc-to-ruby→.
11
- - "More about →to_proc→http://rbjl.net/29-become-a-proc-star→."
12
- - Chaining inspired by →eregon→http://github.com/eregon/Classes/blob/master/to_proc.rb→.
13
- package: default
14
- versions:
15
- - 1.9
16
- - 1.8
17
-
@@ -1,10 +0,0 @@
1
- binding:
2
- summary: Adds a verbose ⇧Binding#inspect⇧.
3
- why: It gives you information about the current environment.
4
- methods:
5
- Binding#inspect: binding.inspect
6
- package: debug
7
- versions:
8
- - 1.9
9
- - 1.8
10
-
@@ -1,10 +0,0 @@
1
- blank:
2
- summary: Does pretty the same as in ActiveSupport (Every object can be asked if it is blank).
3
- why: It's too familiar ;)
4
- methods:
5
- Object#blank?: "'an object'.blank? # => false"
6
- package: default
7
- versions:
8
- - 1.9
9
- - 1.8
10
-
@@ -1,12 +0,0 @@
1
- class2proc:
2
- summary: Creates a new instance of the class.
3
- methods:
4
- Class#to_proc: "[ [1,2],[3,5,6,7,3] ].map(&Set) # => [ Set[1,2], Set[5,6,7,3] ]"
5
- package: default
6
- info:
7
- - Inspired by Ruby Facets.
8
- - "More about →to_proc→http://rbjl.net/29-become-a-proc-star→."
9
- versions:
10
- - 1.9
11
- - 1.8
12
-
@@ -1,17 +0,0 @@
1
- egonil:
2
- summary: Creates a block, where ⇧nil⇧ does not raise ⇧NoMethodError⇧s.
3
- methods:
4
- egonil, nn: |
5
- egonil do
6
- nil.some_methods.that[:do].not.exist
7
- end # => nil
8
-
9
- nn(5){ nil.some_methods.that[:do].not.exist }
10
- # => 5
11
- package: default
12
- info:
13
- - See →this post→http://rbjl.net/26-the-28-bytes-of-ruby-joy→ for more information and discussion.
14
- versions:
15
- - 1.9
16
- - 1.8
17
-
@@ -1,11 +0,0 @@
1
- enumerable:
2
- summary: ⇧Enumerable⇧ extensions.
3
- methods:
4
- Enumerable#mash: "[1,2,3].mash{|e| [e, e.to_s] } # => {1=>'1',2=>'2',3=>'3'}"
5
- package: default
6
- info:
7
- - Inspired by Ruby Facets' ⇧mash⇧.
8
- versions:
9
- - 1.9
10
- - 1.8
11
-
@@ -1,14 +0,0 @@
1
- hash:
2
- summary: Some sugar for dealing with hashs.
3
- methods:
4
- Hash.zip: "Hash.zip [1,2,3], [4,5,6] # => {1 => 4, 2 => 5, 3 => 6}"
5
- Hash#<<: |
6
- {1 => 2} << [3, 4] # => { 1 => 2, 3 => 4 }
7
- {1 => 2} << { 5=>6 } # => { 1 => 2, 5 => 6 }
8
- package: default
9
- info:
10
- - Some of the operators are inspired by Ruby Facets.
11
- versions:
12
- - 1.9
13
- - 1.8
14
-
@@ -1,11 +0,0 @@
1
- hash2proc:
2
- summary: Use a hash to apply procs to specific objects.
3
- methods:
4
- Hash#to_proc: "[1,2,3,4].map(&{\n2 => lambda {|e| e + 1000},\n4 => :to_s,\n}) # => [1, 1002, 3, '4']"
5
- package: default
6
- info:
7
- - "More about →to_proc→http://rbjl.net/29-become-a-proc-star→."
8
- versions:
9
- - 1.9
10
- - 1.8
11
-
@@ -1,12 +0,0 @@
1
- info:
2
- summary: Access environment information with the ⇧Info⇧ module.
3
- why: "You don't need to remember in which global variable, constant or special method the information you are searching for is hidden."
4
- methods:
5
- Info: |
6
- # see the source file for the list of accessors
7
- # you could also add them to the global namespace with: include Info
8
- package: default
9
- versions:
10
- - 1.9
11
- - 1.8 (not all information)
12
-
@@ -1,17 +0,0 @@
1
- iterate:
2
- summary: Iterate over one or more collections.
3
- why: "It's like ⇧.each⇧ with two differences: It feels more like a control structure and you can easily iterate over multiple objects."
4
- methods:
5
- iterate: |
6
- iterate [1,2], [3,4,5] do |e,f|
7
- puts "#{e},#{f}"
8
- end
9
- # outputs
10
- # 1,3
11
- # 2,4
12
- # ,5
13
- package: default
14
- versions:
15
- - 1.9
16
- - 1.8
17
-
@@ -1,20 +0,0 @@
1
- ivars:
2
- summary: This method lets you easily assign lots of instance variables.
3
- why: |
4
- Often, you have to write boilerplate code for assigning instance varialbles, for example this one:
5
- ⇧def initialize(variable1, variable2)
6
-   @variable1, @variable2 = variable1, variable2
7
- end⇧
8
- methods:
9
- instance_variables_from, ivars: |
10
- def a_method(a = 1, b = 2)
11
- instance_variables_from binding # assigns @a and @b
12
-
13
- params = {:c => 3, :d => 4}
14
- instance_variables_from params # # assigns @c and @d
15
- end
16
- package: default
17
- versions:
18
- - 1.9
19
- - 1.8
20
-
@@ -1,13 +0,0 @@
1
- kernel:
2
- summary: Some useful general shortcut methods.
3
- why: Readability.
4
- methods:
5
- activate_warnings!: "activate_warnings! # sets $VERBOSE to 1"
6
- deactivate_warnings!: "deactivate_warnings! # sets $VERBOSE to 0"
7
- library?: "library? # checks, if the current file is ran directly"
8
- ignore_sigint!: "ignore_sigint! # blocks CTRL+C"
9
- package: default
10
- versions:
11
- - 1.9
12
- - 1.8
13
-
@@ -1,12 +0,0 @@
1
- mcopy:
2
- summary: Adds ⇧Object#mcopy⇧ to create a deep copy using ⇧Marshal⇧.
3
- why: Every Ruby book describes, you can do ⇧Marshal.load Marshal.dump object⇧ to create a deep copy... But who needs this verbose syntax in everyday coding?
4
- methods:
5
- Object#mcopy: |
6
- a = %w[hello world]
7
- b = a.mcopy
8
- package: default
9
- versions:
10
- - 1.9
11
- - 1.8
12
-
@@ -1,12 +0,0 @@
1
- mm:
2
- summary: ⇧mm⇧ displays an ordered public method list.
3
- why: See one object's methods without those rarely used inherited methods.
4
- methods:
5
- Object#method_list, Object#mm: "'test'.mm 2 # outputs the list (2 levels deep)"
6
- package: debug
7
- info:
8
- - See →this article→http://rbjl.net/31-the-multi-mega-method-list→ for more information.
9
- versions:
10
- - 1.9
11
- - 1.8 (returns strings instead of symbols)
12
-
@@ -1,13 +0,0 @@
1
- regexp2proc:
2
- summary: Use &/regex/ to match it against strings.
3
- methods:
4
- Regexp#to_proc: |
5
- %w|just another string array|.map &/[jy]/ # => ["j", nil, nil, "y"]
6
- %w|just another string array|.select &/[jy]/ # => ["just", "array"]
7
- package: default
8
- info:
9
- - "More about →to_proc→http://rbjl.net/29-become-a-proc-star→."
10
- versions:
11
- - 1.9
12
- - 1.8
13
-
@@ -1,19 +0,0 @@
1
- sandbox:
2
- summary: Creates a sandbox area.
3
- why: Ruby comes with sandboxes, but they are hidden (-> integrated) in the ⇧$SAFE⇧ concept.
4
- methods:
5
- sandbox: |
6
- sandbox do
7
- # dangerous commands throw SecurityErrors ($SAFE=4)
8
- end
9
- # everything's normal again
10
-
11
- sandbox( lambda{} ) do
12
- # no Exception is thrown, if non-nil parameter is passed
13
- end
14
- # if it is a proc, it will be run instead, if an SecurityError gets raised
15
- package: default
16
- versions:
17
- - 1.9
18
- - 1.8
19
-
@@ -1,23 +0,0 @@
1
- square_brackets_for:
2
- summary: This helper methods defines ⇧[]⇧ and ⇧[]=⇧ for accesing an instance variable.
3
- methods:
4
- square_brackets_for: |
5
- class Klass
6
- def initialize
7
- @var = {
8
- :a_key => 1,
9
- :another_one => 2,
10
- }
11
- end
12
-
13
- square_brackets_for :var # creates [] and []=
14
- # square_brackets_for :var, false # would create only []
15
- end
16
-
17
- a = Klass.new
18
- a[:a_key] # => 1
19
- package: default
20
- versions:
21
- - 1.9
22
- - 1.8
23
-
@@ -1,13 +0,0 @@
1
- string:
2
- summary: ⇧String⇧ extensions.
3
- why: Strings cannot be comfortable enough ;).
4
- methods:
5
- String#^: "'Yes vs No'^3 # => 'Yes'"
6
- String#lchomp: "' Yes'.lchomp # => 'Yes'"
7
- String#lchomp!: "# mutable lchomp version"
8
- String#ords: "'Hallo'.ords # => [72, 97, 108, 108, 111]"
9
- package: default
10
- versions:
11
- - 1.9
12
- - 1.8
13
-
@@ -1,15 +0,0 @@
1
- unary:
2
- summary: Easy conversion between strings and symbols.
3
- why: "Sometimes, you do not care if you get a ⇧String⇧ or ⇧Symbol⇧ as input - but when analysing it, you often need to choose one format. A concise possibility for this conversion is using the unary operators ⇧String#-@⇧ and ⇧Symbol#+@⇧."
4
- methods:
5
- String#+@: "+'was_string' # => 'was_string'"
6
- String#-@: "-'was_string' # => :was_string"
7
- Symbol#+@: "+:was_symbol # => 'was_symbol'"
8
- Symbol#-@: "-:was_symbol # => :was_symbol"
9
- package: default
10
- info:
11
- - "Inspired by (I've seen the unary + for Symbol somewhere on the net... but cannot remember where...)"
12
- versions:
13
- - 1.9
14
- - 1.8 (⇧+:literal⇧ not possible)
15
-
@@ -1,11 +0,0 @@
1
- union:
2
- summary: Easy creation of ⇧Regexp.union⇧s.
3
- methods:
4
- Regexp#|, String#|: |
5
- /Ruby\d/ | /test/i | "cheat"
6
- # creates a Regexp similar to:
7
- # /(Ruby\d|[tT][eE][sS][tT]|cheat)/
8
- package: default
9
- versions:
10
- - 1.9
11
-