zucker 8 → 9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -0
- data/MIT-LICENSE +1 -1
- data/README +1 -1
- data/Rakefile +33 -40
- data/desc/alias_for.yaml +17 -0
- data/desc/aliases.yaml +18 -0
- data/desc/array.yaml +13 -0
- data/desc/array_to_proc.yaml +16 -0
- data/desc/binding.yaml +22 -0
- data/desc/blank.yaml +9 -0
- data/desc/cc.yaml +10 -0
- data/desc/class_to_proc.yaml +11 -0
- data/desc/dd.yaml +23 -0
- data/desc/egonil.yaml +15 -0
- data/desc/engine.yaml +15 -0
- data/desc/enumerable.yaml +10 -0
- data/desc/file.yaml +15 -0
- data/desc/hash.yaml +14 -0
- data/desc/hash_to_proc.yaml +10 -0
- data/desc/info.yaml +20 -0
- data/desc/iterate.yaml +16 -0
- data/desc/ivars.yaml +19 -0
- data/desc/kernel.yaml +14 -0
- data/desc/mcopy.yaml +11 -0
- data/desc/mm.yaml +15 -0
- data/desc/not.yaml +11 -0
- data/desc/oo.yaml +10 -0
- data/desc/os.yaml +19 -0
- data/desc/qq.yaml +11 -0
- data/desc/regexp_to_proc.yaml +12 -0
- data/desc/regexp_visualize.yaml +23 -0
- data/desc/sandbox.yaml +12 -0
- data/desc/square_brackets_for.yaml +22 -0
- data/desc/string.yaml +23 -0
- data/desc/tap.yaml +17 -0
- data/desc/unary.yaml +15 -0
- data/desc/union.yaml +10 -0
- data/desc/version.yaml +28 -0
- data/doc/zucker_doc.html +2688 -0
- data/doc/zucker_doc.rb +553 -0
- data/lib/zucker.rb +10 -9
- data/lib/zucker/array2proc.rb +2 -18
- data/lib/zucker/{2/array2proc.rb → array_to_proc.rb} +0 -0
- data/lib/zucker/binding.rb +4 -5
- data/lib/zucker/cc.rb +7 -2
- data/lib/zucker/class2proc.rb +2 -12
- data/lib/zucker/{1/class2proc.rb → class_to_proc.rb} +0 -0
- data/lib/zucker/file.rb +22 -0
- data/lib/zucker/hash2proc.rb +2 -16
- data/lib/zucker/{1/hash2proc.rb → hash_to_proc.rb} +0 -0
- data/lib/zucker/kernel.rb +4 -2
- data/lib/zucker/mm.rb +14 -8
- data/lib/zucker/regexp2proc.rb +2 -12
- data/lib/zucker/{1/regexp2proc.rb → regexp_to_proc.rb} +0 -0
- data/lib/zucker/regexp_visualize.rb +26 -0
- data/lib/zucker/sandbox.rb +1 -11
- data/spec/alias_for_spec.rb +117 -0
- data/spec/aliases_spec.rb +13 -0
- data/spec/array_spec.rb +23 -0
- data/spec/array_to_proc_spec.rb +12 -0
- data/spec/binding_spec.rb +6 -0
- data/spec/blank_spec.rb +20 -0
- data/spec/cc_spec.rb +6 -0
- data/spec/class_to_proc_spec.rb +9 -0
- data/spec/dd_spec.rb +37 -0
- data/spec/egonil_spec.rb +32 -0
- data/spec/engine_spec.rb +11 -0
- data/spec/enumerable_spec.rb +8 -0
- data/spec/file_spec.rb +30 -0
- data/spec/hash_spec.rb +25 -0
- data/spec/hash_to_proc_spec.rb +12 -0
- data/spec/info_spec.rb +8 -0
- data/spec/iterate_spec.rb +59 -0
- data/spec/ivars_spec.rb +20 -0
- data/spec/kernel_spec.rb +37 -0
- data/spec/mcopy_spec.rb +13 -0
- data/spec/mm_spec.rb +6 -0
- data/spec/not_spec.rb +12 -0
- data/spec/oo_spec.rb +6 -0
- data/spec/os_spec.rb +37 -0
- data/spec/qq_spec.rb +19 -0
- data/spec/regexp_to_proc_spec.rb +9 -0
- data/spec/regexp_visualize_spec.rb +38 -0
- data/spec/sandbox_spec.rb +12 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/square_brackets_for_spec.rb +59 -0
- data/spec/string_spec.rb +65 -0
- data/spec/tap_spec.rb +18 -0
- data/spec/unary_spec.rb +26 -0
- data/spec/union_spec.rb +17 -0
- data/spec/version_spec.rb +55 -0
- data/zucker.gemspec +21 -0
- metadata +139 -323
- data/lib/zucker/1/D.rb +0 -21
- data/lib/zucker/1/aliases.rb +0 -30
- data/lib/zucker/1/all.rb +0 -8
- data/lib/zucker/1/array.rb +0 -19
- data/lib/zucker/1/array2proc.rb +0 -12
- data/lib/zucker/1/binding.rb +0 -27
- data/lib/zucker/1/blank.rb +0 -28
- data/lib/zucker/1/debug.rb +0 -6
- data/lib/zucker/1/default.rb +0 -27
- data/lib/zucker/1/egonil.rb +0 -16
- data/lib/zucker/1/enumerable.rb +0 -14
- data/lib/zucker/1/hash.rb +0 -21
- data/lib/zucker/1/iterate.rb +0 -25
- data/lib/zucker/1/ivars.rb +0 -28
- data/lib/zucker/1/kernel.rb +0 -22
- data/lib/zucker/1/mcopy.rb +0 -11
- data/lib/zucker/1/mm.rb +0 -33
- data/lib/zucker/1/sandbox.rb +0 -17
- data/lib/zucker/1/square_brackets_for.rb +0 -22
- data/lib/zucker/1/string.rb +0 -27
- data/lib/zucker/1/unary.rb +0 -24
- data/lib/zucker/1/union.rb +0 -16
- data/lib/zucker/2/D.rb +0 -21
- data/lib/zucker/2/aliases.rb +0 -30
- data/lib/zucker/2/all.rb +0 -8
- data/lib/zucker/2/array.rb +0 -19
- data/lib/zucker/2/binding.rb +0 -27
- data/lib/zucker/2/blank.rb +0 -28
- data/lib/zucker/2/class2proc.rb +0 -12
- data/lib/zucker/2/debug.rb +0 -6
- data/lib/zucker/2/default.rb +0 -27
- data/lib/zucker/2/egonil.rb +0 -16
- data/lib/zucker/2/enumerable.rb +0 -14
- data/lib/zucker/2/hash.rb +0 -21
- data/lib/zucker/2/hash2proc.rb +0 -16
- data/lib/zucker/2/info.rb +0 -166
- data/lib/zucker/2/iterate.rb +0 -25
- data/lib/zucker/2/ivars.rb +0 -28
- data/lib/zucker/2/kernel.rb +0 -20
- data/lib/zucker/2/mcopy.rb +0 -11
- data/lib/zucker/2/mm.rb +0 -33
- data/lib/zucker/2/regexp2proc.rb +0 -12
- data/lib/zucker/2/sandbox.rb +0 -21
- data/lib/zucker/2/square_brackets_for.rb +0 -22
- data/lib/zucker/2/string.rb +0 -27
- data/lib/zucker/2/unary.rb +0 -24
- data/lib/zucker/2/union.rb +0 -16
- data/lib/zucker/3/D.rb +0 -21
- data/lib/zucker/3/alias_for.rb +0 -21
- data/lib/zucker/3/aliases.rb +0 -30
- data/lib/zucker/3/all.rb +0 -8
- data/lib/zucker/3/array.rb +0 -25
- data/lib/zucker/3/array2proc.rb +0 -18
- data/lib/zucker/3/binding.rb +0 -27
- data/lib/zucker/3/blank.rb +0 -28
- data/lib/zucker/3/class2proc.rb +0 -12
- data/lib/zucker/3/debug.rb +0 -8
- data/lib/zucker/3/default.rb +0 -37
- data/lib/zucker/3/egonil.rb +0 -16
- data/lib/zucker/3/enumerable.rb +0 -14
- data/lib/zucker/3/hash.rb +0 -21
- data/lib/zucker/3/hash2proc.rb +0 -16
- data/lib/zucker/3/info.rb +0 -169
- data/lib/zucker/3/iterate.rb +0 -25
- data/lib/zucker/3/ivars.rb +0 -28
- data/lib/zucker/3/kernel.rb +0 -50
- data/lib/zucker/3/mcopy.rb +0 -10
- data/lib/zucker/3/mm.rb +0 -33
- data/lib/zucker/3/not.rb +0 -19
- data/lib/zucker/3/regexp2proc.rb +0 -12
- data/lib/zucker/3/sandbox.rb +0 -21
- data/lib/zucker/3/square_brackets_for.rb +0 -22
- data/lib/zucker/3/string.rb +0 -49
- data/lib/zucker/3/tap.rb +0 -11
- data/lib/zucker/3/unary.rb +0 -24
- data/lib/zucker/3/union.rb +0 -16
- data/lib/zucker/4/D.rb +0 -21
- data/lib/zucker/4/alias_for.rb +0 -21
- data/lib/zucker/4/aliases.rb +0 -35
- data/lib/zucker/4/all.rb +0 -8
- data/lib/zucker/4/array.rb +0 -25
- data/lib/zucker/4/array2proc.rb +0 -18
- data/lib/zucker/4/binding.rb +0 -27
- data/lib/zucker/4/blank.rb +0 -28
- data/lib/zucker/4/class2proc.rb +0 -12
- data/lib/zucker/4/debug.rb +0 -8
- data/lib/zucker/4/default.rb +0 -40
- data/lib/zucker/4/egonil.rb +0 -16
- data/lib/zucker/4/engine.rb +0 -69
- data/lib/zucker/4/enumerable.rb +0 -14
- data/lib/zucker/4/hash.rb +0 -21
- data/lib/zucker/4/hash2proc.rb +0 -16
- data/lib/zucker/4/info.rb +0 -173
- data/lib/zucker/4/iterate.rb +0 -25
- data/lib/zucker/4/ivars.rb +0 -28
- data/lib/zucker/4/kernel.rb +0 -27
- data/lib/zucker/4/mcopy.rb +0 -10
- data/lib/zucker/4/mm.rb +0 -33
- data/lib/zucker/4/not.rb +0 -19
- data/lib/zucker/4/os.rb +0 -50
- data/lib/zucker/4/q.rb +0 -7
- data/lib/zucker/4/regexp2proc.rb +0 -12
- data/lib/zucker/4/sandbox.rb +0 -23
- data/lib/zucker/4/square_brackets_for.rb +0 -22
- data/lib/zucker/4/string.rb +0 -54
- data/lib/zucker/4/tap.rb +0 -11
- data/lib/zucker/4/unary.rb +0 -24
- data/lib/zucker/4/union.rb +0 -16
- data/lib/zucker/4/version.rb +0 -115
- data/lib/zucker/5/alias_for.rb +0 -21
- data/lib/zucker/5/aliases.rb +0 -51
- data/lib/zucker/5/all.rb +0 -4
- data/lib/zucker/5/array.rb +0 -25
- data/lib/zucker/5/array2proc.rb +0 -18
- data/lib/zucker/5/binding.rb +0 -34
- data/lib/zucker/5/blank.rb +0 -28
- data/lib/zucker/5/cc.rb +0 -25
- data/lib/zucker/5/class2proc.rb +0 -12
- data/lib/zucker/5/control.rb +0 -4
- data/lib/zucker/5/dd.rb +0 -24
- data/lib/zucker/5/debug.rb +0 -4
- data/lib/zucker/5/default.rb +0 -4
- data/lib/zucker/5/egonil.rb +0 -16
- data/lib/zucker/5/engine.rb +0 -69
- data/lib/zucker/5/enumerable.rb +0 -14
- data/lib/zucker/5/env.rb +0 -4
- data/lib/zucker/5/extensions.rb +0 -4
- data/lib/zucker/5/hash.rb +0 -27
- data/lib/zucker/5/hash2proc.rb +0 -16
- data/lib/zucker/5/info.rb +0 -177
- data/lib/zucker/5/iterate.rb +0 -26
- data/lib/zucker/5/ivars.rb +0 -28
- data/lib/zucker/5/kernel.rb +0 -34
- data/lib/zucker/5/mcopy.rb +0 -10
- data/lib/zucker/5/mm.rb +0 -34
- data/lib/zucker/5/not.rb +0 -19
- data/lib/zucker/5/object.rb +0 -4
- data/lib/zucker/5/oo.rb +0 -17
- data/lib/zucker/5/os.rb +0 -49
- data/lib/zucker/5/qq.rb +0 -12
- data/lib/zucker/5/regexp2proc.rb +0 -12
- data/lib/zucker/5/sandbox.rb +0 -25
- data/lib/zucker/5/shortcuts.rb +0 -4
- data/lib/zucker/5/square_brackets_for.rb +0 -21
- data/lib/zucker/5/string.rb +0 -54
- data/lib/zucker/5/tap.rb +0 -11
- data/lib/zucker/5/to_proc.rb +0 -4
- data/lib/zucker/5/unary.rb +0 -24
- data/lib/zucker/5/union.rb +0 -16
- data/lib/zucker/5/version.rb +0 -118
- data/lib/zucker/6/alias_for.rb +0 -21
- data/lib/zucker/6/aliases.rb +0 -51
- data/lib/zucker/6/all.rb +0 -4
- data/lib/zucker/6/array.rb +0 -25
- data/lib/zucker/6/array2proc.rb +0 -18
- data/lib/zucker/6/binding.rb +0 -34
- data/lib/zucker/6/blank.rb +0 -28
- data/lib/zucker/6/cc.rb +0 -25
- data/lib/zucker/6/class2proc.rb +0 -12
- data/lib/zucker/6/control.rb +0 -4
- data/lib/zucker/6/dd.rb +0 -23
- data/lib/zucker/6/debug.rb +0 -4
- data/lib/zucker/6/default.rb +0 -4
- data/lib/zucker/6/egonil.rb +0 -27
- data/lib/zucker/6/engine.rb +0 -68
- data/lib/zucker/6/enumerable.rb +0 -14
- data/lib/zucker/6/env.rb +0 -4
- data/lib/zucker/6/extensions.rb +0 -4
- data/lib/zucker/6/hash.rb +0 -27
- data/lib/zucker/6/hash2proc.rb +0 -16
- data/lib/zucker/6/info.rb +0 -192
- data/lib/zucker/6/iterate.rb +0 -27
- data/lib/zucker/6/ivars.rb +0 -28
- data/lib/zucker/6/kernel.rb +0 -34
- data/lib/zucker/6/mcopy.rb +0 -10
- data/lib/zucker/6/mm.rb +0 -34
- data/lib/zucker/6/not.rb +0 -19
- data/lib/zucker/6/object.rb +0 -4
- data/lib/zucker/6/oo.rb +0 -17
- data/lib/zucker/6/os.rb +0 -54
- data/lib/zucker/6/qq.rb +0 -12
- data/lib/zucker/6/regexp2proc.rb +0 -12
- data/lib/zucker/6/sandbox.rb +0 -25
- data/lib/zucker/6/shortcuts.rb +0 -4
- data/lib/zucker/6/square_brackets_for.rb +0 -21
- data/lib/zucker/6/string.rb +0 -54
- data/lib/zucker/6/tap.rb +0 -11
- data/lib/zucker/6/to_proc.rb +0 -4
- data/lib/zucker/6/unary.rb +0 -24
- data/lib/zucker/6/union.rb +0 -16
- data/lib/zucker/6/version.rb +0 -118
- data/lib/zucker/7/alias_for.rb +0 -21
- data/lib/zucker/7/aliases.rb +0 -51
- data/lib/zucker/7/all.rb +0 -4
- data/lib/zucker/7/array.rb +0 -25
- data/lib/zucker/7/array2proc.rb +0 -18
- data/lib/zucker/7/binding.rb +0 -34
- data/lib/zucker/7/blank.rb +0 -28
- data/lib/zucker/7/cc.rb +0 -25
- data/lib/zucker/7/class2proc.rb +0 -12
- data/lib/zucker/7/control.rb +0 -4
- data/lib/zucker/7/dd.rb +0 -23
- data/lib/zucker/7/debug.rb +0 -4
- data/lib/zucker/7/default.rb +0 -4
- data/lib/zucker/7/egonil.rb +0 -27
- data/lib/zucker/7/engine.rb +0 -68
- data/lib/zucker/7/enumerable.rb +0 -14
- data/lib/zucker/7/env.rb +0 -4
- data/lib/zucker/7/extensions.rb +0 -4
- data/lib/zucker/7/hash.rb +0 -27
- data/lib/zucker/7/hash2proc.rb +0 -16
- data/lib/zucker/7/info.rb +0 -192
- data/lib/zucker/7/iterate.rb +0 -27
- data/lib/zucker/7/ivars.rb +0 -28
- data/lib/zucker/7/kernel.rb +0 -34
- data/lib/zucker/7/mcopy.rb +0 -10
- data/lib/zucker/7/mm.rb +0 -34
- data/lib/zucker/7/not.rb +0 -19
- data/lib/zucker/7/object.rb +0 -4
- data/lib/zucker/7/oo.rb +0 -17
- data/lib/zucker/7/os.rb +0 -54
- data/lib/zucker/7/qq.rb +0 -12
- data/lib/zucker/7/regexp2proc.rb +0 -12
- data/lib/zucker/7/sandbox.rb +0 -25
- data/lib/zucker/7/shortcuts.rb +0 -4
- data/lib/zucker/7/square_brackets_for.rb +0 -21
- data/lib/zucker/7/string.rb +0 -54
- data/lib/zucker/7/tap.rb +0 -11
- data/lib/zucker/7/to_proc.rb +0 -4
- data/lib/zucker/7/unary.rb +0 -24
- data/lib/zucker/7/union.rb +0 -16
- data/lib/zucker/7/version.rb +0 -118
- data/lib/zucker/8/alias_for.rb +0 -21
- data/lib/zucker/8/aliases.rb +0 -51
- data/lib/zucker/8/all.rb +0 -4
- data/lib/zucker/8/array.rb +0 -25
- data/lib/zucker/8/array2proc.rb +0 -18
- data/lib/zucker/8/binding.rb +0 -33
- data/lib/zucker/8/blank.rb +0 -28
- data/lib/zucker/8/cc.rb +0 -25
- data/lib/zucker/8/class2proc.rb +0 -12
- data/lib/zucker/8/control.rb +0 -4
- data/lib/zucker/8/dd.rb +0 -23
- data/lib/zucker/8/debug.rb +0 -4
- data/lib/zucker/8/default.rb +0 -4
- data/lib/zucker/8/egonil.rb +0 -27
- data/lib/zucker/8/engine.rb +0 -68
- data/lib/zucker/8/enumerable.rb +0 -14
- data/lib/zucker/8/env.rb +0 -4
- data/lib/zucker/8/extensions.rb +0 -4
- data/lib/zucker/8/hash.rb +0 -27
- data/lib/zucker/8/hash2proc.rb +0 -16
- data/lib/zucker/8/info.rb +0 -192
- data/lib/zucker/8/iterate.rb +0 -27
- data/lib/zucker/8/ivars.rb +0 -28
- data/lib/zucker/8/kernel.rb +0 -34
- data/lib/zucker/8/mcopy.rb +0 -10
- data/lib/zucker/8/mm.rb +0 -34
- data/lib/zucker/8/not.rb +0 -19
- data/lib/zucker/8/object.rb +0 -4
- data/lib/zucker/8/oo.rb +0 -17
- data/lib/zucker/8/os.rb +0 -54
- data/lib/zucker/8/qq.rb +0 -12
- data/lib/zucker/8/regexp2proc.rb +0 -12
- data/lib/zucker/8/sandbox.rb +0 -25
- data/lib/zucker/8/shortcuts.rb +0 -4
- data/lib/zucker/8/square_brackets_for.rb +0 -21
- data/lib/zucker/8/string.rb +0 -54
- data/lib/zucker/8/tap.rb +0 -11
- data/lib/zucker/8/to_proc.rb +0 -4
- data/lib/zucker/8/unary.rb +0 -24
- data/lib/zucker/8/union.rb +0 -16
- data/lib/zucker/8/version.rb +0 -118
data/lib/zucker.rb
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
module Zucker
|
4
4
|
# version and date get modified by the :prepare_release rake task
|
5
|
-
VERSION = '
|
6
|
-
DATE = '
|
5
|
+
VERSION = '9'
|
6
|
+
DATE = '2011-01-22'
|
7
7
|
|
8
8
|
# cube list
|
9
9
|
PACKAGES = {
|
10
10
|
:control => %w|egonil iterate tap sandbox kernel|,
|
11
11
|
:env => %w|engine info os version|,
|
12
|
-
:extensions => %w|array enumerable hash string unary union|,
|
12
|
+
:extensions => %w|array enumerable file hash string unary union|,
|
13
13
|
:object => %w|blank mcopy not|,
|
14
|
-
:to_proc => %w|
|
14
|
+
:to_proc => %w|array_to_proc class_to_proc hash_to_proc regexp_to_proc|,
|
15
15
|
:shortcuts => %w|aliases alias_for square_brackets_for ivars|,
|
16
|
-
:debug => %w|binding cc dd mm oo qq|,
|
16
|
+
:debug => %w|binding cc dd mm oo qq regexp_visualize|,
|
17
17
|
}
|
18
18
|
|
19
|
-
NON_1_8_CUBES = %w|not
|
19
|
+
NON_1_8_CUBES = %w|not|
|
20
20
|
|
21
21
|
class << self
|
22
22
|
# Zucker require helpers
|
@@ -50,7 +50,7 @@ module Zucker
|
|
50
50
|
}.compact
|
51
51
|
end
|
52
52
|
|
53
|
-
# these aliases 'pollute' the global namespace or may conflict with other
|
53
|
+
# these aliases 'pollute' the global namespace or may conflict with other code
|
54
54
|
def activate_more_aliases!
|
55
55
|
aliases = {
|
56
56
|
:mcopy => :copy,
|
@@ -62,18 +62,19 @@ module Zucker
|
|
62
62
|
}
|
63
63
|
|
64
64
|
loaded_aliases = []
|
65
|
+
|
65
66
|
aliases.each{ |old, new|
|
66
67
|
Object.class_eval "alias #{new} #{old}; loaded_aliases << :#{new}" rescue nil
|
67
68
|
}
|
68
69
|
|
69
70
|
#eval "::RV = RubyVersion; loaded_aliases << :RV" rescue nil
|
70
71
|
(
|
71
|
-
Object.const_set '
|
72
|
+
Object.const_set 'RV', RubyVersion
|
72
73
|
loaded_aliases << :RV
|
73
74
|
) rescue nil
|
74
75
|
#eval "::RE = RubyEngine; loaded_aliases << :RE" rescue nil
|
75
76
|
(
|
76
|
-
Object.const_set '
|
77
|
+
Object.const_set 'RE', RubyEngine
|
77
78
|
loaded_aliases << :RE
|
78
79
|
) rescue nil
|
79
80
|
|
data/lib/zucker/array2proc.rb
CHANGED
@@ -1,18 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Array
|
4
|
-
def to_proc
|
5
|
-
Proc.new{ |obj|
|
6
|
-
if self.first.is_a? Array
|
7
|
-
self.inject(obj){ |result, nested_array|
|
8
|
-
nested_array.to_proc.call result
|
9
|
-
}
|
10
|
-
else
|
11
|
-
obj.send *self
|
12
|
-
end
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# J-_-L
|
18
|
-
|
1
|
+
warn 'Zucker: array2proc has been renamed. Please use array_to_proc!'
|
2
|
+
require 'zucker/array_to_proc'
|
File without changes
|
data/lib/zucker/binding.rb
CHANGED
@@ -7,17 +7,16 @@ class Binding
|
|
7
7
|
' - none'
|
8
8
|
else
|
9
9
|
array.map{|e|
|
10
|
-
val = self.eval "#{e}"
|
11
|
-
val = val.is_a?( Binding ) ? val.to_s : val.inspect
|
10
|
+
val = (self.eval "#{e}").inspect
|
12
11
|
" - #{e}: #{ val }"
|
13
12
|
}.join "\n"
|
14
13
|
end
|
15
14
|
}
|
16
15
|
|
17
|
-
"#{self.to_s}
|
18
|
-
local
|
16
|
+
puts "#{self.to_s}
|
17
|
+
local variables
|
19
18
|
#{ put_vars[ self.eval 'local_variables' ] }
|
20
|
-
(instance
|
19
|
+
(instance variables)
|
21
20
|
#{ put_vars[ self.eval 'instance_variables' ] }
|
22
21
|
self
|
23
22
|
- #{self.eval 'self'}
|
data/lib/zucker/cc.rb
CHANGED
@@ -9,14 +9,19 @@ module Kernel
|
|
9
9
|
$2
|
10
10
|
}.compact
|
11
11
|
|
12
|
-
if !show_irb
|
13
|
-
|
12
|
+
if !show_irb
|
13
|
+
if a = method_stack.index( 'irb_binding' )
|
14
|
+
method_stack = [ method_stack[0], '(irb)', *method_stack[a+1..-1] ]
|
15
|
+
elsif a = method_stack[1..-1].index( '<main>' )
|
16
|
+
method_stack = [ method_stack[0], '(ripl)', *method_stack[a+2..-1] ]
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
# puts method_stack.map.with_index{ |m, i|
|
17
21
|
method_stack.each_with_index{ |m, i|
|
18
22
|
puts " "*i + m
|
19
23
|
}
|
24
|
+
nil
|
20
25
|
end
|
21
26
|
|
22
27
|
alias cc c
|
data/lib/zucker/class2proc.rb
CHANGED
File without changes
|
data/lib/zucker/file.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class << File
|
2
|
+
def gsub(filename, regex_hash)
|
3
|
+
data = File.read filename
|
4
|
+
File.open(filename,'w'){ |file|
|
5
|
+
regex_hash.each{ |regex, new_string|
|
6
|
+
regex = regex.to_s unless regex.is_a? Regexp
|
7
|
+
|
8
|
+
if new_string.is_a? Proc
|
9
|
+
data.gsub! regex, &new_string
|
10
|
+
else
|
11
|
+
data.gsub! regex, new_string
|
12
|
+
end
|
13
|
+
}
|
14
|
+
file.print data
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete! filename
|
19
|
+
return nil if !File.exist?(filename)
|
20
|
+
File.delete filename
|
21
|
+
end
|
22
|
+
end
|
data/lib/zucker/hash2proc.rb
CHANGED
@@ -1,16 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Hash
|
4
|
-
def to_proc
|
5
|
-
Proc.new{ |obj|
|
6
|
-
if self.member? obj
|
7
|
-
self[obj].to_proc.call obj
|
8
|
-
else
|
9
|
-
obj
|
10
|
-
end
|
11
|
-
}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# J-_-L
|
16
|
-
|
1
|
+
warn 'Zucker: hash2proc has been renamed. Please use hash_to_proc!'
|
2
|
+
require 'zucker/hash_to_proc'
|
File without changes
|
data/lib/zucker/kernel.rb
CHANGED
@@ -21,13 +21,15 @@ module Kernel
|
|
21
21
|
$PROGRAM_NAME == $` # __FILE__
|
22
22
|
end
|
23
23
|
alias standalone? executed_directly?
|
24
|
+
alias directly_executed? executed_directly?
|
24
25
|
|
25
26
|
def irb?
|
26
|
-
|
27
|
+
(defined?(IRB) && $0 =~ /irb/) || (defined?(Ripl) && $0 =~ /ripl/)
|
27
28
|
end
|
28
29
|
|
29
30
|
def ignore_sigint! # ctrl+c
|
30
|
-
|
31
|
+
Signal.trap *%w|SIGINT IGNORE|
|
32
|
+
true
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
data/lib/zucker/mm.rb
CHANGED
@@ -2,28 +2,34 @@ require 'zucker'
|
|
2
2
|
|
3
3
|
module Kernel
|
4
4
|
def m(levels = 1)
|
5
|
+
# output helper
|
6
|
+
mputs = proc{ |e| puts e.map(&:to_s)*' ' }
|
7
|
+
|
8
|
+
# how to get results
|
5
9
|
if self.is_a? Module
|
6
10
|
klass, method_function = self, :public_methods
|
7
11
|
else
|
8
12
|
klass, method_function = self.class, :public_instance_methods
|
13
|
+
end
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
# eigenclass
|
16
|
+
eigen = self.singleton_methods
|
17
|
+
if !eigen.empty?
|
18
|
+
puts '= Eigenclass' # sorry for not being up to date, I just love the word
|
19
|
+
mputs[ self.singleton_methods ]
|
15
20
|
end
|
16
21
|
|
22
|
+
# display
|
17
23
|
levels.times{ |level|
|
18
24
|
if cur = klass.ancestors[level]
|
19
|
-
|
20
|
-
|
25
|
+
puts "= #{cur}" # put class name
|
26
|
+
mputs[ cur.send method_function, false ] # put methods of the class
|
21
27
|
else
|
22
28
|
break
|
23
29
|
end
|
24
30
|
}
|
25
31
|
|
26
|
-
|
32
|
+
nil
|
27
33
|
end
|
28
34
|
|
29
35
|
alias mm m
|
data/lib/zucker/regexp2proc.rb
CHANGED
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Regexp
|
2
|
+
def visualize(string, groups = nil)
|
3
|
+
if self =~ string
|
4
|
+
if !groups
|
5
|
+
puts $` + ' >' + $& + '< ' + $'
|
6
|
+
else
|
7
|
+
Array( groups ).each{ |group|
|
8
|
+
begin
|
9
|
+
gr_string = string.dup
|
10
|
+
gr_string[ $~.end( group ), 0 ] = '< '
|
11
|
+
gr_string[ $~.begin( group ), 0 ] = ' >'
|
12
|
+
puts group.to_s + ': ' + gr_string
|
13
|
+
rescue IndexError
|
14
|
+
puts group.to_s + ': no match'
|
15
|
+
end
|
16
|
+
}
|
17
|
+
end
|
18
|
+
else
|
19
|
+
puts 'no match'
|
20
|
+
end
|
21
|
+
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
alias vis visualize
|
26
|
+
end
|
data/lib/zucker/sandbox.rb
CHANGED
@@ -3,21 +3,11 @@ require 'zucker'
|
|
3
3
|
module Kernel
|
4
4
|
private
|
5
5
|
|
6
|
-
def sandbox
|
6
|
+
def sandbox
|
7
7
|
Thread.start do
|
8
8
|
$SAFE = 4
|
9
9
|
yield
|
10
10
|
end.value
|
11
|
-
rescue SecurityError => e
|
12
|
-
if !rescueblock_or_default.nil?
|
13
|
-
if rescueblock_or_default.is_a? Proc
|
14
|
-
rescueblock_or_default.call e
|
15
|
-
else
|
16
|
-
rescueblock_or_default
|
17
|
-
end
|
18
|
-
else
|
19
|
-
raise e
|
20
|
-
end
|
21
11
|
end
|
22
12
|
end
|
23
13
|
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'zucker/alias_for'
|
2
|
+
|
3
|
+
describe 'alias_for' do
|
4
|
+
it 'should create an alias for global methods' do
|
5
|
+
# rspec bug?
|
6
|
+
# def m1
|
7
|
+
# 1
|
8
|
+
# end
|
9
|
+
# alias_for :m1, :a1
|
10
|
+
#
|
11
|
+
# proc do
|
12
|
+
# a1.should == 1
|
13
|
+
# end.should_not raise_exception
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should create an alias for instance methods' do
|
17
|
+
class Array
|
18
|
+
def m2
|
19
|
+
2
|
20
|
+
end
|
21
|
+
alias_for :m2, :a2
|
22
|
+
end
|
23
|
+
proc do
|
24
|
+
|
25
|
+
[1,2,3].a2.should == 2
|
26
|
+
end.should_not raise_exception
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should create an alias for class (singleton) methods' do
|
30
|
+
class Array
|
31
|
+
class << Array
|
32
|
+
def m3
|
33
|
+
3
|
34
|
+
end
|
35
|
+
alias_for :m3, :a3
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
proc do
|
40
|
+
Array.a3.should == 3
|
41
|
+
end.should_not raise_exception
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
it 'should create aliases for the first argument with all other arguments' do
|
46
|
+
class Object
|
47
|
+
def m4
|
48
|
+
4
|
49
|
+
end
|
50
|
+
alias_for :m4, :ma, :mb, :mc
|
51
|
+
end
|
52
|
+
proc do
|
53
|
+
1.ma.should == 4
|
54
|
+
"1".mb.should == 4
|
55
|
+
[1].mc.should == 4
|
56
|
+
end.should_not raise_exception
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# alias_method
|
61
|
+
module Blip
|
62
|
+
def blip
|
63
|
+
'blip'
|
64
|
+
end
|
65
|
+
alias_methods_for :blip, :blap, :blup
|
66
|
+
|
67
|
+
class << self
|
68
|
+
def self_blip
|
69
|
+
'blip'
|
70
|
+
end
|
71
|
+
alias_methods_for :self_blip, :self_blap, :self_blup
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class Hello
|
76
|
+
include Blip
|
77
|
+
|
78
|
+
def hello
|
79
|
+
'hello'
|
80
|
+
end
|
81
|
+
alias_methods_for :hello, :hi, :howdy
|
82
|
+
|
83
|
+
class << self
|
84
|
+
def self_hello
|
85
|
+
'hello'
|
86
|
+
end
|
87
|
+
alias_methods_for :self_hello, :self_hi, :self_howdy
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'alias_methods_for' do
|
92
|
+
let(:h) { Hello.new }
|
93
|
+
|
94
|
+
context "module context" do
|
95
|
+
it "should alias instance methods" do
|
96
|
+
h.blap.should == h.blip
|
97
|
+
h.blup.should == h.blip
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should alias class methods" do
|
101
|
+
Blip.self_blap.should == Blip.self_blip
|
102
|
+
Blip.self_blup.should == Blip.self_blip
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "class context" do
|
107
|
+
it "should alias instance methods" do
|
108
|
+
h.hi.should == h.hello
|
109
|
+
h.howdy.should == h.hello
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should alias class methods" do
|
113
|
+
Hello.self_hi.should == Hello.self_hello
|
114
|
+
Hello.self_howdy.should == Hello.self_hello
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|