oddb2xml 1.1.7 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +3 -2
- data/README.md +18 -0
- data/lib/oddb2xml/cli.rb +26 -8
- data/lib/oddb2xml/downloader.rb +15 -17
- data/lib/oddb2xml/version.rb +1 -1
- data/tools/cacert.pem +3895 -0
- data/{set.bat → tools/set.bat} +0 -0
- data/{win_fetch_cacerts.rb → tools/win_fetch_cacerts.rb} +0 -0
- metadata +31 -30
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -14,7 +14,6 @@ lib/oddb2xml/compressor.rb
|
|
14
14
|
lib/oddb2xml/downloader.rb
|
15
15
|
lib/oddb2xml/extractor.rb
|
16
16
|
lib/oddb2xml/version.rb
|
17
|
-
set.bat
|
18
17
|
spec/builder_spec.rb
|
19
18
|
spec/cli_spec.rb
|
20
19
|
spec/compressor_spec.rb
|
@@ -43,4 +42,6 @@ spec/data/ywesee_bm_update.txt
|
|
43
42
|
spec/downloader_spec.rb
|
44
43
|
spec/extractor_spec.rb
|
45
44
|
spec/spec_helper.rb
|
46
|
-
|
45
|
+
tools/cacert.pem
|
46
|
+
tools/set.bat
|
47
|
+
tools/win_fetch_cacerts.rb
|
data/README.md
CHANGED
@@ -160,3 +160,21 @@ product.xml has relation to substance as `<SUBNO>`.
|
|
160
160
|
</RESULT>
|
161
161
|
</SUBSTANCE>
|
162
162
|
```
|
163
|
+
|
164
|
+
## About SSLv3 cert
|
165
|
+
|
166
|
+
Some websites need SSLv3 connection.
|
167
|
+
If you don't have these root CA files (x509), Please install these Certificates before running.
|
168
|
+
Please confirm wit `ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'`.
|
169
|
+
|
170
|
+
see [cURL Website](http://curl.haxx.se/ca/)
|
171
|
+
|
172
|
+
|
173
|
+
### Windows User
|
174
|
+
|
175
|
+
1. Download this [cacert.pem](http://curl.haxx.se/ca/cacert.pem) (cURL) into your HOME directory.
|
176
|
+
1. Then Choose Menu "Control Panel" > "System" > "Advanced system settings" (This open "System Properties" Window.)
|
177
|
+
2. Click "Advanced" Tab.
|
178
|
+
3. Click "Environment Variables" button.
|
179
|
+
4. Add set variable entry "SSL\_CERT\_FILE=%HOMEPATH%\cacert.pem" (Variable name: SSL\_CCERT\_FILE, Variable value: %HOMEPATH%\cacert.pem) with "New..." button into upper are "User variables for xxx"
|
180
|
+
5. (Please do not remove this cacert.pem. All SSLv3 connections use this file.)
|
data/lib/oddb2xml/cli.rb
CHANGED
@@ -72,19 +72,37 @@ module Oddb2xml
|
|
72
72
|
@flags = YweseeBMExtractor.new(str).to_hash
|
73
73
|
end
|
74
74
|
end
|
75
|
+
ssl = true
|
76
|
+
catch :ssl do
|
75
77
|
LANGUAGES.each do |lang|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
# swissindex
|
79
|
+
types.each do |type|
|
80
|
+
begin
|
81
|
+
thread = thread.new do
|
82
|
+
downloader = SwissIndexDownloader.new(type, lang)
|
83
|
+
xml = downloader.download
|
84
|
+
@mutex.synchronize do
|
85
|
+
hsh = SwissIndexExtractor.new(xml, type).to_hash
|
86
|
+
@index[lang][type] = hsh
|
87
|
+
end
|
88
|
+
end
|
89
|
+
thread.abort_on_exception = true
|
90
|
+
threads << thread
|
91
|
+
rescue Exception
|
92
|
+
ssl = false
|
93
|
+
throw :ssl
|
84
94
|
end
|
85
95
|
end
|
86
96
|
end
|
87
97
|
end
|
98
|
+
unless ssl
|
99
|
+
puts
|
100
|
+
puts "(Aborted)"
|
101
|
+
puts "Please install SSLv3 CA certificates on your machine."
|
102
|
+
puts "You can check with `ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'`."
|
103
|
+
puts "See README."
|
104
|
+
exit
|
105
|
+
end
|
88
106
|
threads.map(&:join)
|
89
107
|
build
|
90
108
|
compress if @options[:compress_ext]
|
data/lib/oddb2xml/downloader.rb
CHANGED
@@ -31,14 +31,16 @@ module Oddb2xml
|
|
31
31
|
end
|
32
32
|
def read_xml_form_zip(target, zipfile)
|
33
33
|
xml = ''
|
34
|
-
if RUBY_PLATFORM =~ /mswin/i # for memory error
|
34
|
+
if RUBY_PLATFORM =~ /mswin|mingw|bccwin|cygwin/i # for memory error
|
35
35
|
Zip::ZipFile.foreach(zipfile) do |entry|
|
36
36
|
if entry.name =~ target
|
37
|
-
entry.get_input_stream
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
io = entry.get_input_stream
|
38
|
+
until io.eof?
|
39
|
+
bytes = io.read(1024)
|
40
|
+
xml << bytes
|
41
|
+
bytes = nil
|
41
42
|
end
|
43
|
+
io.close
|
42
44
|
end
|
43
45
|
end
|
44
46
|
else
|
@@ -61,7 +63,7 @@ module Oddb2xml
|
|
61
63
|
begin
|
62
64
|
response = @agent.get(@url)
|
63
65
|
response.save_as(file)
|
64
|
-
response = nil #
|
66
|
+
response = nil # win
|
65
67
|
return read_xml_form_zip(/^Preparation/iu, file)
|
66
68
|
rescue Timeout::Error
|
67
69
|
retrievable? ? retry : raise
|
@@ -102,7 +104,7 @@ XML
|
|
102
104
|
response = @client.call(:download_all, :xml => soap)
|
103
105
|
if response.success?
|
104
106
|
if xml = response.to_xml
|
105
|
-
response = nil #
|
107
|
+
response = nil # win
|
106
108
|
return xml
|
107
109
|
else
|
108
110
|
# received broken data or internal error
|
@@ -112,11 +114,7 @@ XML
|
|
112
114
|
raise Timeout::Error
|
113
115
|
end
|
114
116
|
rescue HTTPI::SSLError
|
115
|
-
|
116
|
-
puts "Please install SSLv3 cert on your machine."
|
117
|
-
puts "You can check location of cert file with `ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'`."
|
118
|
-
puts "Or confirm SSL_CERT_FILE environment."
|
119
|
-
exit
|
117
|
+
raise Exception # catch me in Cli class
|
120
118
|
rescue Timeout::Error
|
121
119
|
retrievable? ? retry : raise
|
122
120
|
end
|
@@ -144,7 +142,7 @@ XML
|
|
144
142
|
link = Mechanize::Page::Link.new(link_node, @agent, page)
|
145
143
|
response = link.click
|
146
144
|
response.save_as(file)
|
147
|
-
response = nil #
|
145
|
+
response = nil # win
|
148
146
|
end
|
149
147
|
io = File.open(file, 'rb')
|
150
148
|
return io.read
|
@@ -203,13 +201,13 @@ XML
|
|
203
201
|
begin
|
204
202
|
response = @agent.get(@url)
|
205
203
|
response.save_as(file)
|
206
|
-
response = nil #
|
204
|
+
response = nil # win
|
207
205
|
io = File.open(file, 'r')
|
208
206
|
return io.read
|
209
207
|
rescue Timeout::Error
|
210
208
|
retrievable? ? retry : raise
|
211
209
|
ensure
|
212
|
-
io.close unless io.closed? #
|
210
|
+
io.close unless io.closed? # win
|
213
211
|
if File.exists?(file)
|
214
212
|
File.unlink(file)
|
215
213
|
end
|
@@ -226,13 +224,13 @@ XML
|
|
226
224
|
begin
|
227
225
|
response = @agent.get(@url)
|
228
226
|
response.save_as(file)
|
229
|
-
response = nil #
|
227
|
+
response = nil # win
|
230
228
|
io = File.open(file, 'r')
|
231
229
|
return io.read
|
232
230
|
rescue Timeout::Error
|
233
231
|
retrievable? ? retry : raise
|
234
232
|
ensure
|
235
|
-
io.close unless io.closed? #
|
233
|
+
io.close unless io.closed? # win
|
236
234
|
if File.exists?(file)
|
237
235
|
File.unlink(file)
|
238
236
|
end
|
data/lib/oddb2xml/version.rb
CHANGED