Class: Alister::Site
- Inherits:
-
Object
- Object
- Alister::Site
- Defined in:
- lib/site.rb
Overview
Main site builder use this to build your site
Defined Under Namespace
Classes: Page
Instance Method Summary collapse
-
#assets { ... } ⇒ void
Create assets easier.
-
#build_to(path) ⇒ void
(also: #build)
Builds the site.
-
#build_to_and_reset(path) ⇒ void
(also: #build_and_reset)
Builds and then resets the site builder.
-
#file(path, string) ⇒ void
Creates a new file on path.
-
#initialize ⇒ Site
constructor
A new instance of Site.
-
#reset ⇒ void
Resets the site builder for next build.
-
#route(path, page) ⇒ void
Creates a new html page on path.
Constructor Details
#initialize ⇒ Site
29 30 31 32 33 |
# File 'lib/site.rb', line 29 def initialize @path = nil @routes = [] @files = [] end |
Instance Method Details
#assets { ... } ⇒ void
This method returns an undefined value.
Create assets easier
78 79 80 81 |
# File 'lib/site.rb', line 78 def assets(&block) assets = Alister::Assets.new assets.instance_eval(&block) end |
#build_to(path) ⇒ void Also known as: build
This method returns an undefined value.
Builds the site
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/site.rb', line 54 def build_to(path) @path = path @routes.each do |route| create_file(route, 'index.html') end @files.each do |file| create_file(file) end puts '[LOG] Finished creating files' end |
#build_to_and_reset(path) ⇒ void Also known as: build_and_reset
This method returns an undefined value.
Builds and then resets the site builder
94 95 96 97 |
# File 'lib/site.rb', line 94 def build_to_and_reset(path) build_to(path) reset end |
#file(path, string) ⇒ void
This method returns an undefined value.
Creates a new file on path
47 48 49 |
# File 'lib/site.rb', line 47 def file(path, string) @files << Page.new(path, string) end |
#reset ⇒ void
This method returns an undefined value.
Resets the site builder for next build
85 86 87 88 89 |
# File 'lib/site.rb', line 85 def reset @path = nil @routes = [] @files = [] end |
#route(path, page) ⇒ void
This method returns an undefined value.
Creates a new html page on path
39 40 41 |
# File 'lib/site.rb', line 39 def route(path, page) @routes << Page.new(path, page) end |