nanoc3 3.1.7 → 3.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gemtest +0 -0
  2. data/LICENSE +1 -1
  3. data/NEWS.md +9 -0
  4. data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
  5. data/lib/nanoc3/base/item.rb +1 -1
  6. data/lib/nanoc3/base/item_rep.rb +1 -0
  7. data/lib/nanoc3/base/layout.rb +1 -1
  8. data/lib/nanoc3/cli/base.rb +4 -2
  9. data/lib/nanoc3/cli/commands/view.rb +1 -0
  10. data/lib/nanoc3/data_sources/filesystem.rb +25 -6
  11. data/lib/nanoc3/data_sources/filesystem_unified.rb +5 -5
  12. data/lib/nanoc3/extra/validators/links.rb +1 -1
  13. data/lib/nanoc3/filters/rdiscount.rb +2 -1
  14. data/lib/nanoc3/filters/sass.rb +20 -8
  15. data/lib/nanoc3/filters/sass.rb.orig +75 -0
  16. data/lib/nanoc3.rb +1 -1
  17. data/nanoc3.gemspec +41 -0
  18. data/tasks/clean.rake +11 -0
  19. data/tasks/doc.rake +14 -0
  20. data/tasks/gem.rake +13 -0
  21. data/tasks/test.rake +38 -0
  22. data/test/base/core_ext/array_spec.rb +23 -0
  23. data/test/base/core_ext/hash_spec.rb +41 -0
  24. data/test/base/core_ext/string_spec.rb +27 -0
  25. data/test/base/test_code_snippet.rb +33 -0
  26. data/test/base/test_compiler.rb +410 -0
  27. data/test/base/test_compiler_dsl.rb +121 -0
  28. data/test/base/test_context.rb +33 -0
  29. data/test/base/test_data_source.rb +48 -0
  30. data/test/base/test_dependency_tracker.rb +510 -0
  31. data/test/base/test_directed_graph.rb +91 -0
  32. data/test/base/test_filter.rb +85 -0
  33. data/test/base/test_item.rb +141 -0
  34. data/test/base/test_item_rep.rb +953 -0
  35. data/test/base/test_layout.rb +44 -0
  36. data/test/base/test_notification_center.rb +36 -0
  37. data/test/base/test_plugin.rb +32 -0
  38. data/test/base/test_rule.rb +21 -0
  39. data/test/base/test_rule_context.rb +63 -0
  40. data/test/base/test_site.rb +366 -0
  41. data/test/cli/commands/test_compile.rb +12 -0
  42. data/test/cli/commands/test_create_item.rb +12 -0
  43. data/test/cli/commands/test_create_layout.rb +28 -0
  44. data/test/cli/commands/test_create_site.rb +24 -0
  45. data/test/cli/commands/test_help.rb +12 -0
  46. data/test/cli/commands/test_info.rb +12 -0
  47. data/test/cli/commands/test_update.rb +12 -0
  48. data/test/cli/test_logger.rb +12 -0
  49. data/test/data_sources/test_filesystem.rb +420 -0
  50. data/test/data_sources/test_filesystem_unified.rb +538 -0
  51. data/test/data_sources/test_filesystem_verbose.rb +359 -0
  52. data/test/extra/core_ext/test_enumerable.rb +32 -0
  53. data/test/extra/core_ext/test_time.rb +17 -0
  54. data/test/extra/deployers/test_rsync.rb +234 -0
  55. data/test/extra/test_auto_compiler.rb +482 -0
  56. data/test/extra/test_file_proxy.rb +21 -0
  57. data/test/extra/test_vcs.rb +24 -0
  58. data/test/extra/validators/test_links.rb +53 -0
  59. data/test/extra/validators/test_w3c.rb +49 -0
  60. data/test/filters/test_bluecloth.rb +20 -0
  61. data/test/filters/test_coderay.rb +46 -0
  62. data/test/filters/test_colorize_syntax.rb +56 -0
  63. data/test/filters/test_erb.rb +72 -0
  64. data/test/filters/test_erubis.rb +72 -0
  65. data/test/filters/test_haml.rb +98 -0
  66. data/test/filters/test_kramdown.rb +20 -0
  67. data/test/filters/test_less.rb +59 -0
  68. data/test/filters/test_markaby.rb +26 -0
  69. data/test/filters/test_maruku.rb +20 -0
  70. data/test/filters/test_rainpress.rb +31 -0
  71. data/test/filters/test_rdiscount.rb +33 -0
  72. data/test/filters/test_rdoc.rb +18 -0
  73. data/test/filters/test_redcloth.rb +20 -0
  74. data/test/filters/test_relativize_paths.rb +231 -0
  75. data/test/filters/test_rubypants.rb +20 -0
  76. data/test/filters/test_sass.rb +170 -0
  77. data/test/filters/test_sass.rb.orig +103 -0
  78. data/test/gem_loader.rb +11 -0
  79. data/test/helper.rb +99 -0
  80. data/test/helpers/test_blogging.rb +808 -0
  81. data/test/helpers/test_breadcrumbs.rb +83 -0
  82. data/test/helpers/test_capturing.rb +42 -0
  83. data/test/helpers/test_filtering.rb +108 -0
  84. data/test/helpers/test_html_escape.rb +18 -0
  85. data/test/helpers/test_link_to.rb +251 -0
  86. data/test/helpers/test_rendering.rb +109 -0
  87. data/test/helpers/test_tagging.rb +89 -0
  88. data/test/helpers/test_text.rb +26 -0
  89. data/test/helpers/test_xml_sitemap.rb +69 -0
  90. data/test/tasks/test_clean.rb +71 -0
  91. metadata +83 -8
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_coderay_simple
10
+ if_have 'coderay' do
11
+ # Create filter
12
+ filter = ::Nanoc3::Filters::ColorizeSyntax.new
13
+
14
+ # Get input and expected output
15
+ input = '<pre title="moo"><code class="language-ruby"># comment</code></pre>'
16
+ expected_output = '<pre title="moo"><code class="language-ruby"><span class="c"># comment</span></code></pre>'
17
+
18
+ # Run filter
19
+ actual_output = filter.run(input)
20
+ assert_equal(expected_output, actual_output)
21
+ end
22
+ end
23
+
24
+ def test_coderay_with_more_classes
25
+ if_have 'coderay' do
26
+ # Create filter
27
+ filter = ::Nanoc3::Filters::ColorizeSyntax.new
28
+
29
+ # Get input and expected output
30
+ input = '<pre title="moo"><code class="abc language-ruby xyz"># comment</code></pre>'
31
+ expected_output = '<pre title="moo"><code class="abc language-ruby xyz"><span class="c"># comment</span></code></pre>'
32
+
33
+ # Run filter
34
+ actual_output = filter.run(input)
35
+ assert_equal(expected_output, actual_output)
36
+ end
37
+ end
38
+
39
+ def test_pygmentize
40
+ if `which pygmentize`.strip.empty?
41
+ skip "could not find pygmentize"
42
+ end
43
+
44
+ # Create filter
45
+ filter = ::Nanoc3::Filters::ColorizeSyntax.new
46
+
47
+ # Get input and expected output
48
+ input = '<pre title="moo"><code class="language-ruby"># comment</code></pre>'
49
+ expected_output = %r{^<pre title="moo"><code class="language-ruby"><span class="c1"># comment</span>\n?</code></pre>$}
50
+
51
+ # Run filter
52
+ actual_output = filter.run(input, :colorizers => { :ruby => :pygmentize })
53
+ assert_match(expected_output, actual_output)
54
+ end
55
+
56
+ end
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::ERBTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter_with_instance_variable
10
+ # Create filter
11
+ filter = ::Nanoc3::Filters::ERB.new({ :location => 'a cheap motel' })
12
+
13
+ # Run filter
14
+ result = filter.run('<%= "I was hiding in #{@location}." %>')
15
+ assert_equal('I was hiding in a cheap motel.', result)
16
+ end
17
+
18
+ def test_filter_with_instance_method
19
+ # Create filter
20
+ filter = ::Nanoc3::Filters::ERB.new({ :location => 'a cheap motel' })
21
+
22
+ # Run filter
23
+ result = filter.run('<%= "I was hiding in #{location}." %>')
24
+ assert_equal('I was hiding in a cheap motel.', result)
25
+ end
26
+
27
+ def test_filter_error_item
28
+ # Create item and item rep
29
+ item = MiniTest::Mock.new
30
+ item.expect(:identifier, '/foo/bar/baz/')
31
+ item_rep = MiniTest::Mock.new
32
+ item_rep.expect(:name, :quux)
33
+
34
+ # Create filter
35
+ filter = ::Nanoc3::Filters::ERB.new({
36
+ :item => item,
37
+ :item_rep => item_rep,
38
+ :location => 'a cheap motel'
39
+ })
40
+
41
+ # Run filter
42
+ raised = false
43
+ begin
44
+ filter.run('<%= this isn\'t really ruby so it\'ll break, muahaha %>')
45
+ rescue SyntaxError => e
46
+ e.message =~ /(.+?):\d+: /
47
+ assert_match 'item /foo/bar/baz/ (rep quux)', $1
48
+ raised = true
49
+ end
50
+ assert raised
51
+ end
52
+
53
+ def test_filter_with_yield
54
+ # Create filter
55
+ filter = ::Nanoc3::Filters::ERB.new({ :content => 'a cheap motel' })
56
+
57
+ # Run filter
58
+ result = filter.run('<%= "I was hiding in #{yield}." %>')
59
+ assert_equal('I was hiding in a cheap motel.', result)
60
+ end
61
+
62
+ def test_filter_with_yield_without_content
63
+ # Create filter
64
+ filter = ::Nanoc3::Filters::ERB.new({ :location => 'a cheap motel' })
65
+
66
+ # Run filter
67
+ assert_raises LocalJumpError do
68
+ filter.run('<%= "I was hiding in #{yield}." %>')
69
+ end
70
+ end
71
+
72
+ end
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::ErubisTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter_with_instance_variable
10
+ if_have 'erubis' do
11
+ # Create filter
12
+ filter = ::Nanoc3::Filters::Erubis.new({ :location => 'a cheap motel' })
13
+
14
+ # Run filter
15
+ result = filter.run('<%= "I was hiding in #{@location}." %>')
16
+ assert_equal('I was hiding in a cheap motel.', result)
17
+ end
18
+ end
19
+
20
+ def test_filter_with_instance_method
21
+ if_have 'erubis' do
22
+ # Create filter
23
+ filter = ::Nanoc3::Filters::Erubis.new({ :location => 'a cheap motel' })
24
+
25
+ # Run filter
26
+ result = filter.run('<%= "I was hiding in #{location}." %>')
27
+ assert_equal('I was hiding in a cheap motel.', result)
28
+ end
29
+ end
30
+
31
+ def test_filter_error
32
+ if_have 'erubis' do
33
+ # Create filter
34
+ filter = ::Nanoc3::Filters::Erubis.new
35
+
36
+ # Run filter
37
+ raised = false
38
+ begin
39
+ filter.run('<%= this isn\'t really ruby so it\'ll break, muahaha %>')
40
+ rescue SyntaxError => e
41
+ e.message =~ /(.+?):\d+: /
42
+ assert_match '?', $1
43
+ raised = true
44
+ end
45
+ assert raised
46
+ end
47
+ end
48
+
49
+ def test_filter_with_yield
50
+ if_have 'erubis' do
51
+ # Create filter
52
+ filter = ::Nanoc3::Filters::Erubis.new({ :content => 'a cheap motel' })
53
+
54
+ # Run filter
55
+ result = filter.run('<%= "I was hiding in #{yield}." %>')
56
+ assert_equal('I was hiding in a cheap motel.', result)
57
+ end
58
+ end
59
+
60
+ def test_filter_with_yield_without_content
61
+ if_have 'erubis' do
62
+ # Create filter
63
+ filter = ::Nanoc3::Filters::Erubis.new({ :location => 'a cheap motel' })
64
+
65
+ # Run filter
66
+ assert_raises LocalJumpError do
67
+ filter.run('<%= "I was hiding in #{yield}." %>')
68
+ end
69
+ end
70
+ end
71
+
72
+ end
@@ -0,0 +1,98 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::HamlTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ if_have 'haml' do
11
+ # Create filter
12
+ filter = ::Nanoc3::Filters::Haml.new({ :question => 'Is this the Payne residence?' })
13
+
14
+ # Run filter (no assigns)
15
+ result = filter.run('%html')
16
+ assert_match(/<html>.*<\/html>/, result)
17
+
18
+ # Run filter (assigns without @)
19
+ result = filter.run('%p= question')
20
+ assert_equal("<p>Is this the Payne residence?</p>\n", result)
21
+
22
+ # Run filter (assigns with @)
23
+ result = filter.run('%p= @question')
24
+ assert_equal("<p>Is this the Payne residence?</p>\n", result)
25
+ end
26
+ end
27
+
28
+ def test_filter_with_params
29
+ if_have 'haml' do
30
+ # Create filter
31
+ filter = ::Nanoc3::Filters::Haml.new({ :foo => 'bar' })
32
+
33
+ # Check with HTML5
34
+ result = filter.run('%img', :format => :html5)
35
+ assert_match(/<img>/, result)
36
+
37
+ # Check with XHTML
38
+ result = filter.run('%img', :format => :xhtml)
39
+ assert_match(/<img\s*\/>/, result)
40
+ end
41
+ end
42
+
43
+ def test_filter_error
44
+ if_have 'haml' do
45
+ # Create filter
46
+ filter = ::Nanoc3::Filters::Haml.new({ :foo => 'bar' })
47
+
48
+ # Run filter
49
+ raised = false
50
+ begin
51
+ filter.run('%p= this isn\'t really ruby so it\'ll break, muahaha')
52
+ rescue SyntaxError => e
53
+ e.message =~ /(.+?):\d+: /
54
+ assert_match '?', $1
55
+ raised = true
56
+ end
57
+ assert raised
58
+ end
59
+ end
60
+
61
+ def test_filter_with_yield
62
+ if_have 'haml' do
63
+ # Create filter
64
+ filter = ::Nanoc3::Filters::Haml.new({ :content => 'Is this the Payne residence?' })
65
+
66
+ # Run filter
67
+ result = filter.run('%p= yield')
68
+ assert_equal("<p>Is this the Payne residence?</p>\n", result)
69
+ end
70
+ end
71
+
72
+ def test_filter_with_yield_without_content
73
+ if_have 'haml' do
74
+ # Create filter
75
+ filter = ::Nanoc3::Filters::Haml.new({ :location => 'Is this the Payne residence?' })
76
+
77
+ # Run filter
78
+ assert_raises LocalJumpError do
79
+ filter.run('%p= yield')
80
+ end
81
+ end
82
+ end
83
+
84
+ def test_filter_with_proper_indentation
85
+ if_have 'haml' do
86
+ # Create file to include
87
+ File.open('stuff', 'w') do |io|
88
+ io.write("<pre>Max Payne\nMona Sax</pre>")
89
+ end
90
+
91
+ # Run filter
92
+ filter = ::Nanoc3::Filters::Haml.new
93
+ result = filter.run("%body\n ~ File.read('stuff')")
94
+ assert_match(/Max Payne&#x000A;Mona Sax/, result)
95
+ end
96
+ end
97
+
98
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::KramdownTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ if_have 'kramdown' do
11
+ # Create filter
12
+ filter = ::Nanoc3::Filters::Kramdown.new
13
+
14
+ # Run filter
15
+ result = filter.run("This is _so_ **cool**!")
16
+ assert_equal("<p>This is <em>so</em> <strong>cool</strong>!</p>\n", result)
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::LessTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ if_have 'less' do
11
+ # Create item
12
+ @item = Nanoc3::Item.new("blah", { :content_filename => 'content/foo/bar.txt' }, '/foo/bar/')
13
+
14
+ # Create filter
15
+ filter = ::Nanoc3::Filters::Less.new(:item => @item)
16
+
17
+ # Run filter
18
+ result = filter.run('.foo { bar: 1 + 1 }')
19
+ assert_match /\.foo\s*\{\s*bar:\s*2;?\s*\}/, result
20
+ end
21
+ end
22
+
23
+ def test_filter_with_paths_relative_to_site_directory
24
+ if_have 'less' do
25
+ # Create file to import
26
+ FileUtils.mkdir_p('content/foo/bar')
27
+ File.open('content/foo/bar/imported_file.less', 'w') { |io| io.write('p { color: red; }') }
28
+
29
+ # Create item
30
+ @item = Nanoc3::Item.new("blah", { :content_filename => 'content/foo/bar.txt' }, '/foo/bar/')
31
+
32
+ # Create filter
33
+ filter = ::Nanoc3::Filters::Less.new(:item => @item)
34
+
35
+ # Run filter
36
+ result = filter.run('@import "content/foo/bar/imported_file.less";')
37
+ assert_match /p\s*\{\s*color:\s*red;?\s*\}/, result
38
+ end
39
+ end
40
+
41
+ def test_filter_with_paths_relative_to_current_file
42
+ if_have 'less' do
43
+ # Create file to import
44
+ FileUtils.mkdir_p('content/foo/bar')
45
+ File.open('content/foo/bar/imported_file.less', 'w') { |io| io.write('p { color: red; }') }
46
+
47
+ # Create item
48
+ @item = Nanoc3::Item.new("blah", { :content_filename => 'content/foo/bar.txt' }, '/foo/bar/')
49
+
50
+ # Create filter
51
+ filter = ::Nanoc3::Filters::Less.new(:item => @item)
52
+
53
+ # Run filter
54
+ result = filter.run('@import "bar/imported_file.less";')
55
+ assert_match /p\s*\{\s*color:\s*red;?\s*\}/, result
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::MarkabyTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ # Don’t run this test on 1.9.x, because it breaks and it annoys me
11
+ if RUBY_VERSION >= '1.9'
12
+ skip "Markaby is not compatible with 1.9.x"
13
+ return
14
+ end
15
+
16
+ if_have 'markaby' do
17
+ # Create filter
18
+ filter = ::Nanoc3::Filters::Markaby.new
19
+
20
+ # Run filter
21
+ result = filter.run("html do\nend")
22
+ assert_equal("<html></html>", result)
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::MarukuTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ if_have 'maruku' do
11
+ # Create filter
12
+ filter = ::Nanoc3::Filters::Maruku.new
13
+
14
+ # Run filter
15
+ result = filter.run("This is _so_ *cool*!")
16
+ assert_equal("<p>This is <em>so</em> <em>cool</em>!</p>", result)
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::RainpressTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ if_have 'rainpress' do
11
+ # Create filter
12
+ filter = ::Nanoc3::Filters::Rainpress.new
13
+
14
+ # Run filter
15
+ result = filter.run("body { color: black; }")
16
+ assert_equal("body{color:#000}", result)
17
+ end
18
+ end
19
+
20
+ def test_filter_with_options
21
+ if_have 'rainpress' do
22
+ # Create filter
23
+ filter = ::Nanoc3::Filters::Rainpress.new
24
+
25
+ # Run filter
26
+ result = filter.run("body { color: #aabbcc; }", :colors => false)
27
+ assert_equal("body{color:#aabbcc}", result)
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::RDiscountTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ if_have 'rdiscount' do
11
+ # Create filter
12
+ filter = ::Nanoc3::Filters::RDiscount.new
13
+
14
+ # Run filter
15
+ result = filter.run("> Quote")
16
+ assert_match(/<blockquote>\s*<p>Quote<\/p>\s*<\/blockquote>/, result)
17
+ end
18
+ end
19
+
20
+ def test_with_extensions
21
+ if_have 'rdiscount' do
22
+ # Create filter
23
+ filter = ::Nanoc3::Filters::RDiscount.new
24
+
25
+ # Run filter
26
+ input = "The quotation 'marks' sure make this look sarcastic!"
27
+ output_expected = /The quotation &lsquo;marks&rsquo; sure make this look sarcastic!/
28
+ output_actual = filter.run(input, :extensions => [ :smart ])
29
+ assert_match(output_expected, output_actual)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::RDocTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ # Get filter
11
+ filter = ::Nanoc3::Filters::RDoc.new
12
+
13
+ # Run filter
14
+ result = filter.run("= Foo")
15
+ assert_equal("<h1>Foo</h1>\n", result)
16
+ end
17
+
18
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/helper'
4
+
5
+ class Nanoc3::Filters::RedClothTest < MiniTest::Unit::TestCase
6
+
7
+ include Nanoc3::TestHelpers
8
+
9
+ def test_filter
10
+ if_have 'redcloth' do
11
+ # Get filter
12
+ filter = ::Nanoc3::Filters::RedCloth.new
13
+
14
+ # Run filter
15
+ result = filter.run("h1. Foo")
16
+ assert_equal("<h1>Foo</h1>", result)
17
+ end
18
+ end
19
+
20
+ end