lib/licensed/sources/manifest.rb in licensed-2.6.0 vs lib/licensed/sources/manifest.rb in licensed-2.6.1

- old
+ new

@@ -10,11 +10,11 @@ def enabled? File.exist?(manifest_path) || generate_manifest? end def enumerate_dependencies - packages.map do |package_name, sources| + Parallel.map(packages) do |package_name, sources| Licensed::Sources::Manifest::Dependency.new( name: package_name, version: contents_version(*sources), path: configured_license_path(package_name) || sources_license_path(sources), sources: sources, @@ -26,14 +26,14 @@ end end # Returns the license path for a package specified in the configuration. def configured_license_path(package_name) - license_path = @config.dig("manifest", "licenses", package_name) + license_path = config.dig("manifest", "licenses", package_name) return unless license_path - license_path = @config.root.join(license_path) + license_path = config.root.join(license_path) return unless license_path.exist? license_path end # Returns the top-most directory that is common to all paths in `sources` @@ -44,11 +44,11 @@ common_prefix = Pathname.common_prefix(*sources).to_path # don't allow the workspace root to be used as common prefix # the project this is run for should be excluded from the manifest, # or ignored in the config. any license in the root should be ignored. - return common_prefix if common_prefix != @config.root + return common_prefix if common_prefix != config.root end # use the first (or only) sources directory to find license information source = sources.first return File.dirname(source) if File.file?(source) @@ -59,11 +59,11 @@ # in the app manifest def packages manifest.each_with_object({}) do |(src, package_name), hsh| next if src.nil? || src.empty? hsh[package_name] ||= [] - hsh[package_name] << File.join(@config.root, src) + hsh[package_name] << File.join(config.root, src) end end # Returns parsed or generated manifest data for the app def manifest @@ -77,19 +77,19 @@ end end # Returns the manifest location for the app def manifest_path - path = @config.dig("manifest", "path") - return @config.root.join(path) if path + path = config.dig("manifest", "path") + return config.root.join(path) if path - @config.cache_path.join("manifest.json") + config.cache_path.join("manifest.json") end # Returns whether a manifest should be generated automatically def generate_manifest? - !File.exist?(manifest_path) && !@config.dig("manifest", "dependencies").nil? + !File.exist?(manifest_path) && !config.dig("manifest", "dependencies").nil? end # Returns a manifest of files generated automatically based on patterns # set in the licensed configuration file def generate_manifest @@ -126,11 +126,11 @@ end # Returns the project dependencies specified from the licensed configuration def configured_dependencies @configured_dependencies ||= begin - dependencies = @config.dig("manifest", "dependencies")&.dup || {} + dependencies = config.dig("manifest", "dependencies")&.dup || {} dependencies.each do |name, patterns| # map glob pattern(s) listed for the dependency to a listing # of files that match the patterns and are not excluded dependencies[name] = files_from_pattern_list(patterns) & included_files @@ -140,19 +140,19 @@ end end # Returns the set of project files that are included in dependency evaluation def included_files - @sources ||= all_files - files_from_pattern_list(@config.dig("manifest", "exclude")) + @sources ||= all_files - files_from_pattern_list(config.dig("manifest", "exclude")) end # Finds and returns all files in the project that match # the glob pattern arguments. def files_from_pattern_list(patterns) return Set.new if patterns.nil? || patterns.empty? # evaluate all patterns from the project root - Dir.chdir @config.root do + Dir.chdir config.root do Array(patterns).reduce(Set.new) do |files, pattern| if pattern.start_with?("!") # if the pattern is an exclusion, remove all matching files # from the result files - Dir.glob(pattern[1..-1], File::FNM_DOTMATCH)