lib/aranha/fixtures/download.rb in aranha-0.9.0 vs lib/aranha/fixtures/download.rb in aranha-0.9.1

- old
+ new

@@ -1,8 +1,10 @@ # frozen_string_literal: true +require 'aranha/parsers/base' require 'aranha/parsers/source_address' +require 'aranha/parsers/spec/source_target_fixtures' module Aranha module Fixtures class Download attr_reader :pending @@ -27,11 +29,11 @@ Dir["#{fixtures_root}/**/*.url"].select { |path| select_path?(path) } end def select_path?(path) return false unless match_prefix_pattern(path) - !pending || !::File.exist?(target(path)) + !pending || !source_exist?(path) end def match_prefix_pattern(path) relative_path(path).start_with?(@prefix) end @@ -53,9 +55,14 @@ File.expand_path(File.basename(file, '.url') + '.source.html', File.dirname(file)) end def relative_path(path) path.sub(%r{^#{Regexp.quote(fixtures_root)}/}, '') + end + + def source_exist?(path) + stf = ::Aranha::Spec::SourceTargetFixtures.new(::File.dirname(path)) + stf.source_file(::File.basename(path, '.url')).present? end end end end