Skip to content

Commit

Permalink
Handle wkhtmltopdf dep via gem for Heroku environments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Bach committed Aug 31, 2016
1 parent 6c69ad7 commit c4ce57d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ gem 'yard', '0.8.7.6'
gem 'yard-dm', '0.1.1'
gem 'yard-sinatra', '1.0.0'
gem 'eventmachine', '1.0.7'
gem "pdfkit"
gem "wkhtmltopdf-heroku"
gem "pdfkit", '~> 0.8.2'
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ GEM
wasabi (3.5.0)
httpi (~> 2.0)
nokogiri (>= 1.4.2)
wkhtmltopdf-heroku (2.12.3.0)
xml-simple (1.1.5)
yard (0.8.7.6)
yard-dm (0.1.1)
Expand All @@ -164,7 +165,7 @@ DEPENDENCIES
json (~> 1.8.3)
multipart-post (~> 2.0.0)
nokogiri (~> 1.6.7.2)
pdfkit
pdfkit (~> 0.8.2)
pg (~> 0.18.4)
pony (~> 1.11)
rack-ssl (~> 1.4.1)
Expand All @@ -178,6 +179,7 @@ DEPENDENCIES
savon (~> 2.11.1)
sinatra (~> 1.4.6)
thin (~> 1.6.4)
wkhtmltopdf-heroku
xml-simple (~> 1.1.5)
yard (= 0.8.7.6)
yard-dm (= 0.1.1)
Expand Down
9 changes: 9 additions & 0 deletions lib/funcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,12 @@ def getPanelRecordsCount(records)

return size
end

##
# Based on ENV variables, detect if Vulnreport is running on Heroku. This detection
# is based on the premise that a Heroku deploy will be using Heroku Postgres, resulting
# in the presence of an environment variable similar to HEROKU_POSTGRESQL_...
# @return [Boolean] True if running on Heroku, False otherwise
def onHeroku?()
return ENV.any? {|x,_| x =~ /^HEROKU/ }
end
6 changes: 6 additions & 0 deletions web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
require './lib/VRDashConfig'
require './lib/VRLinkedObject'

if(onHeroku?)
#Only load this gem if running on Heroku. If not on Heroku
#this dep should be handled by local library install, not gem
require 'wkhtmltopdf-heroku'
end

# Load all cron files and VRDashConfigs and register them later
Dir["./crons/*.rb"].each {|cronfile| require cronfile}
Dir["./customDashes/*.rb"].each {|dcfile| require dcfile}
Expand Down

0 comments on commit c4ce57d

Please sign in to comment.