ludy 0.0.8 → 0.0.9
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/CHANGES +5 -1
- data/lib/ludy/bind.rb +31 -0
- data/ludy.gemspec +3 -3
- data/test/tc_bind.rb +29 -0
- data/test/tc_ludy_ext.rb +4 -4
- metadata +7 -5
data/CHANGES
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
|
2
2
|
==============================
|
3
3
|
ludy TODO
|
4
|
-
Proc#bind
|
5
4
|
multi
|
6
5
|
chain travel
|
7
6
|
method hook
|
8
7
|
|
8
|
+
==============================
|
9
|
+
ludy 0.0.9, 2008.01.07
|
10
|
+
|
11
|
+
Proc#bind added, see test/tc_bind.rb
|
12
|
+
|
9
13
|
==============================
|
10
14
|
ludy 0.0.8, 2007.12.06
|
11
15
|
|
data/lib/ludy/bind.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (c) 2008, Lin Jen-Shin(a.k.a. godfat 真常)
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
class Proc
|
18
|
+
def bind *args
|
19
|
+
lambda{ |*new_args|
|
20
|
+
self[*(args.map{ |arg|
|
21
|
+
if (arg.kind_of? Symbol) && arg.to_s =~ /^_(\d+)$/
|
22
|
+
# is placeholder
|
23
|
+
new_args[$1.to_i-1]
|
24
|
+
else
|
25
|
+
# is not placeholder
|
26
|
+
arg
|
27
|
+
end
|
28
|
+
} + new_args).first(self.arity)]
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
data/ludy.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# Copyright (c) 2007, Lin Jen-Shin(a.k.a. godfat 真常)
|
4
4
|
#
|
@@ -17,8 +17,9 @@
|
|
17
17
|
require 'rubygems'
|
18
18
|
|
19
19
|
spec = Gem::Specification.new{|s|
|
20
|
+
s.rubyforge_project = 'ludy'
|
20
21
|
s.name = 'ludy'
|
21
|
-
s.version = '0.0.
|
22
|
+
s.version = '0.0.9'
|
22
23
|
s.author = 'Lin Jen-Shin(a.k.a. godfat)'
|
23
24
|
s.email = 'strip number: 135godfat7911@246godfat.890org'
|
24
25
|
s.homepage = 'http://ludy.rubyforge.org/'
|
@@ -31,7 +32,6 @@ spec = Gem::Specification.new{|s|
|
|
31
32
|
}
|
32
33
|
|
33
34
|
s.require_path = 'lib'
|
34
|
-
s.autorequire = 'ludy'
|
35
35
|
s.test_file = 'test/ts_ludy.rb'
|
36
36
|
s.has_rdoc = false
|
37
37
|
# s.extra_rdoc_files = []
|
data/test/tc_bind.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (c) 2008, Lin Jen-Shin(a.k.a. godfat 真常)
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'test/unit'
|
18
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'ludy')
|
19
|
+
require_ludy 'bind'
|
20
|
+
|
21
|
+
class TestCppBind < Test::Unit::TestCase
|
22
|
+
def test_basic
|
23
|
+
assert_equal [9,8,7], ([1,2,3].map &(lambda{|lhs, rhs| lhs-rhs}.bind 10, :_1))
|
24
|
+
assert_equal [3,2,1], (lambda{|a,b,c| [a,b,c]}.bind :_3, :_2, :_1)[1,2,3]
|
25
|
+
assert_equal [1,9,3], (lambda{|a,b,c| [a,b,c]}.bind :_1, 9, :_3)[1,2,3]
|
26
|
+
assert_equal [9,2,3], (lambda{|a,b,c| [a,b,c]}.bind 9)[2,3]
|
27
|
+
assert_equal [9,4,2], (lambda{|a,b,c| [a,b,c]}.bind 9, :_3)[2,3,4]
|
28
|
+
end
|
29
|
+
end
|
data/test/tc_ludy_ext.rb
CHANGED
@@ -135,14 +135,14 @@ class TestLudyExt < Test::Unit::TestCase
|
|
135
135
|
def test_unzip_and_untranspose
|
136
136
|
a = [1,2,3]
|
137
137
|
b = %w{a b c}
|
138
|
-
assert_equal [a, b], a.zip(b).untranspose
|
138
|
+
assert_equal [a, b], a.zip(b).to_a.untranspose
|
139
139
|
assert_equal [a, b], [a, b].transpose.untranspose
|
140
|
-
assert_equal a, a.zip(b).unzip
|
140
|
+
assert_equal a, a.zip(b).to_a.unzip
|
141
141
|
|
142
142
|
c = [nil, false, true]
|
143
|
-
assert_equal [a, b, c], a.zip(b, c).untranspose
|
143
|
+
assert_equal [a, b, c], a.zip(b, c).to_a.untranspose
|
144
144
|
assert_equal [a, b, c], [a, b, c].transpose.untranspose
|
145
|
-
assert_equal a, a.zip(b, c).unzip
|
145
|
+
assert_equal a, a.zip(b, c).to_a.unzip
|
146
146
|
end
|
147
147
|
|
148
148
|
def test_id_and_m
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ludy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin(a.k.a. godfat)
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2008-01-07 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/lib/smulti.rb
|
29
29
|
- lib/ludy
|
30
30
|
- lib/ludy/aspect.rb
|
31
|
+
- lib/ludy/bind.rb
|
31
32
|
- lib/ludy/callstack.rb
|
32
33
|
- lib/ludy/curry.rb
|
33
34
|
- lib/ludy/dice.rb
|
@@ -47,6 +48,7 @@ files:
|
|
47
48
|
- lib/puzzle_generator/misc.rb
|
48
49
|
- lib/puzzle_generator/puzzle.rb
|
49
50
|
- lib/puzzle_generator.rb
|
51
|
+
- test/tc_bind.rb
|
50
52
|
- test/tc_callstack.rb
|
51
53
|
- test/tc_curry.rb
|
52
54
|
- test/tc_dice.rb
|
@@ -87,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
89
|
version:
|
88
90
|
requirements: []
|
89
91
|
|
90
|
-
rubyforge_project:
|
91
|
-
rubygems_version: 0.
|
92
|
+
rubyforge_project: ludy
|
93
|
+
rubygems_version: 1.0.1
|
92
94
|
signing_key:
|
93
95
|
specification_version: 2
|
94
96
|
summary: Aims to extend Ruby standard library, providing some useful tools that's not existed in the standard library.
|