-
Notifications
You must be signed in to change notification settings - Fork 485
Custom pry command cookbook
Pry allows you to create custom commands, so you can customize the Guard interactor. See https://github.com/pry/pry/wiki/Command-system and https://github.com/pry/pry/wiki/Custom-commands for more information.
This commands allows you to switch the used RSpec formatter quickly:
Pry::Commands.block_command 'fuu', "Use fuubar formatter in rspec" do
options = ::Guard.guards(:rspec).runner.options
options[:cli] = options[:cli].sub(/\-\-format \w+/, '--format Fuubar')
output.puts "Using Fuubar as RSpec formatter."
end
Pry::Commands.block_command 'doc', "Use documentation formatter in rspec" do
options = ::Guard.guards(:rspec).runner.options
options[:cli] = options[:cli].sub(/\-\-format \w+/, '--format documentation')
output.puts "Using Documentation as RSpec formatter."
end
~/.guardrc
is just a pryrc that is specific to Guard, so you can use it to disable plugins only in Guard's Pry instance and not those you normally use in development. For instance, pry-stack_explorer is a useful plugin for debugging, but its state output such as frame number indication is unwanted noise in Guard output. So, in ~/.guardrc
simply disable it:
Pry.plugins['stack_explorer'] && Pry.plugins['stack_explorer'].disable!
Note that rc files are evaluated before plugins are fully loaded.
This wiki and the Guard README document contain a lot of information, please take your time and read these instructions carefully.
If you run into any trouble, you may start by understanding how Guard works.
We provide detailed changes for each Guard release.
Be sure to read the CONTRIBUTING guidelines before reporting a new Guard issue or open a pull request.
If you have any questions about the Guard usage or want to share some information with the Guard community, please go to one of the following places:
- Google+ community
- Google group
- StackOverflow
- IRC channel
#guard
(irc.freenode.net) for chatting