Merge branch 'code-cleanup' of git://github.com/tombell/jekyll into code-cleanup

Module Cleanup

* 'code-cleanup' of git://github.com/tombell/jekyll:
  Remove new lines between module and class
  Update tag classes moving into a module
  Update pagination classes moving into a module
  Update converter classes moving into a module
  Strip extra newlines
  Update command classes moving into a module

Conflicts:
	lib/jekyll/commands/serve.rb
This commit is contained in:
Parker Moore 2013-01-27 23:13:16 +01:00
commit b4bea4a586
28 changed files with 510 additions and 533 deletions

View File

@ -27,7 +27,7 @@ command :build do |c|
c.action do |args, options| c.action do |args, options|
options.defaults :serving => false options.defaults :serving => false
options = Jekyll.configuration(options.__hash__) options = Jekyll.configuration(options.__hash__)
Jekyll::BuildCommand.process(options) Jekyll::Commands::Build.process(options)
end end
end end
@ -49,8 +49,8 @@ command :serve do |c|
:serving => true :serving => true
options = Jekyll.configuration(options.__hash__) options = Jekyll.configuration(options.__hash__)
Jekyll::BuildCommand.process(options) Jekyll::Commands::Build.process(options)
Jekyll::ServeCommand.process(options) Jekyll::Commands::Serve.process(options)
end end
end end
@ -65,6 +65,6 @@ command :import do |c|
c.option '--host', 'Host address to use when migrating' c.option '--host', 'Host address to use when migrating'
c.action do |args, options| c.action do |args, options|
Jekyll::MigrateCommand.process(args.first, options) Jekyll::Commands::Migrate.process(args.first, options)
end end
end end

View File

@ -1,5 +1,4 @@
module Jekyll module Jekyll
class Command class Command
def self.globs(source) def self.globs(source)
Dir.chdir(source) do Dir.chdir(source) do
@ -10,5 +9,4 @@ module Jekyll
end end
end end
end end
end end

View File

@ -1,6 +1,6 @@
module Jekyll module Jekyll
module Commands
class BuildCommand < Command class Build < Command
def self.process(options) def self.process(options)
site = Jekyll::Site.new(options) site = Jekyll::Site.new(options)
@ -72,5 +72,5 @@ module Jekyll
end end
end end
end end
end
end end

View File

