brand2csv 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/brand2csv.rb +19 -10
- data/lib/brand2csv/version.rb +1 -1
- data/spec/utilities_spec.rb +9 -7
- metadata +1 -1
data/History.txt
CHANGED
@@ -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
|
|
data/lib/brand2csv.rb
CHANGED
@@ -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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
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",
|
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,
|
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('&', '&')
|
311
|
-
x.children[1].children.each{ |child| zeilen << child.text.gsub('&', '&') unless child.text.length == 0 } # avoid adding <br>
|
318
|
+
# inhaber = />(.*)<\/td/.match(x.children[1].to_s)[1].gsub('<br>',LineSplit).gsub('&', '&')
|
319
|
+
# x.children[1].children.each{ |child| zeilen << child.text.gsub('&', '&') 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,
|
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
|
|
data/lib/brand2csv/version.rb
CHANGED
data/spec/utilities_spec.rb
CHANGED
@@ -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
|
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
|
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- & 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
|
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
|
66
|
-
zeile_3.should
|
67
|
-
|
68
|
-
|
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
|