nanoc3 3.2.4 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metadata +14 -313
- data/.gemtest +0 -0
- data/ChangeLog +0 -3
- data/Gemfile +0 -29
- data/LICENSE +0 -19
- data/NEWS.md +0 -449
- data/README.md +0 -108
- data/Rakefile +0 -14
- data/bin/nanoc3 +0 -12
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/nanoc3.rb +0 -28
- data/lib/nanoc3/base.rb +0 -49
- data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
- data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
- data/lib/nanoc3/base/compilation/compiler.rb +0 -455
- data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
- data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
- data/lib/nanoc3/base/compilation/filter.rb +0 -165
- data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
- data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
- data/lib/nanoc3/base/compilation/rule.rb +0 -73
- data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
- data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
- data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
- data/lib/nanoc3/base/context.rb +0 -47
- data/lib/nanoc3/base/core_ext.rb +0 -6
- data/lib/nanoc3/base/core_ext/array.rb +0 -62
- data/lib/nanoc3/base/core_ext/hash.rb +0 -63
- data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
- data/lib/nanoc3/base/core_ext/string.rb +0 -46
- data/lib/nanoc3/base/directed_graph.rb +0 -275
- data/lib/nanoc3/base/errors.rb +0 -174
- data/lib/nanoc3/base/memoization.rb +0 -67
- data/lib/nanoc3/base/notification_center.rb +0 -84
- data/lib/nanoc3/base/ordered_hash.rb +0 -200
- data/lib/nanoc3/base/plugin_registry.rb +0 -165
- data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
- data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
- data/lib/nanoc3/base/source_data/configuration.rb +0 -24
- data/lib/nanoc3/base/source_data/data_source.rb +0 -234
- data/lib/nanoc3/base/source_data/item.rb +0 -301
- data/lib/nanoc3/base/source_data/layout.rb +0 -130
- data/lib/nanoc3/base/source_data/site.rb +0 -361
- data/lib/nanoc3/base/store.rb +0 -135
- data/lib/nanoc3/cli.rb +0 -133
- data/lib/nanoc3/cli/command.rb +0 -139
- data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
- data/lib/nanoc3/cli/commands/compile.rb +0 -280
- data/lib/nanoc3/cli/commands/create_item.rb +0 -62
- data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
- data/lib/nanoc3/cli/commands/create_site.rb +0 -410
- data/lib/nanoc3/cli/commands/debug.rb +0 -119
- data/lib/nanoc3/cli/commands/info.rb +0 -98
- data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
- data/lib/nanoc3/cli/commands/update.rb +0 -72
- data/lib/nanoc3/cli/commands/view.rb +0 -84
- data/lib/nanoc3/cli/commands/watch.rb +0 -125
- data/lib/nanoc3/cli/error_handler.rb +0 -193
- data/lib/nanoc3/cli/logger.rb +0 -91
- data/lib/nanoc3/data_sources.rb +0 -29
- data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
- data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
- data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
- data/lib/nanoc3/data_sources/filesystem.rb +0 -299
- data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
- data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
- data/lib/nanoc3/extra.rb +0 -22
- data/lib/nanoc3/extra/auto_compiler.rb +0 -103
- data/lib/nanoc3/extra/chick.rb +0 -125
- data/lib/nanoc3/extra/core_ext.rb +0 -4
- data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
- data/lib/nanoc3/extra/core_ext/time.rb +0 -19
- data/lib/nanoc3/extra/deployers.rb +0 -11
- data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
- data/lib/nanoc3/extra/file_proxy.rb +0 -40
- data/lib/nanoc3/extra/validators.rb +0 -12
- data/lib/nanoc3/extra/validators/links.rb +0 -264
- data/lib/nanoc3/extra/validators/w3c.rb +0 -95
- data/lib/nanoc3/extra/vcs.rb +0 -66
- data/lib/nanoc3/extra/vcses.rb +0 -17
- data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
- data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
- data/lib/nanoc3/extra/vcses/git.rb +0 -25
- data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
- data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
- data/lib/nanoc3/filters.rb +0 -53
- data/lib/nanoc3/filters/asciidoc.rb +0 -38
- data/lib/nanoc3/filters/bluecloth.rb +0 -19
- data/lib/nanoc3/filters/coderay.rb +0 -21
- data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
- data/lib/nanoc3/filters/erb.rb +0 -35
- data/lib/nanoc3/filters/erubis.rb +0 -27
- data/lib/nanoc3/filters/haml.rb +0 -27
- data/lib/nanoc3/filters/kramdown.rb +0 -20
- data/lib/nanoc3/filters/less.rb +0 -53
- data/lib/nanoc3/filters/markaby.rb +0 -20
- data/lib/nanoc3/filters/maruku.rb +0 -20
- data/lib/nanoc3/filters/mustache.rb +0 -24
- data/lib/nanoc3/filters/rainpress.rb +0 -19
- data/lib/nanoc3/filters/rdiscount.rb +0 -22
- data/lib/nanoc3/filters/rdoc.rb +0 -33
- data/lib/nanoc3/filters/redcarpet.rb +0 -27
- data/lib/nanoc3/filters/redcloth.rb +0 -47
- data/lib/nanoc3/filters/relativize_paths.rb +0 -45
- data/lib/nanoc3/filters/rubypants.rb +0 -20
- data/lib/nanoc3/filters/sass.rb +0 -66
- data/lib/nanoc3/filters/slim.rb +0 -25
- data/lib/nanoc3/filters/typogruby.rb +0 -23
- data/lib/nanoc3/filters/uglify_js.rb +0 -42
- data/lib/nanoc3/helpers.rb +0 -16
- data/lib/nanoc3/helpers/blogging.rb +0 -319
- data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
- data/lib/nanoc3/helpers/capturing.rb +0 -138
- data/lib/nanoc3/helpers/filtering.rb +0 -50
- data/lib/nanoc3/helpers/html_escape.rb +0 -55
- data/lib/nanoc3/helpers/link_to.rb +0 -151
- data/lib/nanoc3/helpers/rendering.rb +0 -140
- data/lib/nanoc3/helpers/tagging.rb +0 -71
- data/lib/nanoc3/helpers/text.rb +0 -44
- data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
- data/lib/nanoc3/tasks.rb +0 -10
- data/lib/nanoc3/tasks/clean.rake +0 -16
- data/lib/nanoc3/tasks/clean.rb +0 -29
- data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
- data/lib/nanoc3/tasks/validate.rake +0 -92
- data/nanoc3.gemspec +0 -49
- data/tasks/doc.rake +0 -16
- data/tasks/test.rake +0 -44
- data/test/base/core_ext/array_spec.rb +0 -73
- data/test/base/core_ext/hash_spec.rb +0 -98
- data/test/base/core_ext/pathname_spec.rb +0 -27
- data/test/base/core_ext/string_spec.rb +0 -37
- data/test/base/test_checksum_store.rb +0 -35
- data/test/base/test_code_snippet.rb +0 -31
- data/test/base/test_compiler.rb +0 -316
- data/test/base/test_compiler_dsl.rb +0 -161
- data/test/base/test_context.rb +0 -31
- data/test/base/test_data_source.rb +0 -46
- data/test/base/test_dependency_tracker.rb +0 -262
- data/test/base/test_directed_graph.rb +0 -283
- data/test/base/test_filter.rb +0 -83
- data/test/base/test_item.rb +0 -179
- data/test/base/test_item_rep.rb +0 -553
- data/test/base/test_layout.rb +0 -59
- data/test/base/test_memoization.rb +0 -90
- data/test/base/test_notification_center.rb +0 -34
- data/test/base/test_outdatedness_checker.rb +0 -394
- data/test/base/test_plugin.rb +0 -30
- data/test/base/test_rule.rb +0 -19
- data/test/base/test_rule_context.rb +0 -65
- data/test/base/test_site.rb +0 -190
- data/test/cli/commands/test_compile.rb +0 -33
- data/test/cli/commands/test_create_item.rb +0 -14
- data/test/cli/commands/test_create_layout.rb +0 -28
- data/test/cli/commands/test_create_site.rb +0 -24
- data/test/cli/commands/test_help.rb +0 -12
- data/test/cli/commands/test_info.rb +0 -11
- data/test/cli/commands/test_update.rb +0 -10
- data/test/cli/test_cli.rb +0 -102
- data/test/cli/test_error_handler.rb +0 -29
- data/test/cli/test_logger.rb +0 -10
- data/test/data_sources/test_filesystem.rb +0 -433
- data/test/data_sources/test_filesystem_unified.rb +0 -536
- data/test/data_sources/test_filesystem_verbose.rb +0 -357
- data/test/extra/core_ext/test_enumerable.rb +0 -30
- data/test/extra/core_ext/test_time.rb +0 -15
- data/test/extra/deployers/test_rsync.rb +0 -232
- data/test/extra/test_auto_compiler.rb +0 -417
- data/test/extra/test_file_proxy.rb +0 -19
- data/test/extra/test_vcs.rb +0 -22
- data/test/extra/validators/test_links.rb +0 -51
- data/test/extra/validators/test_w3c.rb +0 -47
- data/test/filters/test_asciidoc.rb +0 -22
- data/test/filters/test_bluecloth.rb +0 -18
- data/test/filters/test_coderay.rb +0 -44
- data/test/filters/test_colorize_syntax.rb +0 -283
- data/test/filters/test_erb.rb +0 -99
- data/test/filters/test_erubis.rb +0 -70
- data/test/filters/test_haml.rb +0 -96
- data/test/filters/test_kramdown.rb +0 -18
- data/test/filters/test_less.rb +0 -113
- data/test/filters/test_markaby.rb +0 -24
- data/test/filters/test_maruku.rb +0 -18
- data/test/filters/test_mustache.rb +0 -25
- data/test/filters/test_rainpress.rb +0 -29
- data/test/filters/test_rdiscount.rb +0 -31
- data/test/filters/test_rdoc.rb +0 -18
- data/test/filters/test_redcarpet.rb +0 -63
- data/test/filters/test_redcloth.rb +0 -33
- data/test/filters/test_relativize_paths.rb +0 -332
- data/test/filters/test_rubypants.rb +0 -18
- data/test/filters/test_sass.rb +0 -229
- data/test/filters/test_slim.rb +0 -35
- data/test/filters/test_typogruby.rb +0 -21
- data/test/filters/test_uglify_js.rb +0 -30
- data/test/gem_loader.rb +0 -11
- data/test/helper.rb +0 -179
- data/test/helpers/test_blogging.rb +0 -754
- data/test/helpers/test_breadcrumbs.rb +0 -81
- data/test/helpers/test_capturing.rb +0 -41
- data/test/helpers/test_filtering.rb +0 -106
- data/test/helpers/test_html_escape.rb +0 -32
- data/test/helpers/test_link_to.rb +0 -249
- data/test/helpers/test_rendering.rb +0 -89
- data/test/helpers/test_tagging.rb +0 -87
- data/test/helpers/test_text.rb +0 -24
- data/test/helpers/test_xml_sitemap.rb +0 -103
- data/test/tasks/test_clean.rb +0 -67
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
class Nanoc3::Extra::Validators::LinksTest < MiniTest::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
include Nanoc3::TestHelpers
|
|
6
|
-
|
|
7
|
-
def test_is_external_href?
|
|
8
|
-
# Create validator
|
|
9
|
-
validator = Nanoc3::Extra::Validators::Links.new(nil, nil)
|
|
10
|
-
|
|
11
|
-
# Test
|
|
12
|
-
assert validator.send(:is_external_href?, 'http://example.com/')
|
|
13
|
-
assert validator.send(:is_external_href?, 'https://example.com/')
|
|
14
|
-
assert validator.send(:is_external_href?, 'mailto:bob@example.com')
|
|
15
|
-
assert !validator.send(:is_external_href?, '../stuff')
|
|
16
|
-
assert !validator.send(:is_external_href?, '/stuff')
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_is_valid_internal_href?
|
|
20
|
-
# Create files
|
|
21
|
-
FileUtils.mkdir_p('output')
|
|
22
|
-
FileUtils.mkdir_p('output/stuff')
|
|
23
|
-
File.open('output/origin', 'w') { |io| io.write('hi') }
|
|
24
|
-
File.open('output/foo', 'w') { |io| io.write('hi') }
|
|
25
|
-
File.open('output/stuff/blah', 'w') { |io| io.write('hi') }
|
|
26
|
-
|
|
27
|
-
# Create validator
|
|
28
|
-
validator = Nanoc3::Extra::Validators::Links.new('output', [ 'index.html' ])
|
|
29
|
-
|
|
30
|
-
# Test
|
|
31
|
-
assert validator.send(:is_valid_internal_href?, 'foo', 'output/origin')
|
|
32
|
-
assert validator.send(:is_valid_internal_href?, 'origin', 'output/origin')
|
|
33
|
-
assert validator.send(:is_valid_internal_href?, 'stuff/blah', 'output/origin')
|
|
34
|
-
assert validator.send(:is_valid_internal_href?, '/foo', 'output/origin')
|
|
35
|
-
assert validator.send(:is_valid_internal_href?, '/origin', 'output/origin')
|
|
36
|
-
assert validator.send(:is_valid_internal_href?, '/stuff/blah', 'output/origin')
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def test_is_valid_external_href?
|
|
40
|
-
# Create validator
|
|
41
|
-
validator = Nanoc3::Extra::Validators::Links.new('output', [ 'index.html' ])
|
|
42
|
-
validator.stubs(:fetch_http_status_for).returns(200)
|
|
43
|
-
|
|
44
|
-
# Test
|
|
45
|
-
assert validator.send(:is_valid_external_href?, 'http://example.com/')
|
|
46
|
-
assert validator.send(:is_valid_external_href?, 'https://example.com/')
|
|
47
|
-
assert validator.send(:is_valid_external_href?, 'foo://example.com/')
|
|
48
|
-
refute validator.send(:is_valid_external_href?, 'http://example.com/">')
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
class Nanoc3::Extra::Validators::W3CTest < MiniTest::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
include Nanoc3::TestHelpers
|
|
6
|
-
|
|
7
|
-
def test_simple
|
|
8
|
-
if_have 'w3c_validators' do
|
|
9
|
-
# Create some sample files
|
|
10
|
-
%w{ foo bar baz }.each do |filename|
|
|
11
|
-
%w{ xxx yyy }.each do |extension|
|
|
12
|
-
File.open("#{filename}.#{extension}", 'w') { |io| io.write("hello") }
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Create validator
|
|
17
|
-
w3c = Nanoc3::Extra::Validators::W3C.new('.', [ :xxx ])
|
|
18
|
-
|
|
19
|
-
# Configure expectations
|
|
20
|
-
validator_result = mock
|
|
21
|
-
validator_result.expects(:errors).times(3)
|
|
22
|
-
validator = mock
|
|
23
|
-
validator.expects(:validate_file).times(3).returns(validator_result)
|
|
24
|
-
w3c.expects(:types_to_extensions).with([ :xxx ]).returns([ 'xxx' ])
|
|
25
|
-
w3c.expects(:validator_for).with('xxx').times(3).returns(validator)
|
|
26
|
-
w3c.expects(:validation_started).times(3)
|
|
27
|
-
w3c.expects(:validation_ended).times(3)
|
|
28
|
-
|
|
29
|
-
# Run
|
|
30
|
-
w3c.run
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def test_with_unknown_types
|
|
35
|
-
if_have 'w3c_validators' do
|
|
36
|
-
# Create validator
|
|
37
|
-
w3c = Nanoc3::Extra::Validators::W3C.new('.', [ :foo ])
|
|
38
|
-
|
|
39
|
-
# Test
|
|
40
|
-
exception = assert_raises RuntimeError do
|
|
41
|
-
w3c.run
|
|
42
|
-
end
|
|
43
|
-
assert_equal 'unknown type: foo', exception.message
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
class Nanoc3::Filters::AsciiDocTest < MiniTest::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
include Nanoc3::TestHelpers
|
|
6
|
-
|
|
7
|
-
def test_filter
|
|
8
|
-
if_have 'systemu' do
|
|
9
|
-
if `which asciidoc`.strip.empty?
|
|
10
|
-
skip "could not find asciidoc"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Create filter
|
|
14
|
-
filter = ::Nanoc3::Filters::AsciiDoc.new
|
|
15
|
-
|
|
16
|
-
# Run filter
|
|
17
|
-
result = filter.run("== Blah blah")
|
|
18
|
-
assert_match %r{<h2 id="_blah_blah">Blah blah</h2>}, result
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
class Nanoc3::Filters::BlueClothTest < MiniTest::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
include Nanoc3::TestHelpers
|
|
6
|
-
|
|
7
|
-
def test_filter
|
|
8
|
-
if_have 'bluecloth' do
|
|
9
|
-
# Create filter
|
|
10
|
-
filter = ::Nanoc3::Filters::BlueCloth.new
|
|
11
|
-
|
|
12
|
-
# Run filter
|
|
13
|
-
result = filter.run("> Quote")
|
|
14
|
-
assert_match %r{<blockquote>\s*<p>Quote</p>\s*</blockquote>}, result
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
class Nanoc3::Filters::CodeRayTest < MiniTest::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
include Nanoc3::TestHelpers
|
|
6
|
-
|
|
7
|
-
def test_filter_without_language
|
|
8
|
-
if_have 'coderay' do
|
|
9
|
-
# Get filter
|
|
10
|
-
filter = ::Nanoc3::Filters::CodeRay.new
|
|
11
|
-
|
|
12
|
-
# Run filter
|
|
13
|
-
code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
|
|
14
|
-
assert_raises(ArgumentError) do
|
|
15
|
-
filter.run(code)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_filter_with_known_language
|
|
21
|
-
if_have 'coderay' do
|
|
22
|
-
# Get filter
|
|
23
|
-
filter = ::Nanoc3::Filters::CodeRay.new
|
|
24
|
-
|
|
25
|
-
# Run filter
|
|
26
|
-
code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
|
|
27
|
-
result = filter.run(code, :language => 'ruby')
|
|
28
|
-
assert_match %r{^<span class="keyword">def</span> <span class="function">some_function</span>}, result
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_filter_with_unknown_language
|
|
33
|
-
if_have 'coderay' do
|
|
34
|
-
# Get filter
|
|
35
|
-
filter = ::Nanoc3::Filters::CodeRay.new
|
|
36
|
-
|
|
37
|
-
# Run filter
|
|
38
|
-
code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
|
|
39
|
-
result = filter.run(code, :language => 'skldfhjsdhfjszfnocmluhfixfmersumulh')
|
|
40
|
-
assert_equal code, result
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
end
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
class Nanoc3::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
4
|
-
|
|
5
|
-
include Nanoc3::TestHelpers
|
|
6
|
-
|
|
7
|
-
def test_coderay_simple
|
|
8
|
-
if_have 'coderay', 'nokogiri' do
|
|
9
|
-
# Create filter
|
|
10
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
11
|
-
|
|
12
|
-
# Get input and expected output
|
|
13
|
-
input = '<pre title="moo"><code class="language-ruby"># comment</code></pre>'
|
|
14
|
-
expected_output = '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>'
|
|
15
|
-
|
|
16
|
-
# Run filter
|
|
17
|
-
actual_output = filter.run(input)
|
|
18
|
-
assert_equal(expected_output, actual_output)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def test_coderay_with_comment
|
|
23
|
-
if_have 'coderay', 'nokogiri' do
|
|
24
|
-
# Create filter
|
|
25
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
26
|
-
|
|
27
|
-
# Get input and expected output
|
|
28
|
-
input = %[<pre title="moo"><code>#!ruby\n# comment</code></pre>]
|
|
29
|
-
expected_output = '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>'
|
|
30
|
-
|
|
31
|
-
# Run filter
|
|
32
|
-
actual_output = filter.run(input)
|
|
33
|
-
assert_equal(expected_output, actual_output)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_coderay_with_comment_and_class
|
|
38
|
-
if_have 'coderay', 'nokogiri' do
|
|
39
|
-
# Create filter
|
|
40
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
41
|
-
|
|
42
|
-
# Get input and expected output
|
|
43
|
-
input = %[<pre title="moo"><code class="language-ruby">#!ruby\n# comment</code></pre>]
|
|
44
|
-
expected_output = %[<pre title="moo"><code class="language-ruby"><span class="doctype">#!ruby</span>\n<span class="comment"># comment</span></code></pre>]
|
|
45
|
-
|
|
46
|
-
# Run filter
|
|
47
|
-
actual_output = filter.run(input)
|
|
48
|
-
assert_equal(expected_output, actual_output)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def test_coderay_with_more_classes
|
|
53
|
-
if_have 'coderay', 'nokogiri' do
|
|
54
|
-
# Create filter
|
|
55
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
56
|
-
|
|
57
|
-
# Get input and expected output
|
|
58
|
-
input = '<pre title="moo"><code class="abc language-ruby xyz"># comment</code></pre>'
|
|
59
|
-
expected_output = '<pre title="moo"><code class="abc language-ruby xyz"><span class="comment"># comment</span></code></pre>'
|
|
60
|
-
|
|
61
|
-
# Run filter
|
|
62
|
-
actual_output = filter.run(input)
|
|
63
|
-
assert_equal(expected_output, actual_output)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def test_pygmentize
|
|
68
|
-
if_have 'nokogiri', 'systemu' do
|
|
69
|
-
if `which pygmentize`.strip.empty?
|
|
70
|
-
skip "could not find pygmentize"
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Create filter
|
|
74
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
75
|
-
|
|
76
|
-
# Get input and expected output
|
|
77
|
-
input = '<pre title="moo"><code class="language-ruby"># comment</code></pre>'
|
|
78
|
-
expected_output = '<pre title="moo"><code class="language-ruby"><span class="c1"># comment</span></code></pre>'
|
|
79
|
-
|
|
80
|
-
# Run filter
|
|
81
|
-
actual_output = filter.run(input, :colorizers => { :ruby => :pygmentize })
|
|
82
|
-
assert_equal(expected_output, actual_output)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def test_simon_highlight
|
|
87
|
-
if_have 'nokogiri', 'systemu' do
|
|
88
|
-
if `which highlight`.strip.empty?
|
|
89
|
-
skip "could not find `highlight`"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Create filter
|
|
93
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
94
|
-
|
|
95
|
-
# Get input and expected output
|
|
96
|
-
input = %Q[<pre title="moo"><code class="language-ruby">\n# comment\n</code></pre>]
|
|
97
|
-
expected_output = '<pre title="moo"><code class="language-ruby"><span class="hl slc"># comment</span></code></pre>'
|
|
98
|
-
|
|
99
|
-
# Run filter
|
|
100
|
-
actual_output = filter.run(input, :default_colorizer => :simon_highlight)
|
|
101
|
-
assert_equal(expected_output, actual_output)
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def test_colorize_syntax_with_unknown_syntax
|
|
106
|
-
if_have 'coderay', 'nokogiri' do
|
|
107
|
-
# Create filter
|
|
108
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
109
|
-
|
|
110
|
-
# Run filter
|
|
111
|
-
assert_raises RuntimeError do
|
|
112
|
-
filter.run('<p>whatever</p>', :syntax => :kasflwafhaweoineurl)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def test_colorize_syntax_with_xml
|
|
118
|
-
if_have 'coderay', 'nokogiri' do
|
|
119
|
-
# Create filter
|
|
120
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
121
|
-
|
|
122
|
-
# Get input and expected output
|
|
123
|
-
input = '<p>foo<br/>bar</p>'
|
|
124
|
-
expected_output = '<p>foo<br/>bar</p>'
|
|
125
|
-
|
|
126
|
-
# Run filter
|
|
127
|
-
actual_output = filter.run(input, :syntax => :xml)
|
|
128
|
-
assert_equal(expected_output, actual_output)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def test_colorize_syntax_with_xhtml
|
|
133
|
-
if_have 'coderay', 'nokogiri' do
|
|
134
|
-
# Create filter
|
|
135
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
136
|
-
|
|
137
|
-
# Get input and expected output
|
|
138
|
-
input = '<p>foo<br/>bar</p>'
|
|
139
|
-
expected_output = '<p>foo<br />bar</p>'
|
|
140
|
-
|
|
141
|
-
# Run filter
|
|
142
|
-
actual_output = filter.run(input, :syntax => :xhtml)
|
|
143
|
-
assert_equal(expected_output, actual_output)
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def test_colorize_syntax_with_default_colorizer
|
|
148
|
-
if `which pygmentize`.strip.empty?
|
|
149
|
-
skip 'no pygmentize found, which is required for this test'
|
|
150
|
-
return
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
if_have 'nokogiri', 'systemu' do
|
|
154
|
-
# Create filter
|
|
155
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
156
|
-
|
|
157
|
-
# Get input and expected output
|
|
158
|
-
input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
|
|
159
|
-
expected_output = '<pre><code class="language-ruby"><span class="nb">puts</span> <span class="s2">"foo"</span></code></pre>'
|
|
160
|
-
|
|
161
|
-
# Run filter
|
|
162
|
-
actual_output = filter.run(input, :default_colorizer => :pygmentize)
|
|
163
|
-
assert_equal(expected_output, actual_output)
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def test_colorize_syntax_with_missing_executables
|
|
168
|
-
if_have 'nokogiri', 'systemu' do
|
|
169
|
-
begin
|
|
170
|
-
original_path = ENV['PATH']
|
|
171
|
-
ENV['PATH'] = './blooblooblah'
|
|
172
|
-
|
|
173
|
-
# Create filter
|
|
174
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
175
|
-
|
|
176
|
-
# Get input and expected output
|
|
177
|
-
input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
|
|
178
|
-
|
|
179
|
-
# Run filter
|
|
180
|
-
[ :pygmentize, :simon_highlight ].each do |colorizer|
|
|
181
|
-
begin
|
|
182
|
-
input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
|
|
183
|
-
actual_output = filter.run(
|
|
184
|
-
input,
|
|
185
|
-
:colorizers => { :ruby => colorizer })
|
|
186
|
-
flunk "expected colorizer to raise if no executable is available"
|
|
187
|
-
rescue => e
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
ensure
|
|
191
|
-
ENV['PATH'] = original_path
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def test_colorize_syntax_with_non_language_shebang_line
|
|
197
|
-
if_have 'coderay', 'nokogiri' do
|
|
198
|
-
# Create filter
|
|
199
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
200
|
-
|
|
201
|
-
# Get input and expected output
|
|
202
|
-
input = <<EOS
|
|
203
|
-
before
|
|
204
|
-
<pre><code>
|
|
205
|
-
#!/usr/bin/env ruby
|
|
206
|
-
puts 'hi!'
|
|
207
|
-
</code></pre>
|
|
208
|
-
after
|
|
209
|
-
EOS
|
|
210
|
-
expected_output = <<EOS
|
|
211
|
-
before
|
|
212
|
-
<pre><code>
|
|
213
|
-
#!/usr/bin/env ruby
|
|
214
|
-
puts 'hi!'
|
|
215
|
-
</code></pre>
|
|
216
|
-
after
|
|
217
|
-
EOS
|
|
218
|
-
|
|
219
|
-
# Run filter
|
|
220
|
-
actual_output = filter.run(input)
|
|
221
|
-
assert_equal(expected_output, actual_output)
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
def test_colorize_syntax_with_non_language_shebang_line_and_language_line
|
|
226
|
-
if_have 'coderay', 'nokogiri' do
|
|
227
|
-
# Create filter
|
|
228
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
229
|
-
|
|
230
|
-
# Get input and expected output
|
|
231
|
-
input = <<EOS
|
|
232
|
-
before
|
|
233
|
-
<pre><code>
|
|
234
|
-
#!ruby
|
|
235
|
-
#!/usr/bin/env ruby
|
|
236
|
-
puts 'hi!'
|
|
237
|
-
</code></pre>
|
|
238
|
-
after
|
|
239
|
-
EOS
|
|
240
|
-
expected_output = <<EOS
|
|
241
|
-
before
|
|
242
|
-
<pre><code class=\"language-ruby\"><span class=\"doctype\">#!/usr/bin/env ruby</span>
|
|
243
|
-
puts <span class=\"string\"><span class=\"delimiter\">'</span><span class=\"content\">hi!</span><span class=\"delimiter\">'</span></span></code></pre>
|
|
244
|
-
after
|
|
245
|
-
EOS
|
|
246
|
-
|
|
247
|
-
# Run filter
|
|
248
|
-
actual_output = filter.run(input)
|
|
249
|
-
assert_equal(expected_output, actual_output)
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
def test_strip
|
|
254
|
-
if_have 'coderay', 'nokogiri' do
|
|
255
|
-
# Create filter
|
|
256
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
|
257
|
-
|
|
258
|
-
# Simple test
|
|
259
|
-
assert_equal " bar", filter.send(:strip, "\n bar")
|
|
260
|
-
|
|
261
|
-
# Get input and expected output
|
|
262
|
-
input = <<EOS
|
|
263
|
-
before
|
|
264
|
-
<pre><code class="language-ruby">
|
|
265
|
-
def foo
|
|
266
|
-
end
|
|
267
|
-
</code></pre>
|
|
268
|
-
after
|
|
269
|
-
EOS
|
|
270
|
-
expected_output = <<EOS
|
|
271
|
-
before
|
|
272
|
-
<pre><code class="language-ruby"> <span class=\"keyword\">def</span> <span class=\"function\">foo</span>
|
|
273
|
-
<span class=\"keyword\">end</span></code></pre>
|
|
274
|
-
after
|
|
275
|
-
EOS
|
|
276
|
-
|
|
277
|
-
# Run filter
|
|
278
|
-
actual_output = filter.run(input)
|
|
279
|
-
assert_equal(expected_output, actual_output)
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
end
|