method_args 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +1 -2
  2. data/Rakefile +2 -2
  3. data/method_args.c +13 -7
  4. data/test.rb +6 -6
  5. metadata +2 -2
data/README CHANGED
@@ -3,8 +3,7 @@ Type 'gem install method_args' or download manually at
3
3
  http://rubyforge.org/projects/method-args
4
4
 
5
5
  = Synopses
6
-
7
- This extension adds args method to the Method class. Example:
6
+ This extension allows you to examine the parameters of a method. Example:
8
7
 
9
8
  require 'method_args'
10
9
  class X
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ Rake::TestTask.new do |t|
13
13
  end
14
14
 
15
15
  spec = Gem::Specification.new do |s|
16
- s.version = '0.0.3'
16
+ s.version = '0.0.4'
17
17
  s.name = 'method_args'
18
18
  s.summary = 'Provides Method#args for inspecting arguments'
19
19
  s.description = s.summary
@@ -40,4 +40,4 @@ end
40
40
 
41
41
  file 'Makefile' do |t|
42
42
  ruby 'extconf.rb'
43
- end
43
+ end
@@ -206,13 +206,19 @@ VALUE rb_method_splat_arg(VALUE self) {
206
206
  }
207
207
 
208
208
  void Init_method_args() {
209
- VALUE rb_cMethod;
210
- rb_cMethod = rb_const_get(rb_cObject, rb_intern("Method"));
211
- rb_define_method(rb_cMethod, "args", rb_method_args, 0);
212
- rb_define_method(rb_cMethod, "required_args", rb_method_required_args, 0);
213
- rb_define_method(rb_cMethod, "optional_args", rb_method_optional_args, 0);
214
- rb_define_method(rb_cMethod, "splat_arg", rb_method_splat_arg, 0);
209
+ VALUE cMethod = rb_const_get(rb_cObject, rb_intern("Method"));
210
+ VALUE cUBMethod = rb_const_get(rb_cObject, rb_intern("UnboundMethod"));
211
+
212
+ rb_define_method(cMethod, "args?", rb_method_args_p, 0);
213
+ rb_define_method(cMethod, "args", rb_method_args, 0);
214
+ rb_define_method(cMethod, "required_args", rb_method_required_args, 0);
215
+ rb_define_method(cMethod, "optional_args", rb_method_optional_args, 0);
216
+ rb_define_method(cMethod, "splat_arg", rb_method_splat_arg, 0);
215
217
  // rb_define_method(rb_cMethod, "block_arg", rb_method_block_arg, 0);
216
218
 
217
- rb_define_method(rb_cMethod, "args?", rb_method_args_p, 0);
219
+ rb_define_method(cUBMethod, "args?", rb_method_args_p, 0);
220
+ rb_define_method(cUBMethod, "args", rb_method_args, 0);
221
+ rb_define_method(cUBMethod, "required_args", rb_method_required_args, 0);
222
+ rb_define_method(cUBMethod, "optional_args", rb_method_optional_args, 0);
223
+ rb_define_method(cUBMethod, "splat_arg", rb_method_splat_arg, 0);
218
224
  }
data/test.rb CHANGED
@@ -8,8 +8,7 @@ class A
8
8
  @@expected[:normal] = [[:alpha, :beta], [], nil]
9
9
  def normal(alpha, beta); 2; end
10
10
  def self.normal(alpha, beta); 2; end
11
-
12
-
11
+
13
12
  @@expected[:no_arguments] = [[], [], nil]
14
13
  def no_arguments
15
14
  w = 2
@@ -64,10 +63,11 @@ class MethodTest < Test::Unit::TestCase
64
63
  end
65
64
 
66
65
  def each_method
67
- [A.new, A].each do |object|
68
- @methods.each_pair do |name, expected|
69
- yield object.method(name), expected
70
- end
66
+ a = A.new
67
+ @methods.each_pair do |name, expected|
68
+ yield a.method(name), expected
69
+ yield A.method(name), expected
70
+ yield A.instance_method(name), expected
71
71
  end
72
72
  end
73
73
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: method_args
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.3
7
- date: 2007-09-06 00:00:00 +02:00
6
+ version: 0.0.4
7
+ date: 2007-11-07 00:00:00 +01:00
8
8
  summary: Provides Method#args for inspecting arguments
9
9
  require_paths:
10
10
  - .