class Wst::Page

Public Class Methods

all() click to toggle source
# File lib/wst/page.rb, line 83
def all
  (xml_pages + haml_pages + md_pages).sort
end
save!(file_path, datas, content) click to toggle source

param [String] file_path Relative path of the file to save param [Hash] datas Header datas param [String] content Content to write

# File lib/wst/page.rb, line 90
def save! file_path, datas, content
  Content.save! file_path, datas, content
  page = nil
  if file_path =~ XmlPage.matcher
    page = XmlPage.new file_path
  elsif file_path =~ HamlPage.matcher
    page = HamlPage.new file_path
  elsif file_path =~ MdPage.matcher
    page = MdPage.new file_path
  end
  page
end

Private Class Methods

all_files(glob) click to toggle source
# File lib/wst/page.rb, line 125
def all_files glob
  Dir.glob glob_path glob
end
glob_path(glob) click to toggle source
# File lib/wst/page.rb, line 129
def glob_path glob
  File.join "#{Configuration.config['path']}/_pages", '**', glob
end
haml_pages() click to toggle source
# File lib/wst/page.rb, line 109
def haml_pages
  page_files(@@glob_haml, HamlPage.matcher).inject([]) { |pages, file| pages << HamlPage.new(file) }
end
md_pages() click to toggle source
# File lib/wst/page.rb, line 113
def md_pages
  page_files(@@glob_md, MdContent.matcher).inject([]) { |pages, file| pages << MdPage.new(file) }
end
page_files(glob, matcher) click to toggle source
# File lib/wst/page.rb, line 117
def page_files glob, matcher
  select_match all_files(glob), matcher
end
select_match(files, matcher) click to toggle source
# File lib/wst/page.rb, line 121
def select_match files, matcher
  files.select { |file| file =~ matcher }
end
xml_pages() click to toggle source
# File lib/wst/page.rb, line 105
def xml_pages
  page_files(@@glob_xml, XmlPage.matcher).inject([]) { |pages, file| pages << XmlPage.new(file) }
end