smalltalkable 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/smalltalkable.rb CHANGED
@@ -51,6 +51,10 @@ class Class
51
51
  end
52
52
  EOS
53
53
  end
54
+
55
+ def class_compile(code)
56
+ self.singleton_class.compile code
57
+ end
54
58
  end
55
59
 
56
60
  class Object
@@ -83,6 +87,10 @@ class Object
83
87
  end
84
88
  end
85
89
  alias smalltalkise smalltalkize
90
+
91
+ def class_smalltalkize(method_name, *args)
92
+ self.singleton_class.smalltalkize method_name, *args
93
+ end
86
94
  end
87
95
 
88
96
  def if_nil(true_proc, opts={})
@@ -1,3 +1,3 @@
1
1
  module Smalltalkable
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -41,10 +41,16 @@ class TestSmalltalkable < Test::Unit::TestCase
41
41
  end
42
42
 
43
43
  def test_define_class_method
44
- Counter.class.compile '
44
+ Counter.singleton_class.compile '
45
45
  classMethod
46
46
  "classMethod"'
47
+ assert_raise NoMethodError do String.classMethod end
47
48
  assert_equal 'classMethod', Counter.classMethod
49
+
50
+ Counter.class_compile '
51
+ classMethod2
52
+ "classMethod2"'
53
+ assert_equal 'classMethod2', Counter.classMethod2
48
54
  end
49
55
 
50
56
  def test_smalltalkize
@@ -83,7 +89,7 @@ class TestSmalltalkable < Test::Unit::TestCase
83
89
  String.smalltalkize :rjust => [:rjustWidth, :padding]
84
90
  assert_equal '*******foo', 'foo'.rjustWidth(10, padding:'*')
85
91
 
86
- Time.singleton_class.smalltalkize :gm, :month, :day, :hour, :minute, :second
92
+ Time.class_smalltalkize :gm, :month, :day, :hour, :minute, :second
87
93
  time = Time.gm 2013, month:1, day:2, hour:3, minute:4, second:5
88
94
  assert_equal 2013, time.year
89
95
  assert_equal 1, time.month
@@ -92,7 +98,7 @@ class TestSmalltalkable < Test::Unit::TestCase
92
98
  assert_equal 4, time.min
93
99
  assert_equal 5, time.sec
94
100
 
95
- Time.singleton_class.smalltalkize :local => [:local_year, :month, :day, :hour, :minute, :second]
101
+ Time.class_smalltalkize :local => [:local_year, :month, :day, :hour, :minute, :second]
96
102
  local_time = Time.local_year 2013, month:1, day:2, hour:3, minute:4, second:5
97
103
  assert_equal 2013, local_time.year
98
104
  assert_equal 1, local_time.month
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smalltalkable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-18 00:00:00.000000000 Z
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Smalltalkable is a library to write your ruby code in smalltalkish way.
15
15
  email: