Class: Depec::Analyzer
- Inherits:
-
Object
- Object
- Depec::Analyzer
- Defined in:
- lib/depec/analyzer.rb
Instance Method Summary collapse
- #analyze ⇒ Hash
-
#initialize(dir, config) ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
#initialize(dir, config) ⇒ Analyzer
Returns a new instance of Analyzer.
10 11 12 13 14 |
# File 'lib/depec/analyzer.rb', line 10 def initialize(dir, config) @dir = dir @name = File.basename(@dir) @config = Configuration.call(config).to_h end |
Instance Method Details
#analyze ⇒ Hash
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/depec/analyzer.rb', line 19 def analyze results = { name: @name } @config[:targets].each do |target, | klass = Object.const_get("Depec::Target::#{target.to_s.split('_').collect!{ |w| w.capitalize }.join}").new(@dir) results[target] = klass.used? if [:use] if [:ruby, :node].include?(target) results[:"#{target}_version"] = klass.version if [:version] end if target == :circle_ci results[:circle_ci_images] = klass.images if [:images] end if target == :ruby results[:bundler_version] = klass.bundler_version if [:bundler_version] [:gem_version]&.each do |gem| results[:"#{gem}_gem"] = klass.gem_version(gem) end end if target == :node [:npm_version]&.each do |npm| results[:"#{npm}_npm"] = klass.npm_version(npm) end end end results end |