Class: Build::Files::IOState
- Inherits:
-
Object
- Object
- Build::Files::IOState
- Defined in:
- lib/build/files/state.rb
Instance Attribute Summary collapse
-
#input_state ⇒ Object
readonly
Returns the value of attribute input_state.
-
#output_state ⇒ Object
readonly
Returns the value of attribute output_state.
Instance Method Summary collapse
- #added ⇒ Object
- #changed ⇒ Object
-
#dirty? ⇒ Boolean
Output is dirty if files are missing or if latest input is older than any output.
- #files ⇒ Object
- #fresh? ⇒ Boolean
-
#initialize(inputs, outputs) ⇒ IOState
constructor
A new instance of IOState.
- #inspect ⇒ Object
- #intersects?(outputs) ⇒ Boolean
- #removed ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(inputs, outputs) ⇒ IOState
Returns a new instance of IOState.
141 142 143 144 |
# File 'lib/build/files/state.rb', line 141 def initialize(inputs, outputs) @input_state = State.new(inputs) @output_state = State.new(outputs) end |
Instance Attribute Details
#input_state ⇒ Object (readonly)
Returns the value of attribute input_state.
146 147 148 |
# File 'lib/build/files/state.rb', line 146 def input_state @input_state end |
#output_state ⇒ Object (readonly)
Returns the value of attribute output_state.
147 148 149 |
# File 'lib/build/files/state.rb', line 147 def output_state @output_state end |
Instance Method Details
#added ⇒ Object
188 189 190 |
# File 'lib/build/files/state.rb', line 188 def added @input_state.added + @output_state.added end |
#changed ⇒ Object
196 197 198 |
# File 'lib/build/files/state.rb', line 196 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.
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 175 176 177 178 |
# File 'lib/build/files/state.rb', line 150 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 |
#files ⇒ Object
184 185 186 |
# File 'lib/build/files/state.rb', line 184 def files @input_state.files + @output_state.files end |
#fresh? ⇒ Boolean
180 181 182 |
# File 'lib/build/files/state.rb', line 180 def fresh? not dirty? end |
#inspect ⇒ Object
211 212 213 |
# File 'lib/build/files/state.rb', line 211 def inspect "<IOState Input:#{@input_state.inspect} Output:#{@output_state.inspect}>" end |
#intersects?(outputs) ⇒ Boolean
207 208 209 |
# File 'lib/build/files/state.rb', line 207 def intersects?(outputs) @input_state.intersects?(outputs) or @output_state.intersects?(outputs) end |
#removed ⇒ Object
192 193 194 |
# File 'lib/build/files/state.rb', line 192 def removed @input_state.removed + @output_state.removed end |
#update! ⇒ Object
200 201 202 203 204 205 |
# File 'lib/build/files/state.rb', line 200 def update! input_changed = @input_state.update! output_changed = @output_state.update! input_changed or output_changed end |