Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add the 'say' method to output messages in a nice fashion.

  • Loading branch information...
commit cc08d0916ca74472251f29241432c22602931eab 1 parent 026e97d
@svoop svoop authored
Showing with 23 additions and 7 deletions.
  1. +14 −1 README.textile
  2. +9 −6 lib/inploy/dsl.rb
View
15 README.textile
@@ -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:
View
15 lib/inploy/dsl.rb
@@ -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
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.