Class: CheckZilla::Check::Npm
- Inherits:
-
Object
- Object
- CheckZilla::Check::Npm
- Defined in:
- lib/checkzilla/check/npm.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Npm
constructor
A new instance of Npm.
- #perform! ⇒ Object
Constructor Details
#initialize(&block) ⇒ Npm
Returns a new instance of Npm.
8 9 10 11 12 13 |
# File 'lib/checkzilla/check/npm.rb', line 8 def initialize &block @results = {} instance_eval(&block) if block_given? raise "npm: path required" if !@path self end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/checkzilla/check/npm.rb', line 6 def path @path end |
#results ⇒ Object
Returns the value of attribute results.
5 6 7 |
# File 'lib/checkzilla/check/npm.rb', line 5 def results @results end |
Instance Method Details
#perform! ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/checkzilla/check/npm.rb', line 15 def perform! raise "npm: directory doesn't exist" unless File.exists?(@path) raw_result = `cd #{@path}; npm outdated --silent` raw_result.split("\n").each do |outdated_package| outdated_hash = outdated_package.match /^(.+)@(.+)\s.+\s.+=(.+)$/ @results[outdated_hash[1]] = [outdated_hash[3], outdated_hash[2]] end end |