Class: Guard::PHPCS
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::PHPCS
- Defined in:
- lib/guard/phpcs.rb
Constant Summary collapse
- VERSION =
'0.0.7'
- DEFAULT_OPTIONS =
{ :standard => 'Zend', :executable => 'phpcs', }
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PHPCS
constructor
A new instance of PHPCS.
- #run_on_modifications(paths) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PHPCS
Returns a new instance of PHPCS.
13 14 15 16 17 18 |
# File 'lib/guard/phpcs.rb', line 13 def initialize( = {}) defaults = DEFAULT_OPTIONS.clone @options = defaults.merge() @tabs = @options[:tabs]? " --tab-width=#{@options[:tabs]} " : ' ' super(@options) end |
Instance Method Details
#run_on_modifications(paths) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/guard/phpcs.rb', line 20 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 |