Sha256: d7c4c020e33154953562b49bca2605fed899e27fda3b467def2cbb6aea79d764

Contents?: true

Size: 773 Bytes

Versions: 11

Compression:

Stored size: 773 Bytes

Contents

require 'digest/sha1'

module Milkshake
  class Validator
    
    attr_reader :cache, :link_time
    
    def initialize(cache)
      @cache = cache
      
      @link_time = @cache.key('link.time')
      @cache.reset! if relink?
    end
    
    def current_link_time
      return @current_link_time unless @current_link_time.nil?
      
      path = File.join(RAILS_ROOT, 'tmp', 'relink.txt')
      if File.file?(path)
        @current_link_time = File.mtime(path)
      else
        @current_link_time = Time.now
      end
      
      @current_link_time
    end
    
    def relink?
      (link_time.nil?) or (current_link_time and link_time and current_link_time > link_time)
    end
    
    def persist!
      @cache['link.time'] = Time.now
    end
    
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
milkshake-0.1.9 lib/milkshake/validator.rb
milkshake-0.1.8 lib/milkshake/validator.rb
milkshake-0.1.7 lib/milkshake/validator.rb
milkshake-0.1.6 lib/milkshake/validator.rb
milkshake-0.1.5 lib/milkshake/validator.rb
milkshake-0.1.4 lib/milkshake/validator.rb
milkshake-0.1.3 lib/milkshake/validator.rb
milkshake-0.1.2 lib/milkshake/validator.rb
milkshake-0.1.1 lib/milkshake/validator.rb
milkshake-0.0.2 lib/milkshake/validator.rb
milkshake-0.0.1 lib/milkshake/validator.rb