Class: Jekyll::StaticFile

### Home Classes Methods

### In Files

- lib/jekyll/static_file.rb

### Parent

Object

### Methods

- ::new
- ::reset_cache
- #destination
- #modified?
- #mtime
- #path
- #write

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Jekyll
- Jekyll::Command
- Jekyll::Commands
- Jekyll::Commands::Build
- Jekyll::Commands::Doctor
- Jekyll::Commands::New
- Jekyll::Commands::Serve
- Jekyll::Configuration
- Jekyll::Converter
- Jekyll::Converters
- Jekyll::Converters::Identity
- Jekyll::Converters::Markdown
- Jekyll::Converters::Markdown::KramdownParser
- Jekyll::Converters::Markdown::MarukuParser
- Jekyll::Converters::Markdown::RDiscountParser
- Jekyll::Converters::Markdown::RedcarpetParser
- Jekyll::Converters::Markdown::RedcarpetParser::CommonMethods
- Jekyll::Converters::Markdown::RedcarpetParser::WithPygments
- Jekyll::Converters::Markdown::RedcarpetParser::WithoutPygments
- Jekyll::Converters::Textile
- Jekyll::Convertible
- Jekyll::Deprecator
- Jekyll::Draft
- Jekyll::Excerpt
- Jekyll::FatalException
- Jekyll::Filters
- Jekyll::Generator
- Jekyll::Generators
- Jekyll::Generators::Pagination
- Jekyll::GistTag
- Jekyll::Layout
- Jekyll::Page
- Jekyll::Pager
- Jekyll::Plugin
- Jekyll::Post
- Jekyll::RelatedPosts
- Jekyll::Site
- Jekyll::Site::Cleaner
- Jekyll::StaticFile
- Jekyll::Stevenson
- Jekyll::Tags
- Jekyll::Tags::HighlightBlock
- Jekyll::Tags::IncludeTag
- Jekyll::Tags::PostComparer
- Jekyll::Tags::PostUrl
- Jekyll::URL
- Date
- Enumerable
- Hash
- Object

No matching classes.

# Jekyll::StaticFile

### Public Class Methods

new(site, base, dir, name) click to toggle source

Initialize a new StaticFile.

site - The Site. base - The String path to the <source>. dir - The String path between <source> and the file. name - The String filename of the file.

    # File lib/jekyll/static_file.rb, line 12
    def initialize(site, base, dir, name)
      @site = site
      @base = base
      @dir  = dir
      @name = name
    end

reset_cache() click to toggle source

Reset the mtimes cache (for testing purposes).

Returns nothing.

    # File lib/jekyll/static_file.rb, line 65
    def self.reset_cache
      @@mtimes = Hash.new
      nil
    end

### Public Instance Methods

destination(dest) click to toggle source

Obtain destination path.

dest - The String path to the destination dir.

Returns destination file path.

    # File lib/jekyll/static_file.rb, line 29
    def destination(dest)
      File.join(dest, @dir, @name)
    end

modified?() click to toggle source

Is source path modified?

Returns true if modified since last write.

    # File lib/jekyll/static_file.rb, line 41
    def modified?
      @@mtimes[path] != mtime
    end

mtime() click to toggle source

Returns last modification time for this file.

    # File lib/jekyll/static_file.rb, line 34
    def mtime
      File.stat(path).mtime.to_i
    end

path() click to toggle source

Returns source file path.

    # File lib/jekyll/static_file.rb, line 20
    def path
      File.join(@base, @dir, @name)
    end

write(dest) click to toggle source

Write the static file to the destination directory (if modified).

dest - The String path to the destination dir.

Returns false if the file was not modified since last time (no-op).

    # File lib/jekyll/static_file.rb, line 50
    def write(dest)
      dest_path = destination(dest)

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

      FileUtils.mkdir_p(File.dirname(dest_path))
      FileUtils.cp(path, dest_path)

      true
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.