nanoc 3.8.0 → 4.0.0a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +322 -0
- data/NEWS.md +6 -0
- data/bin/nanoc +0 -18
- data/lib/nanoc.rb +5 -3
- data/lib/nanoc/base.rb +24 -6
- data/lib/nanoc/base/checksummer.rb +6 -4
- data/lib/nanoc/base/compilation/checksum_store.rb +4 -4
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +5 -5
- data/lib/nanoc/base/compilation/compiler.rb +60 -65
- data/lib/nanoc/base/compilation/compiler_dsl.rb +11 -9
- data/lib/nanoc/base/compilation/dependency_tracker.rb +24 -38
- data/lib/nanoc/base/compilation/filter.rb +22 -7
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +14 -12
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +8 -8
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +32 -32
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +3 -1
- data/lib/nanoc/base/compilation/rule.rb +9 -7
- data/lib/nanoc/base/compilation/rule_context.rb +15 -15
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +3 -3
- data/lib/nanoc/base/compilation/rule_memory_store.rb +7 -7
- data/lib/nanoc/base/compilation/rules_collection.rb +28 -30
- data/lib/nanoc/base/context.rb +2 -2
- data/lib/nanoc/base/core_ext/array.rb +17 -25
- data/lib/nanoc/base/core_ext/hash.rb +17 -25
- data/lib/nanoc/base/core_ext/pathname.rb +4 -2
- data/lib/nanoc/base/core_ext/string.rb +5 -3
- data/lib/nanoc/base/directed_graph.rb +4 -9
- data/lib/nanoc/base/error.rb +7 -0
- data/lib/nanoc/base/errors.rb +16 -23
- data/lib/nanoc/base/memoization.rb +4 -2
- data/lib/nanoc/base/notification_center.rb +3 -1
- data/lib/nanoc/base/plugin_registry.rb +14 -21
- data/lib/nanoc/base/result_data/item_rep.rb +43 -88
- data/lib/nanoc/base/source_data/code_snippet.rb +6 -4
- data/lib/nanoc/base/source_data/configuration.rb +3 -1
- data/lib/nanoc/base/source_data/data_source.rb +12 -94
- data/lib/nanoc/base/source_data/identifier.rb +50 -0
- data/lib/nanoc/base/source_data/item.rb +24 -67
- data/lib/nanoc/base/source_data/item_array.rb +6 -4
- data/lib/nanoc/base/source_data/layout.rb +17 -28
- data/lib/nanoc/base/source_data/site.rb +33 -44
- data/lib/nanoc/base/store.rb +3 -5
- data/lib/nanoc/base/temp_filename_factory.rb +3 -2
- data/lib/nanoc/base/views/config.rb +19 -0
- data/lib/nanoc/base/views/item.rb +77 -0
- data/lib/nanoc/base/views/item_collection.rb +43 -0
- data/lib/nanoc/base/views/item_rep.rb +125 -0
- data/lib/nanoc/base/views/layout.rb +42 -0
- data/lib/nanoc/base/views/layout_collection.rb +26 -0
- data/lib/nanoc/base/views/mutable_config.rb +9 -0
- data/lib/nanoc/base/views/mutable_item.rb +9 -0
- data/lib/nanoc/base/views/mutable_item_collection.rb +18 -0
- data/lib/nanoc/base/views/mutable_layout.rb +9 -0
- data/lib/nanoc/base/views/mutable_layout_collection.rb +18 -0
- data/lib/nanoc/base/views/site.rb +35 -0
- data/lib/nanoc/cli.rb +3 -6
- data/lib/nanoc/cli/ansi_string_colorizer.rb +2 -0
- data/lib/nanoc/cli/cleaning_stream.rb +2 -0
- data/lib/nanoc/cli/command_runner.rb +8 -42
- data/lib/nanoc/cli/commands/check.rb +2 -2
- data/lib/nanoc/cli/commands/compile.rb +19 -34
- data/lib/nanoc/cli/commands/create-site.rb +46 -83
- data/lib/nanoc/cli/commands/deploy.rb +4 -4
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/cli/commands/show-plugins.rb +4 -6
- data/lib/nanoc/cli/error_handler.rb +4 -14
- data/lib/nanoc/cli/logger.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners.rb +1 -0
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +2 -0
- data/lib/nanoc/data_sources.rb +1 -17
- data/lib/nanoc/data_sources/filesystem.rb +6 -37
- data/lib/nanoc/data_sources/filesystem_unified.rb +5 -3
- data/lib/nanoc/data_sources/filesystem_verbose.rb +5 -3
- data/lib/nanoc/data_sources/static.rb +4 -2
- data/lib/nanoc/extra.rb +1 -13
- data/lib/nanoc/extra/checking.rb +1 -0
- data/lib/nanoc/extra/checking/check.rb +4 -2
- data/lib/nanoc/extra/checking/checks.rb +1 -0
- data/lib/nanoc/extra/checking/checks/css.rb +1 -0
- data/lib/nanoc/extra/checking/checks/external_links.rb +2 -0
- data/lib/nanoc/extra/checking/checks/html.rb +1 -0
- data/lib/nanoc/extra/checking/checks/internal_links.rb +2 -0
- data/lib/nanoc/extra/checking/checks/mixed_content.rb +2 -0
- data/lib/nanoc/extra/checking/checks/stale.rb +1 -0
- data/lib/nanoc/extra/checking/dsl.rb +1 -0
- data/lib/nanoc/extra/checking/issue.rb +1 -0
- data/lib/nanoc/extra/checking/runner.rb +3 -3
- data/lib/nanoc/extra/core_ext/pathname.rb +5 -3
- data/lib/nanoc/extra/core_ext/time.rb +4 -2
- data/lib/nanoc/extra/deployer.rb +3 -1
- data/lib/nanoc/extra/deployers.rb +1 -0
- data/lib/nanoc/extra/deployers/fog.rb +2 -0
- data/lib/nanoc/extra/deployers/rsync.rb +2 -0
- data/lib/nanoc/extra/filesystem_tools.rb +3 -7
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -0
- data/lib/nanoc/extra/link_collector.rb +1 -0
- data/lib/nanoc/extra/piper.rb +2 -1
- data/lib/nanoc/extra/pruner.rb +5 -3
- data/lib/nanoc/filters.rb +1 -2
- data/lib/nanoc/filters/asciidoc.rb +2 -0
- data/lib/nanoc/filters/bluecloth.rb +1 -0
- data/lib/nanoc/filters/coffeescript.rb +2 -0
- data/lib/nanoc/filters/colorize_syntax.rb +1 -12
- data/lib/nanoc/filters/erb.rb +2 -1
- data/lib/nanoc/filters/erubis.rb +2 -1
- data/lib/nanoc/filters/haml.rb +2 -1
- data/lib/nanoc/filters/handlebars.rb +2 -0
- data/lib/nanoc/filters/kramdown.rb +1 -0
- data/lib/nanoc/filters/less.rb +1 -0
- data/lib/nanoc/filters/markaby.rb +1 -0
- data/lib/nanoc/filters/maruku.rb +1 -0
- data/lib/nanoc/filters/mustache.rb +2 -0
- data/lib/nanoc/filters/pandoc.rb +1 -0
- data/lib/nanoc/filters/rainpress.rb +1 -0
- data/lib/nanoc/filters/rdiscount.rb +1 -0
- data/lib/nanoc/filters/rdoc.rb +1 -0
- data/lib/nanoc/filters/redcarpet.rb +2 -0
- data/lib/nanoc/filters/redcloth.rb +1 -0
- data/lib/nanoc/filters/relativize_paths.rb +1 -0
- data/lib/nanoc/filters/rubypants.rb +1 -0
- data/lib/nanoc/filters/sass.rb +1 -0
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +2 -0
- data/lib/nanoc/filters/slim.rb +3 -1
- data/lib/nanoc/filters/typogruby.rb +2 -0
- data/lib/nanoc/filters/uglify_js.rb +1 -0
- data/lib/nanoc/filters/xsl.rb +2 -0
- data/lib/nanoc/filters/yui_compressor.rb +2 -0
- data/lib/nanoc/helpers/blogging.rb +30 -30
- data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
- data/lib/nanoc/helpers/capturing.rb +6 -17
- data/lib/nanoc/helpers/filtering.rb +3 -3
- data/lib/nanoc/helpers/link_to.rb +3 -3
- data/lib/nanoc/helpers/rendering.rb +11 -11
- data/lib/nanoc/helpers/xml_sitemap.rb +3 -3
- data/lib/nanoc/tasks.rb +1 -0
- data/lib/nanoc/tasks/clean.rake +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/tasks/doc.rake +2 -1
- data/tasks/test.rake +7 -1
- data/test/base/checksummer_spec.rb +15 -15
- data/test/base/core_ext/array_spec.rb +10 -10
- data/test/base/core_ext/hash_spec.rb +16 -16
- data/test/base/core_ext/pathname_spec.rb +2 -2
- data/test/base/core_ext/string_spec.rb +9 -9
- data/test/base/temp_filename_factory_spec.rb +3 -7
- data/test/base/test_checksum_store.rb +5 -5
- data/test/base/test_code_snippet.rb +3 -3
- data/test/base/test_compiler.rb +29 -29
- data/test/base/test_compiler_dsl.rb +23 -23
- data/test/base/test_context.rb +4 -4
- data/test/base/test_data_source.rb +17 -7
- data/test/base/test_dependency_tracker.rb +29 -29
- data/test/base/test_directed_graph.rb +27 -27
- data/test/base/test_item.rb +23 -21
- data/test/base/test_item_array.rb +18 -18
- data/test/base/test_item_rep.rb +76 -76
- data/test/base/test_item_rep_recorder_proxy.rb +4 -4
- data/test/base/test_layout.rb +8 -16
- data/test/base/test_memoization.rb +4 -4
- data/test/base/test_notification_center.rb +6 -6
- data/test/base/test_outdatedness_checker.rb +18 -18
- data/test/base/test_plugin.rb +1 -1
- data/test/base/test_rule.rb +2 -2
- data/test/base/test_rule_context.rb +5 -5
- data/test/base/test_site.rb +62 -38
- data/test/base/test_store.rb +2 -2
- data/test/cli/commands/test_check.rb +1 -1
- data/test/cli/commands/test_compile.rb +24 -18
- data/test/cli/commands/test_create_site.rb +5 -7
- data/test/cli/commands/test_deploy.rb +1 -1
- data/test/data_sources/test_filesystem.rb +22 -67
- data/test/data_sources/test_filesystem_unified.rb +10 -23
- data/test/data_sources/test_filesystem_verbose.rb +8 -53
- data/test/data_sources/test_static.rb +9 -9
- data/test/extra/checking/checks/test_stale.rb +1 -1
- data/test/extra/core_ext/test_pathname.rb +3 -3
- data/test/extra/core_ext/test_time.rb +4 -4
- data/test/extra/test_filesystem_tools.rb +1 -1
- data/test/filters/test_handlebars.rb +3 -3
- data/test/filters/test_less.rb +6 -6
- data/test/filters/test_mustache.rb +2 -2
- data/test/filters/test_relativize_paths.rb +81 -81
- data/test/filters/test_sass.rb +7 -7
- data/test/filters/test_xsl.rb +6 -6
- data/test/helper.rb +1 -1
- data/test/helpers/test_blogging.rb +78 -99
- data/test/helpers/test_breadcrumbs.rb +12 -12
- data/test/helpers/test_capturing.rb +10 -11
- data/test/helpers/test_filtering.rb +6 -6
- data/test/helpers/test_rendering.rb +3 -3
- data/test/helpers/test_tagging.rb +7 -7
- data/test/helpers/test_xml_sitemap.rb +34 -33
- metadata +19 -43
- data/lib/nanoc/cli/commands/autocompile.rb +0 -69
- data/lib/nanoc/cli/commands/create-item.rb +0 -55
- data/lib/nanoc/cli/commands/create-layout.rb +0 -68
- data/lib/nanoc/cli/commands/sync.rb +0 -32
- data/lib/nanoc/cli/commands/update.rb +0 -63
- data/lib/nanoc/cli/commands/validate-css.rb +0 -20
- data/lib/nanoc/cli/commands/validate-html.rb +0 -20
- data/lib/nanoc/cli/commands/validate-links.rb +0 -27
- data/lib/nanoc/cli/commands/watch.rb +0 -176
- data/lib/nanoc/data_sources/deprecated/delicious.rb +0 -38
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +0 -85
- data/lib/nanoc/data_sources/deprecated/twitter.rb +0 -34
- data/lib/nanoc/extra/auto_compiler.rb +0 -99
- data/lib/nanoc/extra/chick.rb +0 -117
- data/lib/nanoc/extra/file_proxy.rb +0 -36
- data/lib/nanoc/extra/validators.rb +0 -8
- data/lib/nanoc/extra/validators/links.rb +0 -18
- data/lib/nanoc/extra/validators/w3c.rb +0 -23
- data/lib/nanoc/extra/vcs.rb +0 -62
- data/lib/nanoc/extra/vcses.rb +0 -15
- data/lib/nanoc/extra/vcses/bazaar.rb +0 -21
- data/lib/nanoc/extra/vcses/dummy.rb +0 -20
- data/lib/nanoc/extra/vcses/git.rb +0 -21
- data/lib/nanoc/extra/vcses/mercurial.rb +0 -21
- data/lib/nanoc/extra/vcses/subversion.rb +0 -21
- data/lib/nanoc/filters/coderay.rb +0 -19
- data/lib/nanoc3.rb +0 -3
- data/lib/nanoc3/cli.rb +0 -3
- data/lib/nanoc3/tasks.rb +0 -3
- data/test/cli/commands/test_create_item.rb +0 -10
- data/test/cli/commands/test_create_layout.rb +0 -24
- data/test/cli/commands/test_sync.rb +0 -27
- data/test/cli/commands/test_update.rb +0 -6
- data/test/cli/commands/test_watch.rb +0 -74
- data/test/extra/test_auto_compiler.rb +0 -437
- data/test/extra/test_vcs.rb +0 -18
- data/test/extra/validators/test_links.rb +0 -4
- data/test/extra/validators/test_w3c.rb +0 -37
- data/test/filters/test_coderay.rb +0 -40
data/test/base/test_store.rb
CHANGED
@@ -10,7 +10,7 @@ class Nanoc::CLI::Commands::CheckTest < Nanoc::TestCase
|
|
10
10
|
|
11
11
|
# Should raise now
|
12
12
|
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
13
|
-
assert_raises Nanoc::Errors::GenericTrivial do
|
13
|
+
assert_raises Nanoc::Int::Errors::GenericTrivial do
|
14
14
|
Nanoc::CLI.run %w( check stale )
|
15
15
|
end
|
16
16
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
4
4
|
def test_profiling_information
|
5
5
|
with_site do |_site|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
File.open('content/foo.md', 'w') { |io| io << 'asdf' }
|
7
|
+
File.open('content/bar.md', 'w') { |io| io << 'asdf' }
|
8
|
+
File.open('content/baz.md', 'w') { |io| io << 'asdf' }
|
9
9
|
|
10
10
|
File.open('Rules', 'w') do |io|
|
11
11
|
io.write "compile '*' do\n"
|
@@ -29,9 +29,9 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
29
29
|
|
30
30
|
def test_auto_prune
|
31
31
|
with_site do |_site|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
File.open('content/foo.md', 'w') { |io| io << 'asdf' }
|
33
|
+
File.open('content/bar.md', 'w') { |io| io << 'asdf' }
|
34
|
+
File.open('content/baz.md', 'w') { |io| io << 'asdf' }
|
35
35
|
|
36
36
|
File.open('Rules', 'w') do |io|
|
37
37
|
io.write "compile '*' do\n"
|
@@ -70,9 +70,9 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
70
70
|
|
71
71
|
def test_auto_prune_with_exclude
|
72
72
|
with_site do |_site|
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
File.open('content/foo.md', 'w') { |io| io << 'asdf' }
|
74
|
+
File.open('content/bar.md', 'w') { |io| io << 'asdf' }
|
75
|
+
File.open('content/baz.md', 'w') { |io| io << 'asdf' }
|
76
76
|
|
77
77
|
File.open('Rules', 'w') do |io|
|
78
78
|
io.write "compile '*' do\n"
|
@@ -152,16 +152,16 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
152
152
|
|
153
153
|
def test_file_action_printer_normal
|
154
154
|
# Create data
|
155
|
-
item = Nanoc::Item.new('content', {}, '/')
|
156
|
-
rep = Nanoc::ItemRep.new(item, :default)
|
157
|
-
rep.
|
155
|
+
item = Nanoc::Int::Item.new('content', {}, '/')
|
156
|
+
rep = Nanoc::Int::ItemRep.new(item, :default)
|
157
|
+
rep.raw_paths[:last] = 'output/foo.txt'
|
158
158
|
rep.compiled = true
|
159
159
|
|
160
160
|
# Listen
|
161
161
|
listener = new_file_action_printer([rep])
|
162
162
|
listener.start
|
163
|
-
Nanoc::NotificationCenter.post(:compilation_started, rep)
|
164
|
-
Nanoc::NotificationCenter.post(:rep_written, rep, rep.raw_path, false, true)
|
163
|
+
Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
|
164
|
+
Nanoc::Int::NotificationCenter.post(:rep_written, rep, rep.raw_path, false, true)
|
165
165
|
listener.stop
|
166
166
|
|
167
167
|
# Check
|
@@ -174,14 +174,14 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
174
174
|
|
175
175
|
def test_file_action_printer_skip
|
176
176
|
# Create data
|
177
|
-
item = Nanoc::Item.new('content', {}, '/')
|
178
|
-
rep = Nanoc::ItemRep.new(item, :default)
|
179
|
-
rep.
|
177
|
+
item = Nanoc::Int::Item.new('content', {}, '/')
|
178
|
+
rep = Nanoc::Int::ItemRep.new(item, :default)
|
179
|
+
rep.raw_paths[:last] = 'output/foo.txt'
|
180
180
|
|
181
181
|
# Listen
|
182
182
|
listener = new_file_action_printer([rep])
|
183
183
|
listener.start
|
184
|
-
Nanoc::NotificationCenter.post(:compilation_started, rep)
|
184
|
+
Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
|
185
185
|
listener.stop
|
186
186
|
|
187
187
|
# Check
|
@@ -193,6 +193,12 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def new_file_action_printer(reps)
|
196
|
+
# Ensure CLI is loaded
|
197
|
+
begin
|
198
|
+
Nanoc::CLI.run(%w( help %))
|
199
|
+
rescue SystemExit
|
200
|
+
end
|
201
|
+
|
196
202
|
listener = Nanoc::CLI::Commands::Compile::FileActionPrinter.new(reps: reps)
|
197
203
|
|
198
204
|
def listener.log(level, action, path, duration)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
4
4
|
def test_create_site_with_existing_name
|
5
5
|
Nanoc::CLI.run %w( create_site foo )
|
6
|
-
assert_raises(::Nanoc::Errors::GenericTrivial) do
|
6
|
+
assert_raises(::Nanoc::Int::Errors::GenericTrivial) do
|
7
7
|
Nanoc::CLI.run %w( create_site foo )
|
8
8
|
end
|
9
9
|
end
|
@@ -12,8 +12,7 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
12
12
|
Nanoc::CLI.run %w( create_site foo )
|
13
13
|
|
14
14
|
FileUtils.cd('foo') do
|
15
|
-
site = Nanoc::Site.new('.')
|
16
|
-
site.load_data
|
15
|
+
site = Nanoc::Int::Site.new('.')
|
17
16
|
site.compile
|
18
17
|
end
|
19
18
|
end
|
@@ -23,8 +22,7 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
23
22
|
|
24
23
|
FileUtils.cd('foo') do
|
25
24
|
File.open('content/blah', 'w') { |io| io << 'asdf' }
|
26
|
-
site = Nanoc::Site.new('.')
|
27
|
-
site.load_data
|
25
|
+
site = Nanoc::Int::Site.new('.')
|
28
26
|
site.compile
|
29
27
|
|
30
28
|
assert File.file?('output/blah')
|
@@ -45,7 +43,7 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
45
43
|
FileUtils.cd('foo') do
|
46
44
|
# Try with encoding = default encoding = utf-8
|
47
45
|
File.open('content/index.html', 'w') { |io| io.write("Hello <\xD6>!\n") }
|
48
|
-
site = Nanoc::Site.new('.')
|
46
|
+
site = Nanoc::Int::Site.new('.')
|
49
47
|
exception = assert_raises(RuntimeError) do
|
50
48
|
site.compile
|
51
49
|
end
|
@@ -53,7 +51,7 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
53
51
|
|
54
52
|
# Try with encoding = specific
|
55
53
|
File.open('nanoc.yaml', 'w') { |io| io.write("meh: true\n") }
|
56
|
-
site = Nanoc::Site.new('.')
|
54
|
+
site = Nanoc::Int::Site.new('.')
|
57
55
|
site.compile
|
58
56
|
end
|
59
57
|
FileUtils
|
@@ -137,7 +137,7 @@ class Nanoc::CLI::Commands::DeployTest < Nanoc::TestCase
|
|
137
137
|
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
138
138
|
|
139
139
|
capturing_stdio do
|
140
|
-
err = assert_raises Nanoc::Errors::GenericTrivial do
|
140
|
+
err = assert_raises Nanoc::Int::Errors::GenericTrivial do
|
141
141
|
Nanoc::CLI.run %w( deploy )
|
142
142
|
end
|
143
143
|
assert_equal 'The site has no deployment configuration for default.', err.message
|
@@ -5,39 +5,12 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
5
5
|
include Nanoc::DataSources::Filesystem
|
6
6
|
end
|
7
7
|
|
8
|
-
def test_setup
|
9
|
-
# Create data source
|
10
|
-
data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
|
11
|
-
|
12
|
-
# Remove files to make sure they are recreated
|
13
|
-
FileUtils.rm_rf('content')
|
14
|
-
FileUtils.rm_rf('layouts/default')
|
15
|
-
FileUtils.rm_rf('lib')
|
16
|
-
|
17
|
-
# Mock VCS
|
18
|
-
vcs = mock
|
19
|
-
vcs.expects(:add).times(2) # One time for each directory
|
20
|
-
data_source.vcs = vcs
|
21
|
-
|
22
|
-
# Recreate files
|
23
|
-
data_source.setup
|
24
|
-
|
25
|
-
# Ensure essential files have been recreated
|
26
|
-
assert(File.directory?('content/'))
|
27
|
-
assert(File.directory?('layouts/'))
|
28
|
-
|
29
|
-
# Ensure no non-essential files have been recreated
|
30
|
-
assert(!File.file?('content/index.html'))
|
31
|
-
assert(!File.file?('layouts/default.html'))
|
32
|
-
refute(File.directory?('lib/'))
|
33
|
-
end
|
34
|
-
|
35
8
|
def test_items
|
36
9
|
# Create data source
|
37
10
|
data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
|
38
11
|
|
39
12
|
# Check
|
40
|
-
data_source.expects(:load_objects).with('content', 'item', Nanoc::Item)
|
13
|
+
data_source.expects(:load_objects).with('content', 'item', Nanoc::Int::Item)
|
41
14
|
data_source.items
|
42
15
|
end
|
43
16
|
|
@@ -46,31 +19,13 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
46
19
|
data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
|
47
20
|
|
48
21
|
# Check
|
49
|
-
data_source.expects(:load_objects).with('layouts', 'layout', Nanoc::Layout)
|
22
|
+
data_source.expects(:load_objects).with('layouts', 'layout', Nanoc::Int::Layout)
|
50
23
|
data_source.layouts
|
51
24
|
end
|
52
25
|
|
53
|
-
def test_create_item
|
54
|
-
# Create data source
|
55
|
-
data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
|
56
|
-
|
57
|
-
# Check
|
58
|
-
data_source.expects(:create_object).with('content', 'the content', 'the attributes', 'the identifier', {})
|
59
|
-
data_source.create_item('the content', 'the attributes', 'the identifier')
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_create_layout
|
63
|
-
# Create data source
|
64
|
-
data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
|
65
|
-
|
66
|
-
# Check
|
67
|
-
data_source.expects(:create_object).with('layouts', 'the content', 'the attributes', 'the identifier', {})
|
68
|
-
data_source.create_layout('the content', 'the attributes', 'the identifier')
|
69
|
-
end
|
70
|
-
|
71
26
|
def test_all_split_files_in_allowing_periods_in_identifiers
|
72
27
|
# Create data source
|
73
|
-
data_source = Nanoc::DataSources::
|
28
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, { allow_periods_in_identifiers: true })
|
74
29
|
|
75
30
|
# Write sample files
|
76
31
|
FileUtils.mkdir_p('foo')
|
@@ -97,7 +52,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
97
52
|
|
98
53
|
def test_all_split_files_in_disallowing_periods_in_identifiers
|
99
54
|
# Create data source
|
100
|
-
data_source = Nanoc::DataSources::
|
55
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
101
56
|
|
102
57
|
# Write sample files
|
103
58
|
FileUtils.mkdir_p('foo')
|
@@ -124,7 +79,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
124
79
|
|
125
80
|
def test_all_split_files_in_with_multiple_dirs
|
126
81
|
# Create data source
|
127
|
-
data_source = Nanoc::DataSources::
|
82
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
128
83
|
|
129
84
|
# Write sample files
|
130
85
|
%w( aaa/foo.html bbb/foo.html ccc/foo.html ).each do |filename|
|
@@ -143,7 +98,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
143
98
|
|
144
99
|
def test_all_split_files_in_with_multiple_content_files
|
145
100
|
# Create data source
|
146
|
-
data_source = Nanoc::DataSources::
|
101
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
147
102
|
|
148
103
|
# Write sample files
|
149
104
|
%w( foo.html foo.xhtml foo.txt foo.yaml bar.html qux.yaml ).each do |filename|
|
@@ -158,7 +113,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
158
113
|
|
159
114
|
def test_basename_of_allowing_periods_in_identifiers
|
160
115
|
# Create data source
|
161
|
-
data_source = Nanoc::DataSources::
|
116
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, { allow_periods_in_identifiers: true })
|
162
117
|
|
163
118
|
# Get input and expected output
|
164
119
|
expected = {
|
@@ -188,7 +143,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
188
143
|
|
189
144
|
def test_basename_of_disallowing_periods_in_identifiers
|
190
145
|
# Create data source
|
191
|
-
data_source = Nanoc::DataSources::
|
146
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
192
147
|
|
193
148
|
# Get input and expected output
|
194
149
|
expected = {
|
@@ -218,7 +173,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
218
173
|
|
219
174
|
def test_ext_of_allowing_periods_in_identifiers
|
220
175
|
# Create data source
|
221
|
-
data_source = Nanoc::DataSources::
|
176
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, { allow_periods_in_identifiers: true })
|
222
177
|
|
223
178
|
# Get input and expected output
|
224
179
|
expected = {
|
@@ -248,7 +203,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
248
203
|
|
249
204
|
def test_ext_of_disallowing_periods_in_identifiers
|
250
205
|
# Create data source
|
251
|
-
data_source = Nanoc::DataSources::
|
206
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
252
207
|
|
253
208
|
# Get input and expected output
|
254
209
|
expected = {
|
@@ -285,7 +240,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
285
240
|
end
|
286
241
|
|
287
242
|
# Create data source
|
288
|
-
data_source = Nanoc::DataSources::
|
243
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
289
244
|
|
290
245
|
# Parse it
|
291
246
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -302,7 +257,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
302
257
|
end
|
303
258
|
|
304
259
|
# Create data source
|
305
|
-
data_source = Nanoc::DataSources::
|
260
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
306
261
|
|
307
262
|
# Parse it
|
308
263
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -319,7 +274,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
319
274
|
end
|
320
275
|
|
321
276
|
# Create data source
|
322
|
-
data_source = Nanoc::DataSources::
|
277
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
323
278
|
|
324
279
|
# Parse it
|
325
280
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -335,7 +290,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
335
290
|
end
|
336
291
|
|
337
292
|
# Create data source
|
338
|
-
data_source = Nanoc::DataSources::
|
293
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
339
294
|
|
340
295
|
# Parse it
|
341
296
|
assert_raises(RuntimeError) do
|
@@ -352,7 +307,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
352
307
|
end
|
353
308
|
|
354
309
|
# Create data source
|
355
|
-
data_source = Nanoc::DataSources::
|
310
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
356
311
|
|
357
312
|
# Parse it
|
358
313
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -370,7 +325,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
370
325
|
end
|
371
326
|
|
372
327
|
# Create data source
|
373
|
-
data_source = Nanoc::DataSources::
|
328
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
374
329
|
|
375
330
|
# Parse it
|
376
331
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -388,7 +343,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
388
343
|
end
|
389
344
|
|
390
345
|
# Create data source
|
391
|
-
data_source = Nanoc::DataSources::
|
346
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
392
347
|
|
393
348
|
# Parse it
|
394
349
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -406,7 +361,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
406
361
|
end
|
407
362
|
|
408
363
|
# Create data source
|
409
|
-
data_source = Nanoc::DataSources::
|
364
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
410
365
|
|
411
366
|
# Parse it
|
412
367
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -423,7 +378,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
423
378
|
io.write "content goes here\n"
|
424
379
|
end
|
425
380
|
|
426
|
-
data_source = Nanoc::DataSources::
|
381
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, encoding: 'utf-8')
|
427
382
|
|
428
383
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
429
384
|
assert_equal({ 'utf8bomawareness' => 'high' }, result[0])
|
@@ -439,7 +394,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
439
394
|
File.open('test.html', 'w') { |io| io.write(content) }
|
440
395
|
|
441
396
|
# Create data source
|
442
|
-
data_source = Nanoc::DataSources::
|
397
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
443
398
|
|
444
399
|
# Parse it
|
445
400
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -457,7 +412,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
457
412
|
File.open('test.html', 'w') { |io| io.write(content) }
|
458
413
|
|
459
414
|
# Create data source
|
460
|
-
data_source = Nanoc::DataSources::
|
415
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
461
416
|
|
462
417
|
# Parse it
|
463
418
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
@@ -471,7 +426,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
471
426
|
File.open('test.yaml', 'w') { |io| io.write('foo: bar') }
|
472
427
|
|
473
428
|
# Create data source
|
474
|
-
data_source = Nanoc::DataSources::
|
429
|
+
data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, nil)
|
475
430
|
|
476
431
|
# Parse it
|
477
432
|
result = data_source.instance_eval { parse('test.html', 'test.yaml', 'foobar') }
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
4
4
|
def new_data_source(params = nil)
|
5
5
|
# Mock site
|
6
|
-
site = Nanoc::Site.new({})
|
6
|
+
site = Nanoc::Int::Site.new({})
|
7
7
|
|
8
8
|
# Create data source
|
9
9
|
data_source = Nanoc::DataSources::FilesystemUnified.new(site, nil, nil, params)
|
@@ -75,19 +75,19 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
75
75
|
expected_out = [
|
76
76
|
klass.new(
|
77
77
|
'test 1',
|
78
|
-
{ 'num' => 1, :filename => 'foo/bar.html', :extension => 'html'
|
78
|
+
{ 'num' => 1, :filename => 'foo/bar.html', :extension => 'html' },
|
79
79
|
'/bar/',
|
80
80
|
binary: false, mtime: File.mtime('foo/bar.html')
|
81
81
|
),
|
82
82
|
klass.new(
|
83
83
|
'test 2',
|
84
|
-
{ 'num' => 2, :filename => 'foo/b.c.html', :extension => 'c.html'
|
84
|
+
{ 'num' => 2, :filename => 'foo/b.c.html', :extension => 'c.html' },
|
85
85
|
'/b/',
|
86
86
|
binary: false, mtime: File.mtime('foo/b.c.html')
|
87
87
|
),
|
88
88
|
klass.new(
|
89
89
|
'test 3',
|
90
|
-
{ 'num' => 3, :filename => 'foo/a/b/c.html', :extension => 'html'
|
90
|
+
{ 'num' => 3, :filename => 'foo/a/b/c.html', :extension => 'html' },
|
91
91
|
'/a/b/c/',
|
92
92
|
binary: false, mtime: File.mtime('foo/a/b/c.html')
|
93
93
|
)
|
@@ -99,9 +99,6 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
99
99
|
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0], 'content must match'
|
100
100
|
assert_equal expected_out[i].stuff[2], actual_out[i].stuff[2], 'identifier must match'
|
101
101
|
assert_equal expected_out[i].stuff[3][:mtime], actual_out[i].stuff[3][:mtime], 'mtime must match'
|
102
|
-
assert_equal expected_out[i].stuff[1][:file].path, actual_out[i].stuff[1][:file].path, 'file paths must match'
|
103
|
-
expected_out[i].stuff[1][:file].close
|
104
|
-
actual_out[i].stuff[1][:file].close
|
105
102
|
['num', :filename, :extension].each do |key|
|
106
103
|
assert_equal expected_out[i].stuff[1][key], actual_out[i].stuff[1][key], "attribute key #{key} must match"
|
107
104
|
end
|
@@ -117,7 +114,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
117
114
|
File.open('foo/stuff.dat', 'w') { |io| io.write('random binary data') }
|
118
115
|
|
119
116
|
# Load
|
120
|
-
items = data_source.send(:load_objects, 'foo', 'item', Nanoc::Item)
|
117
|
+
items = data_source.send(:load_objects, 'foo', 'item', Nanoc::Int::Item)
|
121
118
|
|
122
119
|
# Check
|
123
120
|
assert_equal 1, items.size
|
@@ -136,7 +133,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
136
133
|
|
137
134
|
# Load
|
138
135
|
assert_raises(RuntimeError) do
|
139
|
-
data_source.send(:load_objects, 'foo', 'item', Nanoc::Layout)
|
136
|
+
data_source.send(:load_objects, 'foo', 'item', Nanoc::Int::Layout)
|
140
137
|
end
|
141
138
|
end
|
142
139
|
|
@@ -353,12 +350,6 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
353
350
|
assert_equal expected_out[i].stuff[2], actual_out[i].stuff[2], 'identifier must match'
|
354
351
|
assert_equal expected_out[i].stuff[3][:mtime], actual_out[i].stuff[3][:mtime], 'mtime must match'
|
355
352
|
|
356
|
-
actual_file = actual_out[i].stuff[1][:file]
|
357
|
-
expected_file = expected_out[i].stuff[1][:file]
|
358
|
-
assert(actual_file == expected_file || actual_file.path == expected_file.path, 'file paths must match')
|
359
|
-
actual_file.close unless actual_file.nil?
|
360
|
-
expected_file.close unless expected_file.nil?
|
361
|
-
|
362
353
|
['num', :content_filename, :meta_filename, :extension].each do |key|
|
363
354
|
assert_equal expected_out[i].stuff[1][key], actual_out[i].stuff[1][key], "attribute key #{key} must match"
|
364
355
|
end
|
@@ -442,12 +433,6 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
442
433
|
assert_equal expected_out[i].stuff[2], actual_out[i].stuff[2], 'identifier must match'
|
443
434
|
assert_equal expected_out[i].stuff[3][:mtime], actual_out[i].stuff[3][:mtime], 'mtime must match'
|
444
435
|
|
445
|
-
actual_file = actual_out[i].stuff[1][:file]
|
446
|
-
expected_file = expected_out[i].stuff[1][:file]
|
447
|
-
assert(actual_file == expected_file || actual_file.path == expected_file.path, 'file paths must match')
|
448
|
-
actual_file.close unless actual_file.nil?
|
449
|
-
expected_file.close unless expected_file.nil?
|
450
|
-
|
451
436
|
['num', :content_filename, :meta_filename, :extension].each do |key|
|
452
437
|
assert_equal expected_out[i].stuff[1][key], actual_out[i].stuff[1][key], "attribute key #{key} must match"
|
453
438
|
end
|
@@ -528,7 +513,8 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
528
513
|
data_source = new_data_source
|
529
514
|
|
530
515
|
# Create item
|
531
|
-
|
516
|
+
FileUtils.mkdir_p('content')
|
517
|
+
File.open('content/foo.md', 'w') { |io| io << 'Hëllö' }
|
532
518
|
|
533
519
|
# Parse
|
534
520
|
begin
|
@@ -560,7 +546,8 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
560
546
|
original_default_external_encoding = Encoding.default_external
|
561
547
|
Encoding.default_external = 'ISO-8859-1'
|
562
548
|
|
563
|
-
|
549
|
+
FileUtils.mkdir_p('content')
|
550
|
+
File.open('content/foo.md', 'w') { |io| io << 'Hëllö' }
|
564
551
|
ensure
|
565
552
|
Encoding.default_external = original_default_external_encoding
|
566
553
|
end
|