Class: Deris::Project

Inherits:
Object
  • Object
show all
Includes:
DirectoryWriter, PartialHasher, SubdirectoryList
Defined in:
lib/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SubdirectoryList

#sub_directories

Methods included from DirectoryWriter

#write_file

Methods included from PartialHasher

#partials_hash

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

#directoryObject (readonly)

Returns the value of attribute directory.



8
9
10
# File 'lib/project.rb', line 8

def directory
  @directory
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



8
9
10
# File 'lib/project.rb', line 8

def file_name
  @file_name
end

#partialsObject (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