Sha256: e6951419a3c7e6fa148c8d694d416147fa36ae260229ef64001603766e8f1329

Contents?: true

Size: 802 Bytes

Versions: 14

Compression:

Stored size: 802 Bytes

Contents

# encoding: utf-8

# Sometimes rendering is taking too long, so you want to skip
# it in case that nothing changed in the files which influence
# the output. For example syntax highlighting via Pygments takes
# a while, so it's better to include this mixin and redefine
# #source_files to include every file which influence the output.
module Ace
  module LazyRendering
    def compare_mtime(one, others)
      File.exist?(one) && File.mtime(one) > others.map { |post| File.mtime(post) }.max
    end

    # @api public
    def source_files
      [self.original_path]
    end

    def fresh?
      @fresh ||= compare_mtime(self.output_path, self.source_files)
    end

    def save!
      if self.fresh?
        puts "~ [IGNORE] #{self.output_path}"
      else
        super
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ace-0.4.9 lib/ace/mixins/lazy.rb
ace-0.4.8 lib/ace/mixins/lazy.rb
ace-0.4.7 lib/ace/mixins/lazy.rb
ace-0.4.6 lib/ace/mixins/lazy.rb
ace-0.4.5 lib/ace/mixins/lazy.rb
ace-0.4.4 lib/ace/mixins/lazy.rb
ace-0.4.3 lib/ace/mixins/lazy.rb
ace-0.4.2 lib/ace/mixins/lazy.rb
ace-0.4.1 lib/ace/mixins/lazy.rb
ace-0.4 lib/ace/mixins/lazy.rb
ace-0.3.3 lib/ace/mixins/lazy.rb
ace-0.3.2 lib/ace/mixins/lazy.rb
ace-0.3.1 lib/ace/mixins/lazy.rb
ace-0.3 lib/ace/mixins/lazy.rb