Skip to content

Commit

Permalink
Merge pull request #16 from UNC-Libraries/lazy-load-win32ole
Browse files Browse the repository at this point in the history
Lazy load win32ole.
  • Loading branch information
ldss-jm authored Jan 30, 2019
2 parents fab2597 + 1dedbba commit abf678a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/sierra_postgres_utilities/sierradb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
require 'yaml'
require 'mail'
require 'pg'
begin
require 'win32ole'
rescue LoadError
puts "\n\nwin32ole not found. writing output to .xlsx disabled. win32ole is
probably not available on linux/mac but should be part of the standard
library on Windows installs of Ruby"
end
# 'win32ole' conditionally loaded


module SierraDB

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

def self.write_xlsx(outfile, results, headers)
unless defined?(WIN32OLE)
raise 'WIN32OLE not loaded; cannot write to xlsx file'
begin
require 'win32ole'
rescue LoadError
puts "win32ole not found. writing output to .xlsx disabled. win32ole is
probably not available on linux/mac but should be part of the standard
library on Windows installs of Ruby"
raise
end
excel = WIN32OLE.new('Excel.Application')
excel.visible = false
Expand Down
2 changes: 1 addition & 1 deletion lib/sierra_postgres_utilities/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SierraPostgresUtilities
VERSION = '0.2.1'.freeze
VERSION = '0.2.2'.freeze
end

0 comments on commit abf678a

Please sign in to comment.