matthewgarysmith-rubypodder 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/rubypodder.rb +1 -0
  2. data/tests/tc_rubypodder.rb +15 -11
  3. metadata +2 -2
data/lib/rubypodder.rb CHANGED
@@ -97,6 +97,7 @@ class RubyPodder
97
97
  rio(file_name) < rio(url)
98
98
  rescue
99
99
  @log.error(" Failed to download #{url}")
100
+ File.delete(file_name) if File.exists?(file_name)
100
101
  else
101
102
  record_download(url, guid)
102
103
  end
@@ -179,42 +179,46 @@ class TC_RubyPodder < Test::Unit::TestCase
179
179
  end
180
180
 
181
181
  def test_download
182
- @rp.download("http://www.google.com/index.html")
182
+ @rp.download("http://www.google.com/index.html", 'google')
183
183
  dest_file = @rp.date_dir + "/" + "index.html"
184
184
  assert(File.exists?(dest_file))
185
185
  assert(File.open(dest_file).grep(/google/))
186
186
  end
187
187
 
188
188
  def test_download_recorded
189
- @rp.download("http://www.google.com/index.html")
189
+ @rp.download("http://www.google.com/index.html", 'google')
190
190
  assert(File.exists?(@rp.done_file))
191
191
  assert(File.open(@rp.done_file).grep(/^http:\/\/www.google.com\/index.html$/))
192
192
  end
193
193
 
194
194
  def test_already_downloaded
195
195
  url1 = "http://www.google.com/index.html"
196
- assert(!@rp.already_downloaded(url1), "url1 should not be already downloaded before download of url1")
197
- @rp.download(url1)
196
+ guid1 = "google"
197
+ assert(!@rp.already_downloaded(url1, guid1), "url1 should not be already downloaded before download of url1")
198
+ @rp.download(url1, guid1)
198
199
  File.open( @rp.log_file ) do |f|
199
200
  return if (f.any? { |line| line =~ /ERROR/ }) # Don't test this case if no internet connection
200
201
  end
201
- assert(@rp.already_downloaded(url1), "url1 should be already downloaded after download of url1")
202
+ assert(@rp.already_downloaded(url1, guid1), "url1 should be already downloaded after download of url1")
202
203
  url2 = "http://www.google.co.nz/index.html"
203
- @rp.download(url2)
204
- assert(@rp.already_downloaded(url2), "url2 should be already downloaded after download of url2")
205
- assert(@rp.already_downloaded(url1), "url1 should still be already downloaded after download of url2")
204
+ guid2 = "googlenz"
205
+ @rp.download(url2, guid2)
206
+ assert(@rp.already_downloaded(url2, guid2), "url2 should be already downloaded after download of url2")
207
+ assert(@rp.already_downloaded(url1, guid1), "url1 should still be already downloaded after download of url2")
208
+ url3 = "http://www.google.co.nz/intl/en/about.html"
209
+ assert(@rp.already_downloaded(url3, guid1), "url3 should be already downloaded because it is using giud1")
206
210
  end
207
211
 
208
212
  def test_download_omits_done_items
209
213
  dest_file = @rp.date_dir + "/" + "index.html"
210
214
  system("rm -rf " + dest_file)
211
- @rp.record_download("http://www.google.com/index.html")
212
- @rp.download("http://www.google.com/index.html")
215
+ @rp.record_download("http://www.google.com/index.html", 'google')
216
+ @rp.download("http://www.google.com/index.html", 'google')
213
217
  assert(!File.exists?(dest_file), "#{dest_file} should not be downloaded again if already recorded as done")
214
218
  end
215
219
 
216
220
  def test_download_error_is_logged
217
- @rp.download("http://very.very.broken.url/oh/no/oh/dear.xml")
221
+ @rp.download("http://very.very.broken.url/oh/no/oh/dear.xml", 'oh-dear')
218
222
  File.open( @rp.log_file ) do |f|
219
223
  assert(f.any? { |line| line =~ /ERROR/ }, "Error in download should be logged")
220
224
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matthewgarysmith-rubypodder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lex Miller
@@ -9,7 +9,7 @@ autorequire: rubypodder
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-24 00:00:00 -08:00
12
+ date: 2009-01-25 00:00:00 -08:00
13
13
  default_executable: rubypodder
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency