lib/rake/funnel/support/specs_remover.rb in rake-funnel-0.18.0 vs lib/rake/funnel/support/specs_remover.rb in rake-funnel-0.19.0

- old
+ new

@@ -16,11 +16,12 @@ [projects, packages, specs] end private - def remove(projects, references, specs) + + def remove(projects, references, specs) # rubocop:disable Metrics/MethodLength Dir[*projects].map do |project| Trace.message("Processing #{project} with references #{references} and specs #{specs}") removed_references, removed_specs = with_document(project) do |xml| [remove_references(references, xml), remove_specs(specs, xml)] @@ -43,29 +44,29 @@ removed end def remove_references(references, xml) - deleted = references.map { |ref| + deleted = references.flat_map do |ref| query = "/Project//Reference[starts-with(lower-case(@Include), '#{ref.downcase}')]" xml.elements.delete_all(query) - } - .flatten - .tap { |d| Trace.message("Removed references: #{d.inspect}") } + end - deleted.map { |d| + deleted.each { |d| Trace.message("Removed references: #{d.inspect}") } + + deleted = deleted.flat_map do |d| d.get_elements('/HintPath').map(&:text) - } - .flatten - .tap { |d| Trace.message("HintPaths: #{d}") } + end + + deleted.each { |d| Trace.message("HintPaths: #{d}") } end def remove_specs(specs, xml) - deleted = specs.map { |glob| + deleted = specs.map do |glob| query = "/Project//Compile[matches(lower-case(@Include), '#{glob}')]" xml.elements.delete_all(query) - } + end deleted .flatten .map { |d| d.attributes['Include'] } .tap { |d| Trace.message("Removed specs: #{d}") } @@ -114,10 +115,11 @@ File.write(references, removed) if removed != text end end private + def paket_references_for(project) project_specific = project + '.paket.references' global = File.join(File.dirname(project), 'paket.references') [project_specific, global].select { |f| File.exist?(f) }.first @@ -143,9 +145,10 @@ delete(specs) end private + def list(args) ([] << args).flatten.compact end def delete(files)