nanoc 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.
- data/.gemtest +0 -0
- data/ChangeLog +3 -0
- data/Gemfile +32 -0
- data/LICENSE +19 -0
- data/NEWS.md +470 -0
- data/README.md +114 -0
- data/Rakefile +14 -0
- data/bin/nanoc +7 -27
- data/bin/nanoc3 +3 -0
- data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
- data/lib/nanoc.rb +41 -0
- data/lib/nanoc/base.rb +49 -0
- data/lib/nanoc/base/compilation/checksum_store.rb +57 -0
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +62 -0
- data/lib/nanoc/base/compilation/compiler.rb +458 -0
- data/lib/nanoc/base/compilation/compiler_dsl.rb +214 -0
- data/lib/nanoc/base/compilation/dependency_tracker.rb +200 -0
- data/lib/nanoc/base/compilation/filter.rb +165 -0
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +103 -0
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +102 -0
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +223 -0
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +46 -0
- data/lib/nanoc/base/compilation/rule.rb +73 -0
- data/lib/nanoc/base/compilation/rule_context.rb +84 -0
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +40 -0
- data/lib/nanoc/base/compilation/rule_memory_store.rb +53 -0
- data/lib/nanoc/base/compilation/rules_collection.rb +243 -0
- data/lib/nanoc/base/context.rb +47 -0
- data/lib/nanoc/base/core_ext.rb +6 -0
- data/lib/nanoc/base/core_ext/array.rb +62 -0
- data/lib/nanoc/base/core_ext/hash.rb +63 -0
- data/lib/nanoc/base/core_ext/pathname.rb +26 -0
- data/lib/nanoc/base/core_ext/string.rb +46 -0
- data/lib/nanoc/base/directed_graph.rb +275 -0
- data/lib/nanoc/base/errors.rb +211 -0
- data/lib/nanoc/base/memoization.rb +67 -0
- data/lib/nanoc/base/notification_center.rb +84 -0
- data/lib/nanoc/base/ordered_hash.rb +200 -0
- data/lib/nanoc/base/plugin_registry.rb +181 -0
- data/lib/nanoc/base/result_data/item_rep.rb +492 -0
- data/lib/nanoc/base/source_data/code_snippet.rb +58 -0
- data/lib/nanoc/base/source_data/configuration.rb +24 -0
- data/lib/nanoc/base/source_data/data_source.rb +234 -0
- data/lib/nanoc/base/source_data/item.rb +301 -0
- data/lib/nanoc/base/source_data/layout.rb +130 -0
- data/lib/nanoc/base/source_data/site.rb +361 -0
- data/lib/nanoc/base/store.rb +135 -0
- data/lib/nanoc/cli.rb +137 -0
- data/lib/nanoc/cli/command_runner.rb +104 -0
- data/lib/nanoc/cli/commands/autocompile.rb +58 -0
- data/lib/nanoc/cli/commands/compile.rb +297 -0
- data/lib/nanoc/cli/commands/create_item.rb +60 -0
- data/lib/nanoc/cli/commands/create_layout.rb +73 -0
- data/lib/nanoc/cli/commands/create_site.rb +411 -0
- data/lib/nanoc/cli/commands/debug.rb +117 -0
- data/lib/nanoc/cli/commands/deploy.rb +79 -0
- data/lib/nanoc/cli/commands/info.rb +98 -0
- data/lib/nanoc/cli/commands/nanoc.rb +38 -0
- data/lib/nanoc/cli/commands/prune.rb +50 -0
- data/lib/nanoc/cli/commands/update.rb +70 -0
- data/lib/nanoc/cli/commands/view.rb +82 -0
- data/lib/nanoc/cli/commands/watch.rb +124 -0
- data/lib/nanoc/cli/error_handler.rb +199 -0
- data/lib/nanoc/cli/logger.rb +92 -0
- data/lib/nanoc/data_sources.rb +29 -0
- data/lib/nanoc/data_sources/deprecated/delicious.rb +42 -0
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +87 -0
- data/lib/nanoc/data_sources/deprecated/twitter.rb +38 -0
- data/lib/nanoc/data_sources/filesystem.rb +299 -0
- data/lib/nanoc/data_sources/filesystem_unified.rb +121 -0
- data/lib/nanoc/data_sources/filesystem_verbose.rb +91 -0
- data/lib/nanoc/extra.rb +24 -0
- data/lib/nanoc/extra/auto_compiler.rb +103 -0
- data/lib/nanoc/extra/chick.rb +125 -0
- data/lib/nanoc/extra/core_ext.rb +6 -0
- data/lib/nanoc/extra/core_ext/enumerable.rb +33 -0
- data/lib/nanoc/extra/core_ext/pathname.rb +30 -0
- data/lib/nanoc/extra/core_ext/time.rb +19 -0
- data/lib/nanoc/extra/deployer.rb +47 -0
- data/lib/nanoc/extra/deployers.rb +15 -0
- data/lib/nanoc/extra/deployers/fog.rb +98 -0
- data/lib/nanoc/extra/deployers/rsync.rb +70 -0
- data/lib/nanoc/extra/file_proxy.rb +40 -0
- data/lib/nanoc/extra/pruner.rb +86 -0
- data/lib/nanoc/extra/validators.rb +12 -0
- data/lib/nanoc/extra/validators/links.rb +268 -0
- data/lib/nanoc/extra/validators/w3c.rb +95 -0
- data/lib/nanoc/extra/vcs.rb +66 -0
- data/lib/nanoc/extra/vcses.rb +17 -0
- data/lib/nanoc/extra/vcses/bazaar.rb +25 -0
- data/lib/nanoc/extra/vcses/dummy.rb +24 -0
- data/lib/nanoc/extra/vcses/git.rb +25 -0
- data/lib/nanoc/extra/vcses/mercurial.rb +25 -0
- data/lib/nanoc/extra/vcses/subversion.rb +25 -0
- data/lib/nanoc/filters.rb +59 -0
- data/lib/nanoc/filters/asciidoc.rb +38 -0
- data/lib/nanoc/filters/bluecloth.rb +19 -0
- data/lib/nanoc/filters/coderay.rb +21 -0
- data/lib/nanoc/filters/coffeescript.rb +20 -0
- data/lib/nanoc/filters/colorize_syntax.rb +298 -0
- data/lib/nanoc/filters/erb.rb +38 -0
- data/lib/nanoc/filters/erubis.rb +34 -0
- data/lib/nanoc/filters/haml.rb +27 -0
- data/lib/nanoc/filters/kramdown.rb +20 -0
- data/lib/nanoc/filters/less.rb +53 -0
- data/lib/nanoc/filters/markaby.rb +20 -0
- data/lib/nanoc/filters/maruku.rb +20 -0
- data/lib/nanoc/filters/mustache.rb +24 -0
- data/lib/nanoc/filters/rainpress.rb +19 -0
- data/lib/nanoc/filters/rdiscount.rb +22 -0
- data/lib/nanoc/filters/rdoc.rb +33 -0
- data/lib/nanoc/filters/redcarpet.rb +62 -0
- data/lib/nanoc/filters/redcloth.rb +47 -0
- data/lib/nanoc/filters/relativize_paths.rb +94 -0
- data/lib/nanoc/filters/rubypants.rb +20 -0
- data/lib/nanoc/filters/sass.rb +74 -0
- data/lib/nanoc/filters/slim.rb +25 -0
- data/lib/nanoc/filters/typogruby.rb +23 -0
- data/lib/nanoc/filters/uglify_js.rb +42 -0
- data/lib/nanoc/filters/xsl.rb +46 -0
- data/lib/nanoc/filters/yui_compressor.rb +23 -0
- data/lib/nanoc/helpers.rb +16 -0
- data/lib/nanoc/helpers/blogging.rb +319 -0
- data/lib/nanoc/helpers/breadcrumbs.rb +40 -0
- data/lib/nanoc/helpers/capturing.rb +138 -0
- data/lib/nanoc/helpers/filtering.rb +50 -0
- data/lib/nanoc/helpers/html_escape.rb +55 -0
- data/lib/nanoc/helpers/link_to.rb +151 -0
- data/lib/nanoc/helpers/rendering.rb +140 -0
- data/lib/nanoc/helpers/tagging.rb +71 -0
- data/lib/nanoc/helpers/text.rb +44 -0
- data/lib/nanoc/helpers/xml_sitemap.rb +76 -0
- data/lib/nanoc/tasks.rb +10 -0
- data/lib/nanoc/tasks/clean.rake +16 -0
- data/lib/nanoc/tasks/clean.rb +29 -0
- data/lib/nanoc/tasks/deploy/rsync.rake +16 -0
- data/lib/nanoc/tasks/validate.rake +92 -0
- data/nanoc.gemspec +49 -0
- data/tasks/doc.rake +16 -0
- data/tasks/test.rake +46 -0
- data/test/base/core_ext/array_spec.rb +73 -0
- data/test/base/core_ext/hash_spec.rb +98 -0
- data/test/base/core_ext/pathname_spec.rb +27 -0
- data/test/base/core_ext/string_spec.rb +37 -0
- data/test/base/test_checksum_store.rb +35 -0
- data/test/base/test_code_snippet.rb +31 -0
- data/test/base/test_compiler.rb +403 -0
- data/test/base/test_compiler_dsl.rb +161 -0
- data/test/base/test_context.rb +31 -0
- data/test/base/test_data_source.rb +46 -0
- data/test/base/test_dependency_tracker.rb +262 -0
- data/test/base/test_directed_graph.rb +288 -0
- data/test/base/test_filter.rb +83 -0
- data/test/base/test_item.rb +179 -0
- data/test/base/test_item_rep.rb +579 -0
- data/test/base/test_layout.rb +59 -0
- data/test/base/test_memoization.rb +90 -0
- data/test/base/test_notification_center.rb +34 -0
- data/test/base/test_outdatedness_checker.rb +394 -0
- data/test/base/test_plugin.rb +30 -0
- data/test/base/test_rule.rb +19 -0
- data/test/base/test_rule_context.rb +65 -0
- data/test/base/test_site.rb +190 -0
- data/test/cli/commands/test_compile.rb +33 -0
- data/test/cli/commands/test_create_item.rb +14 -0
- data/test/cli/commands/test_create_layout.rb +28 -0
- data/test/cli/commands/test_create_site.rb +24 -0
- data/test/cli/commands/test_deploy.rb +74 -0
- data/test/cli/commands/test_help.rb +12 -0
- data/test/cli/commands/test_info.rb +11 -0
- data/test/cli/commands/test_prune.rb +98 -0
- data/test/cli/commands/test_update.rb +10 -0
- data/test/cli/test_cli.rb +102 -0
- data/test/cli/test_error_handler.rb +29 -0
- data/test/cli/test_logger.rb +10 -0
- data/test/data_sources/test_filesystem.rb +433 -0
- data/test/data_sources/test_filesystem_unified.rb +536 -0
- data/test/data_sources/test_filesystem_verbose.rb +357 -0
- data/test/extra/core_ext/test_enumerable.rb +30 -0
- data/test/extra/core_ext/test_pathname.rb +17 -0
- data/test/extra/core_ext/test_time.rb +15 -0
- data/test/extra/deployers/test_fog.rb +67 -0
- data/test/extra/deployers/test_rsync.rb +100 -0
- data/test/extra/test_auto_compiler.rb +417 -0
- data/test/extra/test_file_proxy.rb +19 -0
- data/test/extra/test_vcs.rb +22 -0
- data/test/extra/validators/test_links.rb +62 -0
- data/test/extra/validators/test_w3c.rb +47 -0
- data/test/filters/test_asciidoc.rb +22 -0
- data/test/filters/test_bluecloth.rb +18 -0
- data/test/filters/test_coderay.rb +44 -0
- data/test/filters/test_coffeescript.rb +18 -0
- data/test/filters/test_colorize_syntax.rb +379 -0
- data/test/filters/test_erb.rb +105 -0
- data/test/filters/test_erubis.rb +78 -0
- data/test/filters/test_haml.rb +96 -0
- data/test/filters/test_kramdown.rb +18 -0
- data/test/filters/test_less.rb +113 -0
- data/test/filters/test_markaby.rb +24 -0
- data/test/filters/test_maruku.rb +18 -0
- data/test/filters/test_mustache.rb +25 -0
- data/test/filters/test_rainpress.rb +29 -0
- data/test/filters/test_rdiscount.rb +31 -0
- data/test/filters/test_rdoc.rb +18 -0
- data/test/filters/test_redcarpet.rb +73 -0
- data/test/filters/test_redcloth.rb +33 -0
- data/test/filters/test_relativize_paths.rb +533 -0
- data/test/filters/test_rubypants.rb +18 -0
- data/test/filters/test_sass.rb +229 -0
- data/test/filters/test_slim.rb +35 -0
- data/test/filters/test_typogruby.rb +21 -0
- data/test/filters/test_uglify_js.rb +30 -0
- data/test/filters/test_xsl.rb +105 -0
- data/test/filters/test_yui_compressor.rb +44 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +207 -0
- data/test/helpers/test_blogging.rb +754 -0
- data/test/helpers/test_breadcrumbs.rb +81 -0
- data/test/helpers/test_capturing.rb +41 -0
- data/test/helpers/test_filtering.rb +106 -0
- data/test/helpers/test_html_escape.rb +32 -0
- data/test/helpers/test_link_to.rb +249 -0
- data/test/helpers/test_rendering.rb +89 -0
- data/test/helpers/test_tagging.rb +87 -0
- data/test/helpers/test_text.rb +24 -0
- data/test/helpers/test_xml_sitemap.rb +103 -0
- data/test/tasks/test_clean.rb +67 -0
- metadata +327 -15
- data/bin/nanoc-select +0 -86
- data/lib/nanoc-select.rb +0 -11
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::ERBTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter_with_instance_variable
|
|
8
|
+
# Create filter
|
|
9
|
+
filter = ::Nanoc::Filters::ERB.new({ :location => 'a cheap motel' })
|
|
10
|
+
|
|
11
|
+
# Run filter
|
|
12
|
+
result = filter.run('<%= "I was hiding in #{@location}." %>')
|
|
13
|
+
assert_equal('I was hiding in a cheap motel.', result)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_filter_with_instance_method
|
|
17
|
+
# Create filter
|
|
18
|
+
filter = ::Nanoc::Filters::ERB.new({ :location => 'a cheap motel' })
|
|
19
|
+
|
|
20
|
+
# Run filter
|
|
21
|
+
result = filter.run('<%= "I was hiding in #{location}." %>')
|
|
22
|
+
assert_equal('I was hiding in a cheap motel.', result)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_filter_error_item
|
|
26
|
+
# Create item and item rep
|
|
27
|
+
item = MiniTest::Mock.new
|
|
28
|
+
item.expect(:identifier, '/foo/bar/baz/')
|
|
29
|
+
item_rep = MiniTest::Mock.new
|
|
30
|
+
item_rep.expect(:name, :quux)
|
|
31
|
+
|
|
32
|
+
# Create filter
|
|
33
|
+
filter = ::Nanoc::Filters::ERB.new({
|
|
34
|
+
:item => item,
|
|
35
|
+
:item_rep => item_rep,
|
|
36
|
+
:location => 'a cheap motel'
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
# Run filter
|
|
40
|
+
raised = false
|
|
41
|
+
begin
|
|
42
|
+
filter.run('<%= this isn\'t really ruby so it\'ll break, muahaha %>')
|
|
43
|
+
rescue SyntaxError => e
|
|
44
|
+
e.message =~ /(.+?):\d+: /
|
|
45
|
+
assert_match 'item /foo/bar/baz/ (rep quux)', $1
|
|
46
|
+
raised = true
|
|
47
|
+
end
|
|
48
|
+
assert raised
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_filter_with_yield
|
|
52
|
+
# Create filter
|
|
53
|
+
filter = ::Nanoc::Filters::ERB.new({ :content => 'a cheap motel' })
|
|
54
|
+
|
|
55
|
+
# Run filter
|
|
56
|
+
result = filter.run('<%= "I was hiding in #{yield}." %>')
|
|
57
|
+
assert_equal('I was hiding in a cheap motel.', result)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_filter_with_yield_without_content
|
|
61
|
+
# Create filter
|
|
62
|
+
filter = ::Nanoc::Filters::ERB.new({ :location => 'a cheap motel' })
|
|
63
|
+
|
|
64
|
+
# Run filter
|
|
65
|
+
assert_raises LocalJumpError do
|
|
66
|
+
filter.run('<%= "I was hiding in #{yield}." %>')
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_safe_level
|
|
71
|
+
# Set up
|
|
72
|
+
filter = ::Nanoc::Filters::ERB.new
|
|
73
|
+
File.open('moo', 'w') { |io| io.write("one miiillion dollars") }
|
|
74
|
+
|
|
75
|
+
# Without
|
|
76
|
+
res = filter.run('<%= File.read("moo") %>', :safe_level => nil)
|
|
77
|
+
assert_equal 'one miiillion dollars', res
|
|
78
|
+
|
|
79
|
+
# With
|
|
80
|
+
assert_raises(SecurityError) do
|
|
81
|
+
res = filter.run('<%= File.read("moo") %>', :safe_level => 4)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_trim_mode
|
|
86
|
+
# Set up
|
|
87
|
+
filter = ::Nanoc::Filters::ERB.new({ :location => 'a cheap motel' })
|
|
88
|
+
$trim_mode_works = false
|
|
89
|
+
|
|
90
|
+
# Without
|
|
91
|
+
filter.run('% $trim_mode_works = true')
|
|
92
|
+
refute $trim_mode_works
|
|
93
|
+
|
|
94
|
+
# With
|
|
95
|
+
filter.run('% $trim_mode_works = true', :trim_mode => '%')
|
|
96
|
+
assert $trim_mode_works
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_locals
|
|
100
|
+
filter = ::Nanoc::Filters::ERB.new
|
|
101
|
+
result = filter.run('<%= @local %>', :locals => { :local => 123 })
|
|
102
|
+
assert_equal '123', result
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::ErubisTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter_with_instance_variable
|
|
8
|
+
if_have 'erubis' do
|
|
9
|
+
# Create filter
|
|
10
|
+
filter = ::Nanoc::Filters::Erubis.new({ :location => 'a cheap motel' })
|
|
11
|
+
|
|
12
|
+
# Run filter
|
|
13
|
+
result = filter.run('<%= "I was hiding in #{@location}." %>')
|
|
14
|
+
assert_equal('I was hiding in a cheap motel.', result)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_filter_with_instance_method
|
|
19
|
+
if_have 'erubis' do
|
|
20
|
+
# Create filter
|
|
21
|
+
filter = ::Nanoc::Filters::Erubis.new({ :location => 'a cheap motel' })
|
|
22
|
+
|
|
23
|
+
# Run filter
|
|
24
|
+
result = filter.run('<%= "I was hiding in #{location}." %>')
|
|
25
|
+
assert_equal('I was hiding in a cheap motel.', result)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_filter_error
|
|
30
|
+
if_have 'erubis' do
|
|
31
|
+
# Create filter
|
|
32
|
+
filter = ::Nanoc::Filters::Erubis.new
|
|
33
|
+
|
|
34
|
+
# Run filter
|
|
35
|
+
raised = false
|
|
36
|
+
begin
|
|
37
|
+
filter.run('<%= this isn\'t really ruby so it\'ll break, muahaha %>')
|
|
38
|
+
rescue SyntaxError => e
|
|
39
|
+
e.message =~ /(.+?):\d+: /
|
|
40
|
+
assert_match '?', $1
|
|
41
|
+
raised = true
|
|
42
|
+
end
|
|
43
|
+
assert raised
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_filter_with_yield
|
|
48
|
+
if_have 'erubis' do
|
|
49
|
+
# Create filter
|
|
50
|
+
filter = ::Nanoc::Filters::Erubis.new({ :content => 'a cheap motel' })
|
|
51
|
+
|
|
52
|
+
# Run filter
|
|
53
|
+
result = filter.run('<%= "I was hiding in #{yield}." %>')
|
|
54
|
+
assert_equal('I was hiding in a cheap motel.', result)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_filter_with_yield_without_content
|
|
59
|
+
if_have 'erubis' do
|
|
60
|
+
# Create filter
|
|
61
|
+
filter = ::Nanoc::Filters::Erubis.new({ :location => 'a cheap motel' })
|
|
62
|
+
|
|
63
|
+
# Run filter
|
|
64
|
+
assert_raises LocalJumpError do
|
|
65
|
+
filter.run('<%= "I was hiding in #{yield}." %>')
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_filter_with_erbout
|
|
71
|
+
if_have 'erubis' do
|
|
72
|
+
filter = ::Nanoc::Filters::Erubis.new
|
|
73
|
+
result = filter.run('stuff<% _erbout << _erbout %>')
|
|
74
|
+
assert_equal 'stuffstuff', result
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::HamlTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'haml' do
|
|
9
|
+
# Create filter
|
|
10
|
+
filter = ::Nanoc::Filters::Haml.new({ :question => 'Is this the Payne residence?' })
|
|
11
|
+
|
|
12
|
+
# Run filter (no assigns)
|
|
13
|
+
result = filter.run('%html')
|
|
14
|
+
assert_match(/<html>.*<\/html>/, result)
|
|
15
|
+
|
|
16
|
+
# Run filter (assigns without @)
|
|
17
|
+
result = filter.run('%p= question')
|
|
18
|
+
assert_equal("<p>Is this the Payne residence?</p>\n", result)
|
|
19
|
+
|
|
20
|
+
# Run filter (assigns with @)
|
|
21
|
+
result = filter.run('%p= @question')
|
|
22
|
+
assert_equal("<p>Is this the Payne residence?</p>\n", result)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_filter_with_params
|
|
27
|
+
if_have 'haml' do
|
|
28
|
+
# Create filter
|
|
29
|
+
filter = ::Nanoc::Filters::Haml.new({ :foo => 'bar' })
|
|
30
|
+
|
|
31
|
+
# Check with HTML5
|
|
32
|
+
result = filter.run('%img', :format => :html5)
|
|
33
|
+
assert_match(/<img>/, result)
|
|
34
|
+
|
|
35
|
+
# Check with XHTML
|
|
36
|
+
result = filter.run('%img', :format => :xhtml)
|
|
37
|
+
assert_match(/<img\s*\/>/, result)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_filter_error
|
|
42
|
+
if_have 'haml' do
|
|
43
|
+
# Create filter
|
|
44
|
+
filter = ::Nanoc::Filters::Haml.new({ :foo => 'bar' })
|
|
45
|
+
|
|
46
|
+
# Run filter
|
|
47
|
+
raised = false
|
|
48
|
+
begin
|
|
49
|
+
filter.run('%p= this isn\'t really ruby so it\'ll break, muahaha')
|
|
50
|
+
rescue SyntaxError => e
|
|
51
|
+
e.message =~ /(.+?):\d+: /
|
|
52
|
+
assert_match '?', $1
|
|
53
|
+
raised = true
|
|
54
|
+
end
|
|
55
|
+
assert raised
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_filter_with_yield
|
|
60
|
+
if_have 'haml' do
|
|
61
|
+
# Create filter
|
|
62
|
+
filter = ::Nanoc::Filters::Haml.new({ :content => 'Is this the Payne residence?' })
|
|
63
|
+
|
|
64
|
+
# Run filter
|
|
65
|
+
result = filter.run('%p= yield')
|
|
66
|
+
assert_equal("<p>Is this the Payne residence?</p>\n", result)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_filter_with_yield_without_content
|
|
71
|
+
if_have 'haml' do
|
|
72
|
+
# Create filter
|
|
73
|
+
filter = ::Nanoc::Filters::Haml.new({ :location => 'Is this the Payne residence?' })
|
|
74
|
+
|
|
75
|
+
# Run filter
|
|
76
|
+
assert_raises LocalJumpError do
|
|
77
|
+
filter.run('%p= yield')
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_filter_with_proper_indentation
|
|
83
|
+
if_have 'haml' do
|
|
84
|
+
# Create file to include
|
|
85
|
+
File.open('stuff', 'w') do |io|
|
|
86
|
+
io.write("<pre>Max Payne\nMona Sax</pre>")
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Run filter
|
|
90
|
+
filter = ::Nanoc::Filters::Haml.new
|
|
91
|
+
result = filter.run("%body\n ~ File.read('stuff')")
|
|
92
|
+
assert_match(/Max Payne
Mona Sax/, result)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::KramdownTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'kramdown' do
|
|
9
|
+
# Create filter
|
|
10
|
+
filter = ::Nanoc::Filters::Kramdown.new
|
|
11
|
+
|
|
12
|
+
# Run filter
|
|
13
|
+
result = filter.run("This is _so_ **cool**!")
|
|
14
|
+
assert_equal("<p>This is <em>so</em> <strong>cool</strong>!</p>\n", result)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'less' do
|
|
9
|
+
# Create item
|
|
10
|
+
@item = Nanoc::Item.new("blah", { :content_filename => 'content/foo/bar.txt' }, '/foo/bar/')
|
|
11
|
+
|
|
12
|
+
# Create filter
|
|
13
|
+
filter = ::Nanoc::Filters::Less.new(:item => @item, :items => [ @item ])
|
|
14
|
+
|
|
15
|
+
# Run filter
|
|
16
|
+
result = filter.run('.foo { bar: 1 + 1 }')
|
|
17
|
+
assert_match /\.foo\s*\{\s*bar:\s*2;?\s*\}/, result
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_filter_with_paths_relative_to_site_directory
|
|
22
|
+
if_have 'less' do
|
|
23
|
+
# Create file to import
|
|
24
|
+
FileUtils.mkdir_p('content/foo/bar')
|
|
25
|
+
File.open('content/foo/bar/imported_file.less', 'w') { |io| io.write('p { color: red; }') }
|
|
26
|
+
|
|
27
|
+
# Create item
|
|
28
|
+
@item = Nanoc::Item.new("blah", { :content_filename => 'content/foo/bar.txt' }, '/foo/bar/')
|
|
29
|
+
|
|
30
|
+
# Create filter
|
|
31
|
+
filter = ::Nanoc::Filters::Less.new(:item => @item, :items => [ @item ])
|
|
32
|
+
|
|
33
|
+
# Run filter
|
|
34
|
+
result = filter.run('@import "content/foo/bar/imported_file.less";')
|
|
35
|
+
assert_match /p\s*\{\s*color:\s*red;?\s*\}/, result
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_filter_with_paths_relative_to_current_file
|
|
40
|
+
if_have 'less' do
|
|
41
|
+
# Create file to import
|
|
42
|
+
FileUtils.mkdir_p('content/foo/bar')
|
|
43
|
+
File.open('content/foo/bar/imported_file.less', 'w') { |io| io.write('p { color: red; }') }
|
|
44
|
+
|
|
45
|
+
# Create item
|
|
46
|
+
File.open('content/foo/bar.txt', 'w') { |io| io.write('meh') }
|
|
47
|
+
@item = Nanoc::Item.new("blah", { :content_filename => 'content/foo/bar.txt' }, '/foo/bar/')
|
|
48
|
+
|
|
49
|
+
# Create filter
|
|
50
|
+
filter = ::Nanoc::Filters::Less.new(:item => @item, :items => [ @item ])
|
|
51
|
+
|
|
52
|
+
# Run filter
|
|
53
|
+
result = filter.run('@import "bar/imported_file.less";')
|
|
54
|
+
assert_match /p\s*\{\s*color:\s*red;?\s*\}/, result
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_recompile_includes
|
|
59
|
+
if_have 'less' do
|
|
60
|
+
with_site do |site|
|
|
61
|
+
# Create two less files
|
|
62
|
+
Dir['content/*'].each { |i| FileUtils.rm(i) }
|
|
63
|
+
File.open('content/a.less', 'w') do |io|
|
|
64
|
+
io.write('@import "b.less";')
|
|
65
|
+
end
|
|
66
|
+
File.open('content/b.less', 'w') do |io|
|
|
67
|
+
io.write("p { color: red; }")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Update rules
|
|
71
|
+
File.open('Rules', 'w') do |io|
|
|
72
|
+
io.write "compile '*' do\n"
|
|
73
|
+
io.write " filter :less\n"
|
|
74
|
+
io.write "end\n"
|
|
75
|
+
io.write "\n"
|
|
76
|
+
io.write "route '/a/' do\n"
|
|
77
|
+
io.write " item.identifier.chop + '.css'\n"
|
|
78
|
+
io.write "end\n"
|
|
79
|
+
io.write "\n"
|
|
80
|
+
io.write "route '/b/' do\n"
|
|
81
|
+
io.write " nil\n"
|
|
82
|
+
io.write "end\n"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Compile
|
|
86
|
+
site = Nanoc::Site.new('.')
|
|
87
|
+
site.compile
|
|
88
|
+
|
|
89
|
+
# Check
|
|
90
|
+
assert Dir['output/*'].size == 1
|
|
91
|
+
assert File.file?('output/a.css')
|
|
92
|
+
refute File.file?('output/b.css')
|
|
93
|
+
assert_match /^p\s*\{\s*color:\s*red;?\s*\}/, File.read('output/a.css')
|
|
94
|
+
|
|
95
|
+
# Update included file
|
|
96
|
+
File.open('content/b.less', 'w') do |io|
|
|
97
|
+
io.write("p { color: blue; }")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Recompile
|
|
101
|
+
site = Nanoc::Site.new('.')
|
|
102
|
+
site.compile
|
|
103
|
+
|
|
104
|
+
# Recheck
|
|
105
|
+
assert Dir['output/*'].size == 1
|
|
106
|
+
assert File.file?('output/a.css')
|
|
107
|
+
refute File.file?('output/b.css')
|
|
108
|
+
assert_match /^p\s*\{\s*color:\s*blue;?\s*\}/, File.read('output/a.css')
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::MarkabyTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
# Don’t run this test on 1.9.x, because it breaks and it annoys me
|
|
9
|
+
if RUBY_VERSION >= '1.9'
|
|
10
|
+
skip "Markaby is not compatible with 1.9.x"
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
if_have 'markaby' do
|
|
15
|
+
# Create filter
|
|
16
|
+
filter = ::Nanoc::Filters::Markaby.new
|
|
17
|
+
|
|
18
|
+
# Run filter
|
|
19
|
+
result = filter.run("html do\nend")
|
|
20
|
+
assert_equal("<html></html>", result)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::MarukuTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'maruku' do
|
|
9
|
+
# Create filter
|
|
10
|
+
filter = ::Nanoc::Filters::Maruku.new
|
|
11
|
+
|
|
12
|
+
# Run filter
|
|
13
|
+
result = filter.run("This is _so_ *cool*!")
|
|
14
|
+
assert_equal("<p>This is <em>so</em> <em>cool</em>!</p>", result)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|