zucker 10 → 11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/Rakefile +2 -2
- data/desc/binding.yaml +2 -2
- data/desc/kernel.yaml +2 -1
- data/desc/string.yaml +2 -2
- data/doc/zucker_doc.html +107 -42
- data/lib/zucker.rb +5 -5
- data/lib/zucker/alias_for.rb +1 -0
- data/lib/zucker/aliases.rb +1 -0
- data/lib/zucker/array.rb +1 -0
- data/lib/zucker/array_to_proc.rb +2 -1
- data/lib/zucker/binding.rb +18 -15
- data/lib/zucker/blank.rb +1 -0
- data/lib/zucker/cc.rb +1 -0
- data/lib/zucker/class_to_proc.rb +2 -1
- data/lib/zucker/dd.rb +1 -0
- data/lib/zucker/egonil.rb +1 -0
- data/lib/zucker/engine.rb +1 -0
- data/lib/zucker/enumerable.rb +2 -1
- data/lib/zucker/file.rb +6 -0
- data/lib/zucker/hash.rb +1 -0
- data/lib/zucker/hash_to_proc.rb +1 -0
- data/lib/zucker/info.rb +1 -0
- data/lib/zucker/iterate.rb +3 -2
- data/lib/zucker/ivars.rb +1 -0
- data/lib/zucker/kernel.rb +7 -1
- data/lib/zucker/mcopy.rb +1 -0
- data/lib/zucker/mm.rb +1 -0
- data/lib/zucker/not.rb +1 -0
- data/lib/zucker/oo.rb +1 -0
- data/lib/zucker/os.rb +1 -0
- data/lib/zucker/qq.rb +1 -0
- data/lib/zucker/regexp_to_proc.rb +1 -0
- data/lib/zucker/regexp_visualize.rb +6 -1
- data/lib/zucker/sandbox.rb +2 -0
- data/lib/zucker/square_brackets_for.rb +1 -0
- data/lib/zucker/string.rb +1 -0
- data/lib/zucker/tap.rb +3 -2
- data/lib/zucker/unary.rb +1 -0
- data/lib/zucker/union.rb +1 -0
- data/lib/zucker/version.rb +1 -0
- data/spec/kernel_spec.rb +6 -1
- data/spec/regexp_visualize_spec.rb +1 -1
- data/spec/sandbox_spec.rb +1 -1
- data/spec/version_spec.rb +2 -2
- data/zucker.gemspec +12 -3
- metadata +6 -6
data/lib/zucker.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Zucker
|
4
4
|
# version and date get modified by the :prepare_release rake task
|
5
|
-
VERSION = '
|
6
|
-
DATE = '2011-
|
5
|
+
VERSION = '11'
|
6
|
+
DATE = '2011-05-25'
|
7
7
|
|
8
8
|
# cube list
|
9
9
|
PACKAGES = {
|
@@ -22,7 +22,7 @@ module Zucker
|
|
22
22
|
# Zucker require helpers
|
23
23
|
def require_cube(cube, version = '')
|
24
24
|
unless RUBY_VERSION < '1.9' && Zucker::NON_1_8_CUBES.include?(cube)
|
25
|
-
require File.expand_path( File.join('..', 'zucker', version, cube), __FILE__)
|
25
|
+
require ::File.expand_path( ::File.join('..', 'zucker', version, cube), __FILE__)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -33,9 +33,9 @@ module Zucker
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def require_this(filename)
|
36
|
-
version= File.split( File.expand_path( filename) )[-2]
|
36
|
+
version= ::File.split( ::File.expand_path( filename) )[-2]
|
37
37
|
version = '' if version !~ /^\d+$/
|
38
|
-
package = File.basename( filename ).chomp( File.extname( filename ))
|
38
|
+
package = ::File.basename( filename ).chomp( ::File.extname( filename ))
|
39
39
|
Zucker.require_package(package, version)
|
40
40
|
end
|
41
41
|
|
data/lib/zucker/alias_for.rb
CHANGED
data/lib/zucker/aliases.rb
CHANGED
data/lib/zucker/array.rb
CHANGED
data/lib/zucker/array_to_proc.rb
CHANGED
data/lib/zucker/binding.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
require 'zucker'
|
2
|
+
module Zucker Binding = true end
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
5
|
+
class Binding
|
6
|
+
def variables
|
7
|
+
put_vars = lambda { |array|
|
8
|
+
if array.empty?
|
9
|
+
' - none'
|
10
|
+
else
|
11
|
+
array.map{|e|
|
12
|
+
val = (self.eval "#{e}").inspect
|
13
|
+
" - #{e}: #{ val }"
|
14
|
+
}.join "\n"
|
15
|
+
end
|
16
|
+
}
|
15
17
|
|
16
|
-
|
18
|
+
puts "#{self.to_s}
|
17
19
|
local variables
|
18
20
|
#{ put_vars[ self.eval 'local_variables' ] }
|
19
21
|
(instance variables)
|
@@ -23,9 +25,10 @@ self
|
|
23
25
|
block_given?
|
24
26
|
- #{self.eval 'block_given?'}"
|
25
27
|
|
26
|
-
|
28
|
+
end
|
27
29
|
|
28
|
-
|
30
|
+
alias vars variables
|
31
|
+
end
|
29
32
|
end
|
30
33
|
|
31
34
|
# J-_-L
|
data/lib/zucker/blank.rb
CHANGED
data/lib/zucker/cc.rb
CHANGED
data/lib/zucker/class_to_proc.rb
CHANGED
data/lib/zucker/dd.rb
CHANGED
data/lib/zucker/egonil.rb
CHANGED
data/lib/zucker/engine.rb
CHANGED
data/lib/zucker/enumerable.rb
CHANGED
data/lib/zucker/file.rb
CHANGED
data/lib/zucker/hash.rb
CHANGED
data/lib/zucker/hash_to_proc.rb
CHANGED
data/lib/zucker/info.rb
CHANGED
data/lib/zucker/iterate.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'zucker'
|
2
|
+
module Zucker Iterate = true end
|
2
3
|
|
3
4
|
def iterate(*params)
|
4
5
|
# params.shift.zip(*params).each{ |*elements| yield *elements }
|
@@ -14,9 +15,9 @@ def iterate(*params)
|
|
14
15
|
else # multiple params
|
15
16
|
max_size = [first, *params].max_by(&:count).size
|
16
17
|
padded_first = first.to_a + [nil]*(max_size - first.count) # append nils
|
17
|
-
obj = padded_first.zip
|
18
|
+
obj = padded_first.zip(*params)
|
18
19
|
if block_given?
|
19
|
-
obj.map{|es| yield
|
20
|
+
obj.map{|es| yield(*es) }
|
20
21
|
else
|
21
22
|
obj.map.to_enum
|
22
23
|
end
|
data/lib/zucker/ivars.rb
CHANGED
data/lib/zucker/kernel.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'zucker'
|
2
|
+
module Zucker Kernel = true end
|
2
3
|
|
3
4
|
module Kernel
|
4
5
|
private
|
@@ -28,7 +29,12 @@ module Kernel
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def ignore_sigint! # ctrl+c
|
31
|
-
Signal.trap
|
32
|
+
Signal.trap(*%w|SIGINT IGNORE|)
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def ignore_sigquit! # ctrl+\
|
37
|
+
Signal.trap(*%w|SIGQUIT IGNORE|)
|
32
38
|
true
|
33
39
|
end
|
34
40
|
end
|
data/lib/zucker/mcopy.rb
CHANGED
data/lib/zucker/mm.rb
CHANGED
data/lib/zucker/not.rb
CHANGED
data/lib/zucker/oo.rb
CHANGED
data/lib/zucker/os.rb
CHANGED
data/lib/zucker/qq.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
module Zucker RegexpVisualize = true end
|
3
|
+
|
1
4
|
class Regexp
|
2
5
|
def visualize(string, groups = nil)
|
3
6
|
if self =~ string
|
@@ -10,7 +13,7 @@ class Regexp
|
|
10
13
|
gr_string[ $~.end( group ), 0 ] = '< '
|
11
14
|
gr_string[ $~.begin( group ), 0 ] = ' >'
|
12
15
|
puts group.to_s + ': ' + gr_string
|
13
|
-
rescue IndexError
|
16
|
+
rescue IndexError, defined?(Rubinius) && Rubinius::ObjectBoundsExceededError
|
14
17
|
puts group.to_s + ': no match'
|
15
18
|
end
|
16
19
|
}
|
@@ -24,3 +27,5 @@ class Regexp
|
|
24
27
|
|
25
28
|
alias vis visualize
|
26
29
|
end
|
30
|
+
|
31
|
+
# J-_-L
|
data/lib/zucker/sandbox.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'zucker'
|
2
|
+
module Zucker Sandbox = true end
|
2
3
|
|
3
4
|
module Kernel
|
4
5
|
private
|
5
6
|
|
6
7
|
def sandbox
|
8
|
+
warn "zucker: sandbox does not work in rbx and jruby" if defined?(RUBY_ENGINE) && ( RUBY_ENGINE == 'jruby' || RUBY_ENGINE == 'rbx' )
|
7
9
|
Thread.start do
|
8
10
|
$SAFE = 4
|
9
11
|
yield
|
data/lib/zucker/string.rb
CHANGED
data/lib/zucker/tap.rb
CHANGED
data/lib/zucker/unary.rb
CHANGED
data/lib/zucker/union.rb
CHANGED
data/lib/zucker/version.rb
CHANGED
data/spec/kernel_spec.rb
CHANGED
@@ -27,11 +27,16 @@ describe 'executed_directly?' do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe 'irb?' do
|
30
|
-
it 'should return true if called in IRB' do; end
|
30
|
+
it 'should return true if called in IRB or RIPL' do; end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'ignore_sigint!' do
|
34
34
|
it 'should catch ctrl+c signals' do; end
|
35
35
|
end
|
36
36
|
|
37
|
+
describe 'ignore_sigquit!' do
|
38
|
+
it 'should catch ctrl+\ signals' do; end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
37
42
|
# J-_-L
|
@@ -21,7 +21,7 @@ describe 'Regexp#visualize' do
|
|
21
21
|
end.chomp.should == '1: >mail< @example.com'
|
22
22
|
end
|
23
23
|
|
24
|
-
it 'should display "group identifier: no match" the arg2 group could not be matched' do
|
24
|
+
it 'should display "group identifier: no match" if the arg2 group could not be matched' do
|
25
25
|
capture_stdout do
|
26
26
|
regex.vis 'mail@example.com', 3
|
27
27
|
end.chomp.should == '3: no match'
|
data/spec/sandbox_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'zucker/sandbox'
|
2
2
|
|
3
3
|
describe 'sandbox' do
|
4
|
-
unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
4
|
+
unless defined?(RUBY_ENGINE) && ( RUBY_ENGINE == 'jruby' || RUBY_ENGINE == 'rbx' )
|
5
5
|
it 'should throw a SecurityError if bad commands are issued' do
|
6
6
|
proc do
|
7
7
|
sandbox do
|