Class: Dimples::Site

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Site

Returns a new instance of Site.



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

def initialize(config = {})
  @config = Hashie::Mash.new(Configuration.defaults).deep_merge(config)

  @paths = {}.tap do |paths|
    paths[:base] = Dir.pwd
    paths[:output] = File.join(paths[:base], @config.paths.output)
    paths[:sources] = {}.tap do |sources|
      %w[pages posts public templates].each do |type|
        sources[type.to_sym] = File.join(paths[:base], type)
      end
    end
  end

  prepare
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



6
7
8
# File 'lib/dimples/site.rb', line 6

def categories
  @categories
end

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/dimples/site.rb', line 5

def config
  @config
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/dimples/site.rb', line 7

def errors
  @errors
end

#latest_postObject (readonly)

Returns the value of attribute latest_post.



12
13
14
# File 'lib/dimples/site.rb', line 12

def latest_post
  @latest_post
end

#pagesObject (readonly)

Returns the value of attribute pages.



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

def pages
  @pages
end

#pathsObject (readonly)

Returns the value of attribute paths.



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

def paths
  @paths
end

#postsObject (readonly)

Returns the value of attribute posts.



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

def posts
  @posts
end

#templatesObject (readonly)

Returns the value of attribute templates.



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

def templates
  @templates
end

Instance Method Details

#generateObject



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

def generate
  prepare

  read_templates
  read_posts
  read_pages

  create_output_directory
  copy_assets

  publish_posts
  publish_pages
  publish_archives
  publish_categories if @config.generation.categories
rescue PublishingError, RenderingError, GenerationError => error
  @errors << error
end

#inspectObject



48
49
50
# File 'lib/dimples/site.rb', line 48

def inspect
  "#<#{self.class} @paths=#{paths}>"
end