Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy load win32ole. #16

Merged
merged 1 commit into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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