Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Giving Ruby 1.8.7 a chance to join in the #source_location fun.
Ruby
tree: 31a4e7283c

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
ext
test
.gitignore
LICENSE.MIT
README.md
Rakefile
ruby18_source_location.gemspec
ruby18_source_location_mingw32.gemspec
ruby18_source_location_mswin32.gemspec

README.md

The ruby18_source_location gem backports the source_location instance method of Method, UnboundMethod and Proc from Ruby 1.9.

This allows you to use Method#source_location on ruby 1.8.7, and also all the other gems that depend on it.

Usage

gem install ruby18_source_location
    require 'rubygems'
    require 'ruby18_source_location'

    def example
      2
    end

    puts method(:example).source_location.inspect
    # => ["/tmp/example.rb", 4]

    puts Proc.new{}.source_location.inspect
    # => ["/tmp/example.rb", 11]

    puts method(:puts).source_location.inspect
    # => nil

Known issues

Under Ruby-1.8.7, it's not currently possible to get the source_location of methods defined by attr_reader, attr_writer or attr_accessor, unless you are running Ruby Enterprise Edition.

Meta-foo

This is made available under the MIT license (see LICENSE.MIT), contributions and bug reports are welcome.

Something went wrong with that request. Please try again.