henshin 0.4.2 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENCE +18 -0
- data/README.md +133 -0
- data/Rakefile +6 -51
- data/bin/henshin +127 -134
- data/lib/henshin.rb +163 -38
- data/lib/henshin/compressor.rb +31 -0
- data/lib/henshin/compressors/css.rb +20 -0
- data/lib/henshin/compressors/js.rb +20 -0
- data/lib/henshin/core_ext.rb +69 -0
- data/lib/henshin/error.rb +28 -0
- data/lib/henshin/file.rb +67 -0
- data/lib/henshin/files/abstract.rb +102 -0
- data/lib/henshin/files/attributes.rb +31 -0
- data/lib/henshin/files/empty_template.rb +24 -0
- data/lib/henshin/files/physical.rb +117 -0
- data/lib/henshin/files/post.rb +64 -0
- data/lib/henshin/files/templatable.rb +29 -0
- data/lib/henshin/files/template.rb +45 -0
- data/lib/henshin/files/tilt.rb +50 -0
- data/lib/henshin/files/tilt_template.rb +45 -0
- data/lib/henshin/package.rb +27 -0
- data/lib/henshin/packages/script.rb +23 -0
- data/lib/henshin/packages/style.rb +20 -0
- data/lib/henshin/path.rb +143 -0
- data/lib/henshin/publisher.rb +42 -0
- data/lib/henshin/publishers/sftp.rb +79 -0
- data/lib/henshin/reader.rb +68 -0
- data/lib/henshin/safety.rb +74 -0
- data/lib/henshin/scope.rb +55 -0
- data/lib/henshin/site.rb +291 -228
- data/lib/henshin/ui.rb +35 -0
- data/lib/henshin/version.rb +3 -0
- data/lib/henshin/writer.rb +43 -0
- data/lib/rack/henshin.rb +113 -0
- data/site/assets/scripts/config.js +11 -0
- data/site/assets/styles/_mixins.sass +16 -0
- data/site/assets/styles/screen.sass +198 -0
- data/site/config.yml +13 -0
- data/site/drafts/a-work-in-progress.md +5 -0
- data/site/feed.xml.slim +19 -0
- data/site/index.html.slim +28 -0
- data/site/init.rb +33 -0
- data/site/posts/1-hello-world.md +46 -0
- data/site/posts/2-code-testing.md +36 -0
- data/site/posts/3-style-test.md +80 -0
- data/site/templates/default.slim +11 -0
- data/site/templates/post.slim +30 -0
- data/site/test.html.md +7 -0
- data/spec/helper.rb +70 -0
- data/spec/henshin/compressor_spec.rb +25 -0
- data/spec/henshin/compressors/css_spec.rb +22 -0
- data/spec/henshin/compressors/js_spec.rb +22 -0
- data/spec/henshin/core_ext_spec.rb +59 -0
- data/spec/henshin/error_spec.rb +22 -0
- data/spec/henshin/file_spec.rb +28 -0
- data/spec/henshin/files/abstract_spec.rb +98 -0
- data/spec/henshin/files/attributes_spec.rb +25 -0
- data/spec/henshin/files/empty_template_spec.rb +11 -0
- data/spec/henshin/files/physical_spec.rb +55 -0
- data/spec/henshin/files/post_spec.rb +66 -0
- data/spec/henshin/files/template_spec.rb +53 -0
- data/spec/henshin/files/tilt_spec.rb +59 -0
- data/spec/henshin/package_spec.rb +24 -0
- data/spec/henshin/packages/script_spec.rb +17 -0
- data/spec/henshin/packages/style_spec.rb +17 -0
- data/spec/henshin/path_spec.rb +56 -0
- data/spec/henshin/publisher_spec.rb +44 -0
- data/spec/henshin/publishers/sftp_spec.rb +21 -0
- data/spec/henshin/reader_spec.rb +55 -0
- data/spec/henshin/safety_spec.rb +66 -0
- data/spec/henshin/scope_spec.rb +33 -0
- data/spec/henshin/site_spec.rb +142 -0
- data/spec/henshin/ui_spec.rb +26 -0
- data/spec/henshin/writer_spec.rb +26 -0
- metadata +352 -197
- data/.gitignore +0 -27
- data/LICENSE +0 -20
- data/README.markdown +0 -35
- data/VERSION +0 -1
- data/henshin.gemspec +0 -121
- data/lib/henshin/archive.rb +0 -133
- data/lib/henshin/exec/files.rb +0 -46
- data/lib/henshin/ext.rb +0 -55
- data/lib/henshin/gen.rb +0 -154
- data/lib/henshin/labels.rb +0 -144
- data/lib/henshin/plugin.rb +0 -100
- data/lib/henshin/plugins/highlight.rb +0 -24
- data/lib/henshin/plugins/liquid.rb +0 -61
- data/lib/henshin/plugins/maruku.rb +0 -18
- data/lib/henshin/plugins/sass.rb +0 -24
- data/lib/henshin/plugins/textile.rb +0 -18
- data/lib/henshin/post.rb +0 -156
- data/lib/henshin/static.rb +0 -33
- data/test/helper.rb +0 -44
- data/test/site/css/_reset.sass +0 -34
- data/test/site/css/print.css +0 -12
- data/test/site/css/screen.sass +0 -70
- data/test/site/includes/head.html +0 -1
- data/test/site/index.html +0 -23
- data/test/site/layouts/archive_date.html +0 -20
- data/test/site/layouts/archive_month.html +0 -24
- data/test/site/layouts/archive_year.html +0 -26
- data/test/site/layouts/category_index.html +0 -27
- data/test/site/layouts/category_page.html +0 -20
- data/test/site/layouts/main.html +0 -13
- data/test/site/layouts/post.html +0 -36
- data/test/site/layouts/tag_index.html +0 -27
- data/test/site/layouts/tag_page.html +0 -20
- data/test/site/options.yaml +0 -17
- data/test/site/plugins/test.rb +0 -3
- data/test/site/posts/Testing-Stuff.markdown +0 -14
- data/test/site/posts/Textile-Test.textile +0 -7
- data/test/site/posts/cat/test.markdown +0 -6
- data/test/site/posts/lorem-ipsum.markdown +0 -7
- data/test/site/posts/same-date.markdown +0 -7
- data/test/site/static.html +0 -19
- data/test/suite.rb +0 -4
- data/test/test_gen.rb +0 -98
- data/test/test_options.rb +0 -73
- data/test/test_post.rb +0 -67
- data/test/test_site.rb +0 -197
- data/test/test_static.rb +0 -13
@@ -1,20 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>{{ site.title }}</title>
|
6
|
-
{% include head.html %}
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<a href="/">Home</a>
|
10
|
-
<h1>Archive for {{ archive.year }}/{{ archive.month }}/{{ archive.day }}</h1>
|
11
|
-
|
12
|
-
<ul>
|
13
|
-
{% for post in archive.posts[archive.year][archive.month][archive.day] %}
|
14
|
-
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
|
15
|
-
{% endfor %}
|
16
|
-
</ul>
|
17
|
-
|
18
|
-
<span>Copyright © {{ site.author }}</span>
|
19
|
-
</body>
|
20
|
-
</html>
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>{{ site.title }}</title>
|
6
|
-
{% include head.html %}
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<a href="/">Home</a>
|
10
|
-
<h1>Archive for {{ archive.year }}/{{ archive.month }}</h1>
|
11
|
-
|
12
|
-
<ul>
|
13
|
-
{% for day in (1..31) %}
|
14
|
-
{% if archive.posts[archive.year][archive.month][day] %}
|
15
|
-
{% for post in archive.posts[archive.year][archive.month][day] %}
|
16
|
-
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
|
17
|
-
{% endfor %}
|
18
|
-
{% endif %}
|
19
|
-
{% endfor %}
|
20
|
-
</ul>
|
21
|
-
|
22
|
-
<span>Copyright © {{ site.author }}</span>
|
23
|
-
</body>
|
24
|
-
</html>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>{{ site.title }}</title>
|
6
|
-
{% include head.html %}
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<a href="/">Home</a>
|
10
|
-
<h1>Archive for {{ archive.year }}</h1>
|
11
|
-
|
12
|
-
<ul>
|
13
|
-
{% for day in (1..31) %}
|
14
|
-
{% for month in (1..12) %}
|
15
|
-
{% if archive.posts[archive.year][month][day] %}
|
16
|
-
{% for post in archive.posts[archive.year][month][day] %}
|
17
|
-
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
|
18
|
-
{% endfor %}
|
19
|
-
{% endif %}
|
20
|
-
{% endfor %}
|
21
|
-
{% endfor %}
|
22
|
-
</ul>
|
23
|
-
|
24
|
-
<span>Copyright © {{ site.author }}</span>
|
25
|
-
</body>
|
26
|
-
</html>
|
@@ -1,27 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>{{ site.title }}</title>
|
6
|
-
{% include head.html %}
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<a href="/">Home</a>
|
10
|
-
|
11
|
-
<h2>A List of Categories</h2>
|
12
|
-
<ul>
|
13
|
-
{% for category in site.categories %}
|
14
|
-
<li>
|
15
|
-
<a href="{{ category.url }}">{{ category.name }}</a>
|
16
|
-
<ul>
|
17
|
-
{% for post in category.posts %}
|
18
|
-
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
19
|
-
{% endfor %}
|
20
|
-
</ul>
|
21
|
-
</li>
|
22
|
-
{% endfor %}
|
23
|
-
</ul>
|
24
|
-
|
25
|
-
<span>Copyright © {{ site.author }}</span>
|
26
|
-
</body>
|
27
|
-
</html>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>{{ site.title }}</title>
|
6
|
-
{% include head.html %}
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<a href="/">Home</a>
|
10
|
-
|
11
|
-
<h2>{{ category.name }}</h2>
|
12
|
-
<ul>
|
13
|
-
{% for post in category.posts %}
|
14
|
-
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
15
|
-
{% endfor %}
|
16
|
-
</ul>
|
17
|
-
|
18
|
-
<span>Copyright © {{ site.author }}</span>
|
19
|
-
</body>
|
20
|
-
</html>
|
data/test/site/layouts/main.html
DELETED
data/test/site/layouts/post.html
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>{{ post.title }}</title>
|
6
|
-
{% include head.html %}
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
|
10
|
-
<nav>
|
11
|
-
{% if post.next %}
|
12
|
-
<a href="{{ post.next.url }}">←</a> 
|
13
|
-
{% endif %}
|
14
|
-
<a href="/">Home</a>
|
15
|
-
{% if post.prev %}
|
16
|
-
 <a href="{{ post.prev.url }}">→</a>
