Class: Guard::PHPMD
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::PHPMD
- Defined in:
- lib/guard/phpmd.rb
Constant Summary collapse
- VERSION =
'0.0.5'
- DEFAULT_OPTIONS =
{ :path => '.', :rules => 'pmd-rules.xml', :executable => 'phpmd', }
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PHPMD
constructor
A new instance of PHPMD.
- #run_on_modifications(paths) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PHPMD
Returns a new instance of PHPMD.
14 15 16 17 18 |
# File 'lib/guard/phpmd.rb', line 14 def initialize( = {}) defaults = DEFAULT_OPTIONS.clone @options = defaults.merge() super(@options) end |
Instance Method Details
#run_on_modifications(paths) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/guard/phpmd.rb', line 20 def run_on_modifications(paths) @options[:rules] = File. @options[:rules] paths.each do |path| path = File. path Dir.chdir(@options[:path]) do results = `#{@options[:executable]} #{path} text #{@options[:rules]}` if $?.to_i > 0 then ::Guard::Notifier.notify(results, :title => 'PHP Mess Detector', :image => :failed) puts results end end end end |