Class: Deris::Project
- Inherits:
-
Object
- Object
- Deris::Project
- Defined in:
- lib/project.rb
Instance Method Summary collapse
-
#initialize(source) ⇒ Project
constructor
A new instance of Project.
- #write(output) ⇒ Object
Constructor Details
#initialize(source) ⇒ Project
Returns a new instance of Project.
9 10 11 12 13 |
# File 'lib/project.rb', line 9 def initialize(source) @source = source @source_directory = ::File.join(@source, '_src') @defaults = partials_from @source_directory end |
Instance Method Details
#write(output) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/project.rb', line 15 def write(output) # recreate the output directory FileUtils.rm_rf(output) if ::File.exists?(output) FileUtils.mkdir(output) # find and copy all static content static_content_mask = ::File.join(@source, "**") static_content = Dir[static_content_mask].reject{|path| path =~ /_src$/} static_content.each{|path| FileUtils.cp_r(path, output)} # generate the index page from defaults File.new('index', @defaults).write output # generate the other pages of the site from sub-directories source_directories.each do |dir| partials = partials_from dir partials = @defaults.merge(partials) file_name = ::File.basename(dir) File.new(file_name, partials).write output end end |