|
17
|
-
{% endif %}
|
18
|
-
</nav>
|
19
|
-
|
20
|
-
<header>
|
21
|
-
<h1>{{ post.title }}</h1>
|
22
|
-
<time>{{ post.date | date_to_string }}</time>
|
23
|
-
|
24
|
-
<ul class="tags">
|
25
|
-
{% for tag in post.tags %}
|
26
|
-
<li><a href="{{ tag.url }}">{{ tag.name }}</a></li>
|
27
|
-
{% endfor %}
|
28
|
-
</ul>
|
29
|
-
|
30
|
-
</header>
|
31
|
-
|
32
|
-
{{ yield }}
|
33
|
-
|
34
|
-
<span>Copyright © {% if post.author %}{{ post.author }}{% else %}{{ site.author }}{% endif %}</span>
|
35
|
-
</body>
|
36
|
-
</html>
|
@@ -1,27 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>{{ site.title }} > Tags</title>
|
6
|
-
{% include head.html %}
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<a href="/">Home</a>
|
10
|
-
|
11
|
-
<h2>A List of Tags</h2>
|
12
|
-
<ul>
|
13
|
-
{% for tag in site.tags %}
|
14
|
-
<li>
|
15
|
-
<a href="{{ tag.url }}">{{ tag.name }}</a>
|
16
|
-
<ul>
|
17
|
-
{% for post in tag.posts %}
|
18
|
-
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
19
|
-
{% endfor %}
|
20
|
-
</ul>
|
21
|
-
</li>
|
22
|
-
{% endfor %}
|
23
|
-
</ul>
|
24
|
-
|
25
|
-
<span>Copyright © {{ site.author }}</span>
|
26
|
-
</body>
|
27
|
-
</html>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>{{ site.title }}</title>
|
6
|
-
{% include head.html %}
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<a href="/">Home</a>
|
10
|
-
|
11
|
-
<h2>{{ tag.name }}</h2>
|
12
|
-
<ul>
|
13
|
-
{% for post in tag.posts %}
|
14
|
-
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
15
|
-
{% endfor %}
|
16
|
-
</ul>
|
17
|
-
|
18
|
-
<span>Copyright © {{ site.author }}</span>
|
19
|
-
</body>
|
20
|
-
</html>
|
data/test/site/options.yaml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
title: Test Site
|
2
|
-
description: This is a site to test this site generator!
|
3
|
-
time_zone: GMT
|
4
|
-
author: Joshua Hawxwell
|
5
|
-
|
6
|
-
layout: post
|
7
|
-
|
8
|
-
exclude: ['includes', 'css/_reset.sass']
|
9
|
-
post_name: '{title-with-dashes}.{extension}'
|
10
|
-
permalink: '/{year}/{month}/{date}/{title}/index.html'
|
11
|
-
plugins: [maruku, sass, liquid, test, textile, highlight]
|
12
|
-
|
13
|
-
sass:
|
14
|
-
style: :compact
|
15
|
-
|
16
|
-
liquid:
|
17
|
-
include_dir: includes
|
data/test/site/plugins/test.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Testing Stuff
|
3
|
-
date: 2010-10-20 at 17:33:23
|
4
|
-
tags: [test, markdown]
|
5
|
-
category: test
|
6
|
-
---
|
7
|
-
|
8
|
-
So Lorem ipsum dolor *sit amet*, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim __ad minim__ veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
9
|
-
|
10
|
-
$highlight ruby
|
11
|
-
def hello
|
12
|
-
puts "hello"
|
13
|
-
end
|
14
|
-
$end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Textile Test
|
3
|
-
date: 2009-11-09 at 13:23:47
|
4
|
-
tags: [test, plugin]
|
5
|
-
---
|
6
|
-
|
7
|
-
So Lorem ipsum dolor sit _amet, consectetur_ adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris *nisi ut aliquip* ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Lorem Ipsum
|
3
|
-
date: 2010-05-15 at 13:23:47
|
4
|
-
tags: [test, lorem]
|
5
|
-
---
|
6
|
-
|
7
|
-
So Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Same Date as "Lorem Ipsum"
|
3
|
-
date: 2010-05-15 at 13:23:47
|
4
|
-
tags: [test, lorem]
|
5
|
-
---
|
6
|
-
|
7
|
-
So Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
data/test/site/static.html
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title></title>
|
6
|
-
<link rel="stylesheet" href="" type="text/css" />
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
|
10
|
-
|
11
|
-
<header>
|
12
|
-
<h1>This should just be copied over</h1>
|
13
|
-
</header>
|
14
|
-
|
15
|
-
<p>I should be in the root folder! No templates or anything</p>
|
16
|
-
|
17
|
-
<p>init</p>
|
18
|
-
</body>
|
19
|
-
</html>
|
data/test/suite.rb
DELETED
data/test/test_gen.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__) ,'helper')
|
2
|
-
|
3
|
-
class TestGen < Test::Unit::TestCase
|
4
|
-
context "A gen" do
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@site = Henshin::Site.new(site_override).read.process
|
8
|
-
@index = "#{root_dir}/index.html"
|
9
|
-
@sass = "#{root_dir}/css/screen.sass"
|
10
|
-
remove_site
|
11
|
-
end
|
12
|
-
|
13
|
-
def new_sass_gen
|
14
|
-
Henshin::Gen.new(@sass.to_p, @site)
|
15
|
-
end
|
16
|
-
|
17
|
-
def new_html_gen
|
18
|
-
Henshin::Gen.new(@index.to_p, @site)
|
19
|
-
end
|
20
|
-
|
21
|
-
should "be have file data read" do
|
22
|
-
gen = new_html_gen
|
23
|
-
gen.read_file
|
24
|
-
|
25
|
-
assert_equal 'Home Page', gen.data['title']
|
26
|
-
assert_equal "main", gen.data['layout']
|
27
|
-
end
|
28
|
-
|
29
|
-
should "be rendered" do
|
30
|
-
gen = new_html_gen
|
31
|
-
gen.read
|
32
|
-
gen2 = new_html_gen
|
33
|
-
gen2.read
|
34
|
-
gen2.render
|
35
|
-
assert_not_equal gen.content, gen2.content
|
36
|
-
end
|
37
|
-
|
38
|
-
should "get output extension from plugin" do
|
39
|
-
gen = new_sass_gen
|
40
|
-
gen.read
|
41
|
-
assert_equal 'sass', gen.data['input']
|
42
|
-
assert_equal 'css', gen.data['output']
|
43
|
-
end
|
44
|
-
|
45
|
-
should "render with correct layout" do
|
46
|
-
gen = new_html_gen
|
47
|
-
# index.html should use 'main'
|
48
|
-
gen.read
|
49
|
-
gen.render
|
50
|
-
l = File.open("#{root_dir}/layouts/main.html", 'r') {|f| f.read}
|
51
|
-
assert_equal l, gen.data['layout']
|
52
|
-
end
|
53
|
-
|
54
|
-
should "have the correct permalink" do
|
55
|
-
gen = new_html_gen
|
56
|
-
gen.read
|
57
|
-
assert_equal '/index.html', gen.permalink
|
58
|
-
end
|
59
|
-
|
60
|
-
should "have the correct url" do
|
61
|
-
gen = new_html_gen
|
62
|
-
gen.read
|
63
|
-
assert_equal '/', gen.url
|
64
|
-
end
|
65
|
-
|
66
|
-
should "be written to the correct place" do
|
67
|
-
gen = new_html_gen
|
68
|
-
gen.read
|
69
|
-
assert_equal "#{target_dir}/index.html".to_p, gen.write_path
|
70
|
-
end
|
71
|
-
|
72
|
-
should "write with the correct output" do
|
73
|
-
gen = new_sass_gen
|
74
|
-
gen.read
|
75
|
-
assert_equal "#{target_dir}/css/screen.css".to_p, gen.write_path
|
76
|
-
end
|
77
|
-
|
78
|
-
should "turn all data to hash" do
|
79
|
-
gen = new_html_gen
|
80
|
-
gen.read
|
81
|
-
assert gen.to_hash.is_a? Hash
|
82
|
-
end
|
83
|
-
|
84
|
-
should "insert optional payload" do
|
85
|
-
gen = Henshin::Gen.new(@index.to_p, @site, {:name => 'test', :payload => {'data' => 'to_test'}})
|
86
|
-
gen.read
|
87
|
-
assert_equal 'to_test', gen.payload['test']['data']
|
88
|
-
end
|
89
|
-
|
90
|
-
should "be sortable" do
|
91
|
-
gen = new_html_gen
|
92
|
-
gen2 = new_sass_gen
|
93
|
-
gens = [gen, gen2]
|
94
|
-
assert_equal gens.reverse, gens.sort
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
data/test/test_options.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__) ,'helper')
|
2
|
-
|
3
|
-
# Need to remember to remove loaded plugins from the returned
|
4
|
-
# config when comparing against Defaults!
|
5
|
-
class TestOptions < Test::Unit::TestCase
|
6
|
-
context "Loading and setting options" do
|
7
|
-
|
8
|
-
setup do
|
9
|
-
@opts = './options.yaml'
|
10
|
-
end
|
11
|
-
|
12
|
-
should "warn of invalid options.yaml" do
|
13
|
-
mock(YAML).load_file(@opts) {"boo"}
|
14
|
-
mock($stderr).puts("\nCould not read configuration, falling back to defaults...")
|
15
|
-
mock($stderr).puts("-> can't convert String into Hash")
|
16
|
-
|
17
|
-
assert_equal Henshin::Defaults, Henshin::Site.new.config
|
18
|
-
end
|
19
|
-
|
20
|
-
should "warn of no options.yaml" do
|
21
|
-
mock(YAML).load_file(@opts) { raise "No such file or directory - #{@opts}" }
|
22
|
-
mock($stderr).puts("\nCould not read configuration, falling back to defaults...")
|
23
|
-
mock($stderr).puts("-> No such file or directory - #{@opts}")
|
24
|
-
|
25
|
-
assert_equal Henshin::Defaults, Henshin::Site.new.config
|
26
|
-
end
|
27
|
-
|
28
|
-
should "use defaults if no options.yaml" do
|
29
|
-
mock($stderr).puts("\nCould not read configuration, falling back to defaults...")
|
30
|
-
mock($stderr).puts("-> No such file or directory - #{@opts}")
|
31
|
-
|
32
|
-
assert_equal Henshin::Defaults, Henshin::Site.new.config
|
33
|
-
end
|
34
|
-
|
35
|
-
should "merge override with defaults" do
|
36
|
-
mock($stderr).puts("\nCould not read configuration, falling back to defaults...")
|
37
|
-
mock($stderr).puts("-> No such file or directory - #{@opts}")
|
38
|
-
|
39
|
-
override = {'time_zone' => '+01:00'}
|
40
|
-
site = Henshin::Site.new(override)
|
41
|
-
assert_equal '+01:00', site.config['time_zone']
|
42
|
-
end
|
43
|
-
|
44
|
-
should "add special directories to exclude after loading" do
|
45
|
-
mock($stderr).puts("\nCould not read configuration, falling back to defaults...")
|
46
|
-
mock($stderr).puts("-> No such file or directory - #{@opts}")
|
47
|
-
site = Henshin::Site.new
|
48
|
-
to_ignore = ['/_site', '/plugins']
|
49
|
-
assert_equal to_ignore, site.config['exclude']
|
50
|
-
|
51
|
-
mock(YAML).load_file(@opts) { {'exclude' => ['/my_dir', 'my_file.txt']} }
|
52
|
-
site2 = Henshin::Site.new
|
53
|
-
to_ignore = ['/my_dir', 'my_file.txt', '/_site', '/plugins']
|
54
|
-
assert_equal to_ignore, site2.config['exclude']
|
55
|
-
end
|
56
|
-
|
57
|
-
should "convert root, target to Pathnames" do
|
58
|
-
mock($stderr).puts("\nCould not read configuration, falling back to defaults...")
|
59
|
-
mock($stderr).puts("-> No such file or directory - #{@opts}")
|
60
|
-
site = Henshin::Site.new
|
61
|
-
assert site.root.is_a? Pathname
|
62
|
-
assert site.target.is_a? Pathname
|
63
|
-
end
|
64
|
-
|
65
|
-
should "set base" do
|
66
|
-
mock($stderr).puts("\nCould not read configuration, falling back to defaults...")
|
67
|
-
mock($stderr).puts("-> No such file or directory - #{@opts}")
|
68
|
-
site = Henshin::Site.new
|
69
|
-
assert site.base
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|