nanoc3 3.1.9 → 3.2.0a1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/NEWS.md +0 -50
- data/README.md +3 -15
- data/bin/nanoc3 +2 -0
- data/lib/nanoc3/base/checksummer.rb +40 -0
- data/lib/nanoc3/base/code_snippet.rb +30 -12
- data/lib/nanoc3/base/compiled_content_cache.rb +86 -0
- data/lib/nanoc3/base/compiler.rb +134 -95
- data/lib/nanoc3/base/compiler_dsl.rb +12 -11
- data/lib/nanoc3/base/core_ext/string.rb +2 -2
- data/lib/nanoc3/base/data_source.rb +17 -16
- data/lib/nanoc3/base/dependency_tracker.rb +102 -121
- data/lib/nanoc3/base/directed_graph.rb +65 -3
- data/lib/nanoc3/base/errors.rb +20 -16
- data/lib/nanoc3/base/item.rb +58 -50
- data/lib/nanoc3/base/item_rep.rb +177 -150
- data/lib/nanoc3/base/layout.rb +51 -18
- data/lib/nanoc3/base/notification_center.rb +8 -8
- data/lib/nanoc3/base/plugin_registry.rb +9 -9
- data/lib/nanoc3/base/rule.rb +18 -9
- data/lib/nanoc3/base/rule_context.rb +5 -5
- data/lib/nanoc3/base/site.rb +135 -47
- data/lib/nanoc3/base.rb +21 -19
- data/lib/nanoc3/cli/base.rb +51 -74
- data/lib/nanoc3/cli/commands/autocompile.rb +3 -0
- data/lib/nanoc3/cli/commands/compile.rb +35 -74
- data/lib/nanoc3/cli/commands/create_site.rb +17 -5
- data/lib/nanoc3/cli/commands/debug.rb +11 -4
- data/lib/nanoc3/cli/commands/view.rb +0 -1
- data/lib/nanoc3/cli/commands/watch.rb +148 -0
- data/lib/nanoc3/cli/commands.rb +1 -0
- data/lib/nanoc3/cli/logger.rb +15 -21
- data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -1
- data/lib/nanoc3/data_sources/filesystem.rb +11 -40
- data/lib/nanoc3/data_sources/filesystem_unified.rb +22 -22
- data/lib/nanoc3/extra/auto_compiler.rb +1 -1
- data/lib/nanoc3/extra/chick.rb +8 -8
- data/lib/nanoc3/extra/deployers/rsync.rb +2 -3
- data/lib/nanoc3/extra/validators/links.rb +32 -51
- data/lib/nanoc3/extra/validators/w3c.rb +2 -2
- data/lib/nanoc3/extra/vcs.rb +1 -1
- data/lib/nanoc3/filters/colorize_syntax.rb +15 -19
- data/lib/nanoc3/filters/erb.rb +1 -5
- data/lib/nanoc3/filters/erubis.rb +1 -5
- data/lib/nanoc3/filters/haml.rb +1 -2
- data/lib/nanoc3/filters/less.rb +2 -51
- data/lib/nanoc3/filters/mustache.rb +21 -0
- data/lib/nanoc3/filters/rdiscount.rb +1 -2
- data/lib/nanoc3/filters/relativize_paths.rb +3 -2
- data/lib/nanoc3/filters/sass.rb +50 -56
- data/lib/nanoc3/filters.rb +2 -0
- data/lib/nanoc3/helpers/blogging.rb +22 -29
- data/lib/nanoc3/helpers/breadcrumbs.rb +1 -1
- data/lib/nanoc3/helpers/capturing.rb +1 -1
- data/lib/nanoc3/helpers/filtering.rb +1 -1
- data/lib/nanoc3/helpers/link_to.rb +10 -21
- data/lib/nanoc3/helpers/rendering.rb +5 -24
- data/lib/nanoc3/helpers/tagging.rb +6 -6
- data/lib/nanoc3/helpers/text.rb +2 -2
- data/lib/nanoc3.rb +1 -1
- metadata +35 -93
- data/.gemtest +0 -0
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/nanoc3.gemspec +0 -41
- data/tasks/clean.rake +0 -11
- data/tasks/doc.rake +0 -14
- data/tasks/gem.rake +0 -13
- data/tasks/test.rake +0 -38
- data/test/base/core_ext/array_spec.rb +0 -23
- data/test/base/core_ext/hash_spec.rb +0 -41
- data/test/base/core_ext/string_spec.rb +0 -27
- data/test/base/test_code_snippet.rb +0 -33
- data/test/base/test_compiler.rb +0 -410
- data/test/base/test_compiler_dsl.rb +0 -121
- data/test/base/test_context.rb +0 -33
- data/test/base/test_data_source.rb +0 -48
- data/test/base/test_dependency_tracker.rb +0 -510
- data/test/base/test_directed_graph.rb +0 -91
- data/test/base/test_filter.rb +0 -85
- data/test/base/test_item.rb +0 -141
- data/test/base/test_item_rep.rb +0 -953
- data/test/base/test_layout.rb +0 -44
- data/test/base/test_notification_center.rb +0 -36
- data/test/base/test_plugin.rb +0 -32
- data/test/base/test_rule.rb +0 -21
- data/test/base/test_rule_context.rb +0 -63
- data/test/base/test_site.rb +0 -366
- data/test/cli/commands/test_compile.rb +0 -12
- data/test/cli/commands/test_create_item.rb +0 -12
- 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 -12
- data/test/cli/commands/test_update.rb +0 -12
- data/test/cli/test_logger.rb +0 -12
- data/test/data_sources/test_filesystem.rb +0 -420
- data/test/data_sources/test_filesystem_unified.rb +0 -538
- data/test/data_sources/test_filesystem_verbose.rb +0 -359
- data/test/extra/core_ext/test_enumerable.rb +0 -32
- data/test/extra/core_ext/test_time.rb +0 -17
- data/test/extra/deployers/test_rsync.rb +0 -234
- data/test/extra/test_auto_compiler.rb +0 -482
- data/test/extra/test_file_proxy.rb +0 -21
- data/test/extra/test_vcs.rb +0 -24
- data/test/extra/validators/test_links.rb +0 -53
- data/test/extra/validators/test_w3c.rb +0 -49
- data/test/filters/test_bluecloth.rb +0 -20
- data/test/filters/test_coderay.rb +0 -46
- data/test/filters/test_colorize_syntax.rb +0 -84
- data/test/filters/test_erb.rb +0 -72
- data/test/filters/test_erubis.rb +0 -72
- data/test/filters/test_haml.rb +0 -98
- data/test/filters/test_kramdown.rb +0 -20
- data/test/filters/test_less.rb +0 -118
- data/test/filters/test_markaby.rb +0 -26
- data/test/filters/test_maruku.rb +0 -20
- data/test/filters/test_rainpress.rb +0 -31
- data/test/filters/test_rdiscount.rb +0 -33
- data/test/filters/test_rdoc.rb +0 -18
- data/test/filters/test_redcloth.rb +0 -20
- data/test/filters/test_relativize_paths.rb +0 -231
- data/test/filters/test_rubypants.rb +0 -20
- data/test/filters/test_sass.rb +0 -235
- data/test/gem_loader.rb +0 -11
- data/test/helper.rb +0 -99
- data/test/helpers/test_blogging.rb +0 -808
- data/test/helpers/test_breadcrumbs.rb +0 -83
- data/test/helpers/test_capturing.rb +0 -42
- data/test/helpers/test_filtering.rb +0 -108
- data/test/helpers/test_html_escape.rb +0 -18
- data/test/helpers/test_link_to.rb +0 -251
- data/test/helpers/test_rendering.rb +0 -109
- data/test/helpers/test_tagging.rb +0 -89
- data/test/helpers/test_text.rb +0 -26
- data/test/helpers/test_xml_sitemap.rb +0 -69
- data/test/tasks/test_clean.rb +0 -71
@@ -1,84 +0,0 @@
|
|
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
|
-
def test_colorize_syntax_with_missing_executables
|
57
|
-
if_have 'nokogiri' do
|
58
|
-
begin
|
59
|
-
original_path = ENV['PATH']
|
60
|
-
ENV['PATH'] = './blooblooblah'
|
61
|
-
|
62
|
-
# Create filter
|
63
|
-
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
64
|
-
|
65
|
-
# Get input and expected output
|
66
|
-
input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
|
67
|
-
|
68
|
-
# Run filter
|
69
|
-
begin
|
70
|
-
input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
|
71
|
-
actual_output = filter.run(
|
72
|
-
input,
|
73
|
-
:colorizers => { :ruby => :pygmentize })
|
74
|
-
flunk "expected colorizer to raise if no executable is available"
|
75
|
-
rescue => e
|
76
|
-
assert_match /No such file or directory/, e.message
|
77
|
-
end
|
78
|
-
ensure
|
79
|
-
ENV['PATH'] = original_path
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
data/test/filters/test_erb.rb
DELETED
@@ -1,72 +0,0 @@
|
|
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
|
data/test/filters/test_erubis.rb
DELETED
@@ -1,72 +0,0 @@
|
|
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
|
data/test/filters/test_haml.rb
DELETED
@@ -1,98 +0,0 @@
|
|
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
Mona Sax/, result)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
@@ -1,20 +0,0 @@
|
|
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
|
data/test/filters/test_less.rb
DELETED
@@ -1,118 +0,0 @@
|
|
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
|
-
File.open('content/foo/bar.txt', 'w') { |io| io.write('meh') }
|
49
|
-
@item = Nanoc3::Item.new("blah", { :content_filename => 'content/foo/bar.txt' }, '/foo/bar/')
|
50
|
-
|
51
|
-
# Create filter
|
52
|
-
filter = ::Nanoc3::Filters::Less.new(:item => @item, :items => [ @item ])
|
53
|
-
|
54
|
-
# Run filter
|
55
|
-
result = filter.run('@import "bar/imported_file.less";')
|
56
|
-
assert_match /p\s*\{\s*color:\s*red;?\s*\}/, result
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_recompile_includes
|
61
|
-
if_have 'less' do
|
62
|
-
Nanoc3::CLI::Base.new.run([ 'create_site', 'bar' ])
|
63
|
-
FileUtils.cd('bar') do
|
64
|
-
# Create two less files
|
65
|
-
Dir['content/*'].each { |i| FileUtils.rm(i) }
|
66
|
-
File.open('content/a.less', 'w') do |io|
|
67
|
-
io.write('@import "b.less";')
|
68
|
-
end
|
69
|
-
File.open('content/b.less', 'w') do |io|
|
70
|
-
io.write("p { color: red; }")
|
71
|
-
end
|
72
|
-
|
73
|
-
# Update rules
|
74
|
-
File.open('Rules', 'w') do |io|
|
75
|
-
io.write "compile '*' do\n"
|
76
|
-
io.write " filter :less\n"
|
77
|
-
io.write "end\n"
|
78
|
-
io.write "\n"
|
79
|
-
io.write "route '/a/' do\n"
|
80
|
-
io.write " item.identifier.chop + '.css'\n"
|
81
|
-
io.write "end\n"
|
82
|
-
io.write "\n"
|
83
|
-
io.write "route '/b/' do\n"
|
84
|
-
io.write " nil\n"
|
85
|
-
io.write "end\n"
|
86
|
-
end
|
87
|
-
|
88
|
-
# Compile
|
89
|
-
site = Nanoc3::Site.new('.')
|
90
|
-
site.load_data
|
91
|
-
site.compiler.run
|
92
|
-
|
93
|
-
# Check
|
94
|
-
assert Dir['output/*'].size == 1
|
95
|
-
assert File.file?('output/a.css')
|
96
|
-
refute File.file?('output/b.css')
|
97
|
-
assert_match /^p\s*\{\s*color:\s*red;?\s*\}/, File.read('output/a.css')
|
98
|
-
|
99
|
-
# Update included file
|
100
|
-
File.open('content/b.less', 'w') do |io|
|
101
|
-
io.write("p { color: blue; }")
|
102
|
-
end
|
103
|
-
|
104
|
-
# Recompile
|
105
|
-
site = Nanoc3::Site.new('.')
|
106
|
-
site.load_data
|
107
|
-
site.compiler.run
|
108
|
-
|
109
|
-
# Recheck
|
110
|
-
assert Dir['output/*'].size == 1
|
111
|
-
assert File.file?('output/a.css')
|
112
|
-
refute File.file?('output/b.css')
|
113
|
-
assert_match /^p\s*\{\s*color:\s*blue;?\s*\}/, File.read('output/a.css')
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
@@ -1,26 +0,0 @@
|
|
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
|
data/test/filters/test_maruku.rb
DELETED
@@ -1,20 +0,0 @@
|
|
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
|
@@ -1,31 +0,0 @@
|
|
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
|
@@ -1,33 +0,0 @@
|
|
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 ‘marks’ 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
|
data/test/filters/test_rdoc.rb
DELETED
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,20 +0,0 @@
|
|
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
|