Shadows is an extention for Kernel#require which allows you to require shadowed files. This is very useful when extending some other gem. Just shadow the original file by creating a file with exacly the same relative path as the file you want to shadow. Then #require(:shadow) somewhere in your file.
Suppose you have file called some_gem/some_file.rb which you want to shadow.
Just create file with the same path in your gem/app (ie. some_gem/some_file.rb) and call require(:shadow) somwhere in that file.
shadowed some_gem/some_file.rb:
class Person < Struct.new(:name) end
shadowing some_gem/some_file.rb:
require :shadow class Person def whats_your_name? "I'm #{self.name}. What's your name?" end end Person.new('Simon').whats_your_name? # => "I'm Simon. What's your name?"
gem install shadows
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2010 Simon Menke. See LICENSE for details.