Class: Yass::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/yass/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Generator

Returns a new instance of Generator.



7
# File 'lib/yass/generator.rb', line 7

def initialize(site) = @site = site

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



5
6
7
# File 'lib/yass/generator.rb', line 5

def site
  @site
end

Instance Method Details

#generate!Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/yass/generator.rb', line 9

def generate!
  dest_dirs.each { |dir| FileUtils.mkdir_p dir }
  site.sources.each do |source|
    outfile = source.outfile
    if source.dynamic?
      outfile.write Renderer.new(source).render
    else
      FileUtils.cp(source.path, outfile)
    end
  end
  clean if site.clean
end