Quick tip - Ensuring required gems and libs are available
Title: Quick tip - ensuring required gems and libs are available
So you're ready to push your code out to your production server farm. You know your plugins will get there safe as they are located in vendor/lib. But what about checking for gems that must be installed? What about checking for third-party ruby extensions (Example: The tclink payment processing ruby extention from TrustCommerce)?
Just add the code below (with your required lib names) and you should be good to go!
environment.rb
# --- [ check that we have all the gems and libs we need ] ---
missing_libs = []
%w( tzinfo tclink mysql money ).each do |lib|
begin
require lib
rescue LoadError
missing_libs << lib
end
end
if !missing_libs.empty?
STDERR.puts '----------------------------------------------------------------'
STDERR.puts '--- [ The following required libraries could not be loaded ] ---'
STDERR.puts '----------------------------------------------------------------'
missing_libs.each{|lib| STDERR.puts " * #{lib}"}
exit 1
end


Commenting is closed for this article.