lib/screwcap/task.rb in screwcap-0.6.2 vs lib/screwcap/task.rb in screwcap-0.6.3

- old
+ new

@@ -52,10 +52,26 @@ else self.__commands << options.merge({:command => arg, :type => :remote, :from => self.__name}) end end + # execute a ruby command. + # command_set :test do + # run "do this" + # ex { @myvar = true } + # run "do that" + # end + # + # this is good for calling an external service during your deployment. + # + # command_set :after_deploy do + # ex { $hipchat_client.send "Deployment has finished" } + # end + def ex(&block) + self.__commands << {:type => :block, :from => self.__name, :block => block} + end + # SCP a file from your local drive to a remote machine. # task_for :item, :servers => :server do # scp :local => "/tmp/pirate_booty", :remote => "/mnt/app/config/booty.yml" # end @@ -212,10 +228,10 @@ end private def method_missing(m, *args) # :nodoc - if m.to_s[0..1] == "__" or [:run].include?(m) or m.to_s.reverse[0..0] == "=" + if m.to_s[0..1] == "__" or [:run, :ex].include?(m) or m.to_s.reverse[0..0] == "=" super(m, args.first) elsif m == :to_ary # In Ruby 1.9, Array#flatten calls #to_ary on each of the # array's children and only if there is a NoMethodError raised # does it assume the object is not an array. Compare this to