lib/licensed/configuration.rb in licensed-2.13.0 vs lib/licensed/configuration.rb in licensed-2.14.0

- old
+ new

@@ -67,11 +67,13 @@ self["sources"].fetch(source_type, default) end # Is the given dependency reviewed? def reviewed?(dependency) - Array(self["reviewed"][dependency["type"]]).include?(dependency["name"]) + Array(self["reviewed"][dependency["type"]]).any? do |pattern| + File.fnmatch?(pattern, dependency["name"], File::FNM_PATHNAME | File::FNM_CASEFOLD) + end end # Is the given dependency ignored? def ignored?(dependency) Array(self["ignored"][dependency["type"]]).any? do |pattern| @@ -156,32 +158,35 @@ private def self.expand_app_source_path(app_config) return app_config if app_config["source_path"].to_s.empty? + # check if the source path maps to an existing directory source_path = File.expand_path(app_config["source_path"], AppConfiguration.root_for(app_config)) + return app_config if Dir.exist?(source_path) + + # try to expand the source path for glob patterns expanded_source_paths = Dir.glob(source_path).select { |p| File.directory?(p) } - # return the original configuration if glob didn't result in multiple paths - return app_config if expanded_source_paths.size <= 1 + configs = expanded_source_paths.map { |path| app_config.merge("source_path" => path) } - # map the expanded paths to new application configurations - expanded_source_paths.map do |path| - config = app_config.merge("source_path" => path) + # if no directories are found for the source path, return the original config + return app_config if configs.size == 0 - # update configured values for name and cache_path for uniqueness. - # this is only needed when values are explicitly set, AppConfiguration - # will handle configurations that don't have these explicitly set - dir_name = File.basename(path) + # update configured values for name and cache_path for uniqueness. + # this is only needed when values are explicitly set, AppConfiguration + # will handle configurations that don't have these explicitly set + configs.each do |config| + dir_name = File.basename(config["source_path"]) config["name"] = "#{config["name"]}-#{dir_name}" if config["name"] # if a cache_path is set and is not marked as shared, append the app name # to the end of the cache path to make a unique cache path for the app if config["cache_path"] && config["shared_cache"] != true config["cache_path"] = File.join(config["cache_path"], dir_name) end - - config end + + configs end # Find a default configuration file in the given directory. # File preference is given by the order of elements in DEFAULT_CONFIG_FILES #