Guest User

Untitled

a guest
Aug 20th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.08 KB | None | 0 0
  1. # 1) Install pry gem if you don't have it. There's probably a way to do this
  2. #    with straight irb but I'm too lazy to figure it out right now and pry is
  3. #    useful anyway.
  4. #
  5. # 2) Put this is your Rakefile in the root directory. In my case, the directory
  6. #    is named `testy`, so you'll want to modify that in the regular expression in
  7. #    the `reload!` function to match your own directory.
  8. #
  9. # 3) Obviously replace the require_relative lines with your own project files.
  10. #
  11. # That's it! Now when you run `rake console` from the project root directory,
  12. # you'll be loaded into a dev console with your files pre-loaded. You can call
  13. # the `reload!` function in this console to reload your files without having to
  14. # reload the entire console.
  15. #
  16.  
  17. task :console do
  18.   require 'pry'
  19.  
  20.   require_relative './a_file_i_want_to_load'
  21.   require_relative './another_file_i_want_to_load'
  22.   require_relative './yet_another_one_to_load'
  23.  
  24.   def reload!
  25.     files = $LOADED_FEATURES.select { |feat| feat =~ /\/testy\// }
  26.     files.each { |file| load file }
  27.   end
  28.  
  29.   ARGV.clear
  30.   Pry.start
  31. end
Advertisement
Add Comment
Please, Sign In to add comment