Class: Build::Files::IOState

Inherits:
Object
  • Object
show all
Defined in:
lib/build/files/state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inputs, outputs) ⇒ IOState

Returns a new instance of IOState.



137
138
139
140
# File 'lib/build/files/state.rb', line 137

def initialize(inputs, outputs)
	@input_state = State.new(inputs)
	@output_state = State.new(outputs)
end

Instance Attribute Details

#input_stateObject (readonly)

Returns the value of attribute input_state.



142
143
144
# File 'lib/build/files/state.rb', line 142

def input_state
  @input_state
end

#output_stateObject (readonly)

Returns the value of attribute output_state.



143
144
145
# File 'lib/build/files/state.rb', line 143

def output_state
  @output_state
end

Instance Method Details

#addedObject



184
185
186
# File 'lib/build/files/state.rb', line 184

def added
	@input_state.added + @output_state.added
end

#changedObject



192
193
194
# File 'lib/build/files/state.rb', line 192

def changed
	@input_state.changed + @output_state.changed
end

#dirty?Boolean

Output is dirty if files are missing or if latest input is older than any output.

Returns:

  • (Boolean)


146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/build/files/state.rb', line 146

def dirty?
	@dirty = []
	
	if @output_state.missing?
		# puts "Output file missing: #{output_state.missing.inspect}"
		
		return true
	end
	
	# If there are no inputs, we are always clean as long as outputs exist:
	# if @input_state.empty?
	#	return false
	# end
	
	oldest_output_time = @output_state.oldest_time
	newest_input_time = @input_state.newest_time
	
	if newest_input_time and oldest_output_time
		# if newest_input_time > oldest_output_time
		#	puts "Out of date file: #{newest_input_time.inspect} > #{oldest_output_time.inspect}"
		# end
		
		return newest_input_time > oldest_output_time
	end
	
	# puts "Missing file dates: #{newest_input_time.inspect} < #{oldest_output_time.inspect}"
	
	return true
end

#filesObject



180
181
182
# File 'lib/build/files/state.rb', line 180

def files
	@input_state.files + @output_state.files
end

#fresh?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/build/files/state.rb', line 176

def fresh?
	not dirty?
end

#inspectObject



207
208
209
# File 'lib/build/files/state.rb', line 207

def inspect
	"<IOState Input:#{@input_state.inspect} Output:#{@output_state.inspect}>"
end

#intersects?(outputs) ⇒ Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/build/files/state.rb', line 203

def intersects?(outputs)
	@input_state.intersects?(outputs) or @output_state.intersects?(outputs)
end

#removedObject



188
189
190
# File 'lib/build/files/state.rb', line 188

def removed
	@input_state.removed + @output_state.removed
end

#update!Object



196
197
198
199
200
201
# File 'lib/build/files/state.rb', line 196

def update!
	input_changed = @input_state.update!
	output_changed = @output_state.update!

	input_changed or output_changed
end