Class: Dimples::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/dimples/site.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_path) ⇒ Site

Returns a new instance of Site.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dimples/site.rb', line 16

def initialize(output_path)
  @paths = {
    source: File.expand_path(Dir.pwd),
    destination: File.expand_path(output_path)
  }

  @config = read_config

  %w[pages posts static templates].each do |type|
    @paths[type.to_sym] = File.join(@paths[:source], type)
  end

  scan_posts
  scan_pages
  scan_templates
end

Instance Attribute Details

#categoriesObject

Returns the value of attribute categories.



14
15
16
# File 'lib/dimples/site.rb', line 14

def categories
  @categories
end

#postsObject

Returns the value of attribute posts.



14
15
16
# File 'lib/dimples/site.rb', line 14

def posts
  @posts
end

Class Method Details

.generate(output_path) ⇒ Object



10
11
12
# File 'lib/dimples/site.rb', line 10

def self.generate(output_path)
  new(output_path).generate
end

Instance Method Details

#generateObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dimples/site.rb', line 33

def generate
  if Dir.exist?(@paths[:destination])
    puts "Error: The output directory (#{@paths[:destination]}) already exists."
    return
  end

  Dir.mkdir(@paths[:destination])

  generate_posts
  generate_pages
  generate_categories

  copy_assets
end