nanoc 3.5.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +20 -12
- data/NEWS.md +23 -0
- data/README.md +6 -3
- data/doc/yardoc_templates/default/layout/html/footer.erb +16 -7
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base.rb +1 -0
- data/lib/nanoc/base/compilation/compiler_dsl.rb +31 -0
- data/lib/nanoc/base/compilation/filter.rb +34 -0
- data/lib/nanoc/base/result_data/item_rep.rb +3 -3
- data/lib/nanoc/base/source_data/code_snippet.rb +1 -1
- data/lib/nanoc/base/source_data/data_source.rb +12 -0
- data/lib/nanoc/base/source_data/item.rb +1 -1
- data/lib/nanoc/base/source_data/item_array.rb +62 -0
- data/lib/nanoc/base/source_data/layout.rb +1 -1
- data/lib/nanoc/base/source_data/site.rb +24 -3
- data/lib/nanoc/cli/cleaning_stream.rb +10 -0
- data/lib/nanoc/cli/command_runner.rb +25 -12
- data/lib/nanoc/cli/commands/autocompile.rb +5 -3
- data/lib/nanoc/cli/commands/check.rb +9 -1
- data/lib/nanoc/cli/commands/compile.rb +1 -1
- data/lib/nanoc/cli/commands/create-site.rb +5 -5
- data/lib/nanoc/cli/commands/prune.rb +1 -1
- data/lib/nanoc/cli/commands/shell.rb +37 -0
- data/lib/nanoc/cli/commands/show-data.rb +1 -1
- data/lib/nanoc/cli/commands/sync.rb +34 -0
- data/lib/nanoc/cli/error_handler.rb +11 -2
- data/lib/nanoc/extra/checking/checks/stale.rb +10 -2
- data/lib/nanoc/extra/pruner.rb +14 -11
- data/lib/nanoc/filters/asciidoc.rb +2 -2
- data/lib/nanoc/filters/bluecloth.rb +2 -2
- data/lib/nanoc/filters/coderay.rb +2 -2
- data/lib/nanoc/filters/coffeescript.rb +2 -2
- data/lib/nanoc/filters/colorize_syntax.rb +2 -4
- data/lib/nanoc/filters/erb.rb +2 -2
- data/lib/nanoc/filters/erubis.rb +2 -2
- data/lib/nanoc/filters/haml.rb +2 -2
- data/lib/nanoc/filters/handlebars.rb +2 -2
- data/lib/nanoc/filters/kramdown.rb +2 -2
- data/lib/nanoc/filters/less.rb +2 -2
- data/lib/nanoc/filters/markaby.rb +2 -2
- data/lib/nanoc/filters/maruku.rb +2 -2
- data/lib/nanoc/filters/mustache.rb +2 -2
- data/lib/nanoc/filters/pandoc.rb +2 -2
- data/lib/nanoc/filters/rainpress.rb +2 -2
- data/lib/nanoc/filters/rdiscount.rb +2 -2
- data/lib/nanoc/filters/rdoc.rb +3 -17
- data/lib/nanoc/filters/redcarpet.rb +7 -3
- data/lib/nanoc/filters/redcloth.rb +2 -2
- data/lib/nanoc/filters/rubypants.rb +2 -2
- data/lib/nanoc/filters/sass.rb +2 -3
- data/lib/nanoc/filters/slim.rb +2 -2
- data/lib/nanoc/filters/typogruby.rb +2 -2
- data/lib/nanoc/filters/uglify_js.rb +2 -2
- data/lib/nanoc/filters/xsl.rb +2 -1
- data/lib/nanoc/filters/yui_compressor.rb +2 -2
- data/lib/nanoc/helpers/blogging.rb +1 -1
- data/lib/nanoc/helpers/filtering.rb +1 -1
- data/lib/nanoc/helpers/rendering.rb +1 -1
- data/nanoc.gemspec +2 -2
- data/test/base/core_ext/array_spec.rb +4 -12
- data/test/base/core_ext/hash_spec.rb +4 -12
- data/test/base/test_compiler_dsl.rb +63 -0
- data/test/base/test_item.rb +3 -18
- data/test/base/test_item_array.rb +336 -0
- data/test/base/test_item_rep.rb +2 -12
- data/test/base/test_layout.rb +1 -6
- data/test/base/test_outdatedness_checker.rb +1 -1
- data/test/base/test_site.rb +9 -3
- data/test/cli/commands/test_check.rb +22 -0
- data/test/cli/commands/test_compile.rb +2 -2
- data/test/cli/commands/test_deploy.rb +6 -6
- data/test/cli/commands/test_prune.rb +23 -4
- data/test/cli/commands/test_sync.rb +31 -0
- data/test/cli/test_error_handler.rb +16 -11
- data/test/extra/checking/checks/test_stale.rb +24 -1
- data/test/extra/test_auto_compiler.rb +4 -4
- data/test/filters/test_asciidoc.rb +1 -1
- data/test/filters/test_bluecloth.rb +1 -1
- data/test/filters/test_coderay.rb +3 -3
- data/test/filters/test_coffeescript.rb +1 -1
- data/test/filters/test_colorize_syntax.rb +20 -20
- data/test/filters/test_erb.rb +10 -10
- data/test/filters/test_erubis.rb +6 -6
- data/test/filters/test_haml.rb +10 -10
- data/test/filters/test_handlebars.rb +3 -3
- data/test/filters/test_kramdown.rb +1 -1
- data/test/filters/test_less.rb +4 -4
- data/test/filters/test_markaby.rb +1 -1
- data/test/filters/test_maruku.rb +1 -1
- data/test/filters/test_mustache.rb +2 -2
- data/test/filters/test_pandoc.rb +1 -1
- data/test/filters/test_rainpress.rb +2 -2
- data/test/filters/test_rdiscount.rb +2 -2
- data/test/filters/test_rdoc.rb +1 -1
- data/test/filters/test_redcarpet.rb +21 -6
- data/test/filters/test_redcloth.rb +3 -3
- data/test/filters/test_relativize_paths.rb +27 -27
- data/test/filters/test_rubypants.rb +1 -1
- data/test/filters/test_sass.rb +8 -8
- data/test/filters/test_slim.rb +4 -4
- data/test/filters/test_typogruby.rb +1 -1
- data/test/filters/test_uglify_js.rb +2 -2
- data/test/filters/test_xsl.rb +2 -2
- data/test/filters/test_yui_compressor.rb +3 -3
- data/test/helper.rb +6 -1
- metadata +12 -6
data/test/filters/test_erb.rb
CHANGED
@@ -9,7 +9,7 @@ class Nanoc::Filters::ERBTest < MiniTest::Unit::TestCase
|
|
9
9
|
filter = ::Nanoc::Filters::ERB.new({ :location => 'a cheap motel' })
|
10
10
|
|
11
11
|
# Run filter
|
12
|
-
result = filter.
|
12
|
+
result = filter.setup_and_run('<%= "I was hiding in #{@location}." %>')
|
13
13
|
assert_equal('I was hiding in a cheap motel.', result)
|
14
14
|
end
|
15
15
|
|
@@ -18,7 +18,7 @@ class Nanoc::Filters::ERBTest < MiniTest::Unit::TestCase
|
|
18
18
|
filter = ::Nanoc::Filters::ERB.new({ :location => 'a cheap motel' })
|
19
19
|
|
20
20
|
# Run filter
|
21
|
-
result = filter.
|
21
|
+
result = filter.setup_and_run('<%= "I was hiding in #{location}." %>')
|
22
22
|
assert_equal('I was hiding in a cheap motel.', result)
|
23
23
|
end
|
24
24
|
|
@@ -39,7 +39,7 @@ class Nanoc::Filters::ERBTest < MiniTest::Unit::TestCase
|
|
39
39
|
# Run filter
|
40
40
|
raised = false
|
41
41
|
begin
|
42
|
-
filter.
|
42
|
+
filter.setup_and_run('<%= this isn\'t really ruby so it\'ll break, muahaha %>')
|
43
43
|
rescue SyntaxError => e
|
44
44
|
e.message =~ /(.+?):\d+: /
|
45
45
|
assert_match 'item /foo/bar/baz/ (rep quux)', $1
|
@@ -53,7 +53,7 @@ class Nanoc::Filters::ERBTest < MiniTest::Unit::TestCase
|
|
53
53
|
filter = ::Nanoc::Filters::ERB.new({ :content => 'a cheap motel' })
|
54
54
|
|
55
55
|
# Run filter
|
56
|
-
result = filter.
|
56
|
+
result = filter.setup_and_run('<%= "I was hiding in #{yield}." %>')
|
57
57
|
assert_equal('I was hiding in a cheap motel.', result)
|
58
58
|
end
|
59
59
|
|
@@ -63,7 +63,7 @@ class Nanoc::Filters::ERBTest < MiniTest::Unit::TestCase
|
|
63
63
|
|
64
64
|
# Run filter
|
65
65
|
assert_raises LocalJumpError do
|
66
|
-
filter.
|
66
|
+
filter.setup_and_run('<%= "I was hiding in #{yield}." %>')
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -73,12 +73,12 @@ class Nanoc::Filters::ERBTest < MiniTest::Unit::TestCase
|
|
73
73
|
File.open('moo', 'w') { |io| io.write("one miiillion dollars") }
|
74
74
|
|
75
75
|
# Without
|
76
|
-
res = filter.
|
76
|
+
res = filter.setup_and_run('<%= File.read("moo") %>', :safe_level => nil)
|
77
77
|
assert_equal 'one miiillion dollars', res
|
78
78
|
|
79
79
|
# With
|
80
80
|
assert_raises(SecurityError) do
|
81
|
-
res = filter.
|
81
|
+
res = filter.setup_and_run('<%= File.read("moo") %>', :safe_level => 4)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -88,17 +88,17 @@ class Nanoc::Filters::ERBTest < MiniTest::Unit::TestCase
|
|
88
88
|
$trim_mode_works = false
|
89
89
|
|
90
90
|
# Without
|
91
|
-
filter.
|
91
|
+
filter.setup_and_run('% $trim_mode_works = true')
|
92
92
|
refute $trim_mode_works
|
93
93
|
|
94
94
|
# With
|
95
|
-
filter.
|
95
|
+
filter.setup_and_run('% $trim_mode_works = true', :trim_mode => '%')
|
96
96
|
assert $trim_mode_works
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_locals
|
100
100
|
filter = ::Nanoc::Filters::ERB.new
|
101
|
-
result = filter.
|
101
|
+
result = filter.setup_and_run('<%= @local %>', :locals => { :local => 123 })
|
102
102
|
assert_equal '123', result
|
103
103
|
end
|
104
104
|
|
data/test/filters/test_erubis.rb
CHANGED
@@ -10,7 +10,7 @@ class Nanoc::Filters::ErubisTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::Erubis.new({ :location => 'a cheap motel' })
|
11
11
|
|
12
12
|
# Run filter
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run('<%= "I was hiding in #{@location}." %>')
|
14
14
|
assert_equal('I was hiding in a cheap motel.', result)
|
15
15
|
end
|
16
16
|
end
|
@@ -21,7 +21,7 @@ class Nanoc::Filters::ErubisTest < MiniTest::Unit::TestCase
|
|
21
21
|
filter = ::Nanoc::Filters::Erubis.new({ :location => 'a cheap motel' })
|
22
22
|
|
23
23
|
# Run filter
|
24
|
-
result = filter.
|
24
|
+
result = filter.setup_and_run('<%= "I was hiding in #{location}." %>')
|
25
25
|
assert_equal('I was hiding in a cheap motel.', result)
|
26
26
|
end
|
27
27
|
end
|
@@ -34,7 +34,7 @@ class Nanoc::Filters::ErubisTest < MiniTest::Unit::TestCase
|
|
34
34
|
# Run filter
|
35
35
|
raised = false
|
36
36
|
begin
|
37
|
-
filter.
|
37
|
+
filter.setup_and_run('<%= this isn\'t really ruby so it\'ll break, muahaha %>')
|
38
38
|
rescue SyntaxError => e
|
39
39
|
e.message =~ /(.+?):\d+: /
|
40
40
|
assert_match '?', $1
|
@@ -50,7 +50,7 @@ class Nanoc::Filters::ErubisTest < MiniTest::Unit::TestCase
|
|
50
50
|
filter = ::Nanoc::Filters::Erubis.new({ :content => 'a cheap motel' })
|
51
51
|
|
52
52
|
# Run filter
|
53
|
-
result = filter.
|
53
|
+
result = filter.setup_and_run('<%= "I was hiding in #{yield}." %>')
|
54
54
|
assert_equal('I was hiding in a cheap motel.', result)
|
55
55
|
end
|
56
56
|
end
|
@@ -62,7 +62,7 @@ class Nanoc::Filters::ErubisTest < MiniTest::Unit::TestCase
|
|
62
62
|
|
63
63
|
# Run filter
|
64
64
|
assert_raises LocalJumpError do
|
65
|
-
filter.
|
65
|
+
filter.setup_and_run('<%= "I was hiding in #{yield}." %>')
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -70,7 +70,7 @@ class Nanoc::Filters::ErubisTest < MiniTest::Unit::TestCase
|
|
70
70
|
def test_filter_with_erbout
|
71
71
|
if_have 'erubis' do
|
72
72
|
filter = ::Nanoc::Filters::Erubis.new
|
73
|
-
result = filter.
|
73
|
+
result = filter.setup_and_run('stuff<% _erbout << _erbout %>')
|
74
74
|
assert_equal 'stuffstuff', result
|
75
75
|
end
|
76
76
|
end
|
data/test/filters/test_haml.rb
CHANGED
@@ -10,15 +10,15 @@ class Nanoc::Filters::HamlTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::Haml.new({ :question => 'Is this the Payne residence?' })
|
11
11
|
|
12
12
|
# Run filter (no assigns)
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run('%html')
|
14
14
|
assert_match(/<html>.*<\/html>/, result)
|
15
15
|
|
16
16
|
# Run filter (assigns without @)
|
17
|
-
result = filter.
|
17
|
+
result = filter.setup_and_run('%p= question')
|
18
18
|
assert_equal("<p>Is this the Payne residence?</p>\n", result)
|
19
19
|
|
20
20
|
# Run filter (assigns with @)
|
21
|
-
result = filter.
|
21
|
+
result = filter.setup_and_run('%p= @question')
|
22
22
|
assert_equal("<p>Is this the Payne residence?</p>\n", result)
|
23
23
|
end
|
24
24
|
end
|
@@ -29,11 +29,11 @@ class Nanoc::Filters::HamlTest < MiniTest::Unit::TestCase
|
|
29
29
|
filter = ::Nanoc::Filters::Haml.new({ :foo => 'bar' })
|
30
30
|
|
31
31
|
# Check with HTML5
|
32
|
-
result = filter.
|
32
|
+
result = filter.setup_and_run('%img', :format => :html5)
|
33
33
|
assert_match(/<img>/, result)
|
34
34
|
|
35
35
|
# Check with XHTML
|
36
|
-
result = filter.
|
36
|
+
result = filter.setup_and_run('%img', :format => :xhtml)
|
37
37
|
assert_match(/<img\s*\/>/, result)
|
38
38
|
end
|
39
39
|
end
|
@@ -46,8 +46,8 @@ class Nanoc::Filters::HamlTest < MiniTest::Unit::TestCase
|
|
46
46
|
# Run filter
|
47
47
|
raised = false
|
48
48
|
begin
|
49
|
-
filter.
|
50
|
-
rescue SyntaxError => e
|
49
|
+
filter.setup_and_run('%p= this isn\'t really ruby so it\'ll break, muahaha')
|
50
|
+
rescue SyntaxError, Haml::SyntaxError => e
|
51
51
|
e.message =~ /(.+?):\d+: /
|
52
52
|
assert_match '?', $1
|
53
53
|
raised = true
|
@@ -62,7 +62,7 @@ class Nanoc::Filters::HamlTest < MiniTest::Unit::TestCase
|
|
62
62
|
filter = ::Nanoc::Filters::Haml.new({ :content => 'Is this the Payne residence?' })
|
63
63
|
|
64
64
|
# Run filter
|
65
|
-
result = filter.
|
65
|
+
result = filter.setup_and_run('%p= yield')
|
66
66
|
assert_equal("<p>Is this the Payne residence?</p>\n", result)
|
67
67
|
end
|
68
68
|
end
|
@@ -74,7 +74,7 @@ class Nanoc::Filters::HamlTest < MiniTest::Unit::TestCase
|
|
74
74
|
|
75
75
|
# Run filter
|
76
76
|
assert_raises LocalJumpError do
|
77
|
-
filter.
|
77
|
+
filter.setup_and_run('%p= yield')
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -88,7 +88,7 @@ class Nanoc::Filters::HamlTest < MiniTest::Unit::TestCase
|
|
88
88
|
|
89
89
|
# Run filter
|
90
90
|
filter = ::Nanoc::Filters::Haml.new
|
91
|
-
result = filter.
|
91
|
+
result = filter.setup_and_run("%body\n ~ File.read('stuff')")
|
92
92
|
assert_match(/Max Payne
Mona Sax/, result)
|
93
93
|
end
|
94
94
|
end
|
@@ -27,11 +27,11 @@ class Nanoc::Filters::HandlebarsTest < MiniTest::Unit::TestCase
|
|
27
27
|
filter = ::Nanoc::Filters::Handlebars.new(assigns)
|
28
28
|
|
29
29
|
# Run filter
|
30
|
-
result = filter.
|
30
|
+
result = filter.setup_and_run('{{protagonist}} says: {{yield}}.')
|
31
31
|
assert_equal('Max Payne says: No Payne No Gayne.', result)
|
32
|
-
result = filter.
|
32
|
+
result = filter.setup_and_run('We can’t stop {{item.location}}! This is the {{layout.name}} layout!')
|
33
33
|
assert_equal('We can’t stop here! This is the Max Payne layout!', result)
|
34
|
-
result = filter.
|
34
|
+
result = filter.setup_and_run('It’s raining {{config.animals}} here!')
|
35
35
|
assert_equal('It’s raining cats and dogs here!', result)
|
36
36
|
end
|
37
37
|
end
|
@@ -10,7 +10,7 @@ class Nanoc::Filters::KramdownTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::Kramdown.new
|
11
11
|
|
12
12
|
# Run filter
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run("This is _so_ **cool**!")
|
14
14
|
assert_equal("<p>This is <em>so</em> <strong>cool</strong>!</p>\n", result)
|
15
15
|
end
|
16
16
|
end
|
data/test/filters/test_less.rb
CHANGED
@@ -13,7 +13,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
13
13
|
filter = ::Nanoc::Filters::Less.new(:item => @item, :items => [ @item ])
|
14
14
|
|
15
15
|
# Run filter
|
16
|
-
result = filter.
|
16
|
+
result = filter.setup_and_run('.foo { bar: 1 + 1 }')
|
17
17
|
assert_match(/\.foo\s*\{\s*bar:\s*2;?\s*\}/, result)
|
18
18
|
end
|
19
19
|
end
|
@@ -31,7 +31,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
31
31
|
filter = ::Nanoc::Filters::Less.new(:item => @item, :items => [ @item ])
|
32
32
|
|
33
33
|
# Run filter
|
34
|
-
result = filter.
|
34
|
+
result = filter.setup_and_run('@import "content/foo/bar/imported_file.less";')
|
35
35
|
assert_match(/p\s*\{\s*color:\s*red;?\s*\}/, result)
|
36
36
|
end
|
37
37
|
end
|
@@ -50,7 +50,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
50
50
|
filter = ::Nanoc::Filters::Less.new(:item => @item, :items => [ @item ])
|
51
51
|
|
52
52
|
# Run filter
|
53
|
-
result = filter.
|
53
|
+
result = filter.setup_and_run('@import "bar/imported_file.less";')
|
54
54
|
assert_match(/p\s*\{\s*color:\s*red;?\s*\}/, result)
|
55
55
|
end
|
56
56
|
end
|
@@ -119,7 +119,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
119
119
|
filter = ::Nanoc::Filters::Less.new(:item => @item, :items => [ @item ])
|
120
120
|
|
121
121
|
# Run filter with compress option
|
122
|
-
result = filter.
|
122
|
+
result = filter.setup_and_run('.foo { bar: a; } .bar { foo: b; }', :compress => true)
|
123
123
|
assert_match(/^\.foo{bar:a;}\n\.bar{foo:b;}/, result)
|
124
124
|
end
|
125
125
|
end
|
@@ -16,7 +16,7 @@ class Nanoc::Filters::MarkabyTest < MiniTest::Unit::TestCase
|
|
16
16
|
filter = ::Nanoc::Filters::Markaby.new
|
17
17
|
|
18
18
|
# Run filter
|
19
|
-
result = filter.
|
19
|
+
result = filter.setup_and_run("html do\nend")
|
20
20
|
assert_equal("<html></html>", result)
|
21
21
|
end
|
22
22
|
end
|
data/test/filters/test_maruku.rb
CHANGED
@@ -10,7 +10,7 @@ class Nanoc::Filters::MarukuTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::Maruku.new
|
11
11
|
|
12
12
|
# Run filter
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run("This is _so_ *cool*!")
|
14
14
|
assert_equal("<p>This is <em>so</em> <em>cool</em>!</p>", result)
|
15
15
|
end
|
16
16
|
end
|
@@ -17,7 +17,7 @@ class Nanoc::Filters::MustacheTest < MiniTest::Unit::TestCase
|
|
17
17
|
filter = ::Nanoc::Filters::Mustache.new({ :item => item })
|
18
18
|
|
19
19
|
# Run filter
|
20
|
-
result = filter.
|
20
|
+
result = filter.setup_and_run('The protagonist of {{title}} is {{protagonist}}.')
|
21
21
|
assert_equal('The protagonist of Max Payne is Max Payne.', result)
|
22
22
|
end
|
23
23
|
end
|
@@ -36,7 +36,7 @@ class Nanoc::Filters::MustacheTest < MiniTest::Unit::TestCase
|
|
36
36
|
{ :content => 'No Payne No Gayne', :item => item })
|
37
37
|
|
38
38
|
# Run filter
|
39
|
-
result = filter.
|
39
|
+
result = filter.setup_and_run('Max says: {{yield}}.')
|
40
40
|
assert_equal('Max says: No Payne No Gayne.', result)
|
41
41
|
end
|
42
42
|
end
|
data/test/filters/test_pandoc.rb
CHANGED
@@ -14,7 +14,7 @@ class Nanoc::Filters::PandocTest < MiniTest::Unit::TestCase
|
|
14
14
|
filter = ::Nanoc::Filters::Pandoc.new
|
15
15
|
|
16
16
|
# Run filter
|
17
|
-
result = filter.
|
17
|
+
result = filter.setup_and_run("# Heading\n")
|
18
18
|
assert_equal("<h1 id=\"heading\">Heading</h1>", result)
|
19
19
|
end
|
20
20
|
end
|
@@ -10,7 +10,7 @@ class Nanoc::Filters::RainpressTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::Rainpress.new
|
11
11
|
|
12
12
|
# Run filter
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run("body { color: black; }")
|
14
14
|
assert_equal("body{color:#000}", result)
|
15
15
|
end
|
16
16
|
end
|
@@ -21,7 +21,7 @@ class Nanoc::Filters::RainpressTest < MiniTest::Unit::TestCase
|
|
21
21
|
filter = ::Nanoc::Filters::Rainpress.new
|
22
22
|
|
23
23
|
# Run filter
|
24
|
-
result = filter.
|
24
|
+
result = filter.setup_and_run("body { color: #aabbcc; }", :colors => false)
|
25
25
|
assert_equal("body{color:#aabbcc}", result)
|
26
26
|
end
|
27
27
|
end
|
@@ -10,7 +10,7 @@ class Nanoc::Filters::RDiscountTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::RDiscount.new
|
11
11
|
|
12
12
|
# Run filter
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run("> Quote")
|
14
14
|
assert_match(/<blockquote>\s*<p>Quote<\/p>\s*<\/blockquote>/, result)
|
15
15
|
end
|
16
16
|
end
|
@@ -23,7 +23,7 @@ class Nanoc::Filters::RDiscountTest < MiniTest::Unit::TestCase
|
|
23
23
|
# Run filter
|
24
24
|
input = "The quotation 'marks' sure make this look sarcastic!"
|
25
25
|
output_expected = /The quotation ‘marks’ sure make this look sarcastic!/
|
26
|
-
output_actual = filter.
|
26
|
+
output_actual = filter.setup_and_run(input, :extensions => [ :smart ])
|
27
27
|
assert_match(output_expected, output_actual)
|
28
28
|
end
|
29
29
|
end
|
data/test/filters/test_rdoc.rb
CHANGED
@@ -10,7 +10,7 @@ class Nanoc::Filters::RDocTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::RDoc.new
|
11
11
|
|
12
12
|
# Run filter
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run("= Foo")
|
14
14
|
assert_match(%r{<h1( id="label-Foo")?>Foo</h1>\Z}, result)
|
15
15
|
end
|
16
16
|
end
|
@@ -16,7 +16,7 @@ class Nanoc::Filters::RedcarpetTest < MiniTest::Unit::TestCase
|
|
16
16
|
filter = ::Nanoc::Filters::Redcarpet.new
|
17
17
|
|
18
18
|
# Run filter
|
19
|
-
result = filter.
|
19
|
+
result = filter.setup_and_run("> Quote")
|
20
20
|
assert_match(/<blockquote>\s*<p>Quote<\/p>\s*<\/blockquote>/, result)
|
21
21
|
end
|
22
22
|
end
|
@@ -30,11 +30,11 @@ class Nanoc::Filters::RedcarpetTest < MiniTest::Unit::TestCase
|
|
30
30
|
if ::Redcarpet::VERSION > '2'
|
31
31
|
input = "this is ~~good~~ bad"
|
32
32
|
output_expected = /this is <del>good<\/del> bad/
|
33
|
-
output_actual = filter.
|
33
|
+
output_actual = filter.setup_and_run(input, :options => { :strikethrough => true })
|
34
34
|
else
|
35
35
|
input = "The quotation 'marks' sure make this look sarcastic!"
|
36
36
|
output_expected = /The quotation ‘marks’ sure make this look sarcastic!/
|
37
|
-
output_actual = filter.
|
37
|
+
output_actual = filter.setup_and_run(input, :options => [ :smart ])
|
38
38
|
end
|
39
39
|
assert_match(output_expected, output_actual)
|
40
40
|
end
|
@@ -48,7 +48,7 @@ class Nanoc::Filters::RedcarpetTest < MiniTest::Unit::TestCase
|
|
48
48
|
# Run filter
|
49
49
|
input = "![Alt](/path/to/img 'Title')"
|
50
50
|
output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title">}
|
51
|
-
output_actual = filter.
|
51
|
+
output_actual = filter.setup_and_run(input)
|
52
52
|
assert_match(output_expected, output_actual)
|
53
53
|
end
|
54
54
|
end
|
@@ -62,12 +62,27 @@ class Nanoc::Filters::RedcarpetTest < MiniTest::Unit::TestCase
|
|
62
62
|
input = "![Alt](/path/to/img 'Title')"
|
63
63
|
output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title"/>}
|
64
64
|
if ::Redcarpet::VERSION > '2'
|
65
|
-
output_actual = filter.
|
65
|
+
output_actual = filter.setup_and_run(input, :renderer_options => { :xhtml => true })
|
66
66
|
else
|
67
|
-
output_actual = filter.
|
67
|
+
output_actual = filter.setup_and_run(input, :options => [ :xhtml ])
|
68
68
|
end
|
69
69
|
assert_match(output_expected, output_actual)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
def test_html_toc
|
74
|
+
if_have 'redcarpet' do
|
75
|
+
unless ::Redcarpet::VERSION > '2'
|
76
|
+
skip "Requires Redcarpet >= 2"
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create filter
|
80
|
+
filter = ::Nanoc::Filters::Redcarpet.new
|
81
|
+
|
82
|
+
# Run filter
|
83
|
+
input = "# Heading 1\n## Heading 2\n"
|
84
|
+
filter.run(input, :renderer => Redcarpet::Render::HTML_TOC)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
73
88
|
end
|
@@ -10,7 +10,7 @@ class Nanoc::Filters::RedClothTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::RedCloth.new
|
11
11
|
|
12
12
|
# Run filter
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run("h1. Foo")
|
14
14
|
assert_equal("<h1>Foo</h1>", result)
|
15
15
|
end
|
16
16
|
end
|
@@ -21,11 +21,11 @@ class Nanoc::Filters::RedClothTest < MiniTest::Unit::TestCase
|
|
21
21
|
filter = ::Nanoc::Filters::RedCloth.new
|
22
22
|
|
23
23
|
# Run filter without options
|
24
|
-
result = filter.
|
24
|
+
result = filter.setup_and_run("I am a member of SPECTRE.")
|
25
25
|
assert_equal("<p>I am a member of <span class=\"caps\">SPECTRE</span>.</p>", result)
|
26
26
|
|
27
27
|
# Run filter with options
|
28
|
-
result = filter.
|
28
|
+
result = filter.setup_and_run("I am a member of SPECTRE.", :no_span_caps => true)
|
29
29
|
assert_equal("<p>I am a member of SPECTRE.</p>", result)
|
30
30
|
end
|
31
31
|
end
|
@@ -25,7 +25,7 @@ class Nanoc::Filters::RelativizePathsTest < MiniTest::Unit::TestCase
|
|
25
25
|
expected_content = %[<a href="../..">foo</a>]
|
26
26
|
|
27
27
|
# Test
|
28
|
-
actual_content = filter.
|
28
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
29
29
|
assert_equal(expected_content, actual_content)
|
30
30
|
end
|
31
31
|
|
@@ -49,7 +49,7 @@ class Nanoc::Filters::RelativizePathsTest < MiniTest::Unit::TestCase
|
|
49
49
|
expected_content = %[<a href="../..">foo</a>]
|
50
50
|
|
51
51
|
# Test
|
52
|
-
actual_content = filter.
|
52
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
53
53
|
assert_equal(expected_content, actual_content)
|
54
54
|
end
|
55
55
|
|
@@ -73,7 +73,7 @@ class Nanoc::Filters::RelativizePathsTest < MiniTest::Unit::TestCase
|
|
73
73
|
expected_content = %[<a href="../..">foo</a>]
|
74
74
|
|
75
75
|
# Test
|
76
|
-
actual_content = filter.
|
76
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
77
77
|
assert_equal(expected_content, actual_content)
|
78
78
|
end
|
79
79
|
|
@@ -108,7 +108,7 @@ EOS
|
|
108
108
|
expected_match_1 = %r{^<!DOCTYPE html>\s*<html>\s*<head>(.|\s)*<title>Hello</title>\s*</head>\s*<body>\s*<a href="../..">foo</a>\s*</body>\s*</html>\s*$}
|
109
109
|
|
110
110
|
# Test
|
111
|
-
actual_content = filter.
|
111
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
112
112
|
assert_match(expected_match_0, actual_content)
|
113
113
|
assert_match(expected_match_1, actual_content)
|
114
114
|
end
|
@@ -133,7 +133,7 @@ EOS
|
|
133
133
|
expected_content = %[<a href="../..">foo</a> <a href="../../../bar">bar</a>]
|
134
134
|
|
135
135
|
# Test
|
136
|
-
actual_content = filter.
|
136
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
137
137
|
assert_equal(expected_content, actual_content)
|
138
138
|
end
|
139
139
|
|
@@ -157,7 +157,7 @@ EOS
|
|
157
157
|
expected_content = %[<a href="../../../"><img src="../../../bar.png"></a>]
|
158
158
|
|
159
159
|
# Test
|
160
|
-
actual_content = filter.
|
160
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
161
161
|
assert_equal(expected_content, actual_content)
|
162
162
|
end
|
163
163
|
|
@@ -181,7 +181,7 @@ EOS
|
|
181
181
|
expected_content = %[stuff href="/foo" more stuff]
|
182
182
|
|
183
183
|
# Test
|
184
|
-
actual_content = filter.
|
184
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
185
185
|
assert_equal(expected_content, actual_content)
|
186
186
|
end
|
187
187
|
|
@@ -205,7 +205,7 @@ EOS
|
|
205
205
|
expected_content = %[<a href="../../">foo</a>]
|
206
206
|
|
207
207
|
# Test
|
208
|
-
actual_content = filter.
|
208
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
209
209
|
assert_equal(expected_content, actual_content)
|
210
210
|
end
|
211
211
|
|
@@ -229,7 +229,7 @@ EOS
|
|
229
229
|
expected_content = %[<a href="//example.com/">example.com</a>]
|
230
230
|
|
231
231
|
# Test
|
232
|
-
actual_content = filter.
|
232
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
233
233
|
assert_equal(expected_content, actual_content)
|
234
234
|
end
|
235
235
|
|
@@ -253,7 +253,7 @@ EOS
|
|
253
253
|
expected_content = %[<a href="#max-payne">Max Payne</a>]
|
254
254
|
|
255
255
|
# Test
|
256
|
-
actual_content = filter.
|
256
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
257
257
|
assert_equal(expected_content, actual_content)
|
258
258
|
end
|
259
259
|
|
@@ -277,7 +277,7 @@ EOS
|
|
277
277
|
expected_content = %[<a href="http://example.com/">Example</a>]
|
278
278
|
|
279
279
|
# Test
|
280
|
-
actual_content = filter.
|
280
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
281
281
|
assert_equal(expected_content, actual_content)
|
282
282
|
end
|
283
283
|
|
@@ -301,7 +301,7 @@ EOS
|
|
301
301
|
expected_content = %[<a href="example">Example</a>]
|
302
302
|
|
303
303
|
# Test
|
304
|
-
actual_content = filter.
|
304
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
305
305
|
assert_equal(expected_content, actual_content)
|
306
306
|
end
|
307
307
|
|
@@ -326,7 +326,7 @@ EOS
|
|
326
326
|
expected_content = %[<object data="../../example"><param name="movie" content="../../example"></object>]
|
327
327
|
|
328
328
|
# Test
|
329
|
-
actual_content = filter.
|
329
|
+
actual_content = filter.setup_and_run(raw_content, :type => :html)
|
330
330
|
assert_equal(expected_content, actual_content)
|
331
331
|
end
|
332
332
|
|
@@ -337,7 +337,7 @@ EOS
|
|
337
337
|
|
338
338
|
# Test
|
339
339
|
assert_raises(RuntimeError) do
|
340
|
-
filter.
|
340
|
+
filter.setup_and_run("moo")
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
@@ -361,7 +361,7 @@ EOS
|
|
361
361
|
expected_content = %[background: url("../background.png");]
|
362
362
|
|
363
363
|
# Test
|
364
|
-
actual_content = filter.
|
364
|
+
actual_content = filter.setup_and_run(raw_content, :type => :css)
|
365
365
|
assert_equal(expected_content, actual_content)
|
366
366
|
end
|
367
367
|
|
@@ -385,7 +385,7 @@ EOS
|
|
385
385
|
expected_content = %[background: url('../background.png');]
|
386
386
|
|
387
387
|
# Test
|
388
|
-
actual_content = filter.
|
388
|
+
actual_content = filter.setup_and_run(raw_content, :type => :css)
|
389
389
|
assert_equal(expected_content, actual_content)
|
390
390
|
end
|
391
391
|
|
@@ -409,7 +409,7 @@ EOS
|
|
409
409
|
expected_content = %[background: url(../background.png);]
|
410
410
|
|
411
411
|
# Test
|
412
|
-
actual_content = filter.
|
412
|
+
actual_content = filter.setup_and_run(raw_content, :type => :css)
|
413
413
|
assert_equal(expected_content, actual_content)
|
414
414
|
end
|
415
415
|
|
@@ -433,7 +433,7 @@ EOS
|
|
433
433
|
expected_content = %[background: url(../a.png) url(../b.png);]
|
434
434
|
|
435
435
|
# Test
|
436
|
-
actual_content = filter.
|
436
|
+
actual_content = filter.setup_and_run(raw_content, :type => :css)
|
437
437
|
assert_equal(expected_content, actual_content)
|
438
438
|
end
|
439
439
|
|
@@ -460,7 +460,7 @@ EOS
|
|
460
460
|
expected_content = %[background: url(../../);]
|
461
461
|
|
462
462
|
# Test
|
463
|
-
actual_content = filter.
|
463
|
+
actual_content = filter.setup_and_run(raw_content, :type => :css)
|
464
464
|
assert_equal(expected_content, actual_content)
|
465
465
|
end
|
466
466
|
|
@@ -484,7 +484,7 @@ EOS
|
|
484
484
|
expected_content = %[background: url(//example.com);]
|
485
485
|
|
486
486
|
# Test
|
487
|
-
actual_content = filter.
|
487
|
+
actual_content = filter.setup_and_run(raw_content, :type => :css)
|
488
488
|
assert_equal(expected_content, actual_content)
|
489
489
|
end
|
490
490
|
|
@@ -520,7 +520,7 @@ XML
|
|
520
520
|
XML
|
521
521
|
|
522
522
|
# Test
|
523
|
-
actual_content = filter.
|
523
|
+
actual_content = filter.setup_and_run(raw_content, :type => :xml, :select => ['*/@boo'])
|
524
524
|
assert_equal(expected_content, actual_content)
|
525
525
|
end
|
526
526
|
end
|
@@ -555,7 +555,7 @@ XML
|
|
555
555
|
XML
|
556
556
|
|
557
557
|
# Test
|
558
|
-
actual_content = filter.
|
558
|
+
actual_content = filter.setup_and_run(raw_content, :type => :xml, :select => ['far/@href'])
|
559
559
|
assert_equal(expected_content, actual_content)
|
560
560
|
end
|
561
561
|
end
|
@@ -590,7 +590,7 @@ XML
|
|
590
590
|
XML
|
591
591
|
|
592
592
|
# Test
|
593
|
-
actual_content = filter.
|
593
|
+
actual_content = filter.setup_and_run(raw_content, {
|
594
594
|
:type => :xml,
|
595
595
|
:namespaces => {:ex => 'http://example.org'},
|
596
596
|
:select => ['ex:a/@href']
|
@@ -643,7 +643,7 @@ XML
|
|
643
643
|
</html>}
|
644
644
|
|
645
645
|
# Test
|
646
|
-
actual_content = filter.
|
646
|
+
actual_content = filter.setup_and_run(raw_content, :type => :xhtml)
|
647
647
|
assert_match expected_match, actual_content
|
648
648
|
end
|
649
649
|
end
|
@@ -680,7 +680,7 @@ XML
|
|
680
680
|
XML
|
681
681
|
|
682
682
|
# Test
|
683
|
-
actual_content = filter.
|
683
|
+
actual_content = filter.setup_and_run(raw_content.freeze, :type => :xhtml)
|
684
684
|
assert_equal(expected_content, actual_content)
|
685
685
|
end
|
686
686
|
end
|
@@ -717,7 +717,7 @@ XML
|
|
717
717
|
]
|
718
718
|
|
719
719
|
# Test
|
720
|
-
actual_content = filter.
|
720
|
+
actual_content = filter.setup_and_run(raw_content.freeze, :type => :xhtml)
|
721
721
|
assert_equal(expected_content, actual_content)
|
722
722
|
end
|
723
723
|
end
|
@@ -752,7 +752,7 @@ XML
|
|
752
752
|
<![endif]-->]
|
753
753
|
|
754
754
|
# Test
|
755
|
-
actual_content = filter.
|
755
|
+
actual_content = filter.setup_and_run(raw_content.freeze, :type => :html)
|
756
756
|
assert_equal(expected_content, actual_content)
|
757
757
|
end
|
758
758
|
end
|