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,22 +0,0 @@
|
|
1
|
-
def arguments
|
2
|
-
mbinding = @@last_bindings[2]
|
3
|
-
margs = mbinding.eval "local_variables"
|
4
|
-
ret = {}
|
5
|
-
|
6
|
-
margs.each{ |arg|
|
7
|
-
ret[arg.to_sym] = mbinding.eval(arg)
|
8
|
-
}
|
9
|
-
ret
|
10
|
-
end
|
11
|
-
alias args arguments
|
12
|
-
|
13
|
-
#### EVIL ####
|
14
|
-
# set up binding tracer
|
15
|
-
@@last_bindings ||= []
|
16
|
-
set_trace_func lambda { |event, _, _, _, bind, _|
|
17
|
-
if event[/call/]
|
18
|
-
@@last_bindings.unshift bind
|
19
|
-
@@last_bindings.pop if @@last_bindings.size > 5
|
20
|
-
end
|
21
|
-
}
|
22
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
args:
|
2
|
-
summary: hallo
|
3
|
-
why: |
|
4
|
-
Often you just need to
|
5
|
-
for example, do you know this one:
|
6
|
-
⇧def initialize(variable1, variable2)
|
7
|
-
@variable1, @variable2 = variable1, variable2
|
8
|
-
end⇧
|
9
|
-
methods:
|
10
|
-
arguments, args: "def a_method(a=1, b=2)\n arguments # => {a=>1, b=>2}\nend"
|
11
|
-
info:
|
12
|
-
- Not in default, because it uses ⇧Kernel#set_trace_var⇧ (which would)...
|
13
|
-
package: debug
|
14
|
-
versions:
|
15
|
-
- 1.9
|
16
|
-
- 1.8
|
17
|
-
authors:
|
18
|
-
- Jan Lelis
|
19
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'args'
|
2
|
-
|
3
|
-
describe 'arguments' do
|
4
|
-
it 'should create a hash containing all arguments with its names' do
|
5
|
-
|
6
|
-
def ma(hallo = 5, baum = 7)
|
7
|
-
hallo = 9
|
8
|
-
arguments
|
9
|
-
end
|
10
|
-
|
11
|
-
def mb
|
12
|
-
arguments
|
13
|
-
end
|
14
|
-
|
15
|
-
ma(3).should == {:hallo => 3, :baum => 7}
|
16
|
-
mb.should == {}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
def clone_deep
|
3
|
-
case self.class
|
4
|
-
when Array
|
5
|
-
self.map &:clone_deep
|
6
|
-
else
|
7
|
-
self.clone
|
8
|
-
end
|
9
|
-
end
|
10
|
-
alias :dclone :clone_deep
|
11
|
-
|
12
|
-
def dup_deep
|
13
|
-
if self.is_a? Array
|
14
|
-
self.map &:dup_deep
|
15
|
-
else
|
16
|
-
self.dup
|
17
|
-
end
|
18
|
-
end
|
19
|
-
alias :ddup :dup_deep
|
20
|
-
end
|
21
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
|
2
|
-
# File lib/core/facets/hash/op_and.rb, line 19
|
3
|
-
# def &(other)
|
4
|
-
# Hash[ *select{ |k,v|
|
5
|
-
# other[k] == v
|
6
|
-
# }.flatten ]
|
7
|
-
# end
|
8
|
-
|
9
|
-
# def ^(other)
|
10
|
-
# Hash[ *reject{ |k,v|
|
11
|
-
# other[k] == v
|
12
|
-
# }.flatten ]
|
13
|
-
# end
|
14
|
-
|
15
|
-
# def -(other)
|
16
|
-
#
|
17
|
-
# end
|
18
|
-
|
data/lib/zucker/spec/D_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'zucker/D'
|
2
|
-
|
3
|
-
describe 'Object#D' do
|
4
|
-
|
5
|
-
let :a do
|
6
|
-
[ 1, "1", 2..5, [], {:hallo => :du}, nil, true ]
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should not change the object"s value' do
|
10
|
-
a.each{ |e|
|
11
|
-
(e.D).should == e
|
12
|
-
}
|
13
|
-
|
14
|
-
a.each{ |e|
|
15
|
-
(e.D{|value| "This is a: #{value}"}).should == e
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should puts .inspect if no block is given (and not change the object's value)" do
|
20
|
-
capture_stdout do
|
21
|
-
a[0].D
|
22
|
-
a[1].D
|
23
|
-
a[6].D
|
24
|
-
end.should == %{1\n"1"\ntrue\n}
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should puts the block if it is given (and not change the object's value)" do
|
28
|
-
capture_stdout do
|
29
|
-
a[0].D{|value| "This is a: #{value}"}
|
30
|
-
a[1].D{|value| "This is a: #{value}"}
|
31
|
-
a[6].D{|value| "This is a: #{value}"}
|
32
|
-
end.should == %{This is a: 1\nThis is a: 1\nThis is a: true\n}
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'zucker/array2proc'
|
2
|
-
|
3
|
-
describe 'Array#to_proc' do
|
4
|
-
it 'should call the method of the first symbol, using the remaining elements as paramaters' do
|
5
|
-
[1,2,3,4].map( &[:to_s, 2] ).should == ["1", "10", "11", "100"]
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should convert each element to a proc and chain it, if the first parameter is an array" do
|
9
|
-
[1,2,3,4].map( &[[:*,2],[:+,4]] ).should == [1,2,3,4].map{|i| i*2 + 4 }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'zucker/array'
|
2
|
-
|
3
|
-
describe 'Array#^' do
|
4
|
-
it 'should do an exclusive or' do
|
5
|
-
a = [1,2,3,4]
|
6
|
-
b = [3,4,5,6]
|
7
|
-
(a^b).should == [1,2,5,6]
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'Array#sum' do
|
12
|
-
it 'should sum the array' do
|
13
|
-
[1,2,3,4,5].sum.should == 15
|
14
|
-
%w|More Ruby|.sum.should == 'MoreRuby'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'Array#chrs' do
|
19
|
-
it 'should convert the array to a string, using each element as ord value for the char' do
|
20
|
-
[72, 97, 108, 108, 111].chrs.should == 'Hallo'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'zucker/blank'
|
2
|
-
|
3
|
-
describe 'Object#blank?' do
|
4
|
-
it 'should be blank for blank values' do
|
5
|
-
blank_values = [ nil, false, '', ' ', " \n\t \r ", [], {}, // ]
|
6
|
-
|
7
|
-
blank_values.each{ |blank|
|
8
|
-
blank.blank?.should == true
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should not be blank for non blank values' do
|
13
|
-
present_values = [ Object.new, true, 0, 1, 'a', [nil], { nil => nil } ]
|
14
|
-
|
15
|
-
present_values.each{ |present|
|
16
|
-
present.blank?.should == false
|
17
|
-
}
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'zucker/egonil'
|
2
|
-
|
3
|
-
describe 'egonil' do
|
4
|
-
it 'should not raise nil exceptions in the block' do
|
5
|
-
proc do
|
6
|
-
egonil{ nil.some_methods.that[:do].not.exist }
|
7
|
-
end.should_not raise_exception
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should return the nil_value if given' do
|
11
|
-
egonil(9){ nil.some_methods.that[:do].not.exist }.should == 9
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should restore default behaviour after the block' do
|
15
|
-
proc do
|
16
|
-
egonil{ nil.some_methods.that[:do].not.exist }
|
17
|
-
end.should_not raise_exception
|
18
|
-
|
19
|
-
proc do
|
20
|
-
nil.a_method
|
21
|
-
end.should raise_exception NoMethodError
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'raise NoMethodError for non-nil objects' do
|
25
|
-
proc do
|
26
|
-
egonil{ 5.a_method }
|
27
|
-
end.should raise_exception NoMethodError
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'zucker/hash2proc'
|
2
|
-
|
3
|
-
describe 'Hash#to_proc' do
|
4
|
-
it 'should run the proc given in the value for a key in the hash' do
|
5
|
-
[1,2,3,4].map(&{
|
6
|
-
4 => :to_s,
|
7
|
-
# 3 => [:to_s, 2] # "11" => if array2proc is used
|
8
|
-
2 => lambda {|e| e + 1000}
|
9
|
-
}).should == [1, 1002, 3, "4"]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'zucker/hash'
|
2
|
-
|
3
|
-
describe 'Hash.zip' do
|
4
|
-
it 'should zip together both given enumerables and take them as key=>values for a new hash' do
|
5
|
-
Hash.zip( [1,2,3], [4,5,6] ).should == { 1=>4, 2=>5, 3=>6 }
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'Hash#<<' do
|
10
|
-
it 'should append new elements to the hash' do
|
11
|
-
a = { 1=>4, 2=>5, 3=>6 }
|
12
|
-
a << { 4=>7 }
|
13
|
-
a << [5, 8]
|
14
|
-
a.should == { 1=>4, 2=>5, 3=>6, 4=>7, 5=>8 }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'zucker/iterate'
|
2
|
-
|
3
|
-
describe 'Object#iterate' do
|
4
|
-
let :a do [1, 2, 3] end
|
5
|
-
let :b do %w|a b c d| end
|
6
|
-
let :res do Hash.new {[]} end
|
7
|
-
|
8
|
-
it 'should behave like Enumerable#each for a single argument' do
|
9
|
-
iterate a do |ele|
|
10
|
-
res[:iter] << ele
|
11
|
-
end
|
12
|
-
|
13
|
-
a.each do |ele|
|
14
|
-
res[:each] << ele
|
15
|
-
end
|
16
|
-
|
17
|
-
res[:iter].should == res[:each]
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should pass the right params to the block' do
|
21
|
-
res = Hash.new {[]} # TODO: why?
|
22
|
-
res[:iter_a_b] = [] # ....
|
23
|
-
res[:iter_b_a] = [] # ....
|
24
|
-
|
25
|
-
|
26
|
-
iterate a, b do |e,f|
|
27
|
-
res[:iter_a_b] << [e, f]
|
28
|
-
# p res[:iter_a_b], e, f
|
29
|
-
end
|
30
|
-
|
31
|
-
res[:iter_a_b].should == [
|
32
|
-
[1, 'a'],
|
33
|
-
[2, 'b'],
|
34
|
-
[3, 'c'],
|
35
|
-
[nil, 'd'],
|
36
|
-
]
|
37
|
-
|
38
|
-
iterate b, a do |e,f|
|
39
|
-
res[:iter_b_a] << [e, f]
|
40
|
-
end
|
41
|
-
|
42
|
-
res[:iter_b_a].should == [
|
43
|
-
['a', 1],
|
44
|
-
['b', 2],
|
45
|
-
['c', 3],
|
46
|
-
['d', nil],
|
47
|
-
]
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should return enumerators if no block is applied' do
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'zucker/ivars'
|
2
|
-
|
3
|
-
describe 'instance_variables_from' do
|
4
|
-
it 'should tansform the given parameter to instance variables' do
|
5
|
-
def a_method(a = 1, b = 2)
|
6
|
-
instance_variables_from binding # assigns @a and @b
|
7
|
-
|
8
|
-
params = {:c => 3, :d => 4}
|
9
|
-
ivars params # # assigns @c and @d
|
10
|
-
end
|
11
|
-
|
12
|
-
a_method
|
13
|
-
@a.should == 1
|
14
|
-
@b.should == 2
|
15
|
-
@c.should == 3
|
16
|
-
@d.should == 4
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'zucker/kernel'
|
2
|
-
|
3
|
-
describe 'activate_warnings!' do
|
4
|
-
it 'should set $VERBOSE to true' do
|
5
|
-
activate_warnings!
|
6
|
-
$VERBOSE.should == true
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe 'deactivate_warnings!' do
|
11
|
-
it 'should set $VERBOSE to false' do
|
12
|
-
deactivate_warnings!
|
13
|
-
$VERBOSE.should == false
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'library?' do
|
18
|
-
it 'should return false if the file is invoked directly' do
|
19
|
-
library?.should == ( __FILE__ != $PROGRAM_NAME )
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'ignore_sigint!' do
|
24
|
-
it 'should catch ctrl+c signals' do
|
25
|
-
# ...
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|