lib/aranha/fixtures/download.rb in aranha-0.12.1 vs lib/aranha/fixtures/download.rb in aranha-0.13.0
- old
+ new
@@ -29,10 +29,11 @@
Dir["#{fixtures_root}/**/*.url"].select { |path| select_path?(path) }
end
def select_path?(path)
return false unless match_prefix_pattern(path)
+
!pending || !source_exist?(path)
end
def match_prefix_pattern(path)
relative_path(path).start_with?(@prefix)
@@ -44,9 +45,10 @@
def download(url, target)
Rails.logger.info "Baixando \"#{url}\"..."
content = ::Aranha::Parsers::Base.new(url).content
raise "Content is blank for \"#{url}\"" if content.blank?
+
File.open(target, 'wb') { |file| file.write(content) }
end
def url(file)
::Aranha::Parsers::SourceAddress.from_file(file)