Sha256: 221246944b047c404ce031a4e51f90cd5e4e6e1e233cbb37a7e12349472e6bec
Contents?: true
Size: 772 Bytes
Versions: 2
Compression:
Stored size: 772 Bytes
Contents
require 'mirrors/invoke' module Mirrors CLASS_DEFINITION_POINTS = {} NoGemfile = Class.new(StandardError) class << self attr_accessor :project_root end end begin unless Mirrors.project_root appline = caller.detect { |line| line !~ /:in `require'/ } f = File.expand_path(appline.sub(/:\d.*/, '')) Mirrors.project_root = loop do f = File.dirname(f) raise Mirrors::NoGemfile if f == '/' break f if File.exist?("#{f}/Gemfile") end end end class Class alias_method :__lg_orig_inherited, :inherited def inherited(subclass) file = caller[0].sub(/:\d+:in.*/, '') key = Mirrors.module_instance_invoke(subclass, :inspect) Mirrors::CLASS_DEFINITION_POINTS[key] = file __lg_orig_inherited(subclass) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mirrors-0.0.2 | lib/mirrors/hook.rb |
mirrors-0.0.1 | lib/mirrors/hook.rb |