Class: JekyllPagesApi::GeneratedSite
- Inherits:
-
Object
- Object
- JekyllPagesApi::GeneratedSite
- Defined in:
- lib/jekyll_pages_api/generated_site.rb
Overview
Used by the standalone executable to mimic a Jekyll::Site when processing an already-generated site using the Generator.
Instance Attribute Summary collapse
- #basedir ⇒ Object readonly
- #baseurl ⇒ Object readonly
- #body_element_tag ⇒ Object readonly
-
#pages ⇒ Array<>
A dummy empty Array.
- #title_prefix ⇒ Object readonly
Instance Method Summary collapse
-
#each_site_file ⇒ Object
Generator yielding each HTML page (as a GeneratedPage) that should be exported via the API.
-
#initialize(baseurl, basedir, title_prefix, body_element_tag) ⇒ GeneratedSite
constructor
A new instance of GeneratedSite.
Constructor Details
#initialize(baseurl, basedir, title_prefix, body_element_tag) ⇒ GeneratedSite
Returns a new instance of GeneratedSite.
22 23 24 25 26 27 28 |
# File 'lib/jekyll_pages_api/generated_site.rb', line 22 def initialize(baseurl, basedir, title_prefix, body_element_tag) @baseurl = baseurl @basedir = basedir @title_prefix = title_prefix @body_element_tag = body_element_tag @pages = [] end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
10 11 12 |
# File 'lib/jekyll_pages_api/generated_site.rb', line 10 def basedir @basedir end |
#baseurl ⇒ Object (readonly)
10 11 12 |
# File 'lib/jekyll_pages_api/generated_site.rb', line 10 def baseurl @baseurl end |
#body_element_tag ⇒ Object (readonly)
10 11 12 |
# File 'lib/jekyll_pages_api/generated_site.rb', line 10 def body_element_tag @body_element_tag end |
#pages ⇒ Array<>
Returns a dummy empty Array.
13 14 15 |
# File 'lib/jekyll_pages_api/generated_site.rb', line 13 def pages @pages end |
#title_prefix ⇒ Object (readonly)
10 11 12 |
# File 'lib/jekyll_pages_api/generated_site.rb', line 10 def title_prefix @title_prefix end |
Instance Method Details
#each_site_file ⇒ Object
Generator yielding each HTML page (as a JekyllPagesApi::GeneratedPage) that should be exported via the API.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jekyll_pages_api/generated_site.rb', line 32 def each_site_file Dir.glob(File.join(self.basedir, '**', '*')) do |f| next unless f.end_with? '.html' begin page = GeneratedPage.new(f, self.basedir, self.title_prefix, self.body_element_tag, File.read(f)) yield page unless page.data['title'].nil? rescue $stderr.puts "Error while processing #{f}:" raise end end end |