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/6/sandbox.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'zucker'
|
2
|
-
|
3
|
-
module Kernel
|
4
|
-
private
|
5
|
-
|
6
|
-
def sandbox(rescueblock_or_default=nil)
|
7
|
-
Thread.start do
|
8
|
-
$SAFE = 4
|
9
|
-
yield
|
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
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# J-_-L
|
25
|
-
|
data/lib/zucker/6/shortcuts.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'zucker'
|
2
|
-
|
3
|
-
class Module
|
4
|
-
def square_brackets_for(ivar, assignment = true)
|
5
|
-
# undef [] if respond_to? :[]
|
6
|
-
# undef []= if respond_to? :[]=
|
7
|
-
|
8
|
-
define_method :[] do |key|
|
9
|
-
(instance_variable_get :"@#{ivar}")[key]
|
10
|
-
end
|
11
|
-
|
12
|
-
if assignment
|
13
|
-
define_method :[]= do |key, value|
|
14
|
-
(instance_variable_get :"@#{ivar}")[key] = value
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# J-_-L
|
21
|
-
|
data/lib/zucker/6/string.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'zucker'
|
2
|
-
|
3
|
-
class String
|
4
|
-
def -(rem)
|
5
|
-
gsub( Regexp === rem ? rem : rem.to_s, '' )
|
6
|
-
end
|
7
|
-
|
8
|
-
def ^(pos)
|
9
|
-
pos = pos.to_i
|
10
|
-
if pos >= 0
|
11
|
-
self[pos..-1]
|
12
|
-
else
|
13
|
-
self[0...pos]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def lchomp(arg = $/)
|
18
|
-
reverse.chomp(arg).reverse
|
19
|
-
end
|
20
|
-
|
21
|
-
def lchomp!(arg = $/)
|
22
|
-
reverse.chomp!(arg).reverse
|
23
|
-
end
|
24
|
-
|
25
|
-
def ords
|
26
|
-
unpack 'C*'
|
27
|
-
# bytes.to_a
|
28
|
-
end
|
29
|
-
|
30
|
-
def constantize(default_value = nil) # always uses global scope as in AS... is this good?
|
31
|
-
get_constant = lambda{
|
32
|
-
self.split(/::/).inject( Object ){ |base_constant, current_constant|
|
33
|
-
base_constant.const_get current_constant
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
if !default_value && !block_given?
|
38
|
-
get_constant.call
|
39
|
-
else
|
40
|
-
begin
|
41
|
-
get_constant.call
|
42
|
-
rescue NameError
|
43
|
-
if block_given?
|
44
|
-
yield self
|
45
|
-
else
|
46
|
-
default_value
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# J-_-L
|
54
|
-
|
data/lib/zucker/6/tap.rb
DELETED
data/lib/zucker/6/to_proc.rb
DELETED
data/lib/zucker/6/unary.rb
DELETED
data/lib/zucker/6/union.rb
DELETED
data/lib/zucker/6/version.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'zucker'
|
2
|
-
require 'date'
|
3
|
-
require 'time'
|
4
|
-
|
5
|
-
module RubyVersion
|
6
|
-
class << self
|
7
|
-
def to_s
|
8
|
-
RUBY_VERSION
|
9
|
-
end
|
10
|
-
|
11
|
-
# comparable
|
12
|
-
def <=>(other)
|
13
|
-
value = case other
|
14
|
-
when Integer
|
15
|
-
RUBY_VERSION.to_i
|
16
|
-
when Float
|
17
|
-
RUBY_VERSION.to_f
|
18
|
-
when String
|
19
|
-
RUBY_VERSION
|
20
|
-
when Date, Time
|
21
|
-
other.class.parse(RUBY_RELEASE_DATE)
|
22
|
-
else
|
23
|
-
other = other.to_s
|
24
|
-
RUBY_VERSION
|
25
|
-
end
|
26
|
-
value <=> other
|
27
|
-
end
|
28
|
-
include Comparable
|
29
|
-
|
30
|
-
# chaining for dsl-like language
|
31
|
-
def is?(other = nil)
|
32
|
-
if other
|
33
|
-
RubyVersion == other
|
34
|
-
else
|
35
|
-
RubyVersion
|
36
|
-
end
|
37
|
-
end
|
38
|
-
alias is is?
|
39
|
-
|
40
|
-
# aliases
|
41
|
-
alias below <
|
42
|
-
alias below? <
|
43
|
-
alias at_most <=
|
44
|
-
alias at_most? <=
|
45
|
-
alias above >
|
46
|
-
alias above? >
|
47
|
-
alias at_least >=
|
48
|
-
alias at_least? >=
|
49
|
-
alias exactly ==
|
50
|
-
alias exactly? ==
|
51
|
-
def not(other)
|
52
|
-
self != other
|
53
|
-
end
|
54
|
-
alias not? not
|
55
|
-
alias between between?
|
56
|
-
|
57
|
-
# compare dates
|
58
|
-
def newer_than(other)
|
59
|
-
if other.is_a? Date or other.is_a? Time
|
60
|
-
RubyVersion > other
|
61
|
-
else
|
62
|
-
RUBY_RELEASE_DATE > other.to_s
|
63
|
-
end
|
64
|
-
end
|
65
|
-
alias newer_than? newer_than
|
66
|
-
|
67
|
-
def older_than(other)
|
68
|
-
if other.is_a? Date or other.is_a? Time
|
69
|
-
RubyVersion < other
|
70
|
-
else
|
71
|
-
RUBY_RELEASE_DATE < other.to_s
|
72
|
-
end
|
73
|
-
end
|
74
|
-
alias older_than? older_than
|
75
|
-
|
76
|
-
def released_today
|
77
|
-
RubyVersion.date == Date.today
|
78
|
-
end
|
79
|
-
alias released_today? released_today
|
80
|
-
|
81
|
-
# accessors
|
82
|
-
|
83
|
-
def major
|
84
|
-
RUBY_VERSION.to_i
|
85
|
-
end
|
86
|
-
alias main major
|
87
|
-
|
88
|
-
def minor
|
89
|
-
RUBY_VERSION.split('.')[1].to_i
|
90
|
-
end
|
91
|
-
alias mini minor
|
92
|
-
|
93
|
-
def tiny
|
94
|
-
RUBY_VERSION.split('.')[2].to_i
|
95
|
-
end
|
96
|
-
|
97
|
-
alias teeny tiny
|
98
|
-
|
99
|
-
def patchlevel
|
100
|
-
RUBY_PATCHLEVEL
|
101
|
-
end
|
102
|
-
|
103
|
-
def platform
|
104
|
-
RUBY_PLATFORM
|
105
|
-
end
|
106
|
-
|
107
|
-
def release_date
|
108
|
-
Date.parse RUBY_RELEASE_DATE
|
109
|
-
end
|
110
|
-
alias date release_date
|
111
|
-
|
112
|
-
def description
|
113
|
-
RUBY_DESCRIPTION
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
# J-_-L
|
data/lib/zucker/7/alias_for.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'zucker'
|
2
|
-
|
3
|
-
def alias_for(m, *aliases)
|
4
|
-
aliases.each{ |a|
|
5
|
-
class_eval "alias #{a} #{m}"
|
6
|
-
}
|
7
|
-
end
|
8
|
-
alias aliases_for alias_for
|
9
|
-
|
10
|
-
class Module
|
11
|
-
def alias_method_for(m, *alias_methods)
|
12
|
-
alias_methods.each{ |a|
|
13
|
-
class_eval do
|
14
|
-
alias_method a.to_sym, m.to_sym
|
15
|
-
end
|
16
|
-
}
|
17
|
-
end
|
18
|
-
alias alias_methods_for alias_method_for
|
19
|
-
end
|
20
|
-
|
21
|
-
# J-_-L
|
data/lib/zucker/7/aliases.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'zucker'
|
2
|
-
|
3
|
-
class Object
|
4
|
-
alias is_an? is_a? # thanks to utility_belt
|
5
|
-
end
|
6
|
-
|
7
|
-
module Enumerable
|
8
|
-
alias with zip
|
9
|
-
alias % zip
|
10
|
-
end
|
11
|
-
|
12
|
-
class Array
|
13
|
-
alias ** product
|
14
|
-
alias contains? include?
|
15
|
-
end
|
16
|
-
|
17
|
-
class String
|
18
|
-
alias contains? include?
|
19
|
-
end
|
20
|
-
|
21
|
-
class Hash
|
22
|
-
alias + merge
|
23
|
-
end
|
24
|
-
|
25
|
-
class Binding
|
26
|
-
#alias [] eval
|
27
|
-
def [](expr)
|
28
|
-
self.eval "#{expr}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class << File
|
33
|
-
alias filename basename # thanks rdp :)
|
34
|
-
end
|
35
|
-
|
36
|
-
class << Dir
|
37
|
-
def join(*args)
|
38
|
-
File.join(*args)
|
39
|
-
end
|
40
|
-
|
41
|
-
def split(*args)
|
42
|
-
File.split(*args)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# constants - who would use these in real-world code for other things?
|
47
|
-
Infinity = 1.0 / 0.0 # or 2*Float::MAX or Float::INFINITY
|
48
|
-
NaN = 0.0 / 0.0
|
49
|
-
|
50
|
-
# J-_-L
|
51
|
-
|
data/lib/zucker/7/all.rb
DELETED
data/lib/zucker/7/array.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'zucker'
|
2
|
-
|
3
|
-
class Array
|
4
|
-
def ^(other) # TODO: more efficient
|
5
|
-
(self - other) +
|
6
|
-
(other - self)
|
7
|
-
end
|
8
|
-
|
9
|
-
# can take an argument & block to be Rails compatible
|
10
|
-
def sum(identity = 0, &block)
|
11
|
-
# inject(:+)
|
12
|
-
if block_given?
|
13
|
-
map(&block).sum( identity )
|
14
|
-
else
|
15
|
-
inject(:+) || identity
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def chrs
|
20
|
-
self.pack 'C*'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# J-_-L
|
25
|
-
|
data/lib/zucker/7/array2proc.rb
DELETED
data/lib/zucker/7/binding.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'zucker'
|
2
|
-
|
3
|
-
class Binding
|
4
|
-
def inspect
|
5
|
-
put_vars = lambda { |array|
|
6
|
-
if array.empty?
|
7
|
-
' - none'
|
8
|
-
else
|
9
|
-
array.map{|e|
|
10
|
-
val = self.eval "#{e}"
|
11
|
-
val = val.is_a?( Binding ) ? val.to_s : val.inspect
|
12
|
-
" - #{e}: #{ val }"
|
13
|
-
}.join "\n"
|
14
|
-
end
|
15
|
-
}
|
16
|
-
|
17
|
-
"#{self.to_s}
|
18
|
-
local vars
|
19
|
-
#{ put_vars[ self.eval 'local_variables' ] }
|
20
|
-
(instance vars)
|
21
|
-
#{ put_vars[ self.eval 'instance_variables' ] }
|
22
|
-
self
|
23
|
-
- #{self.eval 'self'}
|
24
|
-
block_given?
|
25
|
-
- #{self.eval 'block_given?'}"
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
alias v binding
|
31
|
-
alias vv binding
|
32
|
-
|
33
|
-
# J-_-L
|
34
|
-
|