Skip to content

Instantly share code, notes, and snippets.

@mistersourcerer
Last active January 4, 2019 18:01
Show Gist options
  • Save mistersourcerer/4e94c25840d5d4fdcfb62fde99d613f1 to your computer and use it in GitHub Desktop.
Save mistersourcerer/4e94c25840d5d4fdcfb62fde99d613f1 to your computer and use it in GitHub Desktop.
#_reload method for standard gem `bin/console`
#!/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
@mistersourcerer
Copy link
Author

Updated to remove deleted files from the equation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment