Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1) Install pry gem if you don't have it. There's probably a way to do this
- # with straight irb but I'm too lazy to figure it out right now and pry is
- # useful anyway.
- #
- # 2) Put this is your Rakefile in the root directory. In my case, the directory
- # is named `testy`, so you'll want to modify that in the regular expression in
- # the `reload!` function to match your own directory.
- #
- # 3) Obviously replace the require_relative lines with your own project files.
- #
- # That's it! Now when you run `rake console` from the project root directory,
- # you'll be loaded into a dev console with your files pre-loaded. You can call
- # the `reload!` function in this console to reload your files without having to
- # reload the entire console.
- #
- task :console do
- require 'pry'
- require_relative './a_file_i_want_to_load'
- require_relative './another_file_i_want_to_load'
- require_relative './yet_another_one_to_load'
- def reload!
- files = $LOADED_FEATURES.select { |feat| feat =~ /\/testy\// }
- files.each { |file| load file }
- end
- ARGV.clear
- Pry.start
- end
Advertisement
Add Comment
Please, Sign In to add comment