Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all comments from the Ruby classes. #159

Merged
merged 1 commit into from
Aug 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/jekyll-import/importers/drupal6.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

module JekyllImport
module Importers
class Drupal6 < Importer
Expand Down
6 changes: 0 additions & 6 deletions lib/jekyll-import/importers/drupal7.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

module JekyllImport
module Importers
class Drupal7 < Importer
Expand Down
35 changes: 14 additions & 21 deletions lib/jekyll-import/importers/easyblog.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# NOTE: This migrator is made for Joomla 2.5 database and EasyBlog 3.8.
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

module JekyllImport
module Importers
class Easyblog < Importer
Expand All @@ -15,7 +8,7 @@ def self.validate(options)
end
end
end

def self.specify_options(c)
c.option 'dbname', '--dbname', 'Database name'
c.option 'user', '--user', 'Database user name'
Expand All @@ -24,7 +17,7 @@ def self.specify_options(c)
c.option 'section', '--section', 'Table prefix name'
c.option 'prefix', '--prefix', 'Table prefix name'
end

def self.require_deps
JekyllImport.require_with_fallback(%w[
rubygems
Expand All @@ -33,28 +26,28 @@ def self.require_deps
safe_yaml
])
end

def self.process(options)
dbname = options.fetch('dbname')
user = options.fetch('user')
pass = options.fetch('password', '')
host = options.fetch('host', "localhost")
section = options.fetch('section', '1')
table_prefix = options.fetch('prefix', "jos_")

db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')

FileUtils.mkdir_p("_posts")

# Reads a MySQL database via Sequel and creates a post file for each
# post in wp_posts that has post_status = 'publish'. This restriction is
# made because 'draft' posts are not guaranteed to have valid dates.

query = "
select
select
ep.`title`, `permalink` as alias, concat(`intro`, `content`) as content, ep.`created`, ep.`id`, ec.`title` as category, tags
from
#{table_prefix}easyblog_post ep
from
#{table_prefix}easyblog_post ep
left join #{table_prefix}easyblog_category ec on (ep.category_id = ec.id)
left join (
select
Expand All @@ -66,18 +59,18 @@ def self.process(options)
group by
ept.post_id) x on (ep.id = x.post_id);
"

db[query].each do |post|
# Get required fields and construct Jekyll compatible name.
title = post[:title]
slug = post[:alias]
date = post[:created]
content = post[:content]
category = post[:category]
tags = post[:tags]
tags = post[:tags]
name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
slug]

# Get the relevant fields as a hash, delete empty fields and convert
# to YAML for the header.
data = {
Expand All @@ -86,10 +79,10 @@ def self.process(options)
'joomla_id' => post[:id],
'joomla_url' => post[:alias],
'category' => post[:category],
'tags' => post[:tags],
'tags' => post[:tags],
'date' => date
}.delete_if { |k,v| v.nil? || v == '' }.to_yaml

# Write out the data and content to file
File.open("_posts/#{name}", "w") do |f|
f.puts data
Expand Down
3 changes: 0 additions & 3 deletions lib/jekyll-import/importers/enki.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Adapted by Rodrigo Pinto <rodrigopqn@gmail.com>
# Based on typo.rb by Toby DiPasquale

module JekyllImport
module Importers
class Enki < Importer
Expand Down
3 changes: 1 addition & 2 deletions lib/jekyll-import/importers/ghost.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# NOTE: This migrator is made for Ghost sqlite databases.
module JekyllImport
module Importers
class Ghost < Importer
Expand Down Expand Up @@ -38,7 +37,7 @@ def self.write_post_to_file(post)
# detect if the post is a draft
draft = post[:status].eql?('draft')

# Ghost saves the time in an weird format with 3 more numbers.
# Ghost saves the time in an weird format with 3 more numbers.
# But the time is correct when we remove the last 3 numbers.
date = Time.at(post[:created_at].to_i.to_s[0..-4].to_i)

