oddb2xml 1.1.7 → 1.1.8

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.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.1.8 / 17.01.2013
2
+
3
+ * Improve File reading on Windows
4
+ * Update ssl connection handling and information
5
+
1
6
  === 1.1.7 / 15.01.2013
2
7
 
3
8
  * Updated Manifest.text
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
- win_fetch_cacerts.rb
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
- # swissindex
77
- types.each do |type|
78
- threads << Thread.new do
79
- downloader = SwissIndexDownloader.new(type, lang)
80
- xml = downloader.download
81
- @mutex.synchronize do
82
- hsh = SwissIndexExtractor.new(xml, type).to_hash
83
- @index[lang][type] = hsh
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]
@@ -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 do |io|
38
- while line = io.gets
39
- xml << line
40
- end
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 # mswin
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 # mswin
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
- puts
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 # mswin
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 # mswin
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? # mswin
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 # mswin
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? # mswin
233
+ io.close unless io.closed? # win
236
234
  if File.exists?(file)
237
235
  File.unlink(file)
238
236
  end
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "1.1.7"
2
+ VERSION = "1.1.8"
3
3
  end