class Object
Public Instance Methods
convert_daemon_script(daemon)
click to toggle source
# File lib/capsum/daemons.rb, line 29 def convert_daemon_script(daemon) strip_heredoc <<-EOF #!/usr/bin/env bash start(){ #{daemon[:start]} } stop(){ #{daemon[:stop]} } usage(){ echo "Usage: $(basename $0) {stop|stop}" } command=${1:-usage} shift case "$command" in start) start $@ ;; stop) stop $@ ;; *) usage ;; esac EOF end
setup_whenever_task(*args) { |host| ... }
click to toggle source
# File lib/capsum/whenever.rb, line 17 def setup_whenever_task(*args, &block) args = Array(fetch(:whenever_command)) + args on roles fetch(:whenever_roles) do |host| return if host.nil? args = args + Array(yield(host)) if block_given? within release_path do with fetch(:whenever_command_environment_variables) do execute *args end end end end
strip_heredoc(str)
click to toggle source
# File lib/capsum/daemons.rb, line 55 def strip_heredoc(str) indent = (str.scan(/^[ \t]*(?=\S)/).min || "").size str.gsub(/^[ \t]{#{indent}}/, '') end