Class: Stic::Generators::Static

Inherits:
Stic::Generator show all
Defined in:
lib/stic/generators/static.rb

Overview

The static generators adds file blobs for each static file to the generated output.

The source path for static files will be taken from generator config key path and defaults to ./files.

You can override the path in your site configuration:

generators:
  static:
    path: ./custom_files

Direct Known Subclasses

Page

Instance Attribute Summary

Attributes inherited from Stic::Generator

#config, #site

Instance Method Summary collapse

Methods inherited from Stic::Generator

#disabled?, #initialize, #name

Constructor Details

This class inherits a constructor from Stic::Generator

Instance Method Details

#blob_classObject



29
30
31
# File 'lib/stic/generators/static.rb', line 29

def blob_class
  ::Stic::File
end

#full_pathObject



25
26
27
# File 'lib/stic/generators/static.rb', line 25

def full_path
  @full_path ||= site.source.join(path)
end

#pathObject



21
22
23
# File 'lib/stic/generators/static.rb', line 21

def path
  @path ||= config[:path] || path_default
end

#path_defaultObject



17
18
19
# File 'lib/stic/generators/static.rb', line 17

def path_default
  'files'
end

#runObject



33
34
35
36
37
38
39
40
41
# File 'lib/stic/generators/static.rb', line 33

def run
  full_path.glob('**/*').each do |source|
    next unless source.file?

    path = source.relative_from(full_path)

    site << blob_class.new(site: site, source: source, path: path)
  end
end