Class: Guard::PHPCS
Constant Summary collapse
- VERSION =
'0.0.6'
- DEFAULT_OPTIONS =
{ :standard => 'Zend', :executable => 'phpcs', }
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ PHPCS
constructor
A new instance of PHPCS.
- #run_on_modifications(paths) ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ PHPCS
Returns a new instance of PHPCS.
14 15 16 17 18 19 |
# File 'lib/guard/phpcs.rb', line 14 def initialize(watchers = [], = {}) defaults = DEFAULT_OPTIONS.clone @options = defaults.merge() @tabs = @options[:tabs]? " --tab-width=#{@options[:tabs]} " : ' ' super(watchers, @options) end |
Instance Method Details
#run_on_modifications(paths) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/guard/phpcs.rb', line 21 def run_on_modifications(paths) paths.each do |path| results = `#{@options[:executable]} --report=full#{@tabs}--standard=#{@options[:standard]} #{path}` if $?.to_i > 0 then ::Guard::Notifier.notify(results.gsub(/^-+\n/, '').gsub(/^FILE:.*\n/, '').gsub(/^Time:.*\n/, ''), :title => 'PHP Codesniffer', :image => :failed) puts results end end end |