method_source 0.3.5 → 0.4.0

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.
@@ -1,4 +1,4 @@
1
- # (C) John Mair (banisterfiend) 2010
1
+ # (C) John Mair (banisterfiend) 2011
2
2
  # MIT License
3
3
 
4
4
  direc = File.dirname(__FILE__)
@@ -44,6 +44,20 @@ module MethodSource
44
44
  Class.new { include(method_owner) }
45
45
  end
46
46
 
47
+ # deal with immediate values
48
+ case
49
+ when klass == Symbol
50
+ return :a.method(name).source_location
51
+ when klass == Fixnum
52
+ return 0.method(name).source_location
53
+ when klass == TrueClass
54
+ return true.method(name).source_location
55
+ when klass == FalseClass
56
+ return false.method(name).source_location
57
+ when klass == NilClass
58
+ return nil.method(name).source_location
59
+ end
60
+
47
61
  begin
48
62
  klass.allocate.method(name).source_location
49
63
  rescue TypeError
@@ -1,3 +1,3 @@
1
1
  module MethodSource
2
- VERSION = "0.3.5"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,11 +1,30 @@
1
1
  direc = File.dirname(__FILE__)
2
2
 
3
+ require 'rubygems'
3
4
  require 'bacon'
4
5
  require "#{direc}/../lib/method_source"
5
6
  require "#{direc}/test_helper"
6
7
 
7
8
  describe MethodSource do
8
9
 
10
+ describe "source_location (testing 1.8 implementation)" do
11
+ it 'should return correct source_location for a method' do
12
+ method(:hello).source_location.first.should =~ /test_helper/
13
+ end
14
+
15
+ it 'should not raise for immediate instance methods' do
16
+ [Symbol, Fixnum, TrueClass, FalseClass, NilClass].each do |immediate_class|
17
+ lambda { immediate_class.instance_method(:to_s).source_location }.should.not.raise
18
+ end
19
+ end
20
+
21
+ it 'should not raise for immediate methods' do
22
+ [:a, 1, true, false, nil].each do |immediate|
23
+ lambda { immediate.method(:to_s).source_location }.should.not.raise
24
+ end
25
+ end
26
+ end
27
+
9
28
  before do
10
29
  @hello_module_source = " def hello; :hello_module; end\n"
11
30
  @hello_singleton_source = "def $o.hello; :hello_singleton; end\n"
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 5
9
- version: 0.3.5
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Mair (banisterfiend)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-05 00:00:00 +13:00
17
+ date: 2011-03-16 00:00:00 +13:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ files:
64
64
  - README.markdown
65
65
  - Rakefile
66
66
  - .gemtest
67
- has_rdoc: true
67
+ has_rdoc: yard
68
68
  homepage: http://banisterfiend.wordpress.com
69
69
  licenses: []
70
70