zucker 2 → 3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +12 -0
- data/README +4 -1
- data/Rakefile +17 -7
- data/lib/zucker.rb +7 -1
- data/lib/zucker/2/all.rb +2 -2
- data/lib/zucker/2/debug.rb +3 -3
- data/lib/zucker/2/default.rb +1 -1
- data/lib/zucker/3/D.rb +19 -0
- data/lib/zucker/3/alias_for.rb +19 -0
- data/lib/zucker/3/aliases.rb +28 -0
- data/lib/zucker/3/all.rb +6 -0
- data/lib/zucker/3/array.rb +23 -0
- data/lib/zucker/3/array2proc.rb +16 -0
- data/lib/zucker/3/binding.rb +25 -0
- data/lib/zucker/3/blank.rb +26 -0
- data/lib/zucker/3/class2proc.rb +10 -0
- data/lib/zucker/3/debug.rb +6 -0
- data/lib/zucker/3/default.rb +35 -0
- data/lib/zucker/3/egonil.rb +14 -0
- data/lib/zucker/3/enumerable.rb +12 -0
- data/lib/zucker/3/hash.rb +19 -0
- data/lib/zucker/3/hash2proc.rb +14 -0
- data/lib/zucker/3/info.rb +167 -0
- data/lib/zucker/3/iterate.rb +23 -0
- data/lib/zucker/3/ivars.rb +26 -0
- data/lib/zucker/3/kernel.rb +48 -0
- data/lib/zucker/3/mcopy.rb +8 -0
- data/lib/zucker/3/mm.rb +31 -0
- data/lib/zucker/3/not.rb +17 -0
- data/lib/zucker/3/regexp2proc.rb +10 -0
- data/lib/zucker/3/sandbox.rb +19 -0
- data/lib/zucker/3/square_brackets_for.rb +20 -0
- data/lib/zucker/3/string.rb +47 -0
- data/lib/zucker/3/tap.rb +9 -0
- data/lib/zucker/3/unary.rb +22 -0
- data/lib/zucker/3/union.rb +14 -0
- data/lib/zucker/alias_for.rb +19 -0
- data/lib/zucker/array.rb +8 -2
- data/lib/zucker/debug.rb +2 -0
- data/lib/zucker/default.rb +11 -1
- data/lib/zucker/info.rb +5 -2
- data/lib/zucker/kernel.rb +41 -11
- data/lib/zucker/mcopy.rb +0 -1
- data/lib/zucker/not.rb +17 -0
- data/lib/zucker/string.rb +24 -2
- data/lib/zucker/tap.rb +9 -0
- metadata +41 -160
- data/lib/zucker/1/desc/D.yaml +0 -23
- data/lib/zucker/1/desc/aliases.yaml +0 -16
- data/lib/zucker/1/desc/array.yaml +0 -14
- data/lib/zucker/1/desc/array2proc.yaml +0 -13
- data/lib/zucker/1/desc/binding.yaml +0 -10
- data/lib/zucker/1/desc/blank.yaml +0 -12
- data/lib/zucker/1/desc/class2proc.yaml +0 -12
- data/lib/zucker/1/desc/egonil.yaml +0 -17
- data/lib/zucker/1/desc/enumerable.yaml +0 -11
- data/lib/zucker/1/desc/hash.yaml +0 -12
- data/lib/zucker/1/desc/hash2proc.yaml +0 -11
- data/lib/zucker/1/desc/iterate.yaml +0 -17
- data/lib/zucker/1/desc/ivars.yaml +0 -20
- data/lib/zucker/1/desc/kernel.yaml +0 -13
- data/lib/zucker/1/desc/mcopy.yaml +0 -12
- data/lib/zucker/1/desc/mm.yaml +0 -12
- data/lib/zucker/1/desc/regexp2proc.yaml +0 -13
- data/lib/zucker/1/desc/sandbox.yaml +0 -14
- data/lib/zucker/1/desc/square_brackets_for.yaml +0 -23
- data/lib/zucker/1/desc/string.yaml +0 -13
- data/lib/zucker/1/desc/unary.yaml +0 -15
- data/lib/zucker/1/desc/union.yaml +0 -11
- data/lib/zucker/1/doc/meta.yaml +0 -4
- data/lib/zucker/1/doc/zucker_doc.html +0 -1286
- data/lib/zucker/1/doc/zucker_doc.rb +0 -493
- data/lib/zucker/1/spec/D_spec.rb +0 -27
- data/lib/zucker/1/spec/aliases_spec.rb +0 -34
- data/lib/zucker/1/spec/array2proc_spec.rb +0 -8
- data/lib/zucker/1/spec/array_spec.rb +0 -23
- data/lib/zucker/1/spec/binding_spec.rb +0 -6
- data/lib/zucker/1/spec/blank_spec.rb +0 -20
- data/lib/zucker/1/spec/class2proc_spec.rb +0 -9
- data/lib/zucker/1/spec/egonil_spec.rb +0 -30
- data/lib/zucker/1/spec/enumerable_spec.rb +0 -8
- data/lib/zucker/1/spec/hash2proc_spec.rb +0 -12
- data/lib/zucker/1/spec/hash_spec.rb +0 -10
- data/lib/zucker/1/spec/iterate_spec.rb +0 -54
- data/lib/zucker/1/spec/ivars_spec.rb +0 -20
- data/lib/zucker/1/spec/kernel_spec.rb +0 -34
- data/lib/zucker/1/spec/mcopy_spec.rb +0 -13
- data/lib/zucker/1/spec/mm_spec.rb +0 -6
- data/lib/zucker/1/spec/regexp2proc_spec.rb +0 -9
- data/lib/zucker/1/spec/sandbox_spec.rb +0 -7
- data/lib/zucker/1/spec/square_brackets_for_spec.rb +0 -59
- data/lib/zucker/1/spec/string_spec.rb +0 -29
- data/lib/zucker/1/spec/unary_spec.rb +0 -26
- data/lib/zucker/1/spec/union_spec.rb +0 -13
- data/lib/zucker/2/desc/D.yaml +0 -23
- data/lib/zucker/2/desc/aliases.yaml +0 -16
- data/lib/zucker/2/desc/array.yaml +0 -14
- data/lib/zucker/2/desc/array2proc.yaml +0 -17
- data/lib/zucker/2/desc/binding.yaml +0 -10
- data/lib/zucker/2/desc/blank.yaml +0 -10
- data/lib/zucker/2/desc/class2proc.yaml +0 -12
- data/lib/zucker/2/desc/egonil.yaml +0 -17
- data/lib/zucker/2/desc/enumerable.yaml +0 -11
- data/lib/zucker/2/desc/hash.yaml +0 -14
- data/lib/zucker/2/desc/hash2proc.yaml +0 -11
- data/lib/zucker/2/desc/info.yaml +0 -12
- data/lib/zucker/2/desc/iterate.yaml +0 -17
- data/lib/zucker/2/desc/ivars.yaml +0 -20
- data/lib/zucker/2/desc/kernel.yaml +0 -13
- data/lib/zucker/2/desc/mcopy.yaml +0 -12
- data/lib/zucker/2/desc/mm.yaml +0 -12
- data/lib/zucker/2/desc/regexp2proc.yaml +0 -13
- data/lib/zucker/2/desc/sandbox.yaml +0 -19
- data/lib/zucker/2/desc/square_brackets_for.yaml +0 -23
- data/lib/zucker/2/desc/string.yaml +0 -13
- data/lib/zucker/2/desc/unary.yaml +0 -15
- data/lib/zucker/2/desc/union.yaml +0 -11
- data/lib/zucker/2/doc/zucker_doc.html +0 -1494
- data/lib/zucker/2/doc/zucker_doc.rb +0 -498
- data/lib/zucker/2/spec/D_spec.rb +0 -35
- data/lib/zucker/2/spec/aliases_spec.rb +0 -13
- data/lib/zucker/2/spec/array2proc_spec.rb +0 -12
- data/lib/zucker/2/spec/array_spec.rb +0 -23
- data/lib/zucker/2/spec/binding_spec.rb +0 -8
- data/lib/zucker/2/spec/blank_spec.rb +0 -20
- data/lib/zucker/2/spec/class2proc_spec.rb +0 -9
- data/lib/zucker/2/spec/egonil_spec.rb +0 -30
- data/lib/zucker/2/spec/enumerable_spec.rb +0 -8
- data/lib/zucker/2/spec/hash2proc_spec.rb +0 -12
- data/lib/zucker/2/spec/hash_spec.rb +0 -17
- data/lib/zucker/2/spec/info_spec.rb +0 -8
- data/lib/zucker/2/spec/iterate_spec.rb +0 -54
- data/lib/zucker/2/spec/ivars_spec.rb +0 -20
- data/lib/zucker/2/spec/kernel_spec.rb +0 -28
- data/lib/zucker/2/spec/mcopy_spec.rb +0 -13
- data/lib/zucker/2/spec/mm_spec.rb +0 -8
- data/lib/zucker/2/spec/regexp2proc_spec.rb +0 -9
- data/lib/zucker/2/spec/sandbox_spec.rb +0 -26
- data/lib/zucker/2/spec/spec_helper.rb +0 -18
- data/lib/zucker/2/spec/square_brackets_for_spec.rb +0 -59
- data/lib/zucker/2/spec/string_spec.rb +0 -29
- data/lib/zucker/2/spec/unary_spec.rb +0 -26
- data/lib/zucker/2/spec/union_spec.rb +0 -15
- data/lib/zucker/desc/D.yaml +0 -23
- data/lib/zucker/desc/aliases.yaml +0 -16
- data/lib/zucker/desc/array.yaml +0 -14
- data/lib/zucker/desc/array2proc.yaml +0 -17
- data/lib/zucker/desc/binding.yaml +0 -10
- data/lib/zucker/desc/blank.yaml +0 -10
- data/lib/zucker/desc/class2proc.yaml +0 -12
- data/lib/zucker/desc/egonil.yaml +0 -17
- data/lib/zucker/desc/enumerable.yaml +0 -11
- data/lib/zucker/desc/hash.yaml +0 -14
- data/lib/zucker/desc/hash2proc.yaml +0 -11
- data/lib/zucker/desc/info.yaml +0 -12
- data/lib/zucker/desc/iterate.yaml +0 -17
- data/lib/zucker/desc/ivars.yaml +0 -20
- data/lib/zucker/desc/kernel.yaml +0 -13
- data/lib/zucker/desc/mcopy.yaml +0 -12
- data/lib/zucker/desc/mm.yaml +0 -12
- data/lib/zucker/desc/regexp2proc.yaml +0 -13
- data/lib/zucker/desc/sandbox.yaml +0 -19
- data/lib/zucker/desc/square_brackets_for.yaml +0 -23
- data/lib/zucker/desc/string.yaml +0 -13
- data/lib/zucker/desc/unary.yaml +0 -15
- data/lib/zucker/desc/union.yaml +0 -11
- data/lib/zucker/doc/zucker_doc.html +0 -1494
- data/lib/zucker/doc/zucker_doc.rb +0 -498
- data/lib/zucker/edge/ideas/args.rb +0 -22
- data/lib/zucker/edge/ideas/args.yaml +0 -19
- data/lib/zucker/edge/ideas/args_spec.rb +0 -19
- data/lib/zucker/edge/ideas/clone_deep.rb +0 -21
- data/lib/zucker/edge/ideas/clone_deep_spec.rb +0 -12
- data/lib/zucker/edge/ideas/dclone.yaml +0 -12
- data/lib/zucker/edge/ideas/hash.rb +0 -18
- data/lib/zucker/edge/ideas/require_directory.rb +0 -6
- data/lib/zucker/spec/D_spec.rb +0 -35
- data/lib/zucker/spec/aliases_spec.rb +0 -13
- data/lib/zucker/spec/array2proc_spec.rb +0 -12
- data/lib/zucker/spec/array_spec.rb +0 -23
- data/lib/zucker/spec/binding_spec.rb +0 -8
- data/lib/zucker/spec/blank_spec.rb +0 -20
- data/lib/zucker/spec/class2proc_spec.rb +0 -9
- data/lib/zucker/spec/egonil_spec.rb +0 -30
- data/lib/zucker/spec/enumerable_spec.rb +0 -8
- data/lib/zucker/spec/hash2proc_spec.rb +0 -12
- data/lib/zucker/spec/hash_spec.rb +0 -17
- data/lib/zucker/spec/info_spec.rb +0 -8
- data/lib/zucker/spec/iterate_spec.rb +0 -54
- data/lib/zucker/spec/ivars_spec.rb +0 -20
- data/lib/zucker/spec/kernel_spec.rb +0 -28
- data/lib/zucker/spec/mcopy_spec.rb +0 -13
- data/lib/zucker/spec/mm_spec.rb +0 -8
- data/lib/zucker/spec/regexp2proc_spec.rb +0 -9
- data/lib/zucker/spec/sandbox_spec.rb +0 -26
- data/lib/zucker/spec/spec_helper.rb +0 -18
- data/lib/zucker/spec/square_brackets_for_spec.rb +0 -59
- data/lib/zucker/spec/string_spec.rb +0 -29
- data/lib/zucker/spec/unary_spec.rb +0 -26
- 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
|
-
|
data/lib/zucker/desc/D.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/array.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/blank.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/egonil.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/hash.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/info.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/ivars.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/kernel.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/mcopy.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/mm.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/string.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/unary.yaml
DELETED
@@ -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
|
-
|
data/lib/zucker/desc/union.yaml
DELETED