nanoc3 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Filters::RainpressTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_filter
8
- if_have 'rainpress' do
9
- # Create filter
10
- filter = ::Nanoc3::Filters::Rainpress.new
11
-
12
- # Run filter
13
- result = filter.run("body { color: black; }")
14
- assert_equal("body{color:#000}", result)
15
- end
16
- end
17
-
18
- def test_filter_with_options
19
- if_have 'rainpress' do
20
- # Create filter
21
- filter = ::Nanoc3::Filters::Rainpress.new
22
-
23
- # Run filter
24
- result = filter.run("body { color: #aabbcc; }", :colors => false)
25
- assert_equal("body{color:#aabbcc}", result)
26
- end
27
- end
28
-
29
- end
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Filters::RDiscountTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_filter
8
- if_have 'rdiscount' do
9
- # Create filter
10
- filter = ::Nanoc3::Filters::RDiscount.new
11
-
12
- # Run filter
13
- result = filter.run("> Quote")
14
- assert_match(/<blockquote>\s*<p>Quote<\/p>\s*<\/blockquote>/, result)
15
- end
16
- end
17
-
18
- def test_with_extensions
19
- if_have 'rdiscount' do
20
- # Create filter
21
- filter = ::Nanoc3::Filters::RDiscount.new
22
-
23
- # Run filter
24
- input = "The quotation 'marks' sure make this look sarcastic!"
25
- output_expected = /The quotation &lsquo;marks&rsquo; sure make this look sarcastic!/
26
- output_actual = filter.run(input, :extensions => [ :smart ])
27
- assert_match(output_expected, output_actual)
28
- end
29
- end
30
-
31
- end
@@ -1,18 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Filters::RDocTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_filter
8
- if_have 'rdoc' do
9
- # Get filter
10
- filter = ::Nanoc3::Filters::RDoc.new
11
-
12
- # Run filter
13
- result = filter.run("= Foo")
14
- assert_match(%r{<h1( id="label-Foo")?>Foo</h1>\Z}, result)
15
- end
16
- end
17
-
18
- end
@@ -1,63 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Filters::RedcarpetTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_find
8
- if_have 'redcarpet' do
9
- refute Nanoc3::Filter.named(:redcarpet).nil?
10
- end
11
- end
12
-
13
- def test_filter
14
- if_have 'redcarpet' do
15
- # Create filter
16
- filter = ::Nanoc3::Filters::Redcarpet.new
17
-
18
- # Run filter
19
- result = filter.run("> Quote")
20
- assert_match(/<blockquote>\s*<p>Quote<\/p>\s*<\/blockquote>/, result)
21
- end
22
- end
23
-
24
- def test_with_extensions
25
- if_have 'redcarpet' do
26
- # Create filter
27
- filter = ::Nanoc3::Filters::Redcarpet.new
28
-
29
- # Run filter
30
- input = "The quotation 'marks' sure make this look sarcastic!"
31
- output_expected = /The quotation &lsquo;marks&rsquo; sure make this look sarcastic!/
32
- output_actual = filter.run(input, :options => [ :smart ])
33
- assert_match(output_expected, output_actual)
34
- end
35
- end
36
-
37
- def test_html_by_default
38
- if_have 'redcarpet' do
39
- # Create filter
40
- filter = ::Nanoc3::Filters::Redcarpet.new
41
-
42
- # Run filter
43
- input = "![Alt](/path/to/img 'Title')"
44
- output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title">}
45
- output_actual = filter.run(input)
46
- assert_match(output_expected, output_actual)
47
- end
48
- end
49
-
50
- def test_xhtml_if_requested
51
- if_have 'redcarpet' do
52
- # Create filter
53
- filter = ::Nanoc3::Filters::Redcarpet.new
54
-
55
- # Run filter
56
- input = "![Alt](/path/to/img 'Title')"
57
- output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title"/>}
58
- output_actual = filter.run(input, :options => [ :xhtml ])
59
- assert_match(output_expected, output_actual)
60
- end
61
- end
62
-
63
- end
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Filters::RedClothTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_filter
8
- if_have 'redcloth' do
9
- # Get filter
10
- filter = ::Nanoc3::Filters::RedCloth.new
11
-
12
- # Run filter
13
- result = filter.run("h1. Foo")
14
- assert_equal("<h1>Foo</h1>", result)
15
- end
16
- end
17
-
18
- def test_filter_with_options
19
- if_have 'redcloth' do
20
- # Get filter
21
- filter = ::Nanoc3::Filters::RedCloth.new
22
-
23
- # Run filter without options
24
- result = filter.run("I am a member of SPECTRE.")
25
- assert_equal("<p>I am a member of <span class=\"caps\">SPECTRE</span>.</p>", result)
26
-
27
- # Run filter with options
28
- result = filter.run("I am a member of SPECTRE.", :no_span_caps => true)
29
- assert_equal("<p>I am a member of SPECTRE.</p>", result)
30
- end
31
- end
32
-
33
- end
@@ -1,332 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Filters::RelativizePathsTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_filter_html_with_double_quotes
8
- # Create filter with mock item
9
- filter = Nanoc3::Filters::RelativizePaths.new
10
-
11
- # Mock item
12
- filter.instance_eval do
13
- @item_rep = Nanoc3::ItemRep.new(
14
- Nanoc3::Item.new(
15
- 'content',
16
- {},
17
- '/foo/bar/baz/'),
18
- :blah)
19
- @item_rep.path = '/foo/bar/baz/'
20
- end
21
-
22
- # Set content
23
- raw_content = %[<a href="/foo">foo</a>]
24
- expected_content = %[<a href="../..">foo</a>]
25
-
26
- # Test
27
- actual_content = filter.run(raw_content, :type => :html)
28
- assert_equal(expected_content, actual_content)
29
- end
30
-
31
- def test_filter_html_with_single_quotes
32
- # Create filter with mock item
33
- filter = Nanoc3::Filters::RelativizePaths.new
34
-
35
- # Mock item
36
- filter.instance_eval do
37
- @item_rep = Nanoc3::ItemRep.new(
38
- Nanoc3::Item.new(
39
- 'content',
40
- {},
41
- '/foo/bar/baz/'),
42
- :blah)
43
- @item_rep.path = '/foo/bar/baz/'
44
- end
45
-
46
- # Set content
47
- raw_content = %[<a href='/foo'>foo</a>]
48
- expected_content = %[<a href='../..'>foo</a>]
49
-
50
- # Test
51
- actual_content = filter.run(raw_content, :type => :html)
52
- assert_equal(expected_content, actual_content)
53
- end
54
-
55
- def test_filter_html_without_quotes
56
- # Create filter with mock item
57
- filter = Nanoc3::Filters::RelativizePaths.new
58
-
59
- # Mock item
60
- filter.instance_eval do
61
- @item_rep = Nanoc3::ItemRep.new(
62
- Nanoc3::Item.new(
63
- 'content',
64
- {},
65
- '/foo/bar/baz/'),
66
- :blah)
67
- @item_rep.path = '/foo/bar/baz/'
68
- end
69
-
70
- # Set content
71
- raw_content = %[<a href=/foo>foo</a>]
72
- expected_content = %[<a href=../..>foo</a>]
73
-
74
- # Test
75
- actual_content = filter.run(raw_content, :type => :html)
76
- assert_equal(expected_content, actual_content)
77
- end
78
-
79
- def test_filter_html_multiple
80
- # Create filter with mock item
81
- filter = Nanoc3::Filters::RelativizePaths.new
82
-
83
- # Mock item
84
- filter.instance_eval do
85
- @item_rep = Nanoc3::ItemRep.new(
86
- Nanoc3::Item.new(
87
- 'content',
88
- {},
89
- '/foo/bar/baz/'),
90
- :blah)
91
- @item_rep.path = '/foo/bar/baz/'
92
- end
93
-
94
- # Set content
95
- raw_content = %[<a href="/foo">foo</a> <a href="/bar">bar</a>]
96
- expected_content = %[<a href="../..">foo</a> <a href="../../../bar">bar</a>]
97
-
98
- # Test
99
- actual_content = filter.run(raw_content, :type => :html)
100
- assert_equal(expected_content, actual_content)
101
- end
102
-
103
- def test_filter_html_outside_tag
104
- # Create filter with mock item
105
- filter = Nanoc3::Filters::RelativizePaths.new
106
-
107
- # Mock item
108
- filter.instance_eval do
109
- @item_rep = Nanoc3::ItemRep.new(
110
- Nanoc3::Item.new(
111
- 'content',
112
- {},
113
- '/foo/bar/baz/'),
114
- :blah)
115
- @item_rep.path = '/foo/bar/baz/'
116
- end
117
-
118
- # Set content
119
- raw_content = %[stuff href="/foo" more stuff]
120
- expected_content = %[stuff href="/foo" more stuff]
121
-
122
- # Test
123
- actual_content = filter.run(raw_content, :type => :html)
124
- assert_equal(expected_content, actual_content)
125
- end
126
-
127
- def test_filter_html_root
128
- # Create filter with mock item
129
- filter = Nanoc3::Filters::RelativizePaths.new
130
-
131
- # Mock item
132
- filter.instance_eval do
133
- @item_rep = Nanoc3::ItemRep.new(
134
- Nanoc3::Item.new(
135
- 'content',
136
- {},
137
- '/foo/bar/baz/'),
138
- :blah)
139
- @item_rep.path = '/woof/meow/'
140
- end
141
-
142
- # Set content
143
- raw_content = %[<a href="/">foo</a>]
144
- expected_content = %[<a href="../../">foo</a>]
145
-
146
- # Test
147
- actual_content = filter.run(raw_content, :type => :html)
148
- assert_equal(expected_content, actual_content)
149
- end
150
-
151
- def test_filter_html_network_path
152
- # Create filter with mock item
153
- filter = Nanoc3::Filters::RelativizePaths.new
154
-
155
- # Mock item
156
- filter.instance_eval do
157
- @item_rep = Nanoc3::ItemRep.new(
158
- Nanoc3::Item.new(
159
- 'content',
160
- {},
161
- '/foo/bar/baz/'),
162
- :blah)
163
- @item_rep.path = '/woof/meow/'
164
- end
165
-
166
- # Set content
167
- raw_content = %[<a href="//example.com/">example.com</a>]
168
- expected_content = %[<a href="//example.com/">example.com</a>]
169
-
170
- # Test
171
- actual_content = filter.run(raw_content, :type => :html)
172
- assert_equal(expected_content, actual_content)
173
- end
174
-
175
- def test_filter_implicit
176
- # Create filter with mock item
177
- filter = Nanoc3::Filters::RelativizePaths.new
178
-
179
- # Test
180
- assert_raises(RuntimeError) do
181
- filter.run("moo")
182
- end
183
- end
184
-
185
- def test_filter_css_with_double_quotes
186
- # Create filter with mock item
187
- filter = Nanoc3::Filters::RelativizePaths.new
188
-
189
- # Mock item
190
- filter.instance_eval do
191
- @item_rep = Nanoc3::ItemRep.new(
192
- Nanoc3::Item.new(
193
- 'content',
194
- {},
195
- '/foo/bar/baz/'),
196
- :blah)
197
- @item_rep.path = '/foo/bar/baz/'
198
- end
199
-
200
- # Set content
201
- raw_content = %[background: url("/foo/bar/background.png");]
202
- expected_content = %[background: url("../background.png");]
203
-
204
- # Test
205
- actual_content = filter.run(raw_content, :type => :css)
206
- assert_equal(expected_content, actual_content)
207
- end
208
-
209
- def test_filter_css_with_single_quotes
210
- # Create filter with mock item
211
- filter = Nanoc3::Filters::RelativizePaths.new
212
-
213
- # Mock item
214
- filter.instance_eval do
215
- @item_rep = Nanoc3::ItemRep.new(
216
- Nanoc3::Item.new(
217
- 'content',
218
- {},
219
- '/foo/bar/baz/'),
220
- :blah)
221
- @item_rep.path = '/foo/bar/baz/'
222
- end
223
-
224
- # Set content
225
- raw_content = %[background: url('/foo/bar/background.png');]
226
- expected_content = %[background: url('../background.png');]
227
-
228
- # Test
229
- actual_content = filter.run(raw_content, :type => :css)
230
- assert_equal(expected_content, actual_content)
231
- end
232
-
233
- def test_filter_css_without_quotes
234
- # Create filter with mock item
235
- filter = Nanoc3::Filters::RelativizePaths.new
236
-
237
- # Mock item
238
- filter.instance_eval do
239
- @item_rep = Nanoc3::ItemRep.new(
240
- Nanoc3::Item.new(
241
- 'content',
242
- {},
243
- '/foo/bar/baz/'),
244
- :blah)
245
- @item_rep.path = '/foo/bar/baz/'
246
- end
247
-
248
- # Set content
249
- raw_content = %[background: url(/foo/bar/background.png);]
250
- expected_content = %[background: url(../background.png);]
251
-
252
- # Test
253
- actual_content = filter.run(raw_content, :type => :css)
254
- assert_equal(expected_content, actual_content)
255
- end
256
-
257
- def test_filter_css_multiple
258
- # Create filter with mock item
259
- filter = Nanoc3::Filters::RelativizePaths.new
260
-
261
- # Mock item
262
- filter.instance_eval do
263
- @item_rep = Nanoc3::ItemRep.new(
264
- Nanoc3::Item.new(
265
- 'content',
266
- {},
267
- '/foo/bar/baz/'),
268
- :blah)
269
- @item_rep.path = '/foo/bar/baz/'
270
- end
271
-
272
- # Set content
273
- raw_content = %[background: url(/foo/bar/a.png) url(/foo/bar/b.png);]
274
- expected_content = %[background: url(../a.png) url(../b.png);]
275
-
276
- # Test
277
- actual_content = filter.run(raw_content, :type => :css)
278
- assert_equal(expected_content, actual_content)
279
- end
280
-
281
- def test_filter_css_root
282
- # It is probably a bit weird to have “url(/)” in CSS, but I’ve made a
283
- # test case for this situation anyway. Can’t hurt…
284
-
285
- # Create filter with mock item
286
- filter = Nanoc3::Filters::RelativizePaths.new
287
-
288
- # Mock item
289
- filter.instance_eval do
290
- @item_rep = Nanoc3::ItemRep.new(
291
- Nanoc3::Item.new(
292
- 'content',
293
- {},
294
- '/foo/bar/baz/'),
295
- :blah)
296
- @item_rep.path = '/woof/meow/'
297
- end
298
-
299
- # Set content
300
- raw_content = %[background: url(/);]
301
- expected_content = %[background: url(../../);]
302
-
303
- # Test
304
- actual_content = filter.run(raw_content, :type => :css)
305
- assert_equal(expected_content, actual_content)
306
- end
307
-
308
- def test_filter_css_network_path
309
- # Create filter with mock item
310
- filter = Nanoc3::Filters::RelativizePaths.new
311
-
312
- # Mock item
313
- filter.instance_eval do
314
- @item_rep = Nanoc3::ItemRep.new(
315
- Nanoc3::Item.new(
316
- 'content',
317
- {},
318
- '/foo/bar/baz/'),
319
- :blah)
320
- @item_rep.path = '/woof/meow/'
321
- end
322
-
323
- # Set content
324
- raw_content = %[background: url(//example.com);]
325
- expected_content = %[background: url(//example.com);]
326
-
327
- # Test
328
- actual_content = filter.run(raw_content, :type => :css)
329
- assert_equal(expected_content, actual_content)
330
- end
331
-
332
- end