class Condenser::Export
Attributes
content_types[R]
digest[R]
digest_name[R]
filename[R]
source[R]
sourcemap[R]
Public Class Methods
new(env, input={})
click to toggle source
# File lib/condenser/export.rb, line 6 def initialize(env, input={}) @environment = env @source = input[:source] @sourcemap = input[:map] @filename = input[:filename] @content_types = input[:content_types] @digest = input[:digest] @digest_name = input[:digest_name] end
Public Instance Methods
charset()
click to toggle source
# File lib/condenser/export.rb, line 38 def charset @source.encoding.name.downcase end
content_type()
click to toggle source
# File lib/condenser/export.rb, line 21 def content_type @content_types.last end
ext()
click to toggle source
# File lib/condenser/export.rb, line 73 def ext File.extname(filename) end
hexdigest()
click to toggle source
Public: Returns String hexdigest of source.
# File lib/condenser/export.rb, line 43 def hexdigest @digest.unpack('H*'.freeze).first end
Also aliased as: etag
integrity()
click to toggle source
# File lib/condenser/export.rb, line 48 def integrity "#{@digest_name}-#{[@digest].pack('m0')}" end
length()
click to toggle source
# File lib/condenser/export.rb, line 29 def length @source.bytesize end
Also aliased as: size
path()
click to toggle source
# File lib/condenser/export.rb, line 17 def path filename.sub(/\.(\w+)$/) { |ext| "-#{etag}#{ext}" } end
to_json()
click to toggle source
# File lib/condenser/export.rb, line 52 def to_json { 'path' => path, 'size' => size, 'digest' => hexdigest, 'integrity' => integrity } end
to_s()
click to toggle source
# File lib/condenser/export.rb, line 25 def to_s @source end
write(output_directory)
click to toggle source
# File lib/condenser/export.rb, line 61 def write(output_directory) files = @environment.writers_for_mime_type(content_type).map do |writer| if writer.exist?(self) @environment.logger.debug "Skipping #{ self.path }, already exists" else @environment.logger.info "Writing #{ self.path }" writer.call(output_directory, self) end end files.flatten.compact end