Module: Jekyll::Mephisto
- Defined in:
- lib/jekyll/converters/mephisto.rb
Class Method Summary collapse
-
.postgres(c) ⇒ Object
Accepts a hash with database config variables, exports mephisto posts into a csv export PGPASSWORD if you must.
Class Method Details
.postgres(c) ⇒ Object
Accepts a hash with database config variables, exports mephisto posts into a csv export PGPASSWORD if you must
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jekyll/converters/mephisto.rb', line 9 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 |