@ -1,6 +1,6 @@
module Jekyll module Jekyll
module Commands
class MigrateCommand < Command class Migrate < Command
MIGRATORS = { MIGRATORS = {
:csv => 'CSV', :csv => 'CSV',
:drupal => 'Drupal', :drupal => 'Drupal',
@ -43,5 +43,5 @@ module Jekyll
abort 'invalid migrator. Please specify a valid migrator' abort 'invalid migrator. Please specify a valid migrator'
end end
end end
end
end end

View File

@ -1,6 +1,6 @@
module Jekyll module Jekyll
module Commands
class ServeCommand < Command class Serve < Command
def self.process(options) def self.process(options)
require 'webrick' require 'webrick'
include WEBrick include WEBrick
@ -25,5 +25,5 @@ module Jekyll
t.join() t.join()
end end
end end
end
end end

View File

@ -1,5 +1,4 @@
module Jekyll module Jekyll
class Converter < Plugin class Converter < Plugin
# Public: Get or set the pygments prefix. When an argument is specified, # Public: Get or set the pygments prefix. When an argument is specified,
# the prefix will be set. If no argument is specified, the current prefix # the prefix will be set. If no argument is specified, the current prefix
@ -46,5 +45,4 @@ module Jekyll
self.class.pygments_suffix self.class.pygments_suffix
end end
end end
end end

View File

@ -1,6 +1,6 @@
module Jekyll module Jekyll
module Converters
class IdentityConverter < Converter class Identity < Converter
safe true safe true
priority :lowest priority :lowest
@ -16,7 +16,6 @@ module Jekyll
def convert(content) def convert(content)
content content
end end
end end
end
end end

View File

@ -1,6 +1,6 @@
module Jekyll module Jekyll
module Converters
class MarkdownConverter < Converter class Markdown < Converter
safe true safe true
pygments_prefix "\n" pygments_prefix "\n"
@ -145,5 +145,5 @@ module Jekyll
end end
end end
end end
end
end end

View File

@ -1,6 +1,6 @@
module Jekyll module Jekyll
module Converters
class TextileConverter < Converter class Textile < Converter
safe true safe true
pygments_prefix '<notextile>' pygments_prefix '<notextile>'
@ -46,5 +46,5 @@ module Jekyll
r.to_html r.to_html
end end
end end
end
end end

View File

@ -1,6 +1,4 @@
module Jekyll module Jekyll
class FatalException < StandardError class FatalException < StandardError
end end
end end

View File

@ -1,7 +1,6 @@
require 'uri' require 'uri'
module Jekyll module Jekyll
module Filters module Filters
# Convert a Textile string into HTML output. # Convert a Textile string into HTML output.
# #
@ -10,7 +9,7 @@ module Jekyll
# Returns the HTML formatted String. # Returns the HTML formatted String.
def textilize(input) def textilize(input)
site = @context.registers[:site] site = @context.registers[:site]
converter = site.getConverterImpl(Jekyll::TextileConverter) converter = site.getConverterImpl(Jekyll::Converters::Textile)
converter.convert(input) converter.convert(input)
end end
@ -21,7 +20,7 @@ module Jekyll
# Returns the HTML formatted String. # Returns the HTML formatted String.
def markdownify(input) def markdownify(input)
site = @context.registers[:site] site = @context.registers[:site]
converter = site.getConverterImpl(Jekyll::MarkdownConverter) converter = site.getConverterImpl(Jekyll::Converters::Markdown)
converter.convert(input) converter.convert(input)
end end
@ -124,6 +123,5 @@ module Jekyll
"#{array[0...-1].join(', ')}, #{connector} #{array[-1]}" "#{array[0...-1].join(', ')}, #{connector} #{array[-1]}"
end end
end end
end end
end end

View File

@ -1,7 +1,4 @@
module Jekyll module Jekyll
class Generator < Plugin class Generator < Plugin
end end
end end

View File

@ -1,5 +1,5 @@
module Jekyll module Jekyll
module Generators
class Pagination < Generator class Pagination < Generator
# This generator is safe from arbitrary code execution. # This generator is safe from arbitrary code execution.
safe true safe true
@ -51,6 +51,7 @@ module Jekyll
format.sub(':num', num_page.to_s) format.sub(':num', num_page.to_s)
end end
end end
end
class Pager class Pager
attr_reader :page, :per_page, :posts, :total_posts, :total_pages, :previous_page, :next_page attr_reader :page, :per_page, :posts, :total_posts, :total_pages, :previous_page, :next_page
@ -115,5 +116,4 @@ module Jekyll
} }
end end
end end
end end

View File

@ -1,5 +1,4 @@
module Jekyll module Jekyll
class Layout class Layout
include Convertible include Convertible
@ -40,5 +39,4 @@ module Jekyll
self.ext = File.extname(name) self.ext = File.extname(name)
end end
end end
end end

View File

@ -1,5 +1,4 @@
module Jekyll module Jekyll
class Page class Page
include Convertible include Convertible
@ -161,7 +160,5 @@ module Jekyll
def index? def index?
basename == 'index' basename == 'index'
end end
end end
end end

View File

