brand2csv 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ === 0.1.7 27.05.2013
2
+
3
+ * Avoid force_encoding if ruby version 1.8.*
4
+ * Retry up to three times for failures
5
+ * Make rspec spec pass under Ruby 1.8.*
6
+
1
7
  === 0.1.6 27.05.2013
2
8
 
3
9
  * Added support for parsing results up to 10'000 hits
@@ -440,7 +440,9 @@ module Brand2csv
440
440
  }
441
441
  ausgabe.puts s.chop
442
442
  }
443
+ ausgabe.close
443
444
  else
445
+
444
446
  CSV.open(filename, 'w', :headers=>results[0].members,
445
447
  :write_headers => true,
446
448
  :col_sep => ';'
@@ -517,7 +519,7 @@ module Brand2csv
517
519
  doc = Nokogiri::Slop(File.open(filename))
518
520
  else
519
521
  body = @agent.page.body
520
- body.force_encoding('utf-8')
522
+ body.force_encoding('utf-8') unless /^1\.8/.match(RUBY_VERSION)
521
523
  doc = Nokogiri::Slop(body)
522
524
  filename = "#{LogDir}/vereinfachte_#{pageNr}.html"
523
525
  writeResponse(filename)
@@ -538,7 +540,18 @@ module Brand2csv
538
540
  nextId = einfach.firstHit.to_i - 1 + position.to_i
539
541
  data3 = einfach.getPostDataForDetail(nextId, id)
540
542
  Swissreg::setAllInputValue(@agent.page.forms.first, data3)
541
- @agent.page.forms.first.submit
543
+ nrTries = 1
544
+ while true
545
+ begin
546
+ @agent.page.forms.first.submit
547
+ break
548
+ rescue
549
+ puts "Rescue in submit. nrTries is #{nrTries}"
550
+ nrTries += 1
551
+ sleep 1
552
+ exit 1 if nrTries > 3
553
+ end
554
+ end
542
555
  filename = "#{LogDir}/vereinfachte_detail_#{einfach.firstHit + position}.html"
543
556
  writeResponse(filename)
544
557
  matchResult = @agent.page.search('h1').text
@@ -567,7 +580,7 @@ module Brand2csv
567
580
  doc = Nokogiri::Slop(File.open(filename))
568
581
  else
569
582
  body = @agent.page.body
570
- body.force_encoding('utf-8')
583
+ body.force_encoding('utf-8') unless /^1\.8/.match(RUBY_VERSION)
571
584
  doc = Nokogiri::Slop(body)
572
585
  writeResponse(filename)
573
586
  end
@@ -1,3 +1,3 @@
1
1
  module Brand2csv
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brand2csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: