Module: Shuttle::Helpers
- Included in:
- Deploy
- Defined in:
- lib/shuttle/helpers.rb
Constant Summary collapse
- LEVEL_COLORS =
{ 'info' => :green, 'warning' => :yellow, 'error' => :red }
Instance Method Summary collapse
- #deployer_hostname ⇒ Object
- #error(message) ⇒ Object
- #git_installed? ⇒ Boolean
- #git_remote ⇒ Object
- #log(message, level = 'info') ⇒ Object
- #release_exists? ⇒ Boolean
- #stream_output(buff) ⇒ Object
- #svn_installed? ⇒ Boolean
- #warn(message) ⇒ Object
Instance Method Details
#deployer_hostname ⇒ Object
52 53 54 |
# File 'lib/shuttle/helpers.rb', line 52 def deployer_hostname `hostname`.strip end |
#error(message) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/shuttle/helpers.rb', line 14 def error() log("ERROR: #{}", "error") log("Release v#{version} aborted", "error") raise DeployError, end |
#git_installed? ⇒ Boolean
25 26 27 |
# File 'lib/shuttle/helpers.rb', line 25 def git_installed? ssh.run("which git").success? end |
#git_remote ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/shuttle/helpers.rb', line 42 def git_remote result = ssh.run("cd #{scm_path} && git remote -v") if result.success? result.output.scan(/^origin\t(.+)\s\(fetch\)/).flatten.first else nil end end |
#log(message, level = 'info') ⇒ Object
9 10 11 12 |
# File 'lib/shuttle/helpers.rb', line 9 def log(, level='info') prefix = "----->".send(LEVEL_COLORS[level]) STDOUT.puts("#{prefix} #{}") end |
#release_exists? ⇒ Boolean
33 34 35 |
# File 'lib/shuttle/helpers.rb', line 33 def release_exists? ssh.directory_exists?(release_path) end |
#stream_output(buff) ⇒ Object
37 38 39 40 |
# File 'lib/shuttle/helpers.rb', line 37 def stream_output(buff) str = buff.split("\n").map { |str| " #{str}"}.join("\n") STDOUT.puts(str) end |
#svn_installed? ⇒ Boolean
29 30 31 |
# File 'lib/shuttle/helpers.rb', line 29 def svn_installed? ssh.run("which svn").success? end |
#warn(message) ⇒ Object
21 22 23 |
# File 'lib/shuttle/helpers.rb', line 21 def warn() log("WARNING: #{}", "warning") end |