Sha256: f23431cbe77e8d166d483ac50bf94270b014e6ee590de595ef2b74fee52f224e

Contents?: true

Size: 659 Bytes

Versions: 12

Compression:

Stored size: 659 Bytes

Contents

module Jekyll
  module CSV
    # Reads a csv with title, permalink, body, published_at, and filter.
    # It creates a post file for each row in the csv
    def self.process(file = "posts.csv")
      FileUtils.mkdir_p "_posts"
      posts = 0
      FasterCSV.foreach(file) do |row|
        next if row[0] == "title"
        posts += 1
        name = row[3].split(" ")[0]+"-"+row[1]+(row[4] =~ /markdown/ ? ".markdown" : ".textile")
        File.open("_posts/#{name}", "w") do |f|
          f.puts <<-HEADER
---
layout: post
title: #{row[0]}
---

          HEADER
          f.puts row[2]
        end
      end
      "Created #{posts} posts!"
    end
  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
jekyll-0.12.1 lib/jekyll/migrators/csv.rb
jekyll-reloaded-0.12.2 lib/jekyll/migrators/csv.rb
jekyll-0.12.0 lib/jekyll/migrators/csv.rb
spinto-jekyll-0.11.2.5 lib/jekyll/migrators/csv.rb
jekyll-reloaded-0.12.1 lib/jekyll/migrators/csv.rb
jekyll-reloaded-0.12 lib/jekyll/migrators/csv.rb
spinto-jekyll-0.11.2.3 lib/jekyll/migrators/csv.rb
spinto-jekyll-0.11.2.2 lib/jekyll/migrators/csv.rb
spinto-jekyll-0.11.2.1 lib/jekyll/migrators/csv.rb
jekyll-0.11.2 lib/jekyll/migrators/csv.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/jekyll-0.11.0/lib/jekyll/migrators/csv.rb
jekyll-0.11.0 lib/jekyll/migrators/csv.rb