Class: R::TargetSmart

Inherits:
Target show all
Defined in:
lib/rub/r/target.rb

Overview

Target with additional functionality.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Target

#description, #hash_input, #hash_output, #hash_outputs, #hash_self, #register

Constructor Details

#initializeTargetSmart

Returns a new instance of TargetSmart.



192
193
194
195
# File 'lib/rub/r/target.rb', line 192

def initialize
	@input  = Set.new
	@output = Set.new
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



190
191
192
# File 'lib/rub/r/target.rb', line 190

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



190
191
192
# File 'lib/rub/r/target.rb', line 190

def output
  @output
end

Instance Method Details

#buildObject



218
219
220
221
222
223
224
225
226
# File 'lib/rub/r/target.rb', line 218

def build
	build_dependancies
	
	clean? and return
	
	build_self
	
	clean
end

#cleanvoid

This method returns an undefined value.

Mark target as clean.



200
201
202
203
204
# File 'lib/rub/r/target.rb', line 200

def clean
	output.all?{|f| !f.is_a?(Symbol) and f.exist?} or return
	
	 R::ppersistant["Rub.TargetSmart.#{@output.sort.join('\0')}"] = hash_self
end

#clean?true, false

Is this target clean?

Returns:

  • (true, false)

    True if this target is up-to-date.



209
210
211
212
213
214
215
216
# File 'lib/rub/r/target.rb', line 209

def clean?
	output.each do |f|
		f.is_a?(Symbol) and return false # Tags are never clean.
		f.exist?        or  return false # Output missing, rebuild.
	end
	
	R::ppersistant["Rub.TargetSmart.#{@output.sort.join('\0')}"] == hash_self
end