@ -1,5 +1,4 @@
module Jekyll module Jekyll
class Plugin class Plugin
PRIORITIES = { :lowest => -100, PRIORITIES = { :lowest => -100,
:low => -10, :low => -10,
@ -73,5 +72,4 @@ module Jekyll
# no-op for default # no-op for default
end end
end end
end end

View File

@ -1,5 +1,4 @@
module Jekyll module Jekyll
class Post class Post
include Comparable include Comparable
include Convertible include Convertible
@ -281,5 +280,4 @@ module Jekyll
end end
end end
end end
end end

View File

@ -1,7 +1,6 @@
require 'set' require 'set'
module Jekyll module Jekyll
class Site class Site
attr_accessor :config, :layouts, :posts, :pages, :static_files, attr_accessor :config, :layouts, :posts, :pages, :static_files,
:categories, :exclude, :include, :source, :dest, :lsi, :pygments, :categories, :exclude, :include, :source, :dest, :lsi, :pygments,

View File

@ -1,5 +1,4 @@
module Jekyll module Jekyll
class StaticFile class StaticFile
# The cache of last modification times [path] -> mtime. # The cache of last modification times [path] -> mtime.
@@mtimes = Hash.new @@mtimes = Hash.new
@ -68,5 +67,4 @@ module Jekyll
nil nil
end end
end end
end end

View File

@ -1,5 +1,5 @@
module Jekyll module Jekyll
module Tags
class HighlightBlock < Liquid::Block class HighlightBlock < Liquid::Block
include Liquid::StandardFilters include Liquid::StandardFilters
@ -58,9 +58,9 @@ module Jekyll
def render_codehighlighter(context, code) def render_codehighlighter(context, code)
#The div is required because RDiscount blows ass #The div is required because RDiscount blows ass
<<-HTML <<-HTML
<div> <div>
<pre><code class='#{@lang}'>#{h(code).strip}</code></pre> <pre><code class='#{@lang}'>#{h(code).strip}</code></pre>
</div> </div>
HTML HTML
end end
@ -71,7 +71,7 @@ module Jekyll
end end
end end
end
end end
Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock) Liquid::Template.register_tag('highlight', Jekyll::Tags::HighlightBlock)

View File

@ -1,5 +1,5 @@
module Jekyll module Jekyll
module Tags
class IncludeTag < Liquid::Tag class IncludeTag < Liquid::Tag
def initialize(tag_name, file, tokens) def initialize(tag_name, file, tokens)
super super
@ -31,7 +31,7 @@ module Jekyll
end end
end end
end end
end
end end
Liquid::Template.register_tag('include', Jekyll::IncludeTag) Liquid::Template.register_tag('include', Jekyll::Tags::IncludeTag)

View File

@ -1,5 +1,5 @@
module Jekyll module Jekyll
module Tags
class PostComparer class PostComparer
MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)$/ MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)$/
@ -33,6 +33,7 @@ module Jekyll
return "#" return "#"
end end
end end
end
end end
Liquid::Template.register_tag('post_url', Jekyll::PostUrl) Liquid::Template.register_tag('post_url', Jekyll::Tags::PostUrl)

View File

@ -17,16 +17,16 @@ class TestKramdown < Test::Unit::TestCase
# http://kramdown.rubyforge.org/converter/html.html#options # http://kramdown.rubyforge.org/converter/html.html#options
should "pass kramdown options" do should "pass kramdown options" do
markdown = MarkdownConverter.new(@config) markdown = Converters::Markdown.new(@config)
assert_equal "<h1>Some Header</h1>", markdown.convert('# Some Header #').strip assert_equal "<h1>Some Header</h1>", markdown.convert('# Some Header #').strip
end end
should "convert quotes to smart quotes" do should "convert quotes to smart quotes" do
markdown = MarkdownConverter.new(@config) markdown = Converters::Markdown.new(@config)
assert_equal "<p>&ldquo;Pit&rsquo;hy&rdquo;</p>", markdown.convert(%{"Pit'hy"}).strip assert_equal "<p>&ldquo;Pit&rsquo;hy&rdquo;</p>", markdown.convert(%{"Pit'hy"}).strip
override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } } override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } }
markdown = MarkdownConverter.new(@config.deep_merge(override)) markdown = Converters::Markdown.new(@config.deep_merge(override))
assert_equal "<p>&laquo;Pit&rsaquo;hy&raquo;</p>", markdown.convert(%{"Pit'hy"}).strip assert_equal "<p>&laquo;Pit&rsaquo;hy&raquo;</p>", markdown.convert(%{"Pit'hy"}).strip
end end
end end

View File

