Sha256: 55a1b50c02c4d558b4a92553aa59b02fb2978eae40cd4f6736c43a4593c729f6

Contents?: true

Size: 781 Bytes

Versions: 17

Compression:

Stored size: 781 Bytes

Contents

require 'rubygems'
require 'fastercsv'
require 'fileutils'
require File.join(File.dirname(__FILE__),"csv.rb")
module Jekyll
  module Mephisto
    #Accepts a hash with database config variables, exports mephisto posts into a csv
    #export PGPASSWORD if you must
    def self.postgres(c)
      sql = <<-SQL
      BEGIN;
      CREATE TEMP TABLE jekyll AS
        SELECT title, permalink, body, published_at, filter FROM contents
        WHERE user_id = 1 AND type = 'Article' ORDER BY published_at;
      COPY jekyll TO STDOUT WITH CSV HEADER;
      ROLLBACK;
      SQL
      command = %Q(psql -h #{c[:host] || "localhost"} -c "#{sql.strip}" #{c[:database]} #{c[:username]} -o #{c[:filename] || "posts.csv"})
      puts command
      `#{command}`
      CSV.process
    end
  end
end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
ddemaree-jekyll-0.2.1 lib/jekyll/converters/mephisto.rb
gabrielg-jekyll-0.2.2 lib/jekyll/converters/mephisto.rb
mojombo-jekyll-0.1.3 lib/jekyll/converters/mephisto.rb
mojombo-jekyll-0.1.4 lib/jekyll/converters/mephisto.rb
mojombo-jekyll-0.1.5 lib/jekyll/converters/mephisto.rb
mojombo-jekyll-0.1.6 lib/jekyll/converters/mephisto.rb
mojombo-jekyll-0.2.0 lib/jekyll/converters/mephisto.rb
mojombo-jekyll-0.3.0 lib/jekyll/converters/mephisto.rb
qrush-jekyll-0.3.0.1 lib/jekyll/converters/mephisto.rb
tristandunn-jekyll-0.3.0 lib/jekyll/converters/mephisto.rb
jekyll-0.1.3 lib/jekyll/converters/mephisto.rb
jekyll-0.1.5 lib/jekyll/converters/mephisto.rb
jekyll-0.1.4 lib/jekyll/converters/mephisto.rb
jekyll-0.1.6 lib/jekyll/converters/mephisto.rb
jekyll-0.2.1 lib/jekyll/converters/mephisto.rb
jekyll-0.2.0 lib/jekyll/converters/mephisto.rb
jekyll-0.3.0 lib/jekyll/converters/mephisto.rb