Module: Capistrano::Ops::Wkhtmltopdf::Helpers
- Defined in:
- lib/capistrano/ops/wkhtmltopdf/helpers.rb
Instance Method Summary collapse
- #binary_path ⇒ Object
- #binary_path_and_version ⇒ Object
- #check_file_and_permissions(binary_path, version) ⇒ Object
- #file_existing?(file) ⇒ Boolean
- #gem_version ⇒ Object
- #right_permissions?(file) ⇒ Boolean
Instance Method Details
#binary_path ⇒ Object
7 8 9 10 |
# File 'lib/capistrano/ops/wkhtmltopdf/helpers.rb', line 7 def binary_path gem_path = capture(:bundle, 'show', 'wkhtmltopdf-binary').strip "#{gem_path}/bin" end |
#binary_path_and_version ⇒ Object
16 17 18 |
# File 'lib/capistrano/ops/wkhtmltopdf/helpers.rb', line 16 def binary_path_and_version [binary_path, gem_version] end |
#check_file_and_permissions(binary_path, version) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/capistrano/ops/wkhtmltopdf/helpers.rb', line 28 def (binary_path, version) binary_file = "#{binary_path}/wkhtmltopdf_ubuntu_#{version}_amd64" if file_existing?(binary_file) info('wkhtmltopdf binary already extracted') if (binary_file) info('wkhtmltopdf binary has already the right permissions') else info('adding right permissions to wkhtmltopdf binary') execute("chmod 777 #{binary_file}") end else info('extracting wkhtmltopdf binary') # extract the binary but keep the gzip file execute("cd #{binary_path} && gzip -dk wkhtmltopdf_ubuntu_#{version}_amd64.gz") # add execute permission to the binary execute("chmod 777 #{binary_file}") end info('wkhtmltopdf setup finished') end |
#file_existing?(file) ⇒ Boolean
20 21 22 |
# File 'lib/capistrano/ops/wkhtmltopdf/helpers.rb', line 20 def file_existing?(file) test("[ -f #{file} ]") end |
#gem_version ⇒ Object
12 13 14 |
# File 'lib/capistrano/ops/wkhtmltopdf/helpers.rb', line 12 def gem_version capture(:cat, 'config/initializers/wicked_pdf.rb').scan(/wkhtmltopdf_ubuntu_(\d+\.\d+)_amd64/).flatten.first end |
#right_permissions?(file) ⇒ Boolean
24 25 26 |
# File 'lib/capistrano/ops/wkhtmltopdf/helpers.rb', line 24 def (file) test("[ $(stat -c '%a' #{file}) = '777' ]") end |