Skip to content

Commit 1dedbba

Browse files
committed
Lazy load win32ole.
1 parent fab2597 commit 1dedbba

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/sierra_postgres_utilities/sierradb.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22
require 'yaml'
33
require 'mail'
44
require 'pg'
5-
begin
6-
require 'win32ole'
7-
rescue LoadError
8-
puts "\n\nwin32ole not found. writing output to .xlsx disabled. win32ole is
9-
probably not available on linux/mac but should be part of the standard
10-
library on Windows installs of Ruby"
11-
end
5+
# 'win32ole' conditionally loaded
6+
127

138
module SierraDB
149

@@ -179,8 +174,13 @@ def self.write_csv(outfile, results, headers, col_sep: ',')
179174
end
180175

181176
def self.write_xlsx(outfile, results, headers)
182-
unless defined?(WIN32OLE)
183-
raise 'WIN32OLE not loaded; cannot write to xlsx file'
177+
begin
178+
require 'win32ole'
179+
rescue LoadError
180+
puts "win32ole not found. writing output to .xlsx disabled. win32ole is
181+
probably not available on linux/mac but should be part of the standard
182+
library on Windows installs of Ruby"
183+
raise
184184
end
185185
excel = WIN32OLE.new('Excel.Application')
186186
excel.visible = false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SierraPostgresUtilities
2-
VERSION = '0.2.1'.freeze
2+
VERSION = '0.2.2'.freeze
33
end

0 commit comments

Comments
 (0)