Class: AlpacaBuildTool::Tool
- Inherits:
-
Object
- Object
- AlpacaBuildTool::Tool
- Includes:
- Log
- Defined in:
- lib/alpacabuildtool/tools/tool.rb
Overview
Tool provides basic functionality for console tools
Direct Known Subclasses
MSBuild, NUnit, NUnitOrange, Nuget, ReportGenerator, Wrapper
Instance Attribute Summary
Attributes included from Log
Instance Method Summary collapse
-
#call(args) ⇒ Object
Execute tool in console with arguments.
-
#initialize(configuration) ⇒ Tool
constructor
Creates an instance It check if configuration contains ‘exe’ which is executable If no then tries to find executable in PATH environment variable If not found then get exe from block passed.
Constructor Details
#initialize(configuration) ⇒ Tool
Creates an instance It check if configuration contains ‘exe’ which is executable If no then tries to find executable in PATH environment variable If not found then get exe from block passed
configuration
-
hash with tool configuration
accepts &block with tool extended initialization if exe not found
Tool.new config do
exe_pattern = File.join(DOWNLOAD_DIR, '**', config['exe'])
install(config['id'], DOWNLOAD_DIR, true)
Dir.glob(exe_pattern).first # return executable
end
25 26 27 28 29 30 31 |
# File 'lib/alpacabuildtool/tools/tool.rb', line 25 def initialize(configuration) @configuration = configuration.dup @exe = @configuration['exe'] || '' @exe = find_executable @exe unless File.executable? @exe @exe = yield unless @exe || !block_given? @exe = encapsulate(@exe) if @exe.to_s.include? ' ' end |
Instance Method Details
#call(args) ⇒ Object
Execute tool in console with arguments
args
-
tool arguments
tool.call(['file.cs', {c: true, type: 'test'}])
# >> tool.exe file.cs /c /type:test
40 41 42 43 44 |
# File 'lib/alpacabuildtool/tools/tool.rb', line 40 def call(args) cmd = ([@exe] + format_arguments(args)).join ' ' log.info ">> #{cmd}\n" execute cmd end |