brand2csv 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,12 @@
1
+ === 0.2.1 02.06.2013
2
+
3
+ * Fixed problems with ampersands. Emit clear error when swisssreg.ch not responding correctly
4
+
1
5
  === 0.2.0 02.06.2013
2
6
 
3
7
  * Updated README.md
8
+ * Fix problem with & in names
9
+ * Catch "500 Internal Server Error" when connecting to swissreg
4
10
 
5
11
  === 0.1.9 02.06.2013
6
12
 
@@ -18,6 +18,7 @@ module Brand2csv
18
18
  # Weitere gesehene Fehler
19
19
  BekannteFehler =
20
20
  ['Das Datum ist ung', # ültig'
21
+ '500 Internal Server Error',
21
22
  'Vereinfachte Trefferliste anzeigen',
22
23
  'Es wurden keine Daten gefunden.',
23
24
  'Die Suchkriterien sind teilweise unzul', # ässig',
@@ -134,11 +135,17 @@ module Brand2csv
134
135
  marke = @marke,
135
136
  nummer =@number) # nummer = "559271" ergibt genau einen treffer
136
137
 
137
- @agent.get_file Start_uri # 'https://www.swissreg.ch/srclient/faces/jsp/start.jsp'
138
- writeResponse("#{LogDir}/session_expired.html")
139
- @agent.page.links[3].click
140
- writeResponse("#{LogDir}/homepage.html")
141
- @state = @agent.page.form["javax.faces.ViewState"]
138
+ begin
139
+ @agent.get_file Start_uri # 'https://www.swissreg.ch/srclient/faces/jsp/start.jsp'
140
+ writeResponse("#{LogDir}/session_expired.html")
141
+ checkErrors(@agent.page.body, false)
142
+ @agent.page.links[3].click
143
+ writeResponse("#{LogDir}/homepage.html")
144
+ @state = @agent.page.form["javax.faces.ViewState"]
145
+ rescue Net::HTTPInternalServerError, Mechanize::ResponseCodeError
146
+ puts "Net::HTTPInternalServerError oder Mechanize::ResponseCodeError gesehen.\n #{Base_uri} hat wahrscheinlich Probleme"
147
+ exit 3
148
+ end
142
149
  data = [
143
150
  ["autoScroll", "0,0"],
144
151
  ["id_swissreg:_link_hidden_", ""],
@@ -169,7 +176,7 @@ module Brand2csv
169
176
  ["id_swissreg:mainContent:id_txf_app_no", ""], # Gesuch Nr.
170
177
  ["id_swissreg:mainContent:id_txf_tm_text", "#{marke}"],
171
178
  ["id_swissreg:mainContent:id_txf_applicant", ""], # Inhaber/in
172
- ["id_swissreg:mainContent:id_cbxCountry", "CH"],
179
+ ["id_swissreg:mainContent:id_cbxCountry", '_ALL'],
173
180
  ["id_swissreg:mainContent:id_txf_agent", ""], # Vertreter/in
174
181
  ["id_swissreg:mainContent:id_txf_licensee", ""], # Lizenznehmer
175
182
  ["id_swissreg:mainContent:id_txf_nizza_class", ""], # Nizza Klassifikation Nr.
@@ -211,7 +218,8 @@ module Brand2csv
211
218
 
212
219
  # the number is only passed to facilitate debugging
213
220
  # lines are the address lines
214
- def Swissreg::parseAddress(number, lines)
221
+ def Swissreg::parseAddress(number, inhaber)
222
+ lines = CGI.unescapeHTML(inhaber).split(LineSplit)
215
223
  ort = nil
216
224
  plz = nil
217
225
 
@@ -307,13 +315,14 @@ module Brand2csv
307
315
  end
308
316
  end
309
317
  if x.children.first.text.eql?('Inhaber/in')
310
- inhaber = />(.*)<\/td/.match(x.children[1].to_s)[1].gsub('<br>',LineSplit).gsub('&amp;', '&')
311
- x.children[1].children.each{ |child| zeilen << child.text.gsub('&amp;', '&') unless child.text.length == 0 } # avoid adding <br>
318
+ # inhaber = />(.*)<\/td/.match(x.children[1].to_s)[1].gsub('<br>',LineSplit).gsub('&amp;', '&')
319
+ # x.children[1].children.each{ |child| zeilen << child.text.gsub('&amp;', '&') unless child.text.length == 0 } # avoid adding <br>
320
+ inhaber = />(.*)<\/td/.match(x.children[1].to_s)[1].gsub('<br>',LineSplit)
312
321
  end
313
322
  hinterlegungsdatum = x.children[1].text if x.children.first.text.eql?('Hinterlegungsdatum')
314
323
  number = x.children[1].text if x.children.first.text.eql?('Gesuch Nr.')
315
324
  }
316
- zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, zeilen)
325
+ zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, inhaber)
317
326
  marke = Marke.new(bezeichnung, number, inhaber, DefaultCountry, hinterlegungsdatum, zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort )
318
327
  end
319
328
 
@@ -1,3 +1,3 @@
1
1
  module Brand2csv
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -38,7 +38,7 @@ describe 'Tests parsing adress line' do
38
38
  it "must handle correctly Via San Salvatore, 2" do
39
39
  full_address_line = 'Ideal Hobby Sagl, Via San Salvatore, 2, 6902 Paradiso'
40
40
  number = 'for_debugging'
41
- zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line.split(Swissreg::LineSplit))
41
+ zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
42
42
  zeile_1.should == 'Ideal Hobby Sagl'
43
43
  zeile_2.should == 'Via San Salvatore, 2'
44
44
  zeile_3.should be_nil
@@ -49,7 +49,7 @@ describe 'Tests parsing adress line' do
49
49
  it "must handle correctly 90, route de Frontenex" do
50
50
  full_address_line = 'Olivier Karim Wasem, 90, route de Frontenex, 1208 Genève'
51
51
  number = 'for_debugging'
52
- zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line.split(Swissreg::LineSplit))
52
+ zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
53
53
  zeile_1.should == 'Olivier Karim Wasem'
54
54
  zeile_2.should == '90, route de Frontenex'
55
55
  zeile_3.should be_nil
@@ -60,11 +60,13 @@ describe 'Tests parsing adress line' do
60
60
  it "must handle ampersands correctly" do
61
61
  full_address_line = 'Schweiz. Serum- &amp; Impfinstitut, und Institut zur Erforschung der, Infektionskrankheiten, Rehhagstrasse 79, 3018 Bern'
62
62
  number = 'for_debugging'
63
- zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line.split(Swissreg::LineSplit))
63
+ zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
64
64
  zeile_1.should == 'Schweiz. Serum- & Impfinstitut'
65
- zeile_2.should be_nil
66
- zeile_3.should be_nil
67
- plz.should be_nil
68
- ort.should be_nil
65
+ zeile_2.should == 'und Institut zur Erforschung der'
66
+ zeile_3.should == 'Infektionskrankheiten'
67
+ zeile_4.should == 'Rehhagstrasse 79'
68
+ zeile_5.should be_nil
69
+ plz.should == '3018'
70
+ ort.should == 'Bern'
69
71
  end
70
72
  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.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: