zucker 13.1 → 100.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +17 -2
- data/MIT-LICENSE +1 -1
- data/README.md +22 -0
- data/Rakefile +17 -58
- data/doc/{zucker_doc.rb → create_documentation.rb} +67 -129
- data/doc/zucker.html +1774 -0
- data/lib/zucker.rb +12 -42
- data/lib/zucker/alias_for.rb +9 -16
- data/lib/zucker/all.rb +0 -2
- data/lib/zucker/array_op.rb +15 -0
- data/lib/zucker/blank.rb +39 -21
- data/lib/zucker/camel_snake.rb +15 -0
- data/lib/zucker/constantize.rb +29 -0
- data/lib/zucker/dir_extras.rb +20 -0
- data/lib/zucker/egonil.rb +13 -24
- data/lib/zucker/file_extras.rb +33 -0
- data/lib/zucker/hash_extras.rb +11 -0
- data/lib/zucker/hash_op.rb +28 -0
- data/lib/zucker/instance_variables_from.rb +34 -0
- data/lib/zucker/iterate.rb +24 -21
- data/lib/zucker/marshal_copy.rb +11 -0
- data/lib/zucker/mash.rb +22 -0
- data/lib/zucker/ords.rb +17 -0
- data/lib/zucker/regexp_union.rb +17 -0
- data/lib/zucker/square_brackets_for.rb +12 -15
- data/lib/zucker/string_extras.rb +15 -0
- data/lib/zucker/string_op.rb +20 -0
- data/lib/zucker/tap.rb +13 -8
- data/lib/zucker/unary_conversion.rb +25 -0
- data/spec/alias_for_spec.rb +11 -73
- data/spec/array_op_spec.rb +17 -0
- data/spec/blank_spec.rb +2 -0
- data/spec/camel_snake_spec.rb +15 -0
- data/spec/constantize_spec.rb +33 -0
- data/spec/dir_extras_spec.rb +32 -0
- data/spec/egonil_spec.rb +1 -0
- data/spec/file_extras_spec.rb +57 -0
- data/spec/hash_extras_spec.rb +11 -0
- data/spec/hash_op_spec.rb +28 -0
- data/spec/instance_variables_from_spec.rb +24 -0
- data/spec/iterate_spec.rb +2 -0
- data/spec/{mcopy_spec.rb → marshal_copy_spec.rb} +5 -3
- data/spec/mash_spec.rb +17 -0
- data/spec/ords_spec.rb +15 -0
- data/spec/{union_spec.rb → regexp_union_spec.rb} +4 -2
- data/spec/square_brackets_for_spec.rb +4 -12
- data/spec/string_extras_spec.rb +20 -0
- data/spec/string_op_spec.rb +22 -0
- data/spec/tap_spec.rb +2 -0
- data/spec/{unary_spec.rb → unary_conversion_spec.rb} +4 -2
- data/zucker.gemspec +8 -18
- metadata +75 -147
- data/.gemtest +0 -0
- data/README +0 -7
- data/desc/alias_for.yaml +0 -17
- data/desc/aliases.yaml +0 -18
- data/desc/array.yaml +0 -11
- data/desc/array_to_proc.yaml +0 -16
- data/desc/binding.yaml +0 -22
- data/desc/blank.yaml +0 -11
- data/desc/case.yaml +0 -9
- data/desc/cc.yaml +0 -10
- data/desc/class_to_proc.yaml +0 -11
- data/desc/dd.yaml +0 -23
- data/desc/egonil.yaml +0 -15
- data/desc/engine.yaml +0 -15
- data/desc/enumerable.yaml +0 -10
- data/desc/file.yaml +0 -14
- data/desc/hash.yaml +0 -14
- data/desc/hash_to_proc.yaml +0 -10
- data/desc/info.yaml +0 -20
- data/desc/iterate.yaml +0 -16
- data/desc/ivars.yaml +0 -19
- data/desc/kernel.yaml +0 -15
- data/desc/mcopy.yaml +0 -11
- data/desc/mm.yaml +0 -15
- data/desc/not.yaml +0 -11
- data/desc/oo.yaml +0 -10
- data/desc/os.yaml +0 -19
- data/desc/qq.yaml +0 -11
- data/desc/regexp_to_proc.yaml +0 -12
- data/desc/regexp_visualize.yaml +0 -23
- data/desc/ruby_version.yaml +0 -28
- data/desc/sandbox.yaml +0 -13
- data/desc/square_brackets_for.yaml +0 -22
- data/desc/string.yaml +0 -22
- data/desc/tap.yaml +0 -17
- data/desc/unary.yaml +0 -15
- data/desc/union.yaml +0 -10
- data/doc/zucker_doc.html +0 -3042
- data/lib/zucker/aliases.rb +0 -52
- data/lib/zucker/array.rb +0 -15
- data/lib/zucker/array_to_proc.rb +0 -19
- data/lib/zucker/binding.rb +0 -35
- data/lib/zucker/case.rb +0 -14
- data/lib/zucker/cc.rb +0 -31
- data/lib/zucker/class_to_proc.rb +0 -13
- data/lib/zucker/control.rb +0 -4
- data/lib/zucker/dd.rb +0 -24
- data/lib/zucker/debug.rb +0 -4
- data/lib/zucker/default.rb +0 -4
- data/lib/zucker/engine.rb +0 -70
- data/lib/zucker/enumerable.rb +0 -15
- data/lib/zucker/env.rb +0 -4
- data/lib/zucker/extensions.rb +0 -4
- data/lib/zucker/file.rb +0 -28
- data/lib/zucker/hash.rb +0 -28
- data/lib/zucker/hash_to_proc.rb +0 -17
- data/lib/zucker/info.rb +0 -193
- data/lib/zucker/ivars.rb +0 -29
- data/lib/zucker/kernel.rb +0 -42
- data/lib/zucker/mcopy.rb +0 -11
- data/lib/zucker/mm.rb +0 -41
- data/lib/zucker/not.rb +0 -20
- data/lib/zucker/object.rb +0 -4
- data/lib/zucker/oo.rb +0 -18
- data/lib/zucker/os.rb +0 -55
- data/lib/zucker/qq.rb +0 -13
- data/lib/zucker/regexp_to_proc.rb +0 -13
- data/lib/zucker/regexp_visualize.rb +0 -31
- data/lib/zucker/ruby_version.rb +0 -120
- data/lib/zucker/sandbox.rb +0 -17
- data/lib/zucker/shortcuts.rb +0 -4
- data/lib/zucker/string.rb +0 -55
- data/lib/zucker/to_proc.rb +0 -4
- data/lib/zucker/unary.rb +0 -25
- data/lib/zucker/union.rb +0 -17
- data/spec/aliases_spec.rb +0 -13
- data/spec/array_spec.rb +0 -16
- data/spec/array_to_proc_spec.rb +0 -12
- data/spec/binding_spec.rb +0 -6
- data/spec/case_spec.rb +0 -15
- data/spec/cc_spec.rb +0 -6
- data/spec/class_to_proc_spec.rb +0 -9
- data/spec/dd_spec.rb +0 -37
- data/spec/engine_spec.rb +0 -11
- data/spec/enumerable_spec.rb +0 -8
- data/spec/file_spec.rb +0 -46
- data/spec/hash_spec.rb +0 -25
- data/spec/hash_to_proc_spec.rb +0 -12
- data/spec/info_spec.rb +0 -8
- data/spec/ivars_spec.rb +0 -20
- data/spec/kernel_spec.rb +0 -42
- data/spec/mm_spec.rb +0 -6
- data/spec/not_spec.rb +0 -10
- data/spec/oo_spec.rb +0 -6
- data/spec/os_spec.rb +0 -37
- data/spec/qq_spec.rb +0 -19
- data/spec/regexp_to_proc_spec.rb +0 -9
- data/spec/regexp_visualize_spec.rb +0 -38
- data/spec/ruby_version_spec.rb +0 -55
- data/spec/sandbox_spec.rb +0 -14
- data/spec/string_spec.rb +0 -65
data/spec/regexp_to_proc_spec.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'zucker/regexp_to_proc'
|
2
|
-
|
3
|
-
describe 'Regexp#to_proc' do
|
4
|
-
it 'should match the regex' do
|
5
|
-
%w|just another string array|.map( &/[jy]/).should == ["j", nil, nil, "y"]
|
6
|
-
%w|just another string array|.select( &/[jy]/).should == ["just", "array"]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'zucker/regexp_visualize'
|
2
|
-
|
3
|
-
describe 'Regexp#visualize' do
|
4
|
-
let :regex do /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,4})\b/i end # regex from regular-expressions.info/email.html
|
5
|
-
|
6
|
-
it 'should display a string where >and< mark the found regex' do
|
7
|
-
capture_stdout do
|
8
|
-
regex.vis 'I do not contain an email address.'
|
9
|
-
end.chomp.should == 'no match'
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should display "no match" if the regex could not be matched' do
|
13
|
-
capture_stdout do
|
14
|
-
regex.vis 'I contain an email address: mail@example.com'
|
15
|
-
end.chomp.should == 'I contain an email address: >mail@example.com< '
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should display a string where >and< mark the found regex group if group identifier is given as arg2' do
|
19
|
-
capture_stdout do
|
20
|
-
regex.vis 'mail@example.com', 1
|
21
|
-
end.chomp.should == '1: >mail< @example.com'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should display "group identifier: no match" if the arg2 group could not be matched' do
|
25
|
-
capture_stdout do
|
26
|
-
regex.vis 'mail@example.com', 3
|
27
|
-
end.chomp.should == '3: no match'
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should also take an array of group identfiers as arg2' do
|
31
|
-
capture_stdout do
|
32
|
-
regex.vis 'mail@example.com', [0,1,2]
|
33
|
-
end.chomp.should == "0: >mail@example.com< \n"\
|
34
|
-
"1: >mail< @example.com\n"\
|
35
|
-
"2: mail@ >example.com< "
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
data/spec/ruby_version_spec.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'zucker/ruby_version'
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
describe 'RubyVersion' do
|
5
|
-
before :all do
|
6
|
-
@remember_version = RUBY_VERSION
|
7
|
-
capture_stderr{ RUBY_VERSION = '1.8.7' }
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should display RUBY_VERSION if called directly (to_s)' do
|
11
|
-
RubyVersion.to_s.should == '1.8.7'
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'with "is" method, with parameter' do
|
15
|
-
it 'should check for main version (1.8 or 1.9) when Float paramater is given' do
|
16
|
-
RubyVersion.is?( 1.8 ).should == true
|
17
|
-
RubyVersion.is?( 1.9 ).should == false
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should check with string comparison if parameter is not Float' do
|
21
|
-
RubyVersion.is?( '1.8' ).should == false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'with "is" method, without parameter, but method chaining' do
|
26
|
-
it 'should return a string for usage with comparison operators' do
|
27
|
-
(RubyVersion.is > '1.8.7').should == false
|
28
|
-
(RubyVersion <= '1.8.7').should == true
|
29
|
-
(RubyVersion.is.between? '1.8.6', '1.8.7').should == true
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should create some handy compare aliases' do
|
33
|
-
RubyVersion.is.above( '1.8.7' ).should == false
|
34
|
-
RubyVersion.is.at_least( '1.8.7' ).should == true
|
35
|
-
RubyVersion.is.exactly( '1.8.7' ).should == true
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'also allows to check for the release dates' do
|
39
|
-
RubyVersion.is.older_than( Date.today ).should == true
|
40
|
-
RubyVersion.is.newer_than( '2000-01-01' ).should == true
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should define some accessors' do
|
45
|
-
RubyVersion.major.should == 1
|
46
|
-
RubyVersion.minor.should == 8
|
47
|
-
RubyVersion.tiny.should == 7
|
48
|
-
# RubyVersion.patchlevel # => RUBY_PATCHLEVEL
|
49
|
-
# RubyVersion.description # => RUBY_DESCRIPTION
|
50
|
-
end
|
51
|
-
|
52
|
-
after :all do
|
53
|
-
capture_stderr{ RUBY_VERSION = @remember_version }
|
54
|
-
end
|
55
|
-
end
|
data/spec/sandbox_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'zucker/sandbox'
|
2
|
-
|
3
|
-
describe 'sandbox' do
|
4
|
-
unless defined?(RUBY_ENGINE) && ( RUBY_ENGINE == 'jruby' || RUBY_ENGINE == 'rbx' )
|
5
|
-
it 'should throw a SecurityError if bad commands are issued' do
|
6
|
-
proc do
|
7
|
-
sandbox do
|
8
|
-
`ls`
|
9
|
-
end
|
10
|
-
end.should raise_exception SecurityError
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
data/spec/string_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'zucker/string'
|
2
|
-
|
3
|
-
describe 'String#-' do
|
4
|
-
it 'should remove the applied Regexp or String from self via gsub' do
|
5
|
-
('1234abc5678' - 'b' - /\d/).should == 'ac'
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'String#^' do
|
10
|
-
it 'should give C-like substring access to strings' do
|
11
|
-
string = 'Theoretische Informatik ist voll geil!'
|
12
|
-
|
13
|
-
(string^0).should == 'Theoretische Informatik ist voll geil!'
|
14
|
-
(string^1).should == 'heoretische Informatik ist voll geil!'
|
15
|
-
(string^13).should == 'Informatik ist voll geil!'
|
16
|
-
(string^-1).should == 'Theoretische Informatik ist voll geil'
|
17
|
-
(string^38).should == ''
|
18
|
-
(string^99).should == nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'String#lchomp' do
|
23
|
-
it 'should chomp on the left side' do
|
24
|
-
string = 'Theoretische Informatik ist voll geil!'
|
25
|
-
string.lchomp('T').should == 'heoretische Informatik ist voll geil!'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'String#ords' do
|
30
|
-
it 'should unpack characters' do
|
31
|
-
string = 'Theoretische Informatik ist voll geil!'
|
32
|
-
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]
|
33
|
-
end
|
34
|
-
|
35
|
-
describe 'String#constantize' do
|
36
|
-
it 'should return the constant with that name' do
|
37
|
-
'Object'.constantize.should == Object
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should also work for nested constants' do
|
41
|
-
'Zucker::VERSION'.constantize.should == Zucker::VERSION
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should throw name error if constant does not exist (and no parameter is given)' do
|
45
|
-
proc do
|
46
|
-
'ObfsefsefsefafesafaefRubyZuckerafdfselijfesject'.constantize
|
47
|
-
end.should raise_exception NameError
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should call the block (and not raise an error) if constant does not exist and block given' do
|
51
|
-
proc do
|
52
|
-
'ObfsefsefsefafesafaefRubyZuckerafdfselijfesject'.constantize do |string|
|
53
|
-
Default = [1,2,3]
|
54
|
-
end.should == [1,2,3]
|
55
|
-
end.should_not raise_exception NameError
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should return the second parameter (and not raise an error) if constant does not exist and parameter given' do
|
59
|
-
proc do
|
60
|
-
'ObfsefsefsefafesafaefRubyZuckerafdfselijfesject'.constantize(Array).should == Array
|
61
|
-
end.should_not raise_exception NameError
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|