Class: Jekyll::StaticFile

Inherits:
Object
  • Object
show all
Includes:
Compressor
Defined in:
lib/jekyll-minifier.rb

Instance Method Summary collapse

Methods included from Compressor

#output_compressed, #output_css, #output_file, #output_html, #output_js, #output_json

Instance Method Details

#copy_file(path, dest_path) ⇒ Object



203
204
205
206
# File 'lib/jekyll-minifier.rb', line 203

def copy_file(path, dest_path)
  FileUtils.mkdir_p(File.dirname(dest_path))
  FileUtils.cp(path, dest_path)
end

#write(dest) ⇒ Object



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/jekyll-minifier.rb', line 208

def write(dest)
  dest_path = destination(dest)

  return false if File.exist?(dest_path) and !modified?
  self.class.mtimes[path] = mtime

  if exclude?(dest, dest_path)
    copy_file(path, dest_path)
  else
    case File.extname(dest_path)
      when '.js'
        if dest_path.end_with?('.min.js')
          copy_file(path, dest_path)
        else
          output_js(dest_path, File.read(path))
        end
      when '.json'
        output_json(dest_path, File.read(path))
      when '.css'
        if dest_path.end_with?('.min.css')
          copy_file(path, dest_path)
        else
          output_css(dest_path, File.read(path))
        end
      when '.xml'
        output_html(dest_path, File.read(path))
      else
        copy_file(path, dest_path)
    end
  end
  true
end