Class: Deris::Project
- Inherits:
-
Object
- Object
- Deris::Project
- Includes:
- DirectoryWriter, PartialHasher, SubdirectoryList
- Defined in:
- lib/project.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#partials ⇒ Object
readonly
Returns the value of attribute partials.
Instance Method Summary collapse
-
#initialize(source, defaults = {}) ⇒ Project
constructor
A new instance of Project.
- #sub_output(output) ⇒ Object
- #write(output) ⇒ Object
Methods included from SubdirectoryList
Methods included from DirectoryWriter
Methods included from PartialHasher
Constructor Details
#initialize(source, defaults = {}) ⇒ Project
Returns a new instance of Project.
10 11 12 13 14 15 |
# File 'lib/project.rb', line 10 def initialize(source, defaults = {}) @source = source @file_name = 'index' @directory = ::File.join(@source, '_src') @partials = defaults.merge(partials_hash) end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
8 9 10 |
# File 'lib/project.rb', line 8 def directory @directory end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
8 9 10 |
# File 'lib/project.rb', line 8 def file_name @file_name end |
#partials ⇒ Object (readonly)
Returns the value of attribute partials.
8 9 10 |
# File 'lib/project.rb', line 8 def partials @partials end |
Instance Method Details
#sub_output(output) ⇒ Object
33 34 35 |
# File 'lib/project.rb', line 33 def sub_output(output) return output, 0 # zero default depth end |
#write(output) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/project.rb', line 17 def write(output) # adds additional behaviour on top of the DirectoryWriter mixin # 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)} # call the DirectoryWriter mixin super end |