@ -457,34 +457,34 @@ class TestPost < Test::Unit::TestCase
should "process .md as markdown under default configuration" do should "process .md as markdown under default configuration" do
post = setup_post '2011-04-12-md-extension.md' post = setup_post '2011-04-12-md-extension.md'
conv = post.converter conv = post.converter
assert conv.kind_of? Jekyll::MarkdownConverter assert conv.kind_of? Jekyll::Converters::Markdown
end end
should "process .text as indentity under default configuration" do should "process .text as indentity under default configuration" do
post = setup_post '2011-04-12-text-extension.text' post = setup_post '2011-04-12-text-extension.text'
conv = post.converter conv = post.converter
assert conv.kind_of? Jekyll::IdentityConverter assert conv.kind_of? Jekyll::Converters::Identity
end end
should "process .text as markdown under alternate configuration" do should "process .text as markdown under alternate configuration" do
@site.config['markdown_ext'] = 'markdown,mdw,mdwn,md,text' @site.config['markdown_ext'] = 'markdown,mdw,mdwn,md,text'
post = setup_post '2011-04-12-text-extension.text' post = setup_post '2011-04-12-text-extension.text'
conv = post.converter conv = post.converter
assert conv.kind_of? Jekyll::MarkdownConverter assert conv.kind_of? Jekyll::Converters::Markdown
end end
should "process .md as markdown under alternate configuration" do should "process .md as markdown under alternate configuration" do
@site.config['markdown_ext'] = 'markdown,mkd,mkdn,md,text' @site.config['markdown_ext'] = 'markdown,mkd,mkdn,md,text'
post = setup_post '2011-04-12-text-extension.text' post = setup_post '2011-04-12-text-extension.text'
conv = post.converter conv = post.converter
assert conv.kind_of? Jekyll::MarkdownConverter assert conv.kind_of? Jekyll::Converters::Markdown
end end
should "process .text as textile under alternate configuration" do should "process .text as textile under alternate configuration" do
@site.config['textile_ext'] = 'textile,text' @site.config['textile_ext'] = 'textile,text'
post = setup_post '2011-04-12-text-extension.text' post = setup_post '2011-04-12-text-extension.text'
conv = post.converter conv = post.converter
assert conv.kind_of? Jekyll::TextileConverter assert conv.kind_of? Jekyll::Converters::Textile
end end
end end

View File

@ -8,7 +8,7 @@ class TestRdiscount < Test::Unit::TestCase
'markdown' => 'rdiscount', 'markdown' => 'rdiscount',
'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' } 'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' }
} }
@markdown = MarkdownConverter.new config @markdown = Converters::Markdown.new config
end end
should "pass rdiscount extensions" do should "pass rdiscount extensions" do

View File

@ -7,7 +7,7 @@ class TestRedcarpet < Test::Unit::TestCase
'redcarpet' => { 'extensions' => ['smart', 'strikethrough', 'filter_html'] }, 'redcarpet' => { 'extensions' => ['smart', 'strikethrough', 'filter_html'] },
'markdown' => 'redcarpet' 'markdown' => 'redcarpet'
} }
@markdown = MarkdownConverter.new config @markdown = Converters::Markdown.new config
end end
should "pass redcarpet options" do should "pass redcarpet options" do

View File

