class Guard::Depend::Detect
Attributes
output_paths[R]
Public Class Methods
new(output_paths = nil)
click to toggle source
# File lib/guard/depend/detect.rb, line 6 def initialize(output_paths = nil) @output_paths = output_paths end
Public Instance Methods
out_of_date?(paths = [])
click to toggle source
# File lib/guard/depend/detect.rb, line 10 def out_of_date?(paths = []) paths = paths || [] return false if paths.empty? outdated = check(paths, output) UI.debug("#{output.join(', ')} is not outdated with regard to #{paths.join(', ')}") unless outdated outdated end
Private Instance Methods
check(input, output)
click to toggle source
# File lib/guard/depend/detect.rb, line 28 def check(input, output) input = input.max_by { |f| input_mtime(f) } output = output.min_by { |f| output_mtime(f) } input_mtime = input_mtime(input) output_mtime = output_mtime(output) UI.debug("Newest input file: #{input_mtime} #{input}") UI.debug("Oldest output file: #{output_mtime} #{output}") return input_mtime > output_mtime end
input_mtime(file)
click to toggle source
# File lib/guard/depend/detect.rb, line 41 def input_mtime(file) return Time.new(9999, 12, 31) unless File.readable?(file) File.mtime(file) end
output()
click to toggle source
# File lib/guard/depend/detect.rb, line 21 def output paths = output_paths paths = output_paths.call if output_paths.respond_to?(:call) [paths].flatten.reject(&:nil?) end
output_mtime(file)
click to toggle source
# File lib/guard/depend/detect.rb, line 46 def output_mtime(file) return Time.new(0, 1, 1) unless File.readable?(file) File.mtime(file) end