class R::TargetGenerator
A target that executes a command.
This is a target that executes a command. It can be used directly but it is easier and prettier to use {C.generator}
Attributes
action[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
R::TargetSmart::new
# File lib/rub/r/targetgenerator.rb, line 33 def initialize super @action = 'Building' @cmd = [] end
Public Instance Methods
add_cmd(cmd)
click to toggle source
Add a command to be executed.
@param cmd [Array<String,#to_s] @return [Array<String>] The command.
# File lib/rub/r/targetgenerator.rb, line 45 def add_cmd(cmd) cmd = cmd.map{|a| a.to_s} exe = C.find_command(cmd[0]) if not exe raise "Can't find #{cmd[0]}." exit 1 end cmd[0] = exe @input << cmd[0] @cmd << cmd cmd end
add_cmds(cmds)
click to toggle source
Add multiple commands.
@see add_cmd
@param cmds [Array<Array<String,#to_s>>] The commands. @return [Array<Array<String>>] The commands.
# File lib/rub/r/targetgenerator.rb, line 65 def add_cmds(cmds) cmds.map{|c| add_cmd c} end
build_self()
click to toggle source
# File lib/rub/r/targetgenerator.rb, line 75 def build_self R::run(['mkdir', '-pv', *@output.map{|o| o.dirname}], "Preparing output directories", importance: :low) @cmd.all?{|c| R::run(c, "#@action #{@output.to_a.join", "}")} or exit 1 end
hash_input()
click to toggle source
Calls superclass method
R::Target#hash_input
# File lib/rub/r/targetgenerator.rb, line 69 def hash_input super + Digest::SHA1.digest( @cmd.join("\0") ) end