class Jekyll::Minibundle::StampFile
Attributes
asset_destination_dir[R]
asset_source_path[R]
stamped_at[R]
Public Class Methods
new(site, asset_source_path, asset_destination_path)
click to toggle source
# File lib/jekyll/minibundle/stamp_file.rb 15 def initialize(site, asset_source_path, asset_destination_path) 16 @site = site 17 @asset_source_path = File.join(@site.source, asset_source_path) 18 19 raise ArgumentError, "Stamp source file does not exist: #{@asset_source_path}" unless File.file?(@asset_source_path) 20 21 @asset_destination_dir = File.dirname(asset_destination_path) 22 @asset_destination_extension = File.extname(asset_destination_path) 23 @asset_destination_filename_prefix = File.basename(asset_destination_path)[0..-(@asset_destination_extension.size + 1)] 24 @stamped_at = nil 25 @is_modified = false 26 end
Public Instance Methods
asset_destination_filename()
click to toggle source
# File lib/jekyll/minibundle/stamp_file.rb 48 def asset_destination_filename 49 "#{@asset_destination_filename_prefix}-#{asset_stamp}#{extname}" 50 end
cleanup()
click to toggle source
# File lib/jekyll/minibundle/stamp_file.rb 28 def cleanup 29 # no-op 30 end
destination_path_for_markup()
click to toggle source
# File lib/jekyll/minibundle/stamp_file.rb 32 def destination_path_for_markup 33 # we must rebundle here, if at all, in order to make sure the 34 # destination path in the markup and the generated file path have 35 # the same fingerprint 36 37 source_mtime = mtime 38 39 if @stamped_at != source_mtime 40 @stamped_at = source_mtime 41 @is_modified = true 42 @_asset_stamp = nil 43 end 44 45 asset_destination_path 46 end
extname()
click to toggle source
# File lib/jekyll/minibundle/stamp_file.rb 52 def extname 53 @asset_destination_extension 54 end
modified?()
click to toggle source
# File lib/jekyll/minibundle/stamp_file.rb 56 def modified? 57 @is_modified 58 end
write(site_destination_dir)
click to toggle source
allows writing destination only after `destination_path_for_markup` has been called
# File lib/jekyll/minibundle/stamp_file.rb 62 def write(site_destination_dir) 63 if modified? 64 Files.copy_p(path, destination(site_destination_dir)) 65 @is_modified = false 66 true 67 else 68 false 69 end 70 end
Private Instance Methods
asset_stamp()
click to toggle source
# File lib/jekyll/minibundle/stamp_file.rb 74 def asset_stamp 75 @_asset_stamp ||= AssetStamp.from_file(asset_source_path) 76 end