module Baptize::Plugins::Helpers

Public Instance Methods

asset_path(asset) click to toggle source
# File lib/baptize/plugins/helpers.rb, line 6
def asset_path(asset)
  File.expand_path(File.join("assets", asset))
end
escape_sed_arg(s) click to toggle source
# File lib/baptize/plugins/helpers.rb, line 14
def escape_sed_arg(s)
  s.gsub("'", "'\\\\''").gsub("\n", '\n').gsub("/", "\\\\/").gsub('&', '\\\&')
end
md5_of_file(path, md5) click to toggle source
# File lib/baptize/plugins/helpers.rb, line 10
def md5_of_file(path, md5)
  remote_assert "test $(md5sum #{path.shellescape} | cut -f1 -d' ') = #{md5.shellescape}"
end
render(path, locals = {}) click to toggle source
# File lib/baptize/plugins/helpers.rb, line 22
def render(path, locals = {})
  require 'erb'
  require 'ostruct'
  ERB.new(File.read(path)).result(locals.kind_of?(Binding) ? locals : OpenStruct.new(locals).instance_eval { binding })
end
replace_text(pattern, replacement, path) click to toggle source
# File lib/baptize/plugins/helpers.rb, line 18
def replace_text(pattern, replacement, path)
  remote_execute "sed -i 's/#{escape_sed_arg(pattern)}/#{escape_sed_arg(replacement)}/g' #{path.shellescape}"
end