Skip to content

Commit

Permalink
Merge pull request #416 from Nerian/project_guardrc
Browse files Browse the repository at this point in the history
Support .guardrc file on the folder from which Guard is executed as well
  • Loading branch information
thibaudgg committed Apr 8, 2013
2 parents ae9b9de + e8758d5 commit 3a32b89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/guard/interactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def initialize
# Add Pry hooks:
#
# * Load `~/.guardrc` within each new Pry session.
# * Load project's `.guardrc` within each new Pry session.
# * Restore prompt after each evaluation.
#
def add_hooks
Expand All @@ -112,6 +113,11 @@ def add_hooks
end
end

Pry.config.hooks.add_hook :when_started, :load_project_guard_rc do
project_guard_rc = Dir.pwd + '/.guardrc'
load project_guard_rc if File.exist?(project_guard_rc)
end

if stty_exists?
Pry.config.hooks.add_hook :after_eval, :restore_visibility do
system('stty echo 2>/dev/null')
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

config.after(:each) do
Pry.config.hooks.delete_hook(:when_started, :load_guard_rc)
Pry.config.hooks.delete_hook(:when_started, :load_project_guard_rc)

if ::Guard.options
::Guard.options[:debug] = false
Expand Down

0 comments on commit 3a32b89

Please sign in to comment.