@ -4,7 +4,7 @@ class TestRedCloth < Test::Unit::TestCase
context "RedCloth default (no explicit config) hard_breaks enabled" do context "RedCloth default (no explicit config) hard_breaks enabled" do
setup do setup do
@textile = TextileConverter.new @textile = Converters::Textile.new
end end
should "preserve single line breaks in HTML output" do should "preserve single line breaks in HTML output" do
@ -17,7 +17,7 @@ class TestRedCloth < Test::Unit::TestCase
config = { config = {
'redcloth' => {} 'redcloth' => {}
} }
@textile = TextileConverter.new config @textile = Converters::Textile.new config
end end
should "preserve single line breaks in HTML output" do should "preserve single line breaks in HTML output" do
@ -32,7 +32,7 @@ class TestRedCloth < Test::Unit::TestCase
'hard_breaks' => true # default 'hard_breaks' => true # default
} }
} }
@textile = TextileConverter.new config @textile = Converters::Textile.new config
end end
should "preserve single line breaks in HTML output" do should "preserve single line breaks in HTML output" do
@ -47,7 +47,7 @@ class TestRedCloth < Test::Unit::TestCase
'hard_breaks' => false 'hard_breaks' => false
} }
} }
@textile = TextileConverter.new config @textile = Converters::Textile.new config
end end
should "not generate break tags in HTML output" do should "not generate break tags in HTML output" do
@ -62,7 +62,7 @@ class TestRedCloth < Test::Unit::TestCase
'no_span_caps' => false 'no_span_caps' => false
} }
} }
@textile = TextileConverter.new config @textile = Converters::Textile.new config
end end
should "generate span tags around capitalized words" do should "generate span tags around capitalized words" do
assert_equal "<p><span class=\"caps\">NSC</span></p>", @textile.convert("NSC").strip assert_equal "<p><span class=\"caps\">NSC</span></p>", @textile.convert("NSC").strip
@ -76,7 +76,7 @@ class TestRedCloth < Test::Unit::TestCase
'no_span_caps' => true 'no_span_caps' => true
} }
} }
@textile = TextileConverter.new config @textile = Converters::Textile.new config
end end
should "not generate span tags around capitalized words" do should "not generate span tags around capitalized words" do

View File

@ -4,7 +4,7 @@ require 'helper'
class TestTags < Test::Unit::TestCase class TestTags < Test::Unit::TestCase
def create_post(content, override = {}, converter_class = Jekyll::MarkdownConverter) def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown)
stub(Jekyll).configuration do stub(Jekyll).configuration do
Jekyll::DEFAULTS.deep_merge({'pygments' => true}).deep_merge(override) Jekyll::DEFAULTS.deep_merge({'pygments' => true}).deep_merge(override)
end end
@ -39,7 +39,7 @@ CONTENT
context "language name" do context "language name" do
should "match only the required set of chars" do should "match only the required set of chars" do
r = Jekyll::HighlightBlock::SYNTAX r = Jekyll::Tags::HighlightBlock::SYNTAX
assert_match r, "ruby" assert_match r, "ruby"
assert_match r, "c#" assert_match r, "c#"
assert_match r, "xml+cheetah" assert_match r, "xml+cheetah"
@ -55,19 +55,19 @@ CONTENT
context "initialized tag" do context "initialized tag" do
should "work" do should "work" do
tag = Jekyll::HighlightBlock.new('highlight', 'ruby ', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby ', ["test", "{% endhighlight %}", "\n"])
assert_equal({}, tag.instance_variable_get(:@options)) assert_equal({}, tag.instance_variable_get(:@options))
tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos ', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos ', ["test", "{% endhighlight %}", "\n"])
assert_equal({ 'linenos' => 'inline' }, tag.instance_variable_get(:@options)) assert_equal({ 'linenos' => 'inline' }, tag.instance_variable_get(:@options))
tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table ', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table ', ["test", "{% endhighlight %}", "\n"])
assert_equal({ 'linenos' => 'table' }, tag.instance_variable_get(:@options)) assert_equal({ 'linenos' => 'table' }, tag.instance_variable_get(:@options))
tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table nowrap', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table nowrap', ["test", "{% endhighlight %}", "\n"])
assert_equal({ 'linenos' => 'table', 'nowrap' => true }, tag.instance_variable_get(:@options)) assert_equal({ 'linenos' => 'table', 'nowrap' => true }, tag.instance_variable_get(:@options))
tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl', ["test", "{% endhighlight %}", "\n"])
assert_equal({ 'cssclass' => 'hl', 'linenos' => 'table' }, tag.instance_variable_get(:@options)) assert_equal({ 'cssclass' => 'hl', 'linenos' => 'table' }, tag.instance_variable_get(:@options))
end end
end end
@ -129,7 +129,7 @@ CONTENT
context "using Textile" do context "using Textile" do
setup do setup do
create_post(@content, {}, Jekyll::TextileConverter) create_post(@content, {}, Jekyll::Converters::Textile)
end end
# Broken in RedCloth 4.1.9 # Broken in RedCloth 4.1.9