lib/licensed/sources/cabal.rb in licensed-2.6.0 vs lib/licensed/sources/cabal.rb in licensed-2.6.1
- old
+ new
@@ -41,20 +41,20 @@
else
recursive_dependencies([package_id], package_ids)
end
end
- package_ids.map { |id| package_info(id) }.concat(missing)
+ Parallel.map(package_ids) { |id| package_info(id) }.concat(missing)
end
# Returns the packages document directory and search root directory
# as an array
def package_docs_dirs(package)
unless package["haddock-html"]
# default to a local vendor directory if haddock-html property
# isn't available
- return [File.join(@config.pwd, "vendor", package["name"]), nil]
+ return [File.join(config.pwd, "vendor", package["name"]), nil]
end
html_dir = package["haddock-html"]
data_dir = package["data-dir"]
return [html_dir, nil] unless data_dir
@@ -83,11 +83,11 @@
new_packages = Set.new(package_names) - results
return [] if new_packages.empty?
results.merge new_packages
- dependencies = new_packages.flat_map { |n| package_dependencies(n) }
+ dependencies = Parallel.map(new_packages, &method(:package_dependencies)).flatten
return results if dependencies.empty?
results.merge recursive_dependencies(dependencies, results)
end
@@ -129,14 +129,14 @@
end
# Returns an array of ghc package DB locations as specified in the app
# configuration
def package_db_args
- @package_db_args ||= Array(@config.dig("cabal", "ghc_package_db")).map do |path|
+ @package_db_args ||= Array(config.dig("cabal", "ghc_package_db")).map do |path|
next "--#{path}" if %w(global user).include?(path)
path = realized_ghc_package_path(path)
- path = File.expand_path(path, @config.root)
+ path = File.expand_path(path, config.root)
next unless File.exist?(path)
"--package-db=#{path}"
end.compact
end
@@ -194,17 +194,17 @@
/xmi
end
# Returns the targets to search for `build-depends` in a cabal file
def cabal_file_targets
- targets = Array(@config.dig("cabal", "cabal_file_targets"))
+ targets = Array(config.dig("cabal", "cabal_file_targets"))
targets.push(*DEFAULT_TARGETS) if targets.empty?
targets
end
# Returns an array of the local directory cabal package files
def cabal_files
- @cabal_files ||= Dir.glob(File.join(@config.pwd, "*.cabal"))
+ @cabal_files ||= Dir.glob(File.join(config.pwd, "*.cabal"))
end
# Returns the ghc cli tool version
def ghc_version
return unless ghc?