henshin 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -1
- data/README.markdown +9 -46
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/bin/henshin +11 -12
- data/henshin.gemspec +20 -27
- data/lib/henshin.rb +21 -98
- data/lib/henshin/archive.rb +87 -115
- data/{bin → lib/henshin/exec}/files.rb +0 -0
- data/lib/henshin/ext.rb +35 -58
- data/lib/henshin/gen.rb +83 -68
- data/lib/henshin/labels.rb +144 -0
- data/lib/henshin/plugin.rb +70 -33
- data/lib/henshin/plugins/highlight.rb +19 -26
- data/lib/henshin/plugins/liquid.rb +50 -52
- data/lib/henshin/plugins/maruku.rb +14 -16
- data/lib/henshin/plugins/sass.rb +19 -23
- data/lib/henshin/plugins/textile.rb +14 -16
- data/lib/henshin/post.rb +67 -120
- data/lib/henshin/site.rb +154 -131
- data/lib/henshin/static.rb +10 -8
- data/test/helper.rb +20 -8
- data/test/site/css/{includes/reset.sass → _reset.sass} +0 -0
- data/test/site/css/screen.sass +1 -1
- data/test/site/index.html +2 -3
- data/test/site/layouts/archive_date.html +5 -4
- data/test/site/layouts/archive_month.html +10 -5
- data/test/site/layouts/archive_year.html +13 -6
- data/test/site/layouts/category_page.html +7 -7
- data/test/site/layouts/main.html +3 -4
- data/test/site/layouts/post.html +1 -1
- data/test/site/layouts/tag_index.html +3 -2
- data/test/site/layouts/tag_page.html +6 -6
- data/test/site/options.yaml +2 -2
- data/test/site/plugins/test.rb +1 -3
- data/test/site/posts/Testing-Stuff.markdown +1 -1
- data/test/site/posts/Textile-Test.textile +1 -1
- data/test/site/posts/lorem-ipsum.markdown +1 -1
- data/test/site/posts/same-date.markdown +1 -1
- data/test/{test_henshin.rb → suite.rb} +0 -1
- data/test/test_gen.rb +98 -0
- data/test/test_options.rb +34 -19
- data/test/test_post.rb +67 -0
- data/test/test_site.rb +159 -46
- data/test/test_static.rb +13 -0
- metadata +53 -32
- data/lib/henshin/categories.rb +0 -29
- data/lib/henshin/tags.rb +0 -28
- data/test/test_archives.rb +0 -27
- data/test/test_categories.rb +0 -0
- data/test/test_gens.rb +0 -54
- data/test/test_layouts.rb +0 -14
- data/test/test_posts.rb +0 -75
- data/test/test_statics.rb +0 -0
- data/test/test_tags.rb +0 -0
- data/test/text_exts.rb +0 -0
data/lib/henshin/categories.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
module Henshin
|
2
|
-
class Category
|
3
|
-
|
4
|
-
attr_accessor :name, :posts
|
5
|
-
|
6
|
-
def initialize( name )
|
7
|
-
@name = name
|
8
|
-
@posts = []
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_hash
|
12
|
-
hash = {
|
13
|
-
'name' => @name,
|
14
|
-
'posts' => @posts.sort.collect {|i| i.to_hash},
|
15
|
-
'url' => self.url
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def url
|
20
|
-
"/categories/#{@name.slugify}/"
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
def inspect
|
25
|
-
"#<Category:#{@name}>"
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
data/lib/henshin/tags.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module Henshin
|
2
|
-
class Tag
|
3
|
-
|
4
|
-
attr_accessor :name, :posts
|
5
|
-
|
6
|
-
def initialize( name )
|
7
|
-
@name = name
|
8
|
-
@posts = []
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_hash
|
12
|
-
hash = {
|
13
|
-
'name' => @name,
|
14
|
-
'posts' => @posts.sort.collect {|i| i.to_hash},
|
15
|
-
'url' => self.url
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def url
|
20
|
-
"/tags/#{@name.slugify}/"
|
21
|
-
end
|
22
|
-
|
23
|
-
def inspect
|
24
|
-
"#<Tag:#{@name}>"
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
data/test/test_archives.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__) ,'helper')
|
2
|
-
|
3
|
-
class TestArchives < Test::Unit::TestCase
|
4
|
-
context "An archive" do
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@site = new_site
|
8
|
-
end
|
9
|
-
|
10
|
-
should "turn to hash" do
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
should "turn to hash of dates" do
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
should "turn to hash of months" do
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
should "turn to hash of years" do
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
data/test/test_categories.rb
DELETED
File without changes
|
data/test/test_gens.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__) ,'helper')
|
2
|
-
|
3
|
-
class TestGens < Test::Unit::TestCase
|
4
|
-
context "A gen" do
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@site = new_site
|
8
|
-
@gen = Henshin::Gen.new "#{root_dir}/index.html", @site
|
9
|
-
remove_site
|
10
|
-
end
|
11
|
-
|
12
|
-
should "read frontmatter" do
|
13
|
-
@site.read_layouts
|
14
|
-
@gen.read_yaml
|
15
|
-
assert_equal 'Home Page', @gen.title
|
16
|
-
assert_equal File.open("#{root_dir}/layouts/main.html", "r"){|f| f.read}, @gen.layout
|
17
|
-
end
|
18
|
-
|
19
|
-
should "render with correct layout" do
|
20
|
-
@site.read_layouts
|
21
|
-
@gen.read_yaml
|
22
|
-
# index.html uses 'layout: main'
|
23
|
-
assert_equal File.open("#{root_dir}/layouts/main.html", "r"){|f| f.read}, @gen.layout
|
24
|
-
end
|
25
|
-
|
26
|
-
should "have the correct permalink and url" do
|
27
|
-
@gen.read_yaml
|
28
|
-
assert_equal '/index.html', @gen.permalink
|
29
|
-
assert_equal '/', @gen.url
|
30
|
-
end
|
31
|
-
|
32
|
-
should "respond to #to_hash" do
|
33
|
-
@gen.process
|
34
|
-
assert_equal @gen.title, @gen.to_hash['title']
|
35
|
-
assert_equal @gen.permalink, @gen.to_hash['permalink']
|
36
|
-
assert_equal @gen.url, @gen.to_hash['url']
|
37
|
-
assert_equal @gen.content, @gen.to_hash['content']
|
38
|
-
end
|
39
|
-
|
40
|
-
should "allow a hash to be added to the payload" do
|
41
|
-
payload = { :name => 'people', :payload => {'fname' => 'John', 'sname' => 'Doe'} }
|
42
|
-
gen = Henshin::Gen.new( "#{root_dir}/index.html", @site, payload )
|
43
|
-
gen.read_yaml
|
44
|
-
assert_equal payload[:payload], gen.payload['people']
|
45
|
-
end
|
46
|
-
|
47
|
-
should "be sortable" do
|
48
|
-
another_gen = Henshin::Gen.new( "#{root_dir}/css/print.sass", @site )
|
49
|
-
gen_array = [@gen, another_gen]
|
50
|
-
assert_equal gen_array.reverse, gen_array.sort
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
data/test/test_layouts.rb
DELETED
data/test/test_posts.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__) ,'helper')
|
2
|
-
|
3
|
-
class TestPosts < Test::Unit::TestCase
|
4
|
-
context "A post" do
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@site = new_site
|
8
|
-
@site.read
|
9
|
-
@site.process
|
10
|
-
@post = Henshin::Post.new( "#{root_dir}/posts/lorem-ipsum.markdown", @site )
|
11
|
-
remove_site
|
12
|
-
end
|
13
|
-
|
14
|
-
should "get data from the filename" do
|
15
|
-
post_file = "#{root_dir}/posts/2010-08-10-lorem-ipsum.markdown"
|
16
|
-
site = @site
|
17
|
-
site.config[:file_name] = "{date}-{title-with-dashes}.{extension}"
|
18
|
-
post = Henshin::Post.new( post_file, site )
|
19
|
-
post.read_name
|
20
|
-
assert_equal 'Lorem Ipsum', post.title
|
21
|
-
assert_equal Time.parse('2010-08-10'), post.date
|
22
|
-
assert_equal 'markdown', post.extension
|
23
|
-
end
|
24
|
-
|
25
|
-
should "get category from folder" do
|
26
|
-
post_file = "#{root_dir}/posts/category/test-post.markdown"
|
27
|
-
post = Henshin::Post.new( post_file, @site )
|
28
|
-
post.read_name
|
29
|
-
assert_equal 'category', post.category
|
30
|
-
end
|
31
|
-
|
32
|
-
should "render with correct layout" do
|
33
|
-
@post.process
|
34
|
-
# lorem-ipsum.markdown uses default 'layout: post'
|
35
|
-
assert_equal File.open("#{root_dir}/layouts/post.html"){|f| f.read} , @post.layout
|
36
|
-
end
|
37
|
-
|
38
|
-
should "read frontmatter" do
|
39
|
-
@post.read_yaml
|
40
|
-
assert_equal 'Lorem Ipsum', @post.title
|
41
|
-
assert_equal Time.parse('2010-05-15 at 13:23:47'), @post.date
|
42
|
-
assert_equal ['test', 'lorem'], @post.tags
|
43
|
-
end
|
44
|
-
|
45
|
-
should "have the correct permalink and url" do
|
46
|
-
@post.process
|
47
|
-
assert_equal "/2010/5/15/lorem-ipsum/index.html", @post.permalink
|
48
|
-
assert_equal "/2010/5/15/lorem-ipsum/", @post.url
|
49
|
-
end
|
50
|
-
|
51
|
-
should "respond to #to_hash" do
|
52
|
-
@post.process
|
53
|
-
assert_equal @post.title, @post.to_hash['title']
|
54
|
-
assert_equal @post.author, @post.to_hash['author']
|
55
|
-
assert_equal @post.permalink, @post.to_hash['permalink']
|
56
|
-
assert_equal @post.url, @post.to_hash['url']
|
57
|
-
assert_equal @post.date, @post.to_hash['date']
|
58
|
-
assert_equal @post.category, @post.to_hash['category']
|
59
|
-
assert_equal @post.content, @post.to_hash['content']
|
60
|
-
end
|
61
|
-
|
62
|
-
should "be sortable" do
|
63
|
-
another_post = Henshin::Post.new( "#{root_dir}/posts/Testing-Stuff.markdown", @site )
|
64
|
-
post_array = [another_post, @post]
|
65
|
-
assert_equal post_array.reverse, post_array.sort
|
66
|
-
end
|
67
|
-
|
68
|
-
should "sort by url if dates are same" do
|
69
|
-
another_post = Henshin::Post.new( "#{root_dir}/posts/same-date.markdown", @site )
|
70
|
-
post_array = [another_post, @post]
|
71
|
-
assert_equal post_array.reverse, post_array.sort
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
data/test/test_statics.rb
DELETED
File without changes
|
data/test/test_tags.rb
DELETED
File without changes
|
data/test/text_exts.rb
DELETED
File without changes
|