Module: Albacore::RunCommand
- Extended by:
- AttrMethods
- Included in:
- AspNetCompiler, CSC, Docu, Exec, FluentMigratorRunner, IlMerge, MSBuild, MSDeploy, MSTestTestRunner, MSpecTestRunner, NAnt, NChurn, NCoverConsole, NCoverReport, NDepend, NUnitTestRunner, NuGetInstall, NuGetPack, NuGetPublish, NuGetPush, NuGetUpdate, PLink, SQLCmd, SpecFlowReport, VssGet, XBuild, XUnitTestRunner
- Defined in:
- lib/albacore/support/runcommand.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#working_directory ⇒ Object
Returns the value of attribute working_directory.
Instance Method Summary collapse
- #get_command(params) ⇒ Object
- #initialize ⇒ Object
- #run_command(name = "Command Line", parameters = nil) ⇒ Object
Methods included from AttrMethods
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
7 8 9 |
# File 'lib/albacore/support/runcommand.rb', line 7 def command @command end |
#working_directory ⇒ Object
Returns the value of attribute working_directory.
7 8 9 |
# File 'lib/albacore/support/runcommand.rb', line 7 def working_directory @working_directory end |
Instance Method Details
#get_command(params) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/albacore/support/runcommand.rb', line 35 def get_command(params) executable = @command unless command.nil? executable = File.(@command) if File.exists?(@command) end cmd = "\"#{executable}\"" cmd +=" #{params.join(' ')}" if params.length > 0 cmd end |
#initialize ⇒ Object
10 11 12 13 14 |
# File 'lib/albacore/support/runcommand.rb', line 10 def initialize @working_directory = Dir.pwd @parameters = [] super() end |
#run_command(name = "Command Line", parameters = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/albacore/support/runcommand.rb', line 16 def run_command(name="Command Line", parameters=nil) begin params = Array.new params << parameters unless parameters.nil? params << @parameters unless (@parameters.nil? || @parameters.length==0) cmd = get_command(params) @logger.debug "Executing #{name}: #{cmd}" Dir.chdir(@working_directory) do return system(cmd) end rescue Exception => e puts "Error While Running Command Line Tool: #{e}" raise end end |