class JekyllImport::Importers::CSV::CSVPost

Constants

MissingDataError

Attributes

body[R]
markup[R]
title[R]

Public Class Methods

new(row) click to toggle source

Creates a CSVPost

row - Array of data, length of 4 or 5 with the columns:

1. title
2. permalink
3. body
4. published_at
5. markup (markdown, textile)
# File lib/jekyll-import/importers/csv.rb, line 51
def initialize(row)
  @title = row[0]        || missing_data("Post title not present in first column.")
  @permalink = row[1]    || missing_data("Post permalink not present in second column.")
  @body = row[2]         || missing_data("Post body not present in third column.")
  @published_at = row[3] || missing_data("Post publish date not present in fourth column.")
  @markup = row[4]       || "markdown"
end

Public Instance Methods

filename() click to toggle source
# File lib/jekyll-import/importers/csv.rb, line 67
def filename
  "#{published_at.strftime("%Y-%m-%d")}-#{File.basename(permalink, ".*")}.#{markup}"
end
missing_data(message) click to toggle source
# File lib/jekyll-import/importers/csv.rb, line 71
def missing_data(message)
  raise MissingDataError, message
end
published_at() click to toggle source
# File lib/jekyll-import/importers/csv.rb, line 59
def published_at
  if @published_at && !@published_at.is_a?(DateTime)
    @published_at = DateTime.parse(@published_at)
  else
    @published_at
  end
end