zucker 13.1 → 100.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +17 -2
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +22 -0
  5. data/Rakefile +17 -58
  6. data/doc/{zucker_doc.rb → create_documentation.rb} +67 -129
  7. data/doc/zucker.html +1774 -0
  8. data/lib/zucker.rb +12 -42
  9. data/lib/zucker/alias_for.rb +9 -16
  10. data/lib/zucker/all.rb +0 -2
  11. data/lib/zucker/array_op.rb +15 -0
  12. data/lib/zucker/blank.rb +39 -21
  13. data/lib/zucker/camel_snake.rb +15 -0
  14. data/lib/zucker/constantize.rb +29 -0
  15. data/lib/zucker/dir_extras.rb +20 -0
  16. data/lib/zucker/egonil.rb +13 -24
  17. data/lib/zucker/file_extras.rb +33 -0
  18. data/lib/zucker/hash_extras.rb +11 -0
  19. data/lib/zucker/hash_op.rb +28 -0
  20. data/lib/zucker/instance_variables_from.rb +34 -0
  21. data/lib/zucker/iterate.rb +24 -21
  22. data/lib/zucker/marshal_copy.rb +11 -0
  23. data/lib/zucker/mash.rb +22 -0
  24. data/lib/zucker/ords.rb +17 -0
  25. data/lib/zucker/regexp_union.rb +17 -0
  26. data/lib/zucker/square_brackets_for.rb +12 -15
  27. data/lib/zucker/string_extras.rb +15 -0
  28. data/lib/zucker/string_op.rb +20 -0
  29. data/lib/zucker/tap.rb +13 -8
  30. data/lib/zucker/unary_conversion.rb +25 -0
  31. data/spec/alias_for_spec.rb +11 -73
  32. data/spec/array_op_spec.rb +17 -0
  33. data/spec/blank_spec.rb +2 -0
  34. data/spec/camel_snake_spec.rb +15 -0
  35. data/spec/constantize_spec.rb +33 -0
  36. data/spec/dir_extras_spec.rb +32 -0
  37. data/spec/egonil_spec.rb +1 -0
  38. data/spec/file_extras_spec.rb +57 -0
  39. data/spec/hash_extras_spec.rb +11 -0
  40. data/spec/hash_op_spec.rb +28 -0
  41. data/spec/instance_variables_from_spec.rb +24 -0
  42. data/spec/iterate_spec.rb +2 -0
  43. data/spec/{mcopy_spec.rb → marshal_copy_spec.rb} +5 -3
  44. data/spec/mash_spec.rb +17 -0
  45. data/spec/ords_spec.rb +15 -0
  46. data/spec/{union_spec.rb → regexp_union_spec.rb} +4 -2
  47. data/spec/square_brackets_for_spec.rb +4 -12
  48. data/spec/string_extras_spec.rb +20 -0
  49. data/spec/string_op_spec.rb +22 -0
  50. data/spec/tap_spec.rb +2 -0
  51. data/spec/{unary_spec.rb → unary_conversion_spec.rb} +4 -2
  52. data/zucker.gemspec +8 -18
  53. metadata +75 -147
  54. data/.gemtest +0 -0
  55. data/README +0 -7
  56. data/desc/alias_for.yaml +0 -17
  57. data/desc/aliases.yaml +0 -18
  58. data/desc/array.yaml +0 -11
  59. data/desc/array_to_proc.yaml +0 -16
  60. data/desc/binding.yaml +0 -22
  61. data/desc/blank.yaml +0 -11
  62. data/desc/case.yaml +0 -9
  63. data/desc/cc.yaml +0 -10
  64. data/desc/class_to_proc.yaml +0 -11
  65. data/desc/dd.yaml +0 -23
  66. data/desc/egonil.yaml +0 -15
  67. data/desc/engine.yaml +0 -15
  68. data/desc/enumerable.yaml +0 -10
  69. data/desc/file.yaml +0 -14
  70. data/desc/hash.yaml +0 -14
  71. data/desc/hash_to_proc.yaml +0 -10
  72. data/desc/info.yaml +0 -20
  73. data/desc/iterate.yaml +0 -16
  74. data/desc/ivars.yaml +0 -19
  75. data/desc/kernel.yaml +0 -15
  76. data/desc/mcopy.yaml +0 -11
  77. data/desc/mm.yaml +0 -15
  78. data/desc/not.yaml +0 -11
  79. data/desc/oo.yaml +0 -10
  80. data/desc/os.yaml +0 -19
  81. data/desc/qq.yaml +0 -11
  82. data/desc/regexp_to_proc.yaml +0 -12
  83. data/desc/regexp_visualize.yaml +0 -23
  84. data/desc/ruby_version.yaml +0 -28
  85. data/desc/sandbox.yaml +0 -13
  86. data/desc/square_brackets_for.yaml +0 -22
  87. data/desc/string.yaml +0 -22
  88. data/desc/tap.yaml +0 -17
  89. data/desc/unary.yaml +0 -15
  90. data/desc/union.yaml +0 -10
  91. data/doc/zucker_doc.html +0 -3042
  92. data/lib/zucker/aliases.rb +0 -52
  93. data/lib/zucker/array.rb +0 -15
  94. data/lib/zucker/array_to_proc.rb +0 -19
  95. data/lib/zucker/binding.rb +0 -35
  96. data/lib/zucker/case.rb +0 -14
  97. data/lib/zucker/cc.rb +0 -31
  98. data/lib/zucker/class_to_proc.rb +0 -13
  99. data/lib/zucker/control.rb +0 -4
  100. data/lib/zucker/dd.rb +0 -24
  101. data/lib/zucker/debug.rb +0 -4
  102. data/lib/zucker/default.rb +0 -4
  103. data/lib/zucker/engine.rb +0 -70
  104. data/lib/zucker/enumerable.rb +0 -15
  105. data/lib/zucker/env.rb +0 -4
  106. data/lib/zucker/extensions.rb +0 -4
  107. data/lib/zucker/file.rb +0 -28
  108. data/lib/zucker/hash.rb +0 -28
  109. data/lib/zucker/hash_to_proc.rb +0 -17
  110. data/lib/zucker/info.rb +0 -193
  111. data/lib/zucker/ivars.rb +0 -29
  112. data/lib/zucker/kernel.rb +0 -42
  113. data/lib/zucker/mcopy.rb +0 -11
  114. data/lib/zucker/mm.rb +0 -41
  115. data/lib/zucker/not.rb +0 -20
  116. data/lib/zucker/object.rb +0 -4
  117. data/lib/zucker/oo.rb +0 -18
  118. data/lib/zucker/os.rb +0 -55
  119. data/lib/zucker/qq.rb +0 -13
  120. data/lib/zucker/regexp_to_proc.rb +0 -13
  121. data/lib/zucker/regexp_visualize.rb +0 -31
  122. data/lib/zucker/ruby_version.rb +0 -120
  123. data/lib/zucker/sandbox.rb +0 -17
  124. data/lib/zucker/shortcuts.rb +0 -4
  125. data/lib/zucker/string.rb +0 -55
  126. data/lib/zucker/to_proc.rb +0 -4
  127. data/lib/zucker/unary.rb +0 -25
  128. data/lib/zucker/union.rb +0 -17
  129. data/spec/aliases_spec.rb +0 -13
  130. data/spec/array_spec.rb +0 -16
  131. data/spec/array_to_proc_spec.rb +0 -12
  132. data/spec/binding_spec.rb +0 -6
  133. data/spec/case_spec.rb +0 -15
  134. data/spec/cc_spec.rb +0 -6
  135. data/spec/class_to_proc_spec.rb +0 -9
  136. data/spec/dd_spec.rb +0 -37
  137. data/spec/engine_spec.rb +0 -11
  138. data/spec/enumerable_spec.rb +0 -8
  139. data/spec/file_spec.rb +0 -46
  140. data/spec/hash_spec.rb +0 -25
  141. data/spec/hash_to_proc_spec.rb +0 -12
  142. data/spec/info_spec.rb +0 -8
  143. data/spec/ivars_spec.rb +0 -20
  144. data/spec/kernel_spec.rb +0 -42
  145. data/spec/mm_spec.rb +0 -6
  146. data/spec/not_spec.rb +0 -10
  147. data/spec/oo_spec.rb +0 -6
  148. data/spec/os_spec.rb +0 -37
  149. data/spec/qq_spec.rb +0 -19
  150. data/spec/regexp_to_proc_spec.rb +0 -9
  151. data/spec/regexp_visualize_spec.rb +0 -38
  152. data/spec/ruby_version_spec.rb +0 -55
  153. data/spec/sandbox_spec.rb +0 -14
  154. data/spec/string_spec.rb +0 -65
