nanoc3 3.2.0a4 → 3.2.0b1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.md +20 -2
- data/README.md +7 -3
- data/bin/nanoc3 +1 -3
- data/lib/nanoc3.rb +1 -13
- data/lib/nanoc3/base/compilation/filter.rb +21 -0
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +1 -3
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +1 -1
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -2
- data/lib/nanoc3/base/compilation/rules_collection.rb +37 -13
- data/lib/nanoc3/base/directed_graph.rb +3 -3
- data/lib/nanoc3/base/memoization.rb +6 -9
- data/lib/nanoc3/base/source_data/code_snippet.rb +2 -1
- data/lib/nanoc3/base/source_data/configuration.rb +7 -3
- data/lib/nanoc3/base/source_data/item.rb +52 -10
- data/lib/nanoc3/base/source_data/layout.rb +28 -1
- data/lib/nanoc3/base/source_data/site.rb +14 -3
- data/lib/nanoc3/cli.rb +98 -6
- data/lib/nanoc3/cli/{base.rb → command.rb} +117 -153
- data/lib/nanoc3/cli/commands/autocompile.rb +20 -48
- data/lib/nanoc3/cli/commands/compile.rb +32 -48
- data/lib/nanoc3/cli/commands/create_item.rb +21 -37
- data/lib/nanoc3/cli/commands/create_layout.rb +18 -36
- data/lib/nanoc3/cli/commands/create_site.rb +15 -34
- data/lib/nanoc3/cli/commands/debug.rb +17 -31
- data/lib/nanoc3/cli/commands/info.rb +14 -29
- data/lib/nanoc3/cli/commands/nanoc.rb +37 -0
- data/lib/nanoc3/cli/commands/update.rb +21 -44
- data/lib/nanoc3/cli/commands/view.rb +18 -44
- data/lib/nanoc3/cli/commands/watch.rb +16 -31
- data/lib/nanoc3/data_sources/filesystem.rb +25 -6
- data/lib/nanoc3/data_sources/filesystem_unified.rb +5 -5
- data/lib/nanoc3/extra/auto_compiler.rb +1 -0
- data/lib/nanoc3/extra/file_proxy.rb +0 -1
- data/lib/nanoc3/filters.rb +2 -0
- data/lib/nanoc3/filters/asciidoc.rb +16 -36
- data/lib/nanoc3/filters/bluecloth.rb +2 -2
- data/lib/nanoc3/filters/coderay.rb +2 -2
- data/lib/nanoc3/filters/colorize_syntax.rb +18 -5
- data/lib/nanoc3/filters/erb.rb +2 -2
- data/lib/nanoc3/filters/erubis.rb +2 -2
- data/lib/nanoc3/filters/haml.rb +2 -2
- data/lib/nanoc3/filters/kramdown.rb +2 -2
- data/lib/nanoc3/filters/less.rb +32 -1
- data/lib/nanoc3/filters/markaby.rb +2 -2
- data/lib/nanoc3/filters/maruku.rb +2 -2
- data/lib/nanoc3/filters/mustache.rb +2 -2
- data/lib/nanoc3/filters/rainpress.rb +2 -2
- data/lib/nanoc3/filters/rdiscount.rb +4 -3
- data/lib/nanoc3/filters/rdoc.rb +10 -6
- data/lib/nanoc3/filters/redcarpet.rb +2 -2
- data/lib/nanoc3/filters/redcloth.rb +2 -2
- data/lib/nanoc3/filters/rubypants.rb +2 -2
- data/lib/nanoc3/filters/sass.rb +44 -52
- data/lib/nanoc3/filters/slim.rb +2 -2
- data/lib/nanoc3/filters/typogruby.rb +2 -2
- data/lib/nanoc3/filters/uglify_js.rb +42 -0
- data/nanoc3.gemspec +1 -1
- data/tasks/test.rake +6 -0
- data/test/base/core_ext/array_spec.rb +0 -2
- data/test/base/core_ext/hash_spec.rb +0 -2
- data/test/base/core_ext/pathname_spec.rb +0 -2
- data/test/base/core_ext/string_spec.rb +0 -2
- data/test/base/test_checksum_store.rb +0 -2
- data/test/base/test_code_snippet.rb +0 -2
- data/test/base/test_compiler.rb +2 -4
- data/test/base/test_compiler_dsl.rb +1 -3
- data/test/base/test_context.rb +0 -2
- data/test/base/test_data_source.rb +0 -2
- data/test/base/test_dependency_tracker.rb +0 -2
- data/test/base/test_directed_graph.rb +0 -2
- data/test/base/test_filter.rb +0 -2
- data/test/base/test_item.rb +19 -4
- data/test/base/test_item_rep.rb +0 -2
- data/test/base/test_layout.rb +19 -4
- data/test/base/test_memoization.rb +39 -2
- data/test/base/test_notification_center.rb +0 -2
- data/test/base/test_outdatedness_checker.rb +31 -2
- data/test/base/test_plugin.rb +0 -2
- data/test/base/test_rule.rb +0 -2
- data/test/base/test_rule_context.rb +0 -2
- data/test/base/test_site.rb +30 -3
- data/test/cli/commands/test_compile.rb +24 -3
- data/test/cli/commands/test_create_item.rb +5 -3
- data/test/cli/commands/test_create_layout.rb +4 -4
- data/test/cli/commands/test_create_site.rb +5 -5
- data/test/cli/commands/test_help.rb +3 -3
- data/test/cli/commands/test_info.rb +2 -3
- data/test/cli/commands/test_update.rb +0 -2
- data/test/cli/test_cli.rb +40 -0
- data/test/cli/test_logger.rb +0 -2
- data/test/data_sources/test_filesystem.rb +0 -2
- data/test/data_sources/test_filesystem_unified.rb +32 -58
- data/test/data_sources/test_filesystem_verbose.rb +0 -2
- data/test/extra/core_ext/test_enumerable.rb +0 -2
- data/test/extra/core_ext/test_time.rb +0 -2
- data/test/extra/deployers/test_rsync.rb +0 -2
- data/test/extra/test_auto_compiler.rb +5 -7
- data/test/extra/test_file_proxy.rb +0 -2
- data/test/extra/test_vcs.rb +0 -2
- data/test/extra/validators/test_links.rb +0 -2
- data/test/extra/validators/test_w3c.rb +0 -2
- data/test/filters/test_asciidoc.rb +0 -2
- data/test/filters/test_bluecloth.rb +0 -2
- data/test/filters/test_coderay.rb +0 -2
- data/test/filters/test_colorize_syntax.rb +49 -2
- data/test/filters/test_erb.rb +0 -2
- data/test/filters/test_erubis.rb +0 -2
- data/test/filters/test_haml.rb +0 -2
- data/test/filters/test_kramdown.rb +0 -2
- data/test/filters/test_less.rb +59 -5
- data/test/filters/test_markaby.rb +0 -2
- data/test/filters/test_maruku.rb +0 -2
- data/test/filters/test_mustache.rb +0 -2
- data/test/filters/test_rainpress.rb +0 -2
- data/test/filters/test_rdiscount.rb +0 -2
- data/test/filters/test_rdoc.rb +0 -2
- data/test/filters/test_redcarpet.rb +0 -2
- data/test/filters/test_redcloth.rb +0 -2
- data/test/filters/test_relativize_paths.rb +77 -24
- data/test/filters/test_rubypants.rb +0 -2
- data/test/filters/test_sass.rb +136 -10
- data/test/filters/test_slim.rb +0 -2
- data/test/filters/test_typogruby.rb +0 -2
- data/test/filters/test_uglify_js.rb +30 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +3 -0
- data/test/helpers/test_blogging.rb +0 -2
- data/test/helpers/test_breadcrumbs.rb +0 -2
- data/test/helpers/test_capturing.rb +0 -2
- data/test/helpers/test_filtering.rb +0 -2
- data/test/helpers/test_html_escape.rb +0 -2
- data/test/helpers/test_link_to.rb +0 -2
- data/test/helpers/test_rendering.rb +0 -2
- data/test/helpers/test_tagging.rb +0 -2
- data/test/helpers/test_text.rb +0 -2
- data/test/helpers/test_xml_sitemap.rb +0 -2
- data/test/tasks/test_clean.rb +0 -2
- metadata +11 -9
- data/lib/nanoc3/cli/commands.rb +0 -16
- data/lib/nanoc3/cli/commands/help.rb +0 -71
- data/tasks/clean.rake +0 -11
data/test/base/test_layout.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::LayoutTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
@@ -19,10 +17,14 @@ class Nanoc3::LayoutTest < MiniTest::Unit::TestCase
|
|
19
17
|
def test_frozen_identifier
|
20
18
|
layout = Nanoc3::Layout.new("foo", {}, '/foo')
|
21
19
|
|
22
|
-
|
20
|
+
raised = false
|
21
|
+
begin
|
23
22
|
layout.identifier.chop!
|
23
|
+
rescue => error
|
24
|
+
raised = true
|
25
|
+
assert_equal "can't modify frozen string", error.message
|
24
26
|
end
|
25
|
-
|
27
|
+
assert raised, 'Should have raised when trying to modify a frozen string'
|
26
28
|
end
|
27
29
|
|
28
30
|
def test_lookup_with_known_attribute
|
@@ -41,4 +43,17 @@ class Nanoc3::LayoutTest < MiniTest::Unit::TestCase
|
|
41
43
|
assert_equal(nil, layout[:filter])
|
42
44
|
end
|
43
45
|
|
46
|
+
def test_dump_and_load
|
47
|
+
layout = Nanoc3::Layout.new(
|
48
|
+
"foobar",
|
49
|
+
{ :a => { :b => 123 }},
|
50
|
+
'/foo/')
|
51
|
+
|
52
|
+
layout = Marshal.load(Marshal.dump(layout))
|
53
|
+
|
54
|
+
assert_equal '/foo/', layout.identifier
|
55
|
+
assert_equal 'foobar', layout.raw_content
|
56
|
+
assert_equal({ :a => { :b => 123 }}, layout.attributes)
|
57
|
+
end
|
58
|
+
|
44
59
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::MemoizationTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
@@ -36,6 +34,33 @@ class Nanoc3::MemoizationTest < MiniTest::Unit::TestCase
|
|
36
34
|
|
37
35
|
end
|
38
36
|
|
37
|
+
class EqualSample
|
38
|
+
|
39
|
+
extend Nanoc3::Memoization
|
40
|
+
|
41
|
+
def initialize(value)
|
42
|
+
@value = value
|
43
|
+
end
|
44
|
+
|
45
|
+
def hash
|
46
|
+
4
|
47
|
+
end
|
48
|
+
|
49
|
+
def eql?(other)
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
def ==(other)
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
def run(n)
|
58
|
+
@value*10 + n
|
59
|
+
end
|
60
|
+
memoize :run
|
61
|
+
|
62
|
+
end
|
63
|
+
|
39
64
|
def test
|
40
65
|
sample1a = Sample1.new(10)
|
41
66
|
sample1b = Sample1.new(15)
|
@@ -50,4 +75,16 @@ class Nanoc3::MemoizationTest < MiniTest::Unit::TestCase
|
|
50
75
|
end
|
51
76
|
end
|
52
77
|
|
78
|
+
def test_equal
|
79
|
+
sample1 = EqualSample.new(2)
|
80
|
+
sample2 = EqualSample.new(3)
|
81
|
+
|
82
|
+
3.times do
|
83
|
+
assert_equal (2*10+5), sample1.run(5)
|
84
|
+
assert_equal (2*10+3), sample1.run(3)
|
85
|
+
assert_equal (3*10+5), sample2.run(5)
|
86
|
+
assert_equal (3*10+3), sample2.run(3)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
53
90
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::OutdatednessCheckerTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
@@ -362,4 +360,35 @@ class Nanoc3::OutdatednessCheckerTest < MiniTest::Unit::TestCase
|
|
362
360
|
end
|
363
361
|
end
|
364
362
|
|
363
|
+
def test_items_in_rules_should_not_cause_outdatedness
|
364
|
+
# Create site
|
365
|
+
with_site(:name => 'foo') do |site|
|
366
|
+
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
367
|
+
File.open('Rules', 'w') do |io|
|
368
|
+
io.write("compile '/' do\n")
|
369
|
+
io.write(" filter :erb, :stuff => @items\n")
|
370
|
+
io.write("end\n")
|
371
|
+
io.write("\n")
|
372
|
+
io.write("route '/' do\n")
|
373
|
+
io.write(" '/index.html'\n")
|
374
|
+
io.write("end\n")
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
# Compile
|
379
|
+
FileUtils.cd('foo') do
|
380
|
+
site = Nanoc3::Site.new('.')
|
381
|
+
site.compile
|
382
|
+
end
|
383
|
+
|
384
|
+
# Assert not outdated
|
385
|
+
FileUtils.cd('foo') do
|
386
|
+
site = Nanoc3::Site.new('.')
|
387
|
+
outdatedness_checker = site.compiler.outdatedness_checker
|
388
|
+
site.items.each do |item|
|
389
|
+
refute outdatedness_checker.outdated?(item), "item should not be outdated"
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
365
394
|
end
|
data/test/base/test_plugin.rb
CHANGED
data/test/base/test_rule.rb
CHANGED
data/test/base/test_site.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::SiteTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
@@ -55,7 +53,7 @@ EOF
|
|
55
53
|
|
56
54
|
def test_load_data_sources_first
|
57
55
|
# Create site
|
58
|
-
Nanoc3::CLI
|
56
|
+
Nanoc3::CLI.run %w( create_site bar)
|
59
57
|
|
60
58
|
FileUtils.cd('bar') do
|
61
59
|
# Create data source code
|
@@ -82,6 +80,35 @@ EOF
|
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
83
|
+
def test_setup_child_parent_links
|
84
|
+
Nanoc3::CLI.run %w( create_site bar)
|
85
|
+
FileUtils.cd('bar') do
|
86
|
+
Nanoc3::CLI.run %w( create_item /parent/ )
|
87
|
+
Nanoc3::CLI.run %w( create_item /parent/foo/ )
|
88
|
+
Nanoc3::CLI.run %w( create_item /parent/bar/ )
|
89
|
+
Nanoc3::CLI.run %w( create_item /parent/bar/qux/ )
|
90
|
+
|
91
|
+
site = Nanoc3::Site.new('.')
|
92
|
+
|
93
|
+
root = site.items.find { |i| i.identifier == '/' }
|
94
|
+
style = site.items.find { |i| i.identifier == '/stylesheet/' }
|
95
|
+
parent = site.items.find { |i| i.identifier == '/parent/' }
|
96
|
+
foo = site.items.find { |i| i.identifier == '/parent/foo/' }
|
97
|
+
bar = site.items.find { |i| i.identifier == '/parent/bar/' }
|
98
|
+
qux = site.items.find { |i| i.identifier == '/parent/bar/qux/' }
|
99
|
+
|
100
|
+
assert_equal Set.new([ parent, style ]), Set.new(root.children)
|
101
|
+
assert_equal Set.new([ foo, bar ]), Set.new(parent.children)
|
102
|
+
assert_equal Set.new([ qux ]), Set.new(bar.children)
|
103
|
+
|
104
|
+
assert_equal nil, root.parent
|
105
|
+
assert_equal root, parent.parent
|
106
|
+
assert_equal parent, foo.parent
|
107
|
+
assert_equal parent, bar.parent
|
108
|
+
assert_equal bar, qux.parent
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
85
112
|
end
|
86
113
|
|
87
114
|
describe 'Nanoc3::Site#initialize' do
|
@@ -1,12 +1,33 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::CLI::Commands::CompileTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
8
6
|
|
9
|
-
def
|
7
|
+
def test_profiling_information
|
8
|
+
with_site do |site|
|
9
|
+
Nanoc3::CLI.run %w( create_item foo )
|
10
|
+
Nanoc3::CLI.run %w( create_item bar )
|
11
|
+
Nanoc3::CLI.run %w( create_item baz )
|
12
|
+
|
13
|
+
File.open('Rules', 'w') do |io|
|
14
|
+
io.write "compile '*' do\n"
|
15
|
+
io.write " filter :erb\n"
|
16
|
+
io.write "end\n"
|
17
|
+
io.write "\n"
|
18
|
+
io.write "route '*' do\n"
|
19
|
+
io.write " if item.binary?\n"
|
20
|
+
io.write " item.identifier.chop + '.' + item[:extension]\n"
|
21
|
+
io.write " else\n"
|
22
|
+
io.write " item.identifier + 'index.html'\n"
|
23
|
+
io.write " end\n"
|
24
|
+
io.write "end\n"
|
25
|
+
io.write "\n"
|
26
|
+
io.write "layout '*', :erb\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
Nanoc3::CLI.run %w( compile --verbose )
|
30
|
+
end
|
10
31
|
end
|
11
32
|
|
12
33
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::CLI::Commands::CreateItemTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
8
6
|
|
9
|
-
def
|
7
|
+
def test_run
|
8
|
+
with_site do |site|
|
9
|
+
Nanoc3::CLI.run %w( create_item /blah/ )
|
10
|
+
assert File.file?('content/blah.html')
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::CLI::Commands::CreateLayoutTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
8
6
|
|
9
7
|
def test_can_compile_new_layout
|
10
|
-
|
8
|
+
require 'nanoc3/cli'
|
9
|
+
|
10
|
+
Nanoc3::CLI.run %w( create_site foo )
|
11
11
|
|
12
12
|
FileUtils.cd('foo') do
|
13
13
|
# Create new layout
|
14
|
-
Nanoc3::CLI
|
14
|
+
Nanoc3::CLI.run %w( create_layout moo )
|
15
15
|
|
16
16
|
# Makes rules use new layout
|
17
17
|
rules_raw = File.read('Rules')
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::CLI::Commands::CreateSiteTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
8
6
|
|
9
7
|
def test_create_site_with_existing_name
|
10
|
-
Nanoc3::CLI
|
11
|
-
assert_raises(SystemExit)
|
8
|
+
Nanoc3::CLI.run %w( create_site foo )
|
9
|
+
assert_raises(SystemExit) do
|
10
|
+
Nanoc3::CLI.run %w( create_site foo )
|
11
|
+
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_can_compile_new_site
|
15
|
-
Nanoc3::CLI
|
15
|
+
Nanoc3::CLI.run %w( create_site foo )
|
16
16
|
|
17
17
|
FileUtils.cd('foo') do
|
18
18
|
site = Nanoc3::Site.new('.')
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::CLI::Commands::HelpTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
8
6
|
|
9
|
-
def
|
7
|
+
def test_run
|
8
|
+
Nanoc3::CLI.run %w( help )
|
9
|
+
Nanoc3::CLI.run %w( help co )
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc3::CLITest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc3::TestHelpers
|
6
|
+
|
7
|
+
COMMAND_CODE = <<EOS
|
8
|
+
# encoding: utf-8
|
9
|
+
|
10
|
+
usage '_test [options]'
|
11
|
+
summary 'meh'
|
12
|
+
description 'longer meh'
|
13
|
+
|
14
|
+
run do |opts, args, cmd|
|
15
|
+
File.open('_test.out', 'w') { |io| io.write('It works!') }
|
16
|
+
end
|
17
|
+
EOS
|
18
|
+
|
19
|
+
def test_load_custom_commands
|
20
|
+
Nanoc3::CLI.run %w( create_site foo )
|
21
|
+
|
22
|
+
FileUtils.cd('foo') do
|
23
|
+
# Create command
|
24
|
+
FileUtils.mkdir_p('commands')
|
25
|
+
File.open('commands/_test.rb', 'w') { |io| io.write(COMMAND_CODE) }
|
26
|
+
|
27
|
+
# Run command
|
28
|
+
begin
|
29
|
+
Nanoc3::CLI.run %w( _test )
|
30
|
+
rescue SystemExit
|
31
|
+
assert false, 'Running _test should not cause system exit'
|
32
|
+
end
|
33
|
+
|
34
|
+
# Check
|
35
|
+
assert File.file?('_test.out')
|
36
|
+
assert_equal 'It works!', File.read('_test.out')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/test/cli/test_logger.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
3
|
class Nanoc3::DataSources::FilesystemUnifiedTest < MiniTest::Unit::TestCase
|
6
4
|
|
7
5
|
include Nanoc3::TestHelpers
|
@@ -191,78 +189,54 @@ class Nanoc3::DataSources::FilesystemUnifiedTest < MiniTest::Unit::TestCase
|
|
191
189
|
end
|
192
190
|
|
193
191
|
def test_identifier_for_filename_with_subfilename_allowing_periods_in_identifiers
|
194
|
-
|
195
|
-
data_source = new_data_source(:allow_periods_in_identifiers => true)
|
196
|
-
|
197
|
-
# Build directory
|
198
|
-
FileUtils.mkdir_p('foo')
|
199
|
-
File.open('foo/bar.yaml', 'w') { |io| io.write('test') }
|
200
|
-
File.open('foo/bar.html', 'w') { |io| io.write('test') }
|
201
|
-
File.open('foo/quxbar.yaml', 'w') { |io| io.write('test') }
|
202
|
-
File.open('foo/quxbar.html', 'w') { |io| io.write('test') }
|
203
|
-
File.open('foo/barqux.yaml', 'w') { |io| io.write('test') }
|
204
|
-
File.open('foo/barqux.html', 'w') { |io| io.write('test') }
|
205
|
-
File.open('foo/quxbarqux.yaml', 'w') { |io| io.write('test') }
|
206
|
-
File.open('foo/quxbarqux.html', 'w') { |io| io.write('test') }
|
207
|
-
File.open('foo/qux.bar.yaml', 'w') { |io| io.write('test') }
|
208
|
-
File.open('foo/qux.bar.html', 'w') { |io| io.write('test') }
|
209
|
-
File.open('foo/bar.qux.yaml', 'w') { |io| io.write('test') }
|
210
|
-
File.open('foo/bar.qux.html', 'w') { |io| io.write('test') }
|
211
|
-
File.open('foo/qux.bar.qux.yaml', 'w') { |io| io.write('test') }
|
212
|
-
File.open('foo/qux.bar.qux.html', 'w') { |io| io.write('test') }
|
213
|
-
|
214
|
-
# Check content filename
|
215
|
-
{
|
192
|
+
expectations = {
|
216
193
|
'foo/bar.yaml' => '/foo/bar/',
|
217
194
|
'foo/quxbar.yaml' => '/foo/quxbar/',
|
218
195
|
'foo/barqux.yaml' => '/foo/barqux/',
|
219
196
|
'foo/quxbarqux.yaml' => '/foo/quxbarqux/',
|
220
197
|
'foo/qux.bar.yaml' => '/foo/qux.bar/',
|
221
198
|
'foo/bar.qux.yaml' => '/foo/bar.qux/',
|
222
|
-
'foo/qux.bar.qux.yaml' => '/foo/qux.bar.qux/'
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
199
|
+
'foo/qux.bar.qux.yaml' => '/foo/qux.bar.qux/',
|
200
|
+
'foo/index.yaml' => '/foo/',
|
201
|
+
'index.yaml' => '/',
|
202
|
+
'foo/blah_index.yaml' => '/foo/blah_index/'
|
203
|
+
}
|
204
|
+
|
205
|
+
data_source = new_data_source(:allow_periods_in_identifiers => true)
|
206
|
+
expectations.each_pair do |meta_filename, expected_identifier|
|
207
|
+
content_filename = meta_filename.sub(/yaml$/, 'html')
|
208
|
+
[ meta_filename, content_filename ].each do |filename|
|
209
|
+
assert_equal(
|
210
|
+
expected_identifier,
|
211
|
+
data_source.instance_eval { identifier_for_filename(filename) }
|
212
|
+
)
|
213
|
+
end
|
228
214
|
end
|
229
215
|
end
|
230
216
|
|
231
217
|
def test_identifier_for_filename_with_subfilename_disallowing_periods_in_identifiers
|
232
|
-
|
233
|
-
data_source = new_data_source
|
234
|
-
|
235
|
-
# Build directory
|
236
|
-
FileUtils.mkdir_p('foo')
|
237
|
-
File.open('foo/bar.yaml', 'w') { |io| io.write('test') }
|
238
|
-
File.open('foo/bar.html', 'w') { |io| io.write('test') }
|
239
|
-
File.open('foo/quxbar.yaml', 'w') { |io| io.write('test') }
|
240
|
-
File.open('foo/quxbar.html', 'w') { |io| io.write('test') }
|
241
|
-
File.open('foo/barqux.yaml', 'w') { |io| io.write('test') }
|
242
|
-
File.open('foo/barqux.html', 'w') { |io| io.write('test') }
|
243
|
-
File.open('foo/quxbarqux.yaml', 'w') { |io| io.write('test') }
|
244
|
-
File.open('foo/quxbarqux.html', 'w') { |io| io.write('test') }
|
245
|
-
File.open('foo/qux.bar.yaml', 'w') { |io| io.write('test') }
|
246
|
-
File.open('foo/qux.bar.html', 'w') { |io| io.write('test') }
|
247
|
-
File.open('foo/bar.qux.yaml', 'w') { |io| io.write('test') }
|
248
|
-
File.open('foo/bar.qux.html', 'w') { |io| io.write('test') }
|
249
|
-
File.open('foo/qux.bar.qux.yaml', 'w') { |io| io.write('test') }
|
250
|
-
File.open('foo/qux.bar.qux.html', 'w') { |io| io.write('test') }
|
251
|
-
|
252
|
-
# Check content filename
|
253
|
-
{
|
218
|
+
expectations = {
|
254
219
|
'foo/bar.yaml' => '/foo/bar/',
|
255
220
|
'foo/quxbar.yaml' => '/foo/quxbar/',
|
256
221
|
'foo/barqux.yaml' => '/foo/barqux/',
|
257
222
|
'foo/quxbarqux.yaml' => '/foo/quxbarqux/',
|
258
223
|
'foo/qux.bar.yaml' => '/foo/qux/',
|
259
224
|
'foo/bar.qux.yaml' => '/foo/bar/',
|
260
|
-
'foo/qux.bar.qux.yaml' => '/foo/qux/'
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
225
|
+
'foo/qux.bar.qux.yaml' => '/foo/qux/',
|
226
|
+
'foo/index.yaml' => '/foo/',
|
227
|
+
'index.yaml' => '/',
|
228
|
+
'foo/blah_index.yaml' => '/foo/blah_index/'
|
229
|
+
}
|
230
|
+
|
231
|
+
data_source = new_data_source
|
232
|
+
expectations.each_pair do |meta_filename, expected_identifier|
|
233
|
+
content_filename = meta_filename.sub(/yaml$/, 'html')
|
234
|
+
[ meta_filename, content_filename ].each do |filename|
|
235
|
+
assert_equal(
|
236
|
+
expected_identifier,
|
237
|
+
data_source.instance_eval { identifier_for_filename(filename) }
|
238
|
+
)
|
239
|
+
end
|
266
240
|
end
|
267
241
|
end
|
268
242
|
|