Skip to content

Commit

Permalink
Add the 'say' method to output messages in a nice fashion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Schwyn committed Apr 20, 2012
1 parent 026e97d commit cc08d09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 14 additions & 1 deletion README.textile
Expand Up @@ -166,7 +166,20 @@ To show a "down for maintenance" page during the deployment, use the before_git

If you need another hook, please fork the project and implement it. Or submit an issue, it's very easy.

h2. CONTRIBUTORS:
h3. say

Use the <code>say</code> method to show messages issued by your hooks.

<pre><code># Show a simple message
say 'restart custom daemons'

# Show a message (blank output lines are suppressed)
say 'revert local changes' do |output|
output << `git checkout . 2>&1`
end
</pre></code>

h2. CONTRIBUTORS

Inploy is brought to you by:

Expand Down
15 changes: 9 additions & 6 deletions lib/inploy/dsl.rb
Expand Up @@ -32,10 +32,6 @@ def load_module(filename)
extend eval(filename.split("/").map { |word| camelize(word) }.join("::"))
end

def log(command)
puts "Inploy => #{command}"
end

def rake(command)
run "rake #{command}"
end
Expand All @@ -56,8 +52,15 @@ def using_bundler?
file_exists?("Gemfile")
end

def say(message)
puts "Inploy => #{message}"
output = []
yield output if block_given?
output.each {|o| puts o if o =~ /\S/ }
end

def run(command, disable_sudo = false)
log command
say command

Bundler.with_clean_env do
if disable_sudo
Expand All @@ -81,7 +84,7 @@ def login_shell_wrap(cmd)

def secure_copy(src, dest)
unless file_exists?(dest)
log "cp #{src} #{dest}"
say "cp #{src} #{dest}"
FileUtils.cp src, dest
end
end
Expand Down

0 comments on commit cc08d09

Please sign in to comment.