@@ -1,4 +0,0 @@
1
- require 'zucker'
2
- Zucker.require_this __FILE__
3
-
4
- # J-_-L
data/lib/zucker/unary.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'zucker'
2
- module Zucker Unary = true end
3
-
4
- class String
5
- def +@
6
- self
7
- end
8
-
9
- def -@
10
- to_sym
11
- end
12
- end
13
-
14
- class Symbol
15
- def +@
16
- to_s
17
- end
18
-
19
- def -@
20
- self
21
- end
22
- end
23
-
24
- # J-_-L
25
-
data/lib/zucker/union.rb DELETED
@@ -1,17 +0,0 @@
1
- require 'zucker'
2
- module Zucker Union = true end
3
-
4
- class Regexp
5
- def |(arg)
6
- Regexp.union self, arg.is_a?(Regexp) ? arg : arg.to_s
7
- end
8
- end
9
-
10
- class String
11
- def |(arg)
12
- Regexp.union self, arg.is_a?(Regexp) ? arg : arg.to_s
13
- end
14
- end
15
-
16
- # J-_-L
17
-
data/spec/aliases_spec.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'zucker/aliases'
2
-
3
- describe '(aliases)' do
4
- it 'should create these aliases' do
5
- # see aliases.rb for aliase list
6
- end
7
-
8
- it 'should define these constants' do
9
- Infinity.finite?.should == false
10
- NaN.nan?.should == true
11
- end
12
- end
13
-
data/spec/array_spec.rb DELETED
@@ -1,16 +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#chrs' do
12
- it 'should convert the array to a string, using each element as ord value for the char' do
13
- [72, 97, 108, 108, 111].chrs.should == 'Hallo'
14
- end
15
- end
16
-
@@ -1,12 +0,0 @@
1
- require 'zucker/array_to_proc'
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
-
data/spec/binding_spec.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'zucker/binding'
2
-
3
- describe 'Binding#variables' do
4
- it 'should output information about the current environment' do; end
5
- end
6
-
data/spec/case_spec.rb DELETED
@@ -1,15 +0,0 @@
1
- if defined? BasicObject # 1.9 only
2
- require 'zucker/case'
3
-
4
- describe 'String#to_camel' do
5
- it 'should turn a snake_cased string to CamelCase' do
6
- 'was_snake_case'.to_camel.should == 'WasSnakeCase'
7
- end
8
- end
9
-
10
- describe 'String#to_snake' do
11
- it 'should turn a CamelCased string to snake_case' do
12
- 'WasCamelCase'.to_snake.should == 'was_camel_case'
13
- end
14
- end
15
- end
data/spec/cc_spec.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'zucker/cc'
2
-
3
- describe 'c' do
4
- it 'should output the method callstack' do; end
5
- end
6
-
@@ -1,9 +0,0 @@
1
- require 'zucker/class_to_proc'
2
- require 'set'
3
-
4
- describe 'Class#to_proc' do
5
- it 'should create new instances of the class' do
6
- [ [1,2],[3,5,6,7,3] ].map(&Set).should == [ Set[1,2], Set[5,6,7,3] ]
7
- end
8
- end
9
-
data/spec/dd_spec.rb DELETED
@@ -1,37 +0,0 @@
1
- require 'zucker/dd'
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
- capture_stdout do
11
- a.each{ |e|
12
- (e.d).should == e
13
- }
14
-
15
- a.each{ |e|
16
- (e.d{|value| "This is a: #{value}"}).should == e
17
- }
18
- end
19
- end
20
-
21
- it "should puts .inspect if no block is given (and not change the object's value)" do
22
- capture_stdout do
23
- a[0].d
24
- a[1].d
25
- a[6].d
26
- end.should == %{1\n"1"\ntrue\n}
27
- end
28
-
29
- it "should puts the block if it is given (and not change the object's value)" do
30
- capture_stdout do
31
- a[0].d{|value| "This is a: #{value}"}
32
- a[1].d{|value| "This is a: #{value}"}
33
- a[6].d{|value| "This is a: #{value}"}
34
- end.should == %{This is a: 1\nThis is a: 1\nThis is a: true\n}
35
- end
36
- end
37
-
data/spec/engine_spec.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'zucker/engine'
2
-
3
- describe 'RubyEngine' do
4
- it 'should display the current ruby interpreter (to_s)' do
5
- RubyEngine
6
- end
7
-
8
- it 'should create many method aliases for asking for a specific interpreter' do
9
- # please see the source or description file
10
- end
11
- end
@@ -1,8 +0,0 @@
1
- require 'zucker/enumerable'
2
-
3
- describe 'Enumerable#mash' do
4
- it 'should "map" a hash' do
5
- [1,2,3].mash{|e| [e, e.to_s] }.should == {1=>'1',2=>'2',3=>'3',}
6
- end
7
- end
8
-
data/spec/file_spec.rb DELETED
@@ -1,46 +0,0 @@
1
- require 'zucker/file'
2
- require 'fileutils'
3
-
4
- describe 'File.gsub' do
5
- let :random_filename do
6
- 'test_' + (0..20).map{|e| [*'a'..'z'].send RUBY_VERSION > '1.9' ? :sample : :choice }*''
7
- end
8
-
9
- it 'should read filename in arg1, substitute every key in the arg2 with its value and save the file' do
10
- File.open(random_filename,'w'){ |file|
11
- file.print 'should read filename in arg1, substitute every key in the arg2 with its value and save the file'
12
- }
13
- File.gsub random_filename,
14
- /read/ => 'write',
15
- /\d+/ => proc{|m| (m.to_i+1).to_s }
16
-
17
- File.read(random_filename).should ==
18
- 'should write filename in arg2, substitute every key in the arg3 with its value and save the file'
19
-
20
- FileUtils.rm random_filename
21
- end
22
- end
23
-
24
- describe 'File.delete!' do
25
- let :random_filename do
26
- 'test_' + (0..20).map{|e| [*'a'..'z'].send RUBY_VERSION > '1.9' ? :sample : :choice }*''
27
- end
28
-
29
- it 'should delete the filename given as argument if it exists + return non-nil' do
30
- FileUtils.touch random_filename
31
- res = false
32
- proc do
33
- res = File.delete! random_filename
34
- end.should_not raise_exception
35
- res.should be_true
36
- end
37
-
38
- it 'should do nothing if the filename given as argument does not exist + return nil' do
39
- res = false
40
- proc do
41
- res = File.delete! random_filename
42
- end.should_not raise_exception
43
- res.should be_false
44
- end
45
- end
46
-
data/spec/hash_spec.rb DELETED
@@ -1,25 +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
-
18
- describe 'Hash#&' do
19
- it 'should select a sub hash containt only equal key-value pairs' do
20
- a = { 1=>4, 2=>5, 3=>6 }
21
- b= { 1=>4, 2=>7 }
22
- (a & b).should == { 1=>4 }
23
- end
24
- end
25
-
@@ -1,12 +0,0 @@
1
- require 'zucker/hash_to_proc'
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
-
data/spec/info_spec.rb DELETED
@@ -1,8 +0,0 @@
1
- require 'zucker/info'
2
-
3
- describe 'Info' do
4
- it 'should define accessors for global variables, constants and some special methods/keywords' do
5
- # see sourcefile for the list
6
- end
7
- end
8
-
data/spec/ivars_spec.rb DELETED
@@ -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
-
data/spec/kernel_spec.rb DELETED
@@ -1,42 +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 'executed_directly?' do
24
- it 'should return true if the file is invoked directly' do
25
- executed_directly?.should == ( __FILE__ == $PROGRAM_NAME )
26
- end
27
- end
28
-
29
- describe 'irb?' do
30
- it 'should return true if called in IRB or RIPL' do; end
31
- end
32
-
33
- describe 'ignore_sigint!' do
34
- it 'should catch ctrl+c signals' do; end
35
- end
36
-
37
- describe 'ignore_sigquit!' do
38
- it 'should catch ctrl+\ signals' do; end
39
- end
40
-
41
-
42
- # J-_-L
data/spec/mm_spec.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'zucker/mm'
2
-
3
- describe 'Object#mm' do
4
- it 'should display an ordered method list' do; end
5
- end
6
-
data/spec/not_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- if defined? BasicObject # 1.9 only
2
- require 'zucker/not'
3
-
4
- describe 'Object#not' do
5
- it "should return an object on which all methods are redirected to it's receiver object, but return an inverted boolean" do
6
- [1,2,3].not.empty?.should == true
7
- nil.not.nil?.should == false
8
- end
9
- end
10
- end
data/spec/oo_spec.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'zucker/oo'
2
-
3
- describe 'o' do
4
- it 'should output the current line, file, method and label (if given)' do; end
5
- end
6
-
data/spec/os_spec.rb DELETED
@@ -1,37 +0,0 @@
1
- require 'zucker/os'
2
-
3
- describe 'OS' do
4
- it 'should display the used operation system (to_s)' do; end
5
- end
6
-
7
- describe 'linux?' do
8
- it 'should return true if OS is a linux' do; end
9
- end
10
-
11
- describe 'mac?' do
12
- it 'should return true if OS is a mac or darwin' do; end
13
- end
14
-
15
- describe 'bsd?' do
16
- it 'should return true if OS is a bsd' do; end
17
- end
18
-
19
- describe 'windows?' do
20
- it 'should return true if OS is a windows' do; end
21
- end
22
-
23
- describe 'solaris?' do
24
- it 'should return true if OS is a solaris or sunos' do; end
25
- end
26
-
27
- describe 'posix?' do
28
- it 'should return true if OS is posix compatible' do; end
29
- end
30
-
31
- describe 'OS.is?' do
32
- it "should test if RbConfig::CONFIG['host_os'] matches the regex (boolean value)" do
33
- OS.is?(/linux/).should ==
34
- !!( RbConfig::CONFIG['host_os'] =~ /linux/ )
35
- end
36
- end
37
-
data/spec/qq_spec.rb DELETED
@@ -1,19 +0,0 @@
1
- require 'zucker/qq'
2
-
3
- describe 'q' do
4
-
5
- it 'should output the same as p for a single arg' do
6
- capture_stdout{p /some object/}.should ==
7
- capture_stdout{q /some object/}
8
- end
9
-
10
- it "should output the same as p but for multiple args one one line, values separated by two spaces" do
11
- capture_stdout do
12
- q 1, "1", 2..5, [], {:hallo => :du}, nil, true
13
- end.chop.should ==
14
- capture_stdout do
15
- p 1, "1", 2..5, [], {:hallo => :du}, nil, true
16
- end.chop.gsub( "\n", ' ' )
17
- end
18
- end
19
-