Class: Rake::Task
- Inherits:
-
Object
- Object
- Rake::Task
- Defined in:
- lib/rake/config.rb,
lib/rake/extensions.rb
Class Method Summary collapse
-
.gl_run(*args, &aBlock) ⇒ Object
Execute
command
(as is) on local_host using greenletters to enable expect like behaviour (useful for dealling with passwords). -
.local_sh(*args, &aBlock) ⇒ Object
Execute
command
using sh on local_host using greenletters. -
.remote_ssh(*args, &aBlock) ⇒ Object
Execute
command
using ssh to remote_host using greenletters. -
.rsync_from_remote(remotePath, localPath, options = {}, &aBlock) ⇒ Object
Execute the rsync command on the arguments provided using greenletters.
-
.rsync_to_remote(localPath, remotePath, options = {}, &aBlock) ⇒ Object
Execute the rsync command on the arguments provided using greenletters.
-
.scp_from_remote(remotePath, localPath, options = {}, &aBlock) ⇒ Object
Execute the rsync command on the arguments provided using greenletters.
-
.scp_to_remote_scp(localPath, remotePath, options = {}, &aBlock) ⇒ Object
Execute the rsync command on the arguments provided using greenletters.
Instance Method Summary collapse
-
#execute(args = nil) ⇒ Object
Execute the actions associated with this task.
-
#invoke_with_call_chain(task_args, invocation_chain) ⇒ Object
Same as invoke, but explicitly pass a call chain to detect circular dependencies.
Class Method Details
.gl_run(*args, &aBlock) ⇒ Object
Execute command
(as is) on local_host using greenletters to enable expect like behaviour (useful for dealling with passwords).
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
# File 'lib/rake/config.rb', line 621 def self.gl_run(*args, &aBlock) $TRACE = Rake.application..trace; = Hash.new; if args.last.is_a?(Construct) then raise ConfigurationError, "gl_run should not be passed a Construct"; elsif args.last.is_a?(Hash) = args.pop; end Conf.timeout = Hash.new() unless Conf.has_key?(:timeout); Conf.timeout.maxTimeout = 10 unless Conf.timeout.has_key?(:maxTimeout); if .has_key?(:timeout) then [:timeout] = Conf.timeout.maxTimeout if Conf.timeout.maxTimeout.to_i < [:timeout].to_i ; else [:timeout] = 10; end Rake::Application.mesg args.join(' ') if $TRACE Rake::Application.mesg "#{}" if $TRACE && !.empty?() && .has_key?(:verbose); asyncTriggersBlocks = Array.new; if .has_key? :asyncTriggersBlocks then asyncTriggersBlocks = [:asyncTriggersBlocks]; end exitStatus = 0; if .has_key? :exitStatus then exitStatus = [:exitStatus]; end [:env] = ENV unless .has_key?(:env); [:transcript] = Rake::Application.logger unless .has_key?(:transcript); cmdProcess = Greenletters::Process.new(*args, ); cmdProcess.start!; asyncTriggersBlocks.each do | asyncTriggersBlock | if asyncTriggersBlock.kind_of? Proc then asyncTriggersBlock.call(cmdProcess); end end aBlock.call(cmdProcess) unless aBlock.nil?; cmdProcess.wait_for(:exit, exitStatus); cmdProcess end |
.local_sh(*args, &aBlock) ⇒ Object
Execute command
using sh on local_host using greenletters.
606 607 608 609 610 611 612 613 614 615 616 |
# File 'lib/rake/config.rb', line 606 def self.local_sh(*args, &aBlock) = if args.last.is_a?(Hash) then args.pop else {} end = Conf.sh.data.merge(); cmd = [[:command], [:cmdOptions], "-c", args.flatten.join(' ') ].flatten gl_run(*cmd, , &aBlock); end |
.remote_ssh(*args, &aBlock) ⇒ Object
Execute command
using ssh to remote_host using greenletters.
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
# File 'lib/rake/config.rb', line 584 def self.remote_ssh(*args, &aBlock) = if args.last.is_a?(Hash) then args.pop else {} end = Conf.ssh.data.merge(); [:timeout] = 10 unless .has_key?(:timeout); sshPort = Array.new(); sshPort = [ '-p', [:remotePort]] if .has_key?(:remotePort); cmd = [[:command], [:cmdOptions], '-l', [:userId], sshPort, [:remoteHost] ].flatten gl_run(*cmd, ) do | p | p.wait_for(:output, Regexp.new([:commandPromptRegExp])); Rake::Application.mesg args.flatten.join(' ') if Rake.application..trace; p.puts args.flatten.join(' ') + '; exit'; end end |
.rsync_from_remote(remotePath, localPath, options = {}, &aBlock) ⇒ Object
Execute the rsync command on the arguments provided using greenletters.
571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/rake/config.rb', line 571 def self.rsync_from_remote(remotePath, localPath, = {}, &aBlock) = Conf.rsync.data.merge(); [:timeout] = 10 unless .has_key?(:timeout); cmd = [[:command], [:cmdOptions], "#{[:userId]}@#{[:remoteHost]}:#{remotePath}", localPath, ].flatten gl_run(*cmd, , &aBlock); end |
.rsync_to_remote(localPath, remotePath, options = {}, &aBlock) ⇒ Object
Execute the rsync command on the arguments provided using greenletters.
555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
# File 'lib/rake/config.rb', line 555 def self.rsync_to_remote(localPath, remotePath, = {}, &aBlock) if localPath =~ /\*/ then localPath = Dir.glob(localPath); end = Conf.rsync.data.merge(); [:timeout] = 10 unless .has_key?(:timeout); cmd = [[:command], [:cmdOptions], localPath, "#{[:userId]}@#{[:remoteHost]}:#{remotePath}", ].flatten gl_run(*cmd, , &aBlock); end |
.scp_from_remote(remotePath, localPath, options = {}, &aBlock) ⇒ Object
Execute the rsync command on the arguments provided using greenletters.
542 543 544 545 546 547 548 549 550 551 552 |
# File 'lib/rake/config.rb', line 542 def self.scp_from_remote(remotePath, localPath, = {}, &aBlock) = Conf.scp.data.merge(); [:timeout] = 10 unless .has_key?(:timeout); cmd = [[:command], [:cmdOptions], "#{[:userId]}@#{[:remoteHost]}:#{remotePath}", localPath, ].flatten gl_run(*cmd, , &aBlock); end |
.scp_to_remote_scp(localPath, remotePath, options = {}, &aBlock) ⇒ Object
Execute the rsync command on the arguments provided using greenletters.
529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/rake/config.rb', line 529 def self.scp_to_remote_scp(localPath, remotePath, = {}, &aBlock) = Conf.scp.data.merge(); [:timeout] = 10 unless .has_key?(:timeout); cmd = [[:command], [:cmdOptions], localPath, "#{[:userId]}@#{[:remoteHost]}:#{remotePath}", ].flatten gl_run(*cmd, , &aBlock); end |
Instance Method Details
#execute(args = nil) ⇒ Object
Execute the actions associated with this task.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/rake/extensions.rb', line 173 def execute(args=nil) args ||= EMPTY_TASK_ARGS if application..dryrun Rake::Application.mesg "** Execute (dry run) #{name}" return end if application..trace Rake::Application.mesg "** Execute #{name}" end application.enhance_with_matching_rule(name) if @actions.empty? @actions.each do |act| case act.arity when 1 act.call(self) else act.call(self, args) end end end |
#invoke_with_call_chain(task_args, invocation_chain) ⇒ Object
Same as invoke, but explicitly pass a call chain to detect circular dependencies.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/rake/extensions.rb', line 156 def invoke_with_call_chain(task_args, invocation_chain) # :nodoc: new_chain = InvocationChain.append(self, invocation_chain) @lock.synchronize do if application..trace Rake::Application.mesg "** Invoke #{name} #{format_trace_flags}" end return if @already_invoked @already_invoked = true invoke_prerequisites(task_args, new_chain) execute(task_args) if needed? end rescue Exception => ex add_chain_to(ex, new_chain) raise ex end |