ludy 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,4 +1,17 @@
1
1
 
2
+ ==============================
3
+ ludy 0.0.6, 2007.09.15
4
+
5
+ 1. ludy_ext:
6
+ added:
7
+ 1. Array#combine
8
+
9
+ moved:
10
+ 1. move Symbol#to_proc to Symbol#to_msg,
11
+ and take back the original Symbol#to_proc implementation.
12
+
13
+ 2. change the way we require
14
+
2
15
  ==============================
3
16
  ludy 0.0.5, 2007.09.15
4
17
 
data/lib/ludy/curry.rb CHANGED
@@ -17,7 +17,8 @@
17
17
  begin
18
18
  require_ludy 'ludy_ext'
19
19
  rescue NameError
20
- raise LoadError.new('please require "ludy" first')
20
+ require(File.join(File.dirname(__FILE__), '../', 'ludy'))
21
+ require_ludy 'ludy_ext'
21
22
  end
22
23
 
23
24
  module Ludy
data/lib/ludy/ludy_ext.rb CHANGED
@@ -63,22 +63,18 @@ end
63
63
  =end
64
64
 
65
65
  class Symbol
66
- # def to_proc; lambda{|*args| args.shift.__send__ self, *args}; end
67
- def to_proc
68
- lambda{|*args| eval "args[0].#{self.to_s} #{args[1..-1].join ', '}" }
69
- end
70
- alias_method :to_msg, :to_proc
66
+ def to_proc; lambda{ |*args| args.shift.__send__ self, *args }; end
67
+ def to_msg; lambda{ |*args| eval "args[0].#{self.to_s} #{args[1..-1].join ', '}" }; end
71
68
  end
72
69
 
73
70
  class Array
74
71
  alias_method :filter, :select
75
72
  def foldl func, init; self.inject init, &func; end
76
73
  def foldr func, init
77
- self.reverse_each{ |i|
78
- init = func[i, init]
79
- }
74
+ self.reverse_each{ |i| init = func[i, init] }
80
75
  init
81
76
  end
77
+ def combine *target; self.zip(*target).map &:'inject &:+'.to_msg; end
82
78
  end
83
79
 
84
80
  class Proc
@@ -99,11 +95,7 @@ class Proc
99
95
  end
100
96
  def compose *procs, &block
101
97
  procs << block if block
102
- lambda{ |*args|
103
- ([self] + procs).reverse.inject(args){ |val, fun|
104
- fun[*val]
105
- }
106
- }
98
+ lambda{ |*args| ([self] + procs).reverse.inject(args){ |val, fun| fun[*val] } }
107
99
  end
108
100
  end
109
101
 
data/lib/ludy/rambda.rb CHANGED
@@ -19,7 +19,8 @@ raise LoadError.new('you need ruby2ruby gem to use this tool') unless require 'r
19
19
  begin
20
20
  require_ludy 'ludy_ext'
21
21
  rescue NameError
22
- raise LoadError.new('please require "ludy" first')
22
+ require(File.join(File.dirname(__FILE__), '../', 'ludy'))
23
+ require_ludy 'ludy_ext'
23
24
  end
24
25
 
25
26
  module Ludy
data/lib/ludy/this.rb CHANGED
@@ -17,7 +17,8 @@
17
17
  begin
18
18
  require_ludy 'callstack'
19
19
  rescue NameError
20
- raise LoadError.new('please require "ludy" first')
20
+ require(File.join(File.dirname(__FILE__), '../', 'ludy'))
21
+ require_ludy 'callstack'
21
22
  end
22
23
 
23
24
  module Ludy
@@ -17,7 +17,8 @@
17
17
  begin
18
18
  require_ludy 'lazy'
19
19
  rescue NameError
20
- raise LoadError.new('please require "ludy" first')
20
+ require(File.join(File.dirname(__FILE__), '../', 'ludy'))
21
+ require_ludy 'lazy'
21
22
  end
22
23
 
23
24
  module Ludy
data/ludy.gemspec CHANGED
@@ -18,7 +18,7 @@ require 'rubygems'
18
18
 
19
19
  spec = Gem::Specification.new{|s|
20
20
  s.name = 'ludy'
21
- s.version = '0.0.5'
21
+ s.version = '0.0.6'
22
22
  s.author = 'Lin Jen-Shin(a.k.a. godfat)'
23
23
  s.email = 'strip number: 135godfat7911@246godfat.890org'
24
24
  s.homepage = 'http://ludy.rubyforge.org/'
data/test/tc_ludy_ext.rb CHANGED
@@ -109,7 +109,16 @@ class TestLudyExt < Test::Unit::TestCase
109
109
  end
110
110
 
111
111
  def test_symbol_to_msg
112
- assert_equal [3, 7], [[1,2],[3,4]].map(&:'inject(&:+)')
112
+ assert_equal [3, 7], [[1,2],[3,4]].map(&:'inject &:+'.to_msg)
113
113
  assert_equal 29, :'to_i*2+9'.to_msg['10']
114
114
  end
115
+
116
+ def test_combine
117
+ assert_equal [4, 6], [1,2].combine([3,4])
118
+ assert_equal [9, 12], [1,2].combine([3,4], [5,6])
119
+
120
+ a = [[1,2],[3,4],[5,6]]
121
+ assert_equal [9, 12], a.inject(&:combine)
122
+ assert_equal [9, 12], a.shift.combine(*a)
123
+ end
115
124
  end
data/test/ts_ludy.rb CHANGED
@@ -33,7 +33,8 @@ lambda{ |log|
33
33
  log << output
34
34
  match = output.match /(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors/
35
35
  # result = result.zip(match[1..4].map(&:to_i)).map{|data| data.inject(&:+)}
36
- result = result.zip(match[1..4].map(&:to_i)).map(&:'inject(&:+)')
36
+ # result = result.zip(match[1..4].map(&:to_i)).map(&:'inject &:+'.to_msg)
37
+ result = result.combine match[1..4].map(&:to_i)
37
38
  }
38
39
  log << "Total: #{result[0]} tests, #{result[1]} assertions, #{result[2]} failures, #{result[3]} errors\n\n"
39
40
  log << "---- End testing in #{Time.new - start} seconds. ----\n\n\n\n\n"
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ludy
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.5
6
+ version: 0.0.6
7
7
  date: 2007-09-15 00:00:00 +08:00
8
8
  summary: Aims to extend Ruby standard library, providing some useful tools that's not existed in the standard library.
9
9
  require_paths: