davidrichards-sirb 0.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +227 -0
- data/VERSION.yml +4 -0
- data/bin/sirb +33 -0
- data/lib/overrides/array.rb +6 -0
- data/lib/overrides/file.rb +17 -0
- data/lib/overrides/module.rb +70 -0
- data/lib/overrides/symbol.rb +39 -0
- data/lib/sirb/enumerable_statistics.rb +350 -0
- data/lib/sirb/functional.rb +114 -0
- data/lib/sirb/general_statistics.rb +72 -0
- data/lib/sirb/inter_enumerable_statistics.rb +139 -0
- data/lib/sirb/lib_loader.rb +45 -0
- data/lib/sirb/runner.rb +274 -0
- data/lib/sirb/sproc/proc.rb +5 -0
- data/lib/sirb/sproc/proc_source.rb +130 -0
- data/lib/sirb/sproc/sproc.rb +79 -0
- data/lib/sirb/sproc/usage_notes.txt +25 -0
- data/lib/sirb/sproc.rb +29 -0
- data/lib/sirb/thread_support.rb +20 -0
- data/lib/sirb/unbound_method.rb +5 -0
- data/lib/sirb.rb +52 -0
- data/lib/stored_procedures.rb +10 -0
- data/spec/lib/overrides/array_spec.rb +7 -0
- data/spec/lib/overrides/file_spec.rb +13 -0
- data/spec/lib/overrides/module_spec.rb +86 -0
- data/spec/lib/overrides/symbol_spec.rb +39 -0
- data/spec/lib/sirb/enumerable_statistics_spec.rb +85 -0
- data/spec/lib/sirb/functional_spec.rb +75 -0
- data/spec/lib/sirb/general_statistics_spec.rb +40 -0
- data/spec/lib/sirb/inter_enumerable_statistics_spec.rb +55 -0
- data/spec/lib/sirb/lib_loader_spec.rb +39 -0
- data/spec/lib/sirb/runner_spec.rb +9 -0
- data/spec/lib/sirb/sproc/proc_spec.rb +9 -0
- data/spec/lib/sirb/sproc/sproc_spec.rb +25 -0
- data/spec/lib/sirb/unbound_method_spec.rb +12 -0
- data/spec/lib/sirb_spec.rb +9 -0
- data/spec/spec_helper.rb +15 -0
- metadata +97 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
describe File do
|
4
|
+
it "should have a mkdir_p method, that only creates a directory if it's missing" do
|
5
|
+
file = "/tmp/" + (1..3).map {|x| rand(100).to_s}.join("_")
|
6
|
+
File.should_not be_exist(file)
|
7
|
+
File.mkdir_p(file)
|
8
|
+
File.should be_exist(file)
|
9
|
+
File.should be_directory(file)
|
10
|
+
`rm -rf #{file}` # File.unlink wants other permissions, not bothering with that.
|
11
|
+
File.should_not be_exist(file)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Module do
|
4
|
+
it "should have alias_method_chain" do
|
5
|
+
class A
|
6
|
+
def go
|
7
|
+
'go'
|
8
|
+
end
|
9
|
+
def go_with_flair
|
10
|
+
go_without_flair + " flair"
|
11
|
+
end
|
12
|
+
alias_method_chain :go, :flair
|
13
|
+
end
|
14
|
+
a = A.new
|
15
|
+
a.go.should eql('go flair')
|
16
|
+
a.go_without_flair.should eql('go')
|
17
|
+
Object.send(:remove_const, :A)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have archive_method" do
|
21
|
+
class A
|
22
|
+
archive_method(:go)
|
23
|
+
end
|
24
|
+
a = A.new
|
25
|
+
a.methods.should_not be_include('go')
|
26
|
+
a.methods.should_not be_include('original_go')
|
27
|
+
|
28
|
+
class A
|
29
|
+
def go
|
30
|
+
'go'
|
31
|
+
end
|
32
|
+
archive_method(:go)
|
33
|
+
def go
|
34
|
+
'a new go'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
a = A.new
|
38
|
+
a.methods.should be_include('go')
|
39
|
+
a.methods.should be_include('original_go')
|
40
|
+
a.go.should eql('a new go')
|
41
|
+
a.original_go.should eql('go')
|
42
|
+
Object.send(:remove_const, :A)
|
43
|
+
|
44
|
+
class A
|
45
|
+
def go
|
46
|
+
'go'
|
47
|
+
end
|
48
|
+
archive_method(:go, :different_name)
|
49
|
+
end
|
50
|
+
a = A.new
|
51
|
+
a.methods.should_not be_include('go')
|
52
|
+
a.methods.should be_include('different_name')
|
53
|
+
a.different_name.should eql('go')
|
54
|
+
Object.send(:remove_const, :A)
|
55
|
+
|
56
|
+
class A
|
57
|
+
def go
|
58
|
+
'go'
|
59
|
+
end
|
60
|
+
private :go
|
61
|
+
archive_method(:go, :private_go)
|
62
|
+
end
|
63
|
+
a = A.new
|
64
|
+
a.methods.should_not be_include('go')
|
65
|
+
a.private_methods.should be_include('private_go')
|
66
|
+
a.send(:private_go).should eql('go')
|
67
|
+
Object.send(:remove_const, :A)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should have [] aliased for instance_method" do
|
71
|
+
String[:reverse].bind("hello").call.should eql("olleh")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should have []= setup to define an instance method" do
|
75
|
+
String[:backwards] = lambda { reverse }
|
76
|
+
"david".backwards.should eql('divad')
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should have a safe way to define an instance method only if it isn't already set. (archive_method and alias_method_chain are useful here as well.)" do
|
80
|
+
String[:backwards2] = lambda {reverse}
|
81
|
+
a = "asdf"
|
82
|
+
a.backwards2.should eql('fdsa')
|
83
|
+
String.safe_def(:backwards2) { upcase }
|
84
|
+
a.backwards2.should eql('fdsa')
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Symbol do
|
4
|
+
it "should have a shortcut for to_proc" do
|
5
|
+
[1,2,3].map(&:succ).should eql([2,3,4])
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have [], which is a method to call :some_method on SomeObject" do
|
9
|
+
creator = :new[Array]
|
10
|
+
|
11
|
+
# Longhand
|
12
|
+
creator.call.should be_is_a(Array)
|
13
|
+
creator.call.should be_empty
|
14
|
+
|
15
|
+
creator.call.object_id.should_not eql(creator.call.object_id)
|
16
|
+
|
17
|
+
# Shorthand
|
18
|
+
[creator].should be_is_a(Array)
|
19
|
+
|
20
|
+
# Parameters
|
21
|
+
class A
|
22
|
+
def initialize(value)
|
23
|
+
@value = value
|
24
|
+
end
|
25
|
+
attr_accessor :value
|
26
|
+
end
|
27
|
+
builder = :new[A]
|
28
|
+
builder.call(1).value.should eql(1)
|
29
|
+
builder.call(2).value.should eql(2)
|
30
|
+
Object.send(:remove_const, :A)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have []=, which is a method to create a method on some object" do
|
34
|
+
o = Object.new
|
35
|
+
o.should_not be_respond_to(:my_method)
|
36
|
+
:my_method[o] = lambda {'my method'}
|
37
|
+
o.my_method.should eql('my method')
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
# I'm putting off the default blocks and block parameters, because I'm
|
4
|
+
# not convinced I want to use these yet, they get very confusing very
|
5
|
+
# fast.
|
6
|
+
describe EnumerableStatistics do
|
7
|
+
it "should find the standard deviation of a list" do
|
8
|
+
[1,2,3].std.should eql(1.0)
|
9
|
+
# Verified with R
|
10
|
+
[7,12,15].std.should be_close(4.041452, 0.000001)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should find the variance of a list" do
|
14
|
+
[1,2,3].var.should eql(1.0)
|
15
|
+
[7,12,15].var.should be_close(16.333333, 0.000001)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should find the min" do
|
19
|
+
[1,2,3].min.should eql(1)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should find the min_index" do
|
23
|
+
[1,2,3].min_index.should eql(0)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should find the max" do
|
27
|
+
[1,2,3].max.should eql(3)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should find the max_index" do
|
31
|
+
[1,2,3].max_index.should eql(2)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should find the median" do
|
35
|
+
[6,2,1].median.should eql(2)
|
36
|
+
[6,2,1,7].median.should eql(4.0)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should offer the range" do
|
40
|
+
[1,2,3,4,5].range.should eql([1,5])
|
41
|
+
[5,2,2,3,3,1,4,5].range.should eql([1,5])
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should offer range in a given class with range_as_range" do
|
45
|
+
class MyRange < Range; end
|
46
|
+
a = [1,2,3]
|
47
|
+
a.range_class = MyRange
|
48
|
+
a.range_as_range.should be_is_a(MyRange)
|
49
|
+
Object.send(:remove_const, :MyRange)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should offer the rank of a list" do
|
53
|
+
a = [4,2,6]
|
54
|
+
a.rank.should eql([2,1,3])
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should offer the order of the list" do
|
58
|
+
[10,5,5,1].order.should eql([4,2,2,1])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should offer the quantile of the list" do
|
62
|
+
# This reflects R's approach, which I don't agree with.
|
63
|
+
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0].quantile.should eql([1.0, 3.25, 5.5, 7.75, 10.0])
|
64
|
+
[1.0, 2.0, 3.0, 4.0, 5.0].quantile.should eql([1.0, 2.0, 3.0, 4.0, 5.0])
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should offer a cumulative sum" do
|
68
|
+
[1,2,3].cum_sum.should eql([1.0, 3.0, 6.0])
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should offer a cumulative product" do
|
72
|
+
[1,2,3].cum_prod.should eql([1.0, 2.0, 6.0])
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should offer a cumulative max" do
|
76
|
+
[3,2,1].cum_max.should eql([3,3,3])
|
77
|
+
[1,5,3,2,1].cum_max.should eql([1,5,5,5,5])
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should offer a cumulative max" do
|
81
|
+
[1,2,3].cum_min.should eql([1,1,1])
|
82
|
+
[5,1,3,2,1].cum_min.should eql([5,1,1,1,1])
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Functional do
|
4
|
+
it "should implement an apply method, a reverse map" do
|
5
|
+
a = [[1,2],[3,4]]
|
6
|
+
sum = lambda {|x,y| x+y}
|
7
|
+
sums = sum.apply(a)
|
8
|
+
sums.should eql([3,7])
|
9
|
+
sums = sum|a
|
10
|
+
sums.should eql([3,7])
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should implement a reduce method, an inverse inject" do
|
14
|
+
data = [1,2,3,4]
|
15
|
+
sum = lambda {|x,y| x+y}
|
16
|
+
total = sum.reduce(data)
|
17
|
+
total.should eql(10)
|
18
|
+
total = sum<=data
|
19
|
+
total.should eql(10)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should implement a compose method" do
|
23
|
+
f = lambda {|x| x*x }
|
24
|
+
g = lambda {|x| x+1 }
|
25
|
+
(f.compose(g))[2].should eql(9)
|
26
|
+
(g.compose(f))[2].should eql(5)
|
27
|
+
(f*g)[2].should eql(9)
|
28
|
+
(g*f)[2].should eql(5)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be able to apply a value to the head of a parameters list" do
|
32
|
+
product = lambda {|x,y| x*y}
|
33
|
+
doubler = product.apply_head(2)
|
34
|
+
doubler.call(3).should eql(6)
|
35
|
+
doubler = product.apply_head(2,3)
|
36
|
+
doubler.call.should eql(6)
|
37
|
+
# doubler = product >> 2
|
38
|
+
# doubler.call(3).should eql(6)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should be able to apply a value to the tail of a parameters list" do
|
42
|
+
difference = lambda {|x,y| x-y }
|
43
|
+
decrement = difference.apply_tail(1)
|
44
|
+
decrement.call(5).should eql(4)
|
45
|
+
decrement = difference.apply_tail(5,1)
|
46
|
+
decrement.call.should eql(4)
|
47
|
+
# decrement = difference << 1
|
48
|
+
# decrement.call(5).should eql(4)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be able to memoize a proc" do
|
52
|
+
require 'benchmark'
|
53
|
+
Benchmark::Tms[:to_f] = lambda {to_s.split(/\(|\)/)[-2].to_f}
|
54
|
+
factorial = lambda {|x| return 1 if x==0; x*factorial[x-1]; }
|
55
|
+
memoized_factorial = factorial.memoize
|
56
|
+
cached_factorial = +factorial # Alias
|
57
|
+
m1 = Benchmark.measure {factorial.call(30)}
|
58
|
+
m2 = Benchmark.measure {factorial.call(30)}
|
59
|
+
m3 = Benchmark.measure {memoized_factorial.call(30)}
|
60
|
+
m4 = Benchmark.measure {memoized_factorial.call(30)}
|
61
|
+
m5 = Benchmark.measure {cached_factorial.call(30)}
|
62
|
+
|
63
|
+
# They should both be about the same
|
64
|
+
(m1.to_f).should be_close(m2.to_f, 0.005)
|
65
|
+
|
66
|
+
# A memoized function should be faster than a non-memoized one
|
67
|
+
(m2.to_f > m4.to_f).should eql(true)
|
68
|
+
|
69
|
+
# The first one is not memoized, the second is.
|
70
|
+
(m3.to_f > m4.to_f).should eql(true)
|
71
|
+
|
72
|
+
# Should both have been memoized, since they are aliases.
|
73
|
+
(m5.to_f).should be_close(m4.to_f, 0.005)
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
describe GeneralStatistics do
|
4
|
+
it "should safely create a max method (aliasing an existing max to original_max)" do
|
5
|
+
class CheckMaxOne
|
6
|
+
def max
|
7
|
+
'original max'
|
8
|
+
end
|
9
|
+
include GeneralStatistics
|
10
|
+
end
|
11
|
+
|
12
|
+
@c = CheckMaxOne.new
|
13
|
+
@c.original_max.should eql('original max')
|
14
|
+
@c.max(1,2,3).should eql(3)
|
15
|
+
@c.max(1,2).should eql(2)
|
16
|
+
@c.max(1).should eql(1)
|
17
|
+
@c.max.should be_nil
|
18
|
+
@c.max_index(4,5,6).should eql(2)
|
19
|
+
Object.send(:remove_const, :CheckMaxOne)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should safely create a min method (aliasing an existing min to original_min)" do
|
23
|
+
class CheckMinOne
|
24
|
+
def min
|
25
|
+
'original min'
|
26
|
+
end
|
27
|
+
include GeneralStatistics
|
28
|
+
end
|
29
|
+
|
30
|
+
@c = CheckMinOne.new
|
31
|
+
@c.original_min.should eql('original min')
|
32
|
+
@c.min(1,2,3).should eql(1)
|
33
|
+
@c.min(1,2).should eql(1)
|
34
|
+
@c.min(1).should eql(1)
|
35
|
+
@c.min.should be_nil
|
36
|
+
@c.min_index(4,5,6).should eql(0)
|
37
|
+
Object.send(:remove_const, :CheckMinOne)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
describe InterEnumerableStatistics do
|
4
|
+
|
5
|
+
it "should calculate p_max over a series of enumerables" do
|
6
|
+
a = [1,2,3]
|
7
|
+
b = [3,2,1]
|
8
|
+
c = [0,0,0]
|
9
|
+
p_max(a,b,c).should eql([3,2,3])
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should calculate a p_min over a series of enumerables" do
|
13
|
+
a = [1,2,3]
|
14
|
+
b = [3,2,1]
|
15
|
+
c = [3,3,3]
|
16
|
+
p_min(a,b,c).should eql([1,2,1])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create an accurate correlation between two lists" do
|
20
|
+
a = [1,2,3]
|
21
|
+
b = [1,2,3]
|
22
|
+
correlation(a,b).should eql(1.0)
|
23
|
+
cor(a,b).should eql(1.0)
|
24
|
+
a = [7,12,15]
|
25
|
+
b = [19,21,27]
|
26
|
+
# Verified with R
|
27
|
+
cor(a,b).should be_close(0.9112932, 0.0000001)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to call a block on pairs and then sum that up" do
|
31
|
+
a = [1,2,3]
|
32
|
+
b = [1,2,3]
|
33
|
+
to_pairs(a,b) { |a,b| a * b }.should eql([1, 4, 9])
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be able to sum a set of pairs given a block operator" do
|
37
|
+
a = [1,2,3]
|
38
|
+
b = [1,2,3]
|
39
|
+
sum_pairs(a,b) { |a,b| a * b }.should eql(14.0)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should be able to sum onto an arbitrary object" do
|
43
|
+
@a = [1,2,3]
|
44
|
+
@b = [1,2,3]
|
45
|
+
sum_pairs(@a,@b, 0) { |a,b| a * b }.should eql(14)
|
46
|
+
sum_pairs(@a,@b, 10) { |a,b| a * b }.should eql(24)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should find the product of a list" do
|
50
|
+
x = [1,2,3,4]
|
51
|
+
product(*x).should eql(24.0)
|
52
|
+
product(1,2,3,4).should eql(24.0)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
describe LibLoader do
|
4
|
+
it "should be able to load a library by name only" do
|
5
|
+
lambda{LibLoader.add_lib(:md5)}.should_not raise_error
|
6
|
+
LibLoader.libs_loaded.should be_include('md5')
|
7
|
+
defined?(MD5).should eql("constant")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be able to custom define what loading means" do
|
11
|
+
LibLoader.add_lib(:my_load) { @two = 1 + 1 }
|
12
|
+
LibLoader.libs_loaded.should be_include('my_load')
|
13
|
+
@two.should eql(2)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have a list of all libs attempted" do
|
17
|
+
LibLoader.add_lib(:garbage)
|
18
|
+
LibLoader.all_libs.should be_include('garbage')
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have read access to the libs hash" do
|
22
|
+
LibLoader.libs.should be_is_a(Hash)
|
23
|
+
lambda{LibLoader.libs = nil}.should raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should keep track of the libs loaded" do
|
27
|
+
LibLoader.add_lib(:md5)
|
28
|
+
LibLoader.libs_loaded.should be_include('md5')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should require a raised error to count the load as a fail (not just a false value from the experience)" do
|
32
|
+
LibLoader.add_lib(:junk) {false}
|
33
|
+
LibLoader.failed_libs.should_not be_include('junk')
|
34
|
+
LibLoader.add_lib(:junk2)
|
35
|
+
LibLoader.failed_libs.should be_include('junk2')
|
36
|
+
LibLoader.add_lib(:junk) { raise StandardError }
|
37
|
+
LibLoader.failed_libs.should be_include('junk')
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
# I haven't gotten the runner stuff worked out yet. I'll wait until I
|
4
|
+
# refactor Sproc, then I need to make sure this interface is 100%.
|
5
|
+
# describe Runner do
|
6
|
+
# it "should do some good...come back to this." do
|
7
|
+
#
|
8
|
+
# end
|
9
|
+
# end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../../spec_helper")
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "/../../../../lib/stored_procedures"))
|
3
|
+
|
4
|
+
describe Sproc do
|
5
|
+
it "should instantiate like a normal Proc" do
|
6
|
+
lambda {@s = Sproc.new {1 + 1} }.should_not raise_error
|
7
|
+
@s.call.should eql(2)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have an alternate constructor, build, that takes a block" do
|
11
|
+
lambda {@s = Sproc.build {1 + 1} }.should_not raise_error
|
12
|
+
@s.call.should eql(2)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have an alternate constructor, build, that takes a string" do
|
16
|
+
lambda {@s = Sproc.build "1 + 1" }.should_not raise_error
|
17
|
+
@s.should be_is_a(Sproc)
|
18
|
+
@s.call.should eql(2)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not let build take other kinds of parameters" do
|
22
|
+
lambda {@s = Sproc.build 1 }.should raise_error
|
23
|
+
lambda {@s = Sproc.build nil }.should raise_error
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper")
|
2
|
+
|
3
|
+
describe UnboundMethod do
|
4
|
+
it "should use [] as an alias for bind" do
|
5
|
+
# Long form
|
6
|
+
String[:reverse].bind("hello").call.should eql("olleh")
|
7
|
+
# Slightly shorter form
|
8
|
+
String[:reverse]["hello"].call.should eql("olleh")
|
9
|
+
# Target form
|
10
|
+
String[:reverse]["hello"][].should eql("olleh")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
2
|
+
|
3
|
+
describe Sirb do
|
4
|
+
|
5
|
+
it "should attempt to load the known useful mathematical and statistical libraries" do
|
6
|
+
LibLoader.all_libs.should be_include( *["enumerable statistics", "mathn", "matrix", "narray", "rbtree", "rgl", "rnum", "rubygems", "general statistics", "statisticus"])
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/sirb")
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
include Sirb
|
5
|
+
|
6
|
+
Spec::Runner.configure do |config|
|
7
|
+
# == Mock Framework
|
8
|
+
#
|
9
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
10
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
11
|
+
#
|
12
|
+
# config.mock_with :mocha
|
13
|
+
# config.mock_with :flexmock
|
14
|
+
# config.mock_with :rr
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: davidrichards-sirb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.14
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Richards
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-23 00:00:00 -07:00
|
13
|
+
default_executable: sirb
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A series of useful tools that a console should probably have, if your goal is to crunch a few numbers. It includes all the packages that I use, if you have them. Also incorporates some functional style programming and stored procedures to make your console experience even more delightful.
|
17
|
+
email: davidlamontrichards@gmail.com
|
18
|
+
executables:
|
19
|
+
- sirb
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.rdoc
|
26
|
+
- VERSION.yml
|
27
|
+
- bin/sirb
|
28
|
+
- lib/overrides
|
29
|
+
- lib/overrides/array.rb
|
30
|
+
- lib/overrides/file.rb
|
31
|
+
- lib/overrides/module.rb
|
32
|
+
- lib/overrides/symbol.rb
|
33
|
+
- lib/sirb
|
34
|
+
- lib/sirb/enumerable_statistics.rb
|
35
|
+
- lib/sirb/functional.rb
|
36
|
+
- lib/sirb/general_statistics.rb
|
37
|
+
- lib/sirb/inter_enumerable_statistics.rb
|
38
|
+
- lib/sirb/lib_loader.rb
|
39
|
+
- lib/sirb/runner.rb
|
40
|
+
- lib/sirb/sproc
|
41
|
+
- lib/sirb/sproc/proc.rb
|
42
|
+
- lib/sirb/sproc/proc_source.rb
|
43
|
+
- lib/sirb/sproc/sproc.rb
|
44
|
+
- lib/sirb/sproc/usage_notes.txt
|
45
|
+
- lib/sirb/sproc.rb
|
46
|
+
- lib/sirb/thread_support.rb
|
47
|
+
- lib/sirb/unbound_method.rb
|
48
|
+
- lib/sirb.rb
|
49
|
+
- lib/stored_procedures.rb
|
50
|
+
- spec/lib
|
51
|
+
- spec/lib/overrides
|
52
|
+
- spec/lib/overrides/array_spec.rb
|
53
|
+
- spec/lib/overrides/file_spec.rb
|
54
|
+
- spec/lib/overrides/module_spec.rb
|
55
|
+
- spec/lib/overrides/symbol_spec.rb
|
56
|
+
- spec/lib/sirb
|
57
|
+
- spec/lib/sirb/enumerable_statistics_spec.rb
|
58
|
+
- spec/lib/sirb/functional_spec.rb
|
59
|
+
- spec/lib/sirb/general_statistics_spec.rb
|
60
|
+
- spec/lib/sirb/inter_enumerable_statistics_spec.rb
|
61
|
+
- spec/lib/sirb/lib_loader_spec.rb
|
62
|
+
- spec/lib/sirb/runner_spec.rb
|
63
|
+
- spec/lib/sirb/sproc
|
64
|
+
- spec/lib/sirb/sproc/proc_spec.rb
|
65
|
+
- spec/lib/sirb/sproc/sproc_spec.rb
|
66
|
+
- spec/lib/sirb/unbound_method_spec.rb
|
67
|
+
- spec/lib/sirb_spec.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://github.com/davidrichards/sirb
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options:
|
73
|
+
- --inline-source
|
74
|
+
- --charset=UTF-8
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.2.0
|
93
|
+
signing_key:
|
94
|
+
specification_version: 2
|
95
|
+
summary: Descriptive statistics + IRB + any other useful numerical library you may have around
|
96
|
+
test_files: []
|
97
|
+
|