From: duerst@... Date: 2017-06-26T03:59:11+00:00 Subject: [ruby-core:81771] [Ruby trunk Feature#10771] An easy way to get the source location of a constant Issue #10771 has been updated by duerst (Martin D��rst). jphelps (Jeremy Phelps) wrote: > I've got a patch ready for this, but I have no idea how to submit it. There are serious contradictions in this page: > > https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute I updated this page a bit, hopefully removing the contradictions. Please tell us if there still are some problems. ---------------------------------------- Feature #10771: An easy way to get the source location of a constant https://bugs.ruby-lang.org/issues/10771#change-65468 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented: * Tracepoint emits a signal when a constant is defined. * Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows: foo1.rb 1| module Foo 2| Bar = :bar 3| end 4| Foo.constant(:Bar) #=> # 5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2] * Implement `Module#constant_source_location` foo2.rb 1| module Foo 2| Bar = :bar 3| end 4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2] ---Files-------------------------------- const_source_location.tar.gz (1.96 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: