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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
module Jekyll
class Converter < Plugin
# 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
@ -46,5 +45,4 @@ module Jekyll
self.class.pygments_suffix
end
end
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
module Jekyll
module Tags
class HighlightBlock < Liquid::Block
include Liquid::StandardFilters
@ -58,9 +58,9 @@ module Jekyll
def render_codehighlighter(context, code)
#The div is required because RDiscount blows ass
<<-HTML
<div>
<div>
<pre><code class='#{@lang}'>#{h(code).strip}</code></pre>
</div>
</div>
HTML
end
@ -71,7 +71,7 @@ module Jekyll
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 Tags
class IncludeTag < Liquid::Tag
def initialize(tag_name, file, tokens)
super
@ -31,7 +31,7 @@ module Jekyll
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 Tags
class PostComparer
MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)$/
@ -33,6 +33,7 @@ module Jekyll
return "#"
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
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
end
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
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
end
end

View File

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

View File

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

View File

@ -7,7 +7,7 @@ class TestRedcarpet < Test::Unit::TestCase
'redcarpet' => { 'extensions' => ['smart', 'strikethrough', 'filter_html'] },
'markdown' => 'redcarpet'
}
@markdown = MarkdownConverter.new config
@markdown = Converters::Markdown.new config
end
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
setup do
@textile = TextileConverter.new
@textile = Converters::Textile.new
end
should "preserve single line breaks in HTML output" do
@ -17,7 +17,7 @@ class TestRedCloth < Test::Unit::TestCase
config = {
'redcloth' => {}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "preserve single line breaks in HTML output" do
@ -32,7 +32,7 @@ class TestRedCloth < Test::Unit::TestCase
'hard_breaks' => true # default
}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "preserve single line breaks in HTML output" do
@ -47,7 +47,7 @@ class TestRedCloth < Test::Unit::TestCase
'hard_breaks' => false
}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "not generate break tags in HTML output" do
@ -62,7 +62,7 @@ class TestRedCloth < Test::Unit::TestCase
'no_span_caps' => false
}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "generate span tags around capitalized words" do
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
}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "not generate span tags around capitalized words" do

View File

@ -4,7 +4,7 @@ require 'helper'
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
Jekyll::DEFAULTS.deep_merge({'pygments' => true}).deep_merge(override)
end
@ -39,7 +39,7 @@ CONTENT
context "language name" 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, "c#"
assert_match r, "xml+cheetah"
@ -55,19 +55,19 @@ CONTENT
context "initialized tag" 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))
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))
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))
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))
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))
end
end
@ -129,7 +129,7 @@ CONTENT
context "using Textile" do
setup do
create_post(@content, {}, Jekyll::TextileConverter)
create_post(@content, {}, Jekyll::Converters::Textile)
end
# Broken in RedCloth 4.1.9