Class: LicenseFinder::Scanner
- Inherits:
-
Object
- Object
- LicenseFinder::Scanner
- Defined in:
- lib/license_finder/scanner.rb
Constant Summary collapse
- PACKAGE_MANAGERS =
[GoDep, GoWorkspace, Go15VendorExperiment, Glide, Gvt, Govendor, Dep, Bundler, NPM, Pip, Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget, Carthage, Mix, Conan, Sbt, Cargo].freeze
Instance Method Summary collapse
- #active_package_managers ⇒ Object
- #active_packages ⇒ Object
-
#initialize(config = { project_path: Pathname.new('') }) ⇒ Scanner
constructor
A new instance of Scanner.
Constructor Details
#initialize(config = { project_path: Pathname.new('') }) ⇒ Scanner
Returns a new instance of Scanner.
6 7 8 9 10 |
# File 'lib/license_finder/scanner.rb', line 6 def initialize(config = { project_path: Pathname.new('') }) @config = config @project_path = @config[:project_path] @logger = @config[:logger] end |
Instance Method Details
#active_package_managers ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/license_finder/scanner.rb', line 18 def active_package_managers return @package_managers if @package_managers active_pm_classes = [] PACKAGE_MANAGERS.each do |pm_class| active = pm_class.new(@config).active? if active @logger.info pm_class, 'is active', color: :green active_pm_classes << pm_class else @logger.debug pm_class, 'is not active', color: :red end end @logger.info 'License Finder', 'No active and installed package managers found for project.', color: :red if active_pm_classes.empty? active_pm_classes -= active_pm_classes.map(&:takes_priority_over) @package_managers = active_pm_classes.map { |pm_class| pm_class.new(@config) } end |
#active_packages ⇒ Object
12 13 14 15 16 |
# File 'lib/license_finder/scanner.rb', line 12 def active_packages package_managers = active_package_managers installed_package_managers = package_managers.select { |pm| pm.class.installed?(@logger) } installed_package_managers.flat_map(&:current_packages_with_relations) end |