Class: Factories::PageFactory

Inherits:
BaseFactory show all
Defined in:
lib/factories/page_factory.rb

Overview

This class is a factory for parsing page text and creating a correseponding page model

Instance Method Summary collapse

Instance Method Details

#create_jekyll_page_text(text, title, permalink) ⇒ Object

This method takes parameters for a given page and formats them as a valid page for a Jekyll website

Params:

text

the required markdown contents of the post

title

the required title of the post

permalink

the link to the page on a Jekyll website (e.g /about)



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/factories/page_factory.rb', line 28

def create_jekyll_page_text(text, title, permalink)
  header_converted_text = fix_header_syntax(text)
  header_converted_text = add_line_break_to_markdown_if_necessary(header_converted_text)

  %(---
layout: page
title: #{title}
permalink: #{permalink}
---
#{header_converted_text})
end

#create_page(page_contents, github_ref, pull_request_url) ⇒ Object

This method parses markdown in a page a returns a page model

Params: page_contents::markdown in a given page github_ref::a sha for a ref indicating the head of a branch a page is pushed to on the GitHub server pull_request_url::a url to the pull request with the branch the pull request is pushed to on the GitHub server



16
17
18
# File 'lib/factories/page_factory.rb', line 16

def create_page(page_contents, github_ref, pull_request_url)
  create_page_model(page_contents, github_ref, pull_request_url) if !page_contents.nil? && page_contents.is_a?(String)
end