benelux 0.5.15 → 0.5.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,12 @@
1
1
  BENELUX, CHANGES
2
2
 
3
3
 
4
+ #### 0.5.16 (2010-06-08) ##############################
5
+
6
+ * ADDED: Support for timing class methods.
7
+ * ADDED: New Calculator attribute: time
8
+
9
+
4
10
  #### 0.5.15 (2010-04-03) ##############################
5
11
 
6
12
  * FIXED: require 'storable'. Rookie!
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "benelux"
3
3
  s.rubyforge_project = 'benelux'
4
- s.version = "0.5.15"
4
+ s.version = "0.5.16"
5
5
  s.summary = "Benelux: A mad way to time Ruby codes"
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
@@ -5,7 +5,7 @@ require 'selectable'
5
5
  require 'storable'
6
6
 
7
7
  module Benelux
8
- VERSION = "0.5.15"
8
+ VERSION = "0.5.16"
9
9
  NOTSUPPORTED = [Class, Object, Kernel]
10
10
 
11
11
  class BeneluxError < RuntimeError; end
@@ -41,8 +41,18 @@ module Benelux
41
41
  thread_id, call_id = Thread.current.object_id.abs, @klass.object_id.abs
42
42
  @methorig = methorig = :"__benelux_#{@meth}_#{thread_id}_#{call_id}"
43
43
  Benelux.ld "%20s: %s" % ['Alias', @methorig]
44
+
44
45
  @klass.module_eval do
45
- alias_method methorig, m # Can't use the instance variables
46
+ Benelux.ld [:def, self, m,
47
+ MethodPacker.method_defined?(self, m),
48
+ MethodPacker.class_method_defined?(self, m)].inspect
49
+ if MethodPacker.method_defined?(self, m)
50
+ alias_method methorig, m # Can't use the instance variables
51
+ elsif MethodPacker.class_method_defined?(self, m)
52
+ eval "class << self; alias #{methorig} #{m}; end"
53
+ else
54
+ raise BeneluxError, "No such method: #{self}.#{m}"
55
+ end
46
56
  end
47
57
  install_method # see generate_packed_method
48
58
  self.add_tags :class => @klass.to_s.to_sym,
@@ -55,6 +65,16 @@ module Benelux
55
65
  Benelux.packed_methods[:all] << self
56
66
 
57
67
  end
68
+ def self.method_defined?(klass, meth)
69
+ meth &&= meth.to_s if RUBY_VERSION < "1.9"
70
+ klass.method_defined?(meth) ||
71
+ klass.private_method_defined?(meth) ||
72
+ klass.protected_method_defined?(meth)
73
+ end
74
+ def self.class_method_defined?(klass, meth)
75
+ meth &&= meth.to_s if RUBY_VERSION < "1.9"
76
+ klass.singleton_methods.member? meth
77
+ end
58
78
  def install_method
59
79
  raise "You need to implement this method"
60
80
  end
@@ -132,7 +132,8 @@ module Benelux
132
132
  field :n => Integer
133
133
  field :min => Float
134
134
  field :max => Float
135
-
135
+ field :time => Float
136
+
136
137
  def initialize
137
138
  reset
138
139
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benelux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.15
4
+ version: 0.5.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-03 00:00:00 -04:00
12
+ date: 2010-06-08 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency