Last active
January 4, 2019 18:01
-
-
Save mistersourcerer/4e94c25840d5d4fdcfb62fde99d613f1 to your computer and use it in GitHub Desktop.
#_reload method for standard gem `bin/console`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "bundler/setup" | |
require "awesome_gem" | |
def _app_path | |
@app_path ||= File.expand_path "../../lib/", __FILE__ | |
end | |
def _load | |
all_files = $".select { |path| path.start_with?(_app_path) }. | |
select { |f| File.exists?(f) } # remove file deleted during development | |
main = all_files.pop { |f| f.contains? "awesome_gem.rb" } | |
load main | |
all_files.each { |f| load f } | |
include AwesomeGem | |
end | |
def _reload | |
Object.send(:remove_const, :"AwesomeGem"); | |
_load | |
puts "reloaded :)" | |
end | |
require "pry" | |
include AwesomeGem | |
Pry.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to remove deleted files from the equation.