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/base/test_layout.rb
CHANGED
@@ -17,14 +17,9 @@ class Nanoc::LayoutTest < MiniTest::Unit::TestCase
|
|
17
17
|
def test_frozen_identifier
|
18
18
|
layout = Nanoc::Layout.new("foo", {}, '/foo')
|
19
19
|
|
20
|
-
|
21
|
-
begin
|
20
|
+
assert_raises_frozen_error do
|
22
21
|
layout.identifier.chop!
|
23
|
-
rescue => error
|
24
|
-
raised = true
|
25
|
-
assert_match(/(^can't modify frozen [Ss]tring|^unable to modify frozen object$)/, error.message)
|
26
22
|
end
|
27
|
-
assert raised, 'Should have raised when trying to modify a frozen string'
|
28
23
|
end
|
29
24
|
|
30
25
|
def test_lookup_with_known_attribute
|
@@ -284,7 +284,7 @@ class Nanoc::OutdatednessCheckerTest < MiniTest::Unit::TestCase
|
|
284
284
|
|
285
285
|
# Change code
|
286
286
|
FileUtils.cd('foo') do
|
287
|
-
File.open('
|
287
|
+
File.open('nanoc.yaml', 'w') { |io| io.write('awesome: true') }
|
288
288
|
end
|
289
289
|
|
290
290
|
# Check
|
data/test/base/test_site.rb
CHANGED
@@ -5,7 +5,7 @@ class Nanoc::SiteTest < MiniTest::Unit::TestCase
|
|
5
5
|
include Nanoc::TestHelpers
|
6
6
|
|
7
7
|
def test_initialize_with_dir_without_config_yaml
|
8
|
-
assert_raises(
|
8
|
+
assert_raises(Nanoc::Errors::GenericTrivial) do
|
9
9
|
Nanoc::Site.new('.')
|
10
10
|
end
|
11
11
|
end
|
@@ -16,6 +16,12 @@ class Nanoc::SiteTest < MiniTest::Unit::TestCase
|
|
16
16
|
assert_equal 'public_html', site.config[:output_dir]
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_initialize_with_dir_with_nanoc_yaml
|
20
|
+
File.open('nanoc.yaml', 'w') { |io| io.write('output_dir: public_html') }
|
21
|
+
site = Nanoc::Site.new('.')
|
22
|
+
assert_equal 'public_html', site.config[:output_dir]
|
23
|
+
end
|
24
|
+
|
19
25
|
def test_initialize_with_config_hash
|
20
26
|
site = Nanoc::Site.new(:foo => 'bar')
|
21
27
|
assert_equal 'bar', site.config[:foo]
|
@@ -65,7 +71,7 @@ EOF
|
|
65
71
|
end
|
66
72
|
|
67
73
|
# Update configuration
|
68
|
-
File.open('
|
74
|
+
File.open('nanoc.yaml', 'w') do |io|
|
69
75
|
io.write "data_sources:\n"
|
70
76
|
io.write " - type: site_test_foo"
|
71
77
|
end
|
@@ -170,7 +176,7 @@ describe 'Nanoc::Site#data_sources' do
|
|
170
176
|
|
171
177
|
it 'should also use the toplevel config for data sources' do
|
172
178
|
with_site do
|
173
|
-
File.open('
|
179
|
+
File.open('nanoc.yaml', 'w') do |io|
|
174
180
|
io.write "data_sources:\n"
|
175
181
|
io.write " -\n"
|
176
182
|
io.write " type: filesystem_unified\n"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::CLI::Commands::CheckTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
def test_check_stale
|
8
|
+
with_site do |site|
|
9
|
+
FileUtils.mkdir_p('output')
|
10
|
+
|
11
|
+
# Should not raise now
|
12
|
+
Nanoc::CLI.run %w( check stale )
|
13
|
+
|
14
|
+
# Should raise now
|
15
|
+
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
16
|
+
assert_raises Nanoc::Errors::GenericTrivial do
|
17
|
+
Nanoc::CLI.run %w( check stale )
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -60,7 +60,7 @@ class Nanoc::CLI::Commands::CompileTest < MiniTest::Unit::TestCase
|
|
60
60
|
Nanoc::CLI.run %w( compile )
|
61
61
|
assert File.file?('output/stray.html')
|
62
62
|
|
63
|
-
File.open('
|
63
|
+
File.open('nanoc.yaml', 'w') do |io|
|
64
64
|
io.write "prune:\n"
|
65
65
|
io.write " auto_prune: true\n"
|
66
66
|
end
|
@@ -103,7 +103,7 @@ class Nanoc::CLI::Commands::CompileTest < MiniTest::Unit::TestCase
|
|
103
103
|
Nanoc::CLI.run %w( compile )
|
104
104
|
assert File.file?('output/stray.html')
|
105
105
|
|
106
|
-
File.open('
|
106
|
+
File.open('nanoc.yaml', 'w') do |io|
|
107
107
|
io.write "prune:\n"
|
108
108
|
io.write " auto_prune: true\n"
|
109
109
|
io.write " exclude: [ 'excluded_dir' ]\n"
|
@@ -7,7 +7,7 @@ class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
7
7
|
def test_deploy
|
8
8
|
if_have 'systemu' do
|
9
9
|
with_site do |site|
|
10
|
-
File.open('
|
10
|
+
File.open('nanoc.yaml', 'w') do |io|
|
11
11
|
io.write "deploy:\n"
|
12
12
|
io.write " public:\n"
|
13
13
|
io.write " kind: rsync\n"
|
@@ -28,7 +28,7 @@ class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
28
28
|
def test_deploy_with_dry_run
|
29
29
|
if_have 'systemu' do
|
30
30
|
with_site do |site|
|
31
|
-
File.open('
|
31
|
+
File.open('nanoc.yaml', 'w') do |io|
|
32
32
|
io.write "deploy:\n"
|
33
33
|
io.write " public:\n"
|
34
34
|
io.write " kind: rsync\n"
|
@@ -49,7 +49,7 @@ class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
49
49
|
def test_deploy_with_list
|
50
50
|
if_have 'systemu' do
|
51
51
|
with_site do |site|
|
52
|
-
File.open('
|
52
|
+
File.open('nanoc.yaml', 'w') do |io|
|
53
53
|
io.write "deploy:\n"
|
54
54
|
io.write " public:\n"
|
55
55
|
io.write " kind: rsync\n"
|
@@ -74,7 +74,7 @@ class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
74
74
|
def test_deploy_without_kind
|
75
75
|
if_have 'systemu' do
|
76
76
|
with_site do |site|
|
77
|
-
File.open('
|
77
|
+
File.open('nanoc.yaml', 'w') do |io|
|
78
78
|
io.write "deploy:\n"
|
79
79
|
io.write " public:\n"
|
80
80
|
io.write " dst: mydestination"
|
@@ -98,7 +98,7 @@ class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
98
98
|
def test_deploy_without_target_without_default
|
99
99
|
if_have 'systemu' do
|
100
100
|
with_site do |site|
|
101
|
-
File.open('
|
101
|
+
File.open('nanoc.yaml', 'w') do |io|
|
102
102
|
io.write "deploy:\n"
|
103
103
|
io.write " public:\n"
|
104
104
|
io.write " dst: mydestination"
|
@@ -120,7 +120,7 @@ class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
120
120
|
def test_deploy_without_target_with_default
|
121
121
|
if_have 'systemu' do
|
122
122
|
with_site do |site|
|
123
|
-
File.open('
|
123
|
+
File.open('nanoc.yaml', 'w') do |io|
|
124
124
|
io.write "deploy:\n"
|
125
125
|
io.write " default:\n"
|
126
126
|
io.write " dst: mydestination"
|
@@ -7,7 +7,7 @@ class Nanoc::CLI::Commands::PruneTest < MiniTest::Unit::TestCase
|
|
7
7
|
def test_run_without_yes
|
8
8
|
with_site do |site|
|
9
9
|
# Set output dir
|
10
|
-
File.open('
|
10
|
+
File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' }
|
11
11
|
FileUtils.mkdir_p('output2')
|
12
12
|
|
13
13
|
# Create source files
|
@@ -29,7 +29,7 @@ class Nanoc::CLI::Commands::PruneTest < MiniTest::Unit::TestCase
|
|
29
29
|
def test_run_with_yes
|
30
30
|
with_site do |site|
|
31
31
|
# Set output dir
|
32
|
-
File.open('
|
32
|
+
File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' }
|
33
33
|
FileUtils.mkdir_p('output2')
|
34
34
|
|
35
35
|
# Create source files
|
@@ -49,7 +49,7 @@ class Nanoc::CLI::Commands::PruneTest < MiniTest::Unit::TestCase
|
|
49
49
|
def test_run_with_dry_run
|
50
50
|
with_site do |site|
|
51
51
|
# Set output dir
|
52
|
-
File.open('
|
52
|
+
File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' }
|
53
53
|
FileUtils.mkdir_p('output2')
|
54
54
|
|
55
55
|
# Create source files
|
@@ -69,7 +69,7 @@ class Nanoc::CLI::Commands::PruneTest < MiniTest::Unit::TestCase
|
|
69
69
|
def test_run_with_exclude
|
70
70
|
with_site do |site|
|
71
71
|
# Set output dir
|
72
|
-
File.open('
|
72
|
+
File.open('nanoc.yaml', 'w') { |io| io.write "prune:\n exclude: [ 'good-dir', 'good-file.html' ]" }
|
73
73
|
FileUtils.mkdir_p('output')
|
74
74
|
|
75
75
|
# Create source files
|
@@ -117,4 +117,23 @@ class Nanoc::CLI::Commands::PruneTest < MiniTest::Unit::TestCase
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
+
def test_run_with_nested_empty_dirs
|
121
|
+
with_site do |site|
|
122
|
+
# Set output dir
|
123
|
+
File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output' }
|
124
|
+
FileUtils.mkdir_p('output')
|
125
|
+
|
126
|
+
# Create output files
|
127
|
+
FileUtils.mkdir_p('output/a/b/c')
|
128
|
+
File.open('output/a/b/c/index.html', 'w') { |io| io.write 'stuff' }
|
129
|
+
|
130
|
+
Nanoc::CLI.run %w( prune --yes )
|
131
|
+
|
132
|
+
assert !File.file?('output/a/b/c/index.html')
|
133
|
+
assert !File.directory?('output/a/b/c')
|
134
|
+
assert !File.directory?('output/a/b')
|
135
|
+
assert !File.directory?('output/a')
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
120
139
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Nanoc::CLI::Commands::SyncTest < MiniTest::Unit::TestCase
|
2
|
+
|
3
|
+
include Nanoc::TestHelpers
|
4
|
+
|
5
|
+
def test_run
|
6
|
+
with_site do
|
7
|
+
File.open('lib/foo_data_source.rb', 'w') do |io|
|
8
|
+
io.write "class FooDataSource < Nanoc::DataSource\n"
|
9
|
+
io.write " identifier :sync_test_foo\n"
|
10
|
+
io.write " def sync\n"
|
11
|
+
io.write " File.open('foo_source_data.yaml', 'w') do |io|\n"
|
12
|
+
io.write " io.write 'sync: true'\n"
|
13
|
+
io.write " end\n"
|
14
|
+
io.write " end\n"
|
15
|
+
io.write "end\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
File.open('nanoc.yaml', 'w') do |io|
|
19
|
+
io.write "data_sources:\n"
|
20
|
+
io.write " - type: sync_test_foo\n"
|
21
|
+
io.write " items_root: /"
|
22
|
+
end
|
23
|
+
|
24
|
+
Nanoc::CLI.run %w( sync )
|
25
|
+
|
26
|
+
assert File.file?('foo_source_data.yaml')
|
27
|
+
assert_equal File.read('foo_source_data.yaml'), 'sync: true'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -4,26 +4,31 @@ class Nanoc::CLI::ErrorHandlerTest < MiniTest::Unit::TestCase
|
|
4
4
|
|
5
5
|
include Nanoc::TestHelpers
|
6
6
|
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@handler = Nanoc::CLI::ErrorHandler.new
|
10
|
+
end
|
11
|
+
|
7
12
|
def test_resolution_for_with_unknown_gem
|
8
13
|
error = LoadError.new('no such file to load -- afjlrestjlsgrshter')
|
9
|
-
assert_nil handler.send(:resolution_for, error)
|
14
|
+
assert_nil @handler.send(:resolution_for, error)
|
10
15
|
end
|
11
16
|
|
12
|
-
def
|
13
|
-
|
17
|
+
def test_resolution_for_with_known_gem_without_bundler
|
18
|
+
def @handler.using_bundler? ; false ; end
|
14
19
|
error = LoadError.new('no such file to load -- kramdown')
|
15
|
-
assert_match(/^
|
16
|
-
ensure
|
17
|
-
$loud = false
|
20
|
+
assert_match(/^Install the 'kramdown' gem using `gem install kramdown`./, @handler.send(:resolution_for, error))
|
18
21
|
end
|
19
22
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
+
def test_resolution_for_with_known_gem_with_bundler
|
24
|
+
def @handler.using_bundler? ; true ; end
|
25
|
+
error = LoadError.new('no such file to load -- kramdown')
|
26
|
+
assert_match(/^Make sure the gem is added to Gemfile/, @handler.send(:resolution_for, error))
|
23
27
|
end
|
24
28
|
|
25
|
-
def
|
26
|
-
|
29
|
+
def test_resolution_for_with_not_load_error
|
30
|
+
error = RuntimeError.new('nuclear meltdown detected')
|
31
|
+
assert_nil @handler.send(:resolution_for, error)
|
27
32
|
end
|
28
33
|
|
29
34
|
end
|
@@ -45,5 +45,28 @@ class Nanoc::Extra::Checking::Checks::StaleTest < MiniTest::Unit::TestCase
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
def test_run_excluded
|
49
|
+
with_site do |site|
|
50
|
+
assert Dir['content/*'].empty?
|
51
|
+
assert Dir['output/*'].empty?
|
52
|
+
|
53
|
+
File.open('nanoc.yaml', 'w') { |io| io.write "prune:\n exclude: [ 'excluded.html' ]" }
|
54
|
+
File.open('content/index.html', 'w') { |io| io.write('stuff') }
|
55
|
+
File.open('output/excluded.html', 'w') { |io| io.write('stuff') }
|
56
|
+
assert self.calc_issues.empty?
|
57
|
+
end
|
58
|
+
end
|
49
59
|
|
60
|
+
def test_run_excluded_with_broken_config
|
61
|
+
with_site do |site|
|
62
|
+
assert Dir['content/*'].empty?
|
63
|
+
assert Dir['output/*'].empty?
|
64
|
+
|
65
|
+
File.open('nanoc.yaml', 'w') { |io| io.write "prune:\n blah: meh" }
|
66
|
+
File.open('content/index.html', 'w') { |io| io.write('stuff') }
|
67
|
+
File.open('output/excluded.html', 'w') { |io| io.write('stuff') }
|
68
|
+
refute self.calc_issues.empty?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -369,10 +369,10 @@ class Nanoc::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
|
|
369
369
|
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
|
370
370
|
|
371
371
|
# Set config to 1st value
|
372
|
-
File.open('
|
372
|
+
File.open('nanoc.yaml', 'w') do |io|
|
373
373
|
io.write "value: Foo"
|
374
374
|
end
|
375
|
-
File.utime(Time.now+5, Time.now+5, '
|
375
|
+
File.utime(Time.now+5, Time.now+5, 'nanoc.yaml')
|
376
376
|
|
377
377
|
# Check
|
378
378
|
status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
|
@@ -381,10 +381,10 @@ class Nanoc::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
|
|
381
381
|
end
|
382
382
|
|
383
383
|
# Set config to 2nd value
|
384
|
-
File.open('
|
384
|
+
File.open('nanoc.yaml', 'w') do |io|
|
385
385
|
io.write "value: Bar"
|
386
386
|
end
|
387
|
-
File.utime(Time.now+5, Time.now+5, '
|
387
|
+
File.utime(Time.now+5, Time.now+5, 'nanoc.yaml')
|
388
388
|
|
389
389
|
# Check
|
390
390
|
status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
|
@@ -14,7 +14,7 @@ class Nanoc::Filters::AsciiDocTest < MiniTest::Unit::TestCase
|
|
14
14
|
filter = ::Nanoc::Filters::AsciiDoc.new
|
15
15
|
|
16
16
|
# Run filter
|
17
|
-
result = filter.
|
17
|
+
result = filter.setup_and_run("== Blah blah")
|
18
18
|
assert_match %r{<h2 id="_blah_blah">Blah blah</h2>}, result
|
19
19
|
end
|
20
20
|
end
|
@@ -10,7 +10,7 @@ class Nanoc::Filters::BlueClothTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::BlueCloth.new
|
11
11
|
|
12
12
|
# Run filter
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run("> Quote")
|
14
14
|
assert_match %r{<blockquote>\s*<p>Quote</p>\s*</blockquote>}, result
|
15
15
|
end
|
16
16
|
end
|
@@ -12,7 +12,7 @@ class Nanoc::Filters::CodeRayTest < MiniTest::Unit::TestCase
|
|
12
12
|
# Run filter
|
13
13
|
code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
|
14
14
|
assert_raises(ArgumentError) do
|
15
|
-
filter.
|
15
|
+
filter.setup_and_run(code)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -24,7 +24,7 @@ class Nanoc::Filters::CodeRayTest < MiniTest::Unit::TestCase
|
|
24
24
|
|
25
25
|
# Run filter
|
26
26
|
code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
|
27
|
-
result = filter.
|
27
|
+
result = filter.setup_and_run(code, :language => 'ruby')
|
28
28
|
assert_match %r{^<span class="keyword">def</span> <span class="function">some_function</span>}, result
|
29
29
|
end
|
30
30
|
end
|
@@ -36,7 +36,7 @@ class Nanoc::Filters::CodeRayTest < MiniTest::Unit::TestCase
|
|
36
36
|
|
37
37
|
# Run filter
|
38
38
|
code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
|
39
|
-
result = filter.
|
39
|
+
result = filter.setup_and_run(code, :language => 'skldfhjsdhfjszfnocmluhfixfmersumulh')
|
40
40
|
assert_equal code, result
|
41
41
|
end
|
42
42
|
end
|
@@ -10,7 +10,7 @@ class Nanoc::Filters::CoffeeScriptTest < MiniTest::Unit::TestCase
|
|
10
10
|
filter = ::Nanoc::Filters::CoffeeScript.new
|
11
11
|
|
12
12
|
# Run filter (no assigns)
|
13
|
-
result = filter.
|
13
|
+
result = filter.setup_and_run('alert 42')
|
14
14
|
assert_equal("(function() { alert(42); }).call(this); ", result.gsub(/\s+/, ' '))
|
15
15
|
end
|
16
16
|
end
|
@@ -17,7 +17,7 @@ class Nanoc::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
17
17
|
expected_output = CODERAY_PRE + '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>' + CODERAY_POST
|
18
18
|
|
19
19
|
# Run filter
|
20
|
-
actual_output = filter.
|
20
|
+
actual_output = filter.setup_and_run(input)
|
21
21
|
assert_equal(expected_output, actual_output)
|
22
22
|
end
|
23
23
|
end
|
@@ -32,7 +32,7 @@ class Nanoc::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
32
32
|
expected_output = input # because we are using a dummy
|
33
33
|
|
34
34
|
# Run filter
|
35
|
-
actual_output = filter.
|
35
|
+
actual_output = filter.setup_and_run(input, :default_colorizer => :dummy)
|
36
36
|
assert_equal(expected_output, actual_output)
|
37
37
|
end
|
38
38
|
end
|
@@ -68,7 +68,7 @@ EOS
|
|
68
68
|
EOS
|
69
69
|
|
70
70
|
# Run filter
|
71
|
-
actual_output = filter.
|
71
|
+
actual_output = filter.setup_and_run(input, :default_colorizer => :dummy, :is_fullpage => true)
|
72
72
|
assert_equal(expected_output, actual_output)
|
73
73
|
end
|
74
74
|
end
|
@@ -83,7 +83,7 @@ EOS
|
|
83
83
|
expected_output = CODERAY_PRE + '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>' + CODERAY_POST
|
84
84
|
|
85
85
|
# Run filter
|
86
|
-
actual_output = filter.
|
86
|
+
actual_output = filter.setup_and_run(input)
|
87
87
|
assert_equal(expected_output, actual_output)
|
88
88
|
end
|
89
89
|
end
|
@@ -98,7 +98,7 @@ EOS
|
|
98
98
|
expected_output = "<pre title=\"moo\"><code>def moo ; end\n#!ruby\n# comment</code></pre>"
|
99
99
|
|
100
100
|
# Run filter
|
101
|
-
actual_output = filter.
|
101
|
+
actual_output = filter.setup_and_run(input)
|
102
102
|
assert_equal(expected_output, actual_output)
|
103
103
|
end
|
104
104
|
end
|
@@ -113,7 +113,7 @@ EOS
|
|
113
113
|
expected_output = CODERAY_PRE + %[<pre title="moo"><code class="language-ruby"><span class="doctype">#!ruby</span>\n<span class="comment"># comment</span></code></pre>] + CODERAY_POST
|
114
114
|
|
115
115
|
# Run filter
|
116
|
-
actual_output = filter.
|
116
|
+
actual_output = filter.setup_and_run(input)
|
117
117
|
assert_equal(expected_output, actual_output)
|
118
118
|
end
|
119
119
|
end
|
@@ -128,7 +128,7 @@ EOS
|
|
128
128
|
expected_output = CODERAY_PRE + '<pre title="moo"><code class="abc language-ruby xyz"><span class="comment"># comment</span></code></pre>' + CODERAY_POST
|
129
129
|
|
130
130
|
# Run filter
|
131
|
-
actual_output = filter.
|
131
|
+
actual_output = filter.setup_and_run(input)
|
132
132
|
assert_equal(expected_output, actual_output)
|
133
133
|
end
|
134
134
|
end
|
@@ -147,7 +147,7 @@ EOS
|
|
147
147
|
expected_output = '<pre title="moo"><code class="language-ruby"><span class="c1"># comment</span></code></pre>'
|
148
148
|
|
149
149
|
# Run filter
|
150
|
-
actual_output = filter.
|
150
|
+
actual_output = filter.setup_and_run(input, :colorizers => { :ruby => :pygmentize })
|
151
151
|
assert_equal(expected_output, actual_output)
|
152
152
|
end
|
153
153
|
end
|
@@ -162,7 +162,7 @@ EOS
|
|
162
162
|
expected_output = '<pre title="moo"><code class="language-ruby"><span class="c1"># comment…</span></code></pre>'
|
163
163
|
|
164
164
|
# Run filter
|
165
|
-
actual_output = filter.
|
165
|
+
actual_output = filter.setup_and_run(input, :colorizers => { :ruby => :pygmentsrb })
|
166
166
|
assert_equal(expected_output, actual_output)
|
167
167
|
end
|
168
168
|
end
|
@@ -181,7 +181,7 @@ EOS
|
|
181
181
|
expected_output = '<pre title="moo"><code class="language-ruby"><span class="hl slc"># comment</span></code></pre>'
|
182
182
|
|
183
183
|
# Run filter
|
184
|
-
actual_output = filter.
|
184
|
+
actual_output = filter.setup_and_run(input, :default_colorizer => :simon_highlight)
|
185
185
|
assert_equal(expected_output, actual_output)
|
186
186
|
end
|
187
187
|
end
|
@@ -193,7 +193,7 @@ EOS
|
|
193
193
|
|
194
194
|
# Run filter
|
195
195
|
assert_raises RuntimeError do
|
196
|
-
filter.
|
196
|
+
filter.setup_and_run('<p>whatever</p>', :syntax => :kasflwafhaweoineurl)
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
@@ -208,7 +208,7 @@ EOS
|
|
208
208
|
expected_output = '<p>foo<br/>bar</p>'
|
209
209
|
|
210
210
|
# Run filter
|
211
|
-
actual_output = filter.
|
211
|
+
actual_output = filter.setup_and_run(input, :syntax => :xml)
|
212
212
|
assert_equal(expected_output, actual_output)
|
213
213
|
end
|
214
214
|
end
|
@@ -223,7 +223,7 @@ EOS
|
|
223
223
|
expected_output = '<p>foo<br />bar</p>'
|
224
224
|
|
225
225
|
# Run filter
|
226
|
-
actual_output = filter.
|
226
|
+
actual_output = filter.setup_and_run(input, :syntax => :xhtml)
|
227
227
|
assert_equal(expected_output, actual_output)
|
228
228
|
end
|
229
229
|
end
|
@@ -243,7 +243,7 @@ EOS
|
|
243
243
|
expected_output = '<pre><code class="language-ruby"><span class="nb">puts</span> <span class="s2">"foo"</span></code></pre>'
|
244
244
|
|
245
245
|
# Run filter
|
246
|
-
actual_output = filter.
|
246
|
+
actual_output = filter.setup_and_run(input, :default_colorizer => :pygmentize)
|
247
247
|
assert_equal(expected_output, actual_output)
|
248
248
|
end
|
249
249
|
end
|
@@ -264,7 +264,7 @@ EOS
|
|
264
264
|
[ :albino, :pygmentize, :simon_highlight ].each do |colorizer|
|
265
265
|
begin
|
266
266
|
input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
|
267
|
-
filter.
|
267
|
+
filter.setup_and_run(
|
268
268
|
input,
|
269
269
|
:colorizers => { :ruby => colorizer })
|
270
270
|
flunk "expected colorizer to raise if no executable is available"
|
@@ -301,7 +301,7 @@ after
|
|
301
301
|
EOS
|
302
302
|
|
303
303
|
# Run filter
|
304
|
-
actual_output = filter.
|
304
|
+
actual_output = filter.setup_and_run(input)
|
305
305
|
assert_equal(expected_output, actual_output)
|
306
306
|
end
|
307
307
|
end
|
@@ -329,7 +329,7 @@ after
|
|
329
329
|
EOS
|
330
330
|
|
331
331
|
# Run filter
|
332
|
-
actual_output = filter.
|
332
|
+
actual_output = filter.setup_and_run(input)
|
333
333
|
assert_equal(expected_output, actual_output)
|
334
334
|
end
|
335
335
|
end
|
@@ -344,7 +344,7 @@ EOS
|
|
344
344
|
expected_output = '<code class="language-ruby"># comment</code>'
|
345
345
|
|
346
346
|
# Run filter
|
347
|
-
actual_output = filter.
|
347
|
+
actual_output = filter.setup_and_run(input, :outside_pre => false)
|
348
348
|
assert_equal(expected_output, actual_output)
|
349
349
|
end
|
350
350
|
end
|
@@ -359,7 +359,7 @@ EOS
|
|
359
359
|
expected_output = '<code class="language-ruby"><span class="comment"># comment</span></code>'
|
360
360
|
|
361
361
|
# Run filter
|
362
|
-
actual_output = filter.
|
362
|
+
actual_output = filter.setup_and_run(input, :outside_pre => true)
|
363
363
|
assert_equal(expected_output, actual_output)
|
364
364
|
end
|
365
365
|
end
|
@@ -389,7 +389,7 @@ after
|
|
389
389
|
EOS
|
390
390
|
|
391
391
|
# Run filter
|
392
|
-
actual_output = filter.
|
392
|
+
actual_output = filter.setup_and_run(input)
|
393
393
|
assert_equal(expected_output, actual_output)
|
394
394
|
end
|
395
395
|
end
|