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
data/lib/zucker/spec/mm_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'zucker/sandbox'
|
2
|
-
|
3
|
-
describe 'sandbox' do
|
4
|
-
it 'should throw a SecurityError if bad commands are issued' do
|
5
|
-
proc do
|
6
|
-
sandbox do
|
7
|
-
`ls`
|
8
|
-
end
|
9
|
-
end.should raise_exception SecurityError
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should not throw an exception for errors, if the given parameter is not nil' do
|
13
|
-
proc do
|
14
|
-
sandbox( true ) do
|
15
|
-
`ls`
|
16
|
-
end
|
17
|
-
end.should_not raise_exception
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should run the proc passed as parameter for errors, if it is given' do
|
21
|
-
sandbox( lambda{|e| e.class } ) do
|
22
|
-
`ls`
|
23
|
-
end.should == SecurityError
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
|
3
|
-
def capture_stdout
|
4
|
-
capture = StringIO.new
|
5
|
-
restore, $stdout = $stdout, capture
|
6
|
-
yield
|
7
|
-
$stdout = restore
|
8
|
-
capture.string
|
9
|
-
end
|
10
|
-
|
11
|
-
def capture_stderr
|
12
|
-
capture = StringIO.new
|
13
|
-
restore, $stderr = $stderr, capture
|
14
|
-
yield
|
15
|
-
$stderr = restore
|
16
|
-
capture.string
|
17
|
-
end
|
18
|
-
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'zucker/square_brackets_for'
|
2
|
-
|
3
|
-
describe 'square_brackets_for' do
|
4
|
-
|
5
|
-
before do
|
6
|
-
class Klass
|
7
|
-
def initialize
|
8
|
-
@var = {
|
9
|
-
:a_key => 1,
|
10
|
-
:another_one => 2,
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
@eigenvar = {
|
15
|
-
:a_key => 99
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should define a [] getter (not a setter) for an instance var, if the second parameter is false' do
|
21
|
-
|
22
|
-
class Klass
|
23
|
-
square_brackets_for :var, nil
|
24
|
-
end
|
25
|
-
|
26
|
-
a = Klass.new
|
27
|
-
a[:a_key].should == 1
|
28
|
-
|
29
|
-
proc do
|
30
|
-
a[:this_is] = 'not possible'
|
31
|
-
end.should raise_exception NoMethodError
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should define [] and []= for accessing an instance variable' do
|
35
|
-
|
36
|
-
class Klass
|
37
|
-
square_brackets_for :var
|
38
|
-
end
|
39
|
-
|
40
|
-
a = Klass.new
|
41
|
-
a[:a_key].should == 1
|
42
|
-
|
43
|
-
a[:this_is] = 'useful'
|
44
|
-
a[:this_is].should == 'useful'
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should also work for class-instance variables' do
|
48
|
-
|
49
|
-
class Klass
|
50
|
-
class << Klass
|
51
|
-
square_brackets_for :eigenvar
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
Klass[:a_key].should == 99
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
@@ -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
|
-
|