ludy 0.0.1 → 0.0.2

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/lib/ludy/ludy_ext.rb CHANGED
@@ -25,6 +25,13 @@ class Object
25
25
  def alias_instance_method new_msg, old_msg
26
26
  self.class.send :alias_method, new_msg, old_msg
27
27
  end
28
+ def if
29
+ yield if self
30
+ end
31
+ def else
32
+ if self then self
33
+ else yield end
34
+ end
28
35
  end
29
36
 
30
37
  class NilClass
@@ -32,3 +39,11 @@ class NilClass
32
39
  self
33
40
  end
34
41
  end
42
+
43
+ class Fixnum
44
+ def collect
45
+ result = []
46
+ self.times{|i| result.push(yield(i))}
47
+ result
48
+ end
49
+ end
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.1'
21
+ s.version = '0.0.2'
22
22
  s.author = 'Lin Jen-Shin(a.k.a. godfat)'
23
23
  s.email = 'strip number: 135godfat7911@246gmail.890com'
24
24
  s.homepage = 'http://ludy.rubyforge.org/'
data/test/tc_ludy_ext.rb CHANGED
@@ -18,10 +18,36 @@ require 'test/unit'
18
18
  require(File.join(File.dirname(__FILE__), '..', 'lib', 'ludy'))
19
19
  require_ludy 'ludy_ext'
20
20
  class TestLudyExt < Test::Unit::TestCase
21
- def test_tap
21
+ def test_object_tap
22
22
  assert_equal '11', 10.tap{|i| assert_equal '10', i.to_s}.succ.to_s
23
23
  end
24
24
  def test_nil
25
25
  assert_nil nil.XD.Orz.zzz
26
26
  end
27
+ def test_fixnum_collect
28
+ a, b, c = 3.collect{|i| i}
29
+ assert_equal 0, a
30
+ assert_equal 1, b
31
+ assert_equal 2, c
32
+
33
+ array = 5.collect{Array.new}
34
+ assert_equal 5, array.size
35
+ 5.times{|y|
36
+ 5.times{|x|
37
+ break if x == y
38
+ assert_not_equal array[x].object_id, array[y].object_id
39
+ }
40
+ assert_equal Array, array[y].class
41
+ }
42
+ end
43
+ def test_if
44
+ assert_equal "XD", (true ).if{"XD"}
45
+ assert ! (false).if{"XD"}
46
+ assert_equal "Orz", (false).if{"XD"}.else{"Orz"}
47
+ assert_equal "XD", (true ).if{"XD"}.else{"Orz"}
48
+ assert_equal "XD", (true ).if{"xd"}.upcase
49
+ assert ! (false).if{"xd"}.upcase
50
+ assert_equal "OTL", (false).if{"xd"}.else{"otl"}.upcase
51
+ assert_equal "XD", (true ).if{"xd"}.else{"otl"}.upcase
52
+ end
27
53
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ 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.1
7
- date: 2007-04-30 00:00:00 +08:00
6
+ version: 0.0.2
7
+ date: 2007-07-18 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:
10
10
  - lib
@@ -30,11 +30,10 @@ authors:
30
30
  - Lin Jen-Shin(a.k.a. godfat)
31
31
  files:
32
32
  - lib/lib
33
- - lib/ludy
34
- - lib/ludy.rb
35
33
  - lib/lib/amulti.rb
36
34
  - lib/lib/multi.rb
37
35
  - lib/lib/smulti.rb
36
+ - lib/ludy
38
37
  - lib/ludy/callstack.rb
39
38
  - lib/ludy/dice.rb
40
39
  - lib/ludy/lazy.rb
@@ -44,6 +43,7 @@ files:
44
43
  - lib/ludy/variable.rb
45
44
  - lib/ludy/y_combinator.rb
46
45
  - lib/ludy/z_combinator.rb
46
+ - lib/ludy.rb
47
47
  - test/tc_callstack.rb
48
48
  - test/tc_dice.rb
49
49
  - test/tc_lazy.rb