Expand Down
7 changes: 0 additions & 7 deletions lib/jekyll-import/importers/joomla.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# NOTE: This migrator is made for Joomla 1.5 databases.
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

module JekyllImport
module Importers
class Joomla < Importer
Expand Down
2 changes: 0 additions & 2 deletions lib/jekyll-import/importers/jrnl.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Author: Aniket Pant <me@aniketpant.com>

module JekyllImport
module Importers
class Jrnl < Importer
Expand Down
10 changes: 0 additions & 10 deletions lib/jekyll-import/importers/mephisto.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# Quickly hacked together my Michael Ivey
# Based on mt.rb by Nick Gerakines, open source and publically
# available under the MIT license. Use this module at your own risk.

# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

module JekyllImport
module Importers
class Mephisto < Importer
Expand Down
10 changes: 0 additions & 10 deletions lib/jekyll-import/importers/mt.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# Created by Nick Gerakines, open source and publically available under the
# MIT license. Use this module at your own risk.
# I'm an Erlang/Perl/C++ guy so please forgive my dirty ruby.

# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

module JekyllImport
module Importers
class MT < Importer
Expand Down
9 changes: 0 additions & 9 deletions lib/jekyll-import/importers/posterous.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, api_key)'
# Other arguments are optional; the default values are:
# * :include_imgs => false # should images be downloaded as well?
# * :blog => 'primary' # blog, if you have more than one.
# * :base_path => '/' # for image, if they will be served from a different host for eg.

# For example, to download images as well as your posts, use the above command with
# ....process(email, pass, api_key, :include_imgs => true)

module JekyllImport
module Importers
class Posterous < Importer
Expand Down
10 changes: 0 additions & 10 deletions lib/jekyll-import/importers/rss.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# Created by Kendall Buchanan (https://github.com/kendagriff) on 2011-12-22.
# Use at your own risk. The end.
#
# Usage:
# (URL)
# ruby -r 'jekyll/jekyll-import/rss' -e "JekyllImport::RSS.process(:source => 'http://yourdomain.com/your-favorite-feed.xml')"
#
# (Local file)
# ruby -r 'jekyll/jekyll-import/rss' -e "JekyllImport::RSS.process(:source => './somefile/on/your/computer.xml')"

module JekyllImport
module Importers
class RSS < Importer
Expand Down
7 changes: 0 additions & 7 deletions lib/jekyll-import/importers/s9y.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# Migrator to import entries from an Serendipity (S9Y) blog
#
# Entries can be exported from http://blog.example.com/rss.php?version=2.0&all=1
#
# Usage:
# ruby -r './s9y_rss.rb' -e 'Jekyll::S9Y.process("http://blog.example.com/rss.php?version=2.0&all=1")'

module JekyllImport
module Importers
class S9Y < Importer
Expand Down
6 changes: 0 additions & 6 deletions lib/jekyll-import/importers/textpattern.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

module JekyllImport
module Importers
class TextPattern < Importer
Expand Down
1 change: 0 additions & 1 deletion lib/jekyll-import/importers/typo.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Author: Toby DiPasquale <toby@cbcg.net>
module JekyllImport
module Importers
class Typo < Importer
Expand Down
9 changes: 0 additions & 9 deletions lib/jekyll-import/importers/wordpress.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
#
# If you are running MacPorts, it the mysql2 gem can be installed like this:
# $ gem install mysql2 -- --with-mysql-lib=/opt/local/lib/mysql56/mysql/ --with-mysql-include=/opt/local/include/mysql56/mysql

module JekyllImport
module Importers
class WordPress < Importer
Expand Down
4 changes: 1 addition & 3 deletions lib/jekyll-import/importers/wordpressdotcom.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# coding: utf-8
# This importer takes a wordpress.xml file, which can be exported from your
# wordpress.com blog (/wp-admin/export.php).
# encoding: UTF-8

module JekyllImport
module Importers
Expand Down