brand2csv 0.2.6 → 0.2.7

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.
@@ -1,3 +1,7 @@
1
+ === 0.2.7 27.08.2013
2
+
3
+ * Update to handle too many result view in swissreg
4
+
1
5
  === 0.2.6 26.08.2013
2
6
 
3
7
  * Update to work with ruby 1.8.7
@@ -10,6 +10,7 @@ require 'logger'
10
10
 
11
11
  module Brand2csv
12
12
 
13
+
13
14
  class Marke < Struct.new(:name, :markennummer, :inhaber, :land, :hinterlegungsdatum, :zeile_1, :zeile_2, :zeile_3, :zeile_4, :zeile_5, :plz, :ort)
14
15
  end
15
16
 
@@ -420,11 +421,18 @@ module Brand2csv
420
421
  # There we find info like "Seite 1 von 26 - Treffer 1-250 von 6'349" and upto 250 links to details
421
422
  def initialize(doc)
422
423
  @inputData = []
424
+ @pageNr = @nrSubPages = @firstHit = @nrHits = 0
423
425
  m = HitRegexpDE.match(doc.text)
424
- @pageNr = m[1].sub("'", '').to_i
425
- @nrSubPages = m[2].sub("'", '').to_i
426
- @firstHit = m[3].sub("'", '').to_i
427
- @nrHits = m[5].sub("'", '').to_i
426
+ if m
427
+ begin
428
+ c = m.to_a.map{|n| n.gsub(/'/, "").to_i }
429
+ @pageNr = c[1]
430
+ @nrSubPages = c[2]
431
+ @firstHit = c[3]
432
+ @nrHits = c[5]
433
+ rescue NoMethodError
434
+ end
435
+ end
428
436
  @trademark_search_id = Swissreg::inputValue(Swissreg::getInputValuesFromPage(doc), Vivian)
429
437
  @links2details = []
430
438
  doc.search('input').each{ |input|
@@ -478,13 +486,19 @@ module Brand2csv
478
486
  if filename && File.exists?(filename)
479
487
  doc = Nokogiri::Slop(File.open(filename))
480
488
  else
481
- body = @agent.page.body
489
+ form = @agent.page.form
490
+ btn = form.buttons.last
491
+ if btn && btn.name == "id_swissreg:mainContent:id_show_simple_view_hitlist"
492
+ res = @agent.submit(form, btn)
493
+ body = res.body
494
+ else
495
+ body = @agent.page.body
496
+ end
482
497
  body.force_encoding('utf-8') unless /^1\.8/.match(RUBY_VERSION)
483
498
  doc = Nokogiri::Slop(body)
484
499
  filename = "#{LogDir}/vereinfachte_#{pageNr}.html"
485
500
  writeResponse(filename)
486
501
  end
487
-
488
502
  einfach = Swissreg::Vereinfachte.new(doc)
489
503
  puts "#{Time.now.strftime("%H:%M:%S")} status: getAllHits for #{pageNr} of #{einfach.nrSubPages} pages" if $VERBOSE
490
504
  subPage2Fetch = pageNr + 1
@@ -1,3 +1,3 @@
1
1
  module Brand2csv
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brand2csv
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 6
10
- version: 0.2.6
9
+ - 7
10
+ version: 0.2.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Niklaus Giger, Zeno R.R. Davatz
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-08-26 00:00:00 Z
18
+ date: 2013-08-27 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: mechanize