Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hook instead of RC_FILES; Increased verbosity.

Pry::RC_FILES went away recently, in this commit:
  pry/pry@d830ebb

The hooks should work both in 0.9.10 and HEAD pry.

Also, gave the user a hint about ~/.guardrc, because it changes the
interactor experience quite a bit with/without one.
  • Loading branch information...
commit 2837fbd084b4e8e2127ecea92a50d71fec3e4aa7 1 parent 8f169d4
@rking rking authored rking@sharpsaw.org committed
Showing with 14 additions and 3 deletions.
  1. +14 −3 lib/guard/interactor.rb
View
17 lib/guard/interactor.rb
@@ -16,11 +16,22 @@ class Interactor
require 'guard/commands/pause'
require 'guard/commands/reload'
require 'guard/commands/show'
+ GUARD_RC = '~/.guardrc'
+ HISTORY_FILE = '~/.guard_history'
def initialize
- Pry::RC_FILES.unshift '~/.guardrc'
- Pry.config.history.file = '~/.guard_history'
-
+ Pry.config.hooks.add_hook :when_started, :load_guard_rc do
+ if File.exist? File.expand_path GUARD_RC
+ load GUARD_RC
+ else
+ example_guard_rc_url = 'https://gist.github.com/da7f4b2f8465a3d75cd4'
+ Pry.output.puts <<-EOT
+- No ~/.guardrc found, so commands will be more verbose.
+(See tersifying example at #{example_guard_rc_url} )
+ EOT
+ end
+ end
+ Pry.config.history.file = HISTORY_FILE
Pry.config.prompt = [
proc do |target_self, nest_level, pry|
"[#{pry.input_array.size}] #{ ::Guard.listener.paused? ? 'pause' : 'guard' }(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
Please sign in to comment.
Something went wrong with that request. Please try again.