nanoc 3.7.4 → 3.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +19 -18
- data/LICENSE +1 -1
- data/NEWS.md +14 -0
- data/Rakefile +1 -1
- data/doc/yardoc_handlers/identifier.rb +1 -5
- data/lib/nanoc.rb +1 -3
- data/lib/nanoc/base.rb +1 -4
- data/lib/nanoc/base/checksummer.rb +10 -12
- data/lib/nanoc/base/compilation/checksum_store.rb +0 -4
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +0 -4
- data/lib/nanoc/base/compilation/compiler.rb +27 -31
- data/lib/nanoc/base/compilation/compiler_dsl.rb +3 -7
- data/lib/nanoc/base/compilation/dependency_tracker.rb +2 -6
- data/lib/nanoc/base/compilation/filter.rb +1 -7
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +0 -4
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +0 -4
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +0 -4
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +0 -6
- data/lib/nanoc/base/compilation/rule.rb +1 -5
- data/lib/nanoc/base/compilation/rule_context.rb +7 -11
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +0 -4
- data/lib/nanoc/base/compilation/rule_memory_store.rb +0 -4
- data/lib/nanoc/base/compilation/rules_collection.rb +5 -9
- data/lib/nanoc/base/context.rb +0 -3
- data/lib/nanoc/base/core_ext.rb +0 -1
- data/lib/nanoc/base/core_ext/array.rb +0 -2
- data/lib/nanoc/base/core_ext/hash.rb +0 -2
- data/lib/nanoc/base/core_ext/pathname.rb +0 -2
- data/lib/nanoc/base/core_ext/string.rb +0 -2
- data/lib/nanoc/base/directed_graph.rb +0 -4
- data/lib/nanoc/base/errors.rb +1 -39
- data/lib/nanoc/base/memoization.rb +0 -4
- data/lib/nanoc/base/notification_center.rb +1 -7
- data/lib/nanoc/base/plugin_registry.rb +4 -10
- data/lib/nanoc/base/result_data/item_rep.rb +8 -16
- data/lib/nanoc/base/source_data/code_snippet.rb +1 -5
- data/lib/nanoc/base/source_data/configuration.rb +0 -4
- data/lib/nanoc/base/source_data/data_source.rb +2 -5
- data/lib/nanoc/base/source_data/item.rb +3 -7
- data/lib/nanoc/base/source_data/item_array.rb +1 -5
- data/lib/nanoc/base/source_data/layout.rb +2 -6
- data/lib/nanoc/base/source_data/site.rb +20 -23
- data/lib/nanoc/base/store.rb +1 -5
- data/lib/nanoc/base/temp_filename_factory.rb +0 -4
- data/lib/nanoc/cli.rb +3 -5
- data/lib/nanoc/cli/ansi_string_colorizer.rb +6 -10
- data/lib/nanoc/cli/cleaning_stream.rb +2 -6
- data/lib/nanoc/cli/command_runner.rb +1 -5
- data/lib/nanoc/cli/commands/autocompile.rb +2 -6
- data/lib/nanoc/cli/commands/check.rb +0 -4
- data/lib/nanoc/cli/commands/compile.rb +12 -27
- data/lib/nanoc/cli/commands/create-item.rb +1 -5
- data/lib/nanoc/cli/commands/create-layout.rb +0 -4
- data/lib/nanoc/cli/commands/create-site.rb +2 -8
- data/lib/nanoc/cli/commands/deploy.rb +3 -7
- data/lib/nanoc/cli/commands/prune.rb +2 -6
- data/lib/nanoc/cli/commands/shell.rb +4 -8
- data/lib/nanoc/cli/commands/show-data.rb +3 -7
- data/lib/nanoc/cli/commands/show-plugins.rb +3 -7
- data/lib/nanoc/cli/commands/show-rules.rb +11 -15
- data/lib/nanoc/cli/commands/sync.rb +0 -4
- data/lib/nanoc/cli/commands/update.rb +1 -7
- data/lib/nanoc/cli/commands/validate-css.rb +0 -4
- data/lib/nanoc/cli/commands/validate-html.rb +0 -4
- data/lib/nanoc/cli/commands/validate-links.rb +0 -4
- data/lib/nanoc/cli/commands/view.rb +3 -7
- data/lib/nanoc/cli/commands/watch.rb +4 -10
- data/lib/nanoc/cli/error_handler.rb +9 -13
- data/lib/nanoc/cli/logger.rb +8 -12
- data/lib/nanoc/cli/stream_cleaners.rb +0 -4
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -5
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +0 -4
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +1 -5
- data/lib/nanoc/data_sources.rb +2 -4
- data/lib/nanoc/data_sources/deprecated/delicious.rb +6 -10
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +7 -11
- data/lib/nanoc/data_sources/deprecated/twitter.rb +2 -6
- data/lib/nanoc/data_sources/filesystem.rb +10 -13
- data/lib/nanoc/data_sources/filesystem_unified.rb +0 -4
- data/lib/nanoc/data_sources/filesystem_verbose.rb +0 -4
- data/lib/nanoc/data_sources/static.rb +4 -8
- data/lib/nanoc/extra.rb +2 -4
- data/lib/nanoc/extra/auto_compiler.rb +2 -6
- data/lib/nanoc/extra/checking.rb +0 -4
- data/lib/nanoc/extra/checking/check.rb +0 -4
- data/lib/nanoc/extra/checking/checks.rb +0 -2
- data/lib/nanoc/extra/checking/checks/css.rb +6 -6
- data/lib/nanoc/extra/checking/checks/external_links.rb +3 -11
- data/lib/nanoc/extra/checking/checks/html.rb +6 -6
- data/lib/nanoc/extra/checking/checks/internal_links.rb +3 -7
- data/lib/nanoc/extra/checking/checks/stale.rb +3 -7
- data/lib/nanoc/extra/checking/dsl.rb +0 -4
- data/lib/nanoc/extra/checking/issue.rb +0 -4
- data/lib/nanoc/extra/checking/runner.rb +4 -7
- data/lib/nanoc/extra/chick.rb +7 -17
- data/lib/nanoc/extra/core_ext.rb +0 -1
- data/lib/nanoc/extra/core_ext/pathname.rb +0 -4
- data/lib/nanoc/extra/core_ext/time.rb +0 -2
- data/lib/nanoc/extra/deployer.rb +0 -4
- data/lib/nanoc/extra/deployers.rb +0 -4
- data/lib/nanoc/extra/deployers/fog.rb +7 -11
- data/lib/nanoc/extra/deployers/rsync.rb +1 -5
- data/lib/nanoc/extra/file_proxy.rb +1 -5
- data/lib/nanoc/extra/filesystem_tools.rb +37 -12
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +0 -4
- data/lib/nanoc/extra/link_collector.rb +3 -7
- data/lib/nanoc/extra/piper.rb +0 -6
- data/lib/nanoc/extra/pruner.rb +1 -7
- data/lib/nanoc/extra/validators.rb +0 -4
- data/lib/nanoc/extra/validators/links.rb +0 -4
- data/lib/nanoc/extra/validators/w3c.rb +0 -4
- data/lib/nanoc/extra/vcs.rb +3 -7
- data/lib/nanoc/extra/vcses.rb +0 -2
- data/lib/nanoc/extra/vcses/bazaar.rb +0 -4
- data/lib/nanoc/extra/vcses/dummy.rb +0 -4
- data/lib/nanoc/extra/vcses/git.rb +0 -4
- data/lib/nanoc/extra/vcses/mercurial.rb +0 -4
- data/lib/nanoc/extra/vcses/subversion.rb +0 -4
- data/lib/nanoc/filters.rb +0 -2
- data/lib/nanoc/filters/asciidoc.rb +1 -5
- data/lib/nanoc/filters/bluecloth.rb +0 -2
- data/lib/nanoc/filters/coderay.rb +0 -2
- data/lib/nanoc/filters/coffeescript.rb +0 -4
- data/lib/nanoc/filters/colorize_syntax.rb +17 -15
- data/lib/nanoc/filters/erb.rb +1 -3
- data/lib/nanoc/filters/erubis.rb +2 -4
- data/lib/nanoc/filters/haml.rb +2 -4
- data/lib/nanoc/filters/handlebars.rb +0 -4
- data/lib/nanoc/filters/kramdown.rb +7 -4
- data/lib/nanoc/filters/less.rb +1 -3
- data/lib/nanoc/filters/markaby.rb +0 -2
- data/lib/nanoc/filters/maruku.rb +0 -2
- data/lib/nanoc/filters/mustache.rb +1 -5
- data/lib/nanoc/filters/pandoc.rb +0 -2
- data/lib/nanoc/filters/rainpress.rb +0 -2
- data/lib/nanoc/filters/rdiscount.rb +0 -2
- data/lib/nanoc/filters/rdoc.rb +0 -2
- data/lib/nanoc/filters/redcarpet.rb +0 -4
- data/lib/nanoc/filters/redcloth.rb +0 -2
- data/lib/nanoc/filters/relativize_paths.rb +2 -4
- data/lib/nanoc/filters/rubypants.rb +0 -2
- data/lib/nanoc/filters/sass.rb +2 -4
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +0 -2
- data/lib/nanoc/filters/slim.rb +2 -6
- data/lib/nanoc/filters/typogruby.rb +0 -4
- data/lib/nanoc/filters/uglify_js.rb +0 -2
- data/lib/nanoc/filters/xsl.rb +1 -5
- data/lib/nanoc/filters/yui_compressor.rb +0 -4
- data/lib/nanoc/helpers.rb +0 -2
- data/lib/nanoc/helpers/blogging.rb +12 -20
- data/lib/nanoc/helpers/breadcrumbs.rb +0 -4
- data/lib/nanoc/helpers/capturing.rb +2 -10
- data/lib/nanoc/helpers/filtering.rb +0 -4
- data/lib/nanoc/helpers/html_escape.rb +3 -7
- data/lib/nanoc/helpers/link_to.rb +0 -4
- data/lib/nanoc/helpers/rendering.rb +8 -12
- data/lib/nanoc/helpers/tagging.rb +0 -4
- data/lib/nanoc/helpers/text.rb +1 -5
- data/lib/nanoc/helpers/xml_sitemap.rb +3 -7
- data/lib/nanoc/tasks/clean.rb +1 -7
- data/lib/nanoc/tasks/deploy/rsync.rake +0 -2
- data/lib/nanoc/tasks/validate.rake +0 -4
- data/lib/nanoc/version.rb +1 -3
- data/nanoc.gemspec +12 -9
- data/tasks/rubocop.rake +1 -1
- data/tasks/test.rake +6 -7
- data/test/base/checksummer_spec.rb +28 -44
- data/test/base/core_ext/array_spec.rb +1 -9
- data/test/base/core_ext/hash_spec.rb +7 -19
- data/test/base/core_ext/pathname_spec.rb +2 -4
- data/test/base/core_ext/string_spec.rb +0 -4
- data/test/base/temp_filename_factory_spec.rb +0 -8
- data/test/base/test_checksum_store.rb +0 -2
- data/test/base/test_code_snippet.rb +0 -2
- data/test/base/test_compiler.rb +15 -17
- data/test/base/test_compiler_dsl.rb +7 -9
- data/test/base/test_context.rb +2 -4
- 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 +2 -4
- data/test/base/test_filter.rb +5 -7
- data/test/base/test_item.rb +17 -13
- data/test/base/test_item_array.rb +2 -4
- data/test/base/test_item_rep.rb +79 -73
- data/test/base/test_layout.rb +3 -5
- data/test/base/test_memoization.rb +13 -21
- data/test/base/test_notification_center.rb +0 -2
- data/test/base/test_outdatedness_checker.rb +34 -36
- data/test/base/test_plugin.rb +0 -2
- data/test/base/test_rule.rb +3 -5
- data/test/base/test_rule_context.rb +4 -6
- data/test/base/test_site.rb +9 -17
- data/test/base/test_store.rb +2 -6
- data/test/cli/commands/test_check.rb +1 -3
- data/test/cli/commands/test_compile.rb +24 -15
- data/test/cli/commands/test_create_item.rb +1 -3
- data/test/cli/commands/test_create_layout.rb +0 -2
- data/test/cli/commands/test_create_site.rb +0 -3
- data/test/cli/commands/test_deploy.rb +9 -11
- data/test/cli/commands/test_help.rb +0 -2
- data/test/cli/commands/test_info.rb +0 -2
- data/test/cli/commands/test_prune.rb +6 -8
- data/test/cli/commands/test_sync.rb +0 -2
- data/test/cli/commands/test_update.rb +0 -2
- data/test/cli/commands/test_watch.rb +4 -6
- data/test/cli/test_cleaning_stream.rb +4 -6
- data/test/cli/test_cli.rb +9 -5
- data/test/cli/test_error_handler.rb +9 -7
- data/test/cli/test_logger.rb +0 -2
- data/test/data_sources/test_filesystem.rb +8 -10
- data/test/data_sources/test_filesystem_unified.rb +35 -34
- data/test/data_sources/test_filesystem_verbose.rb +31 -33
- data/test/data_sources/test_static.rb +20 -21
- data/test/extra/checking/checks/test_css.rb +23 -2
- data/test/extra/checking/checks/test_external_links.rb +2 -4
- data/test/extra/checking/checks/test_html.rb +4 -3
- data/test/extra/checking/checks/test_internal_links.rb +1 -3
- data/test/extra/checking/checks/test_stale.rb +4 -6
- data/test/extra/checking/test_check.rb +0 -2
- data/test/extra/checking/test_dsl.rb +1 -3
- data/test/extra/checking/test_runner.rb +0 -2
- data/test/extra/core_ext/test_pathname.rb +0 -3
- data/test/extra/core_ext/test_time.rb +0 -2
- data/test/extra/deployers/test_fog.rb +13 -15
- data/test/extra/deployers/test_rsync.rb +4 -6
- data/test/extra/test_auto_compiler.rb +47 -25
- data/test/extra/test_file_proxy.rb +1 -3
- data/test/extra/test_filesystem_tools.rb +47 -7
- data/test/extra/test_link_collector.rb +0 -2
- data/test/extra/test_piper.rb +3 -5
- data/test/extra/test_vcs.rb +0 -2
- data/test/extra/validators/test_links.rb +0 -1
- data/test/extra/validators/test_w3c.rb +2 -4
- data/test/filters/test_asciidoc.rb +0 -2
- data/test/filters/test_bluecloth.rb +0 -2
- data/test/filters/test_coderay.rb +2 -4
- data/test/filters/test_coffeescript.rb +0 -2
- data/test/filters/test_colorize_syntax.rb +16 -18
- data/test/filters/test_erb.rb +12 -14
- data/test/filters/test_erubis.rb +4 -6
- data/test/filters/test_haml.rb +7 -9
- data/test/filters/test_handlebars.rb +10 -12
- data/test/filters/test_kramdown.rb +13 -1
- data/test/filters/test_less.rb +9 -11
- data/test/filters/test_markaby.rb +0 -2
- data/test/filters/test_maruku.rb +0 -2
- data/test/filters/test_mustache.rb +4 -6
- data/test/filters/test_pandoc.rb +1 -3
- data/test/filters/test_rainpress.rb +1 -3
- data/test/filters/test_rdiscount.rb +1 -3
- data/test/filters/test_rdoc.rb +0 -2
- data/test/filters/test_redcarpet.rb +6 -8
- data/test/filters/test_redcloth.rb +1 -3
- data/test/filters/test_relativize_paths.rb +29 -34
- data/test/filters/test_rubypants.rb +0 -2
- data/test/filters/test_sass.rb +8 -10
- data/test/filters/test_slim.rb +2 -4
- data/test/filters/test_typogruby.rb +0 -3
- data/test/filters/test_uglify_js.rb +2 -4
- data/test/filters/test_xsl.rb +16 -18
- data/test/filters/test_yui_compressor.rb +3 -5
- data/test/fixtures/vcr_cassettes/css_run_parse_error.yml +65 -0
- data/test/gem_loader.rb +1 -1
- data/test/helper.rb +11 -15
- data/test/helpers/test_blogging.rb +61 -63
- data/test/helpers/test_breadcrumbs.rb +0 -2
- data/test/helpers/test_capturing.rb +4 -6
- data/test/helpers/test_filtering.rb +2 -4
- data/test/helpers/test_html_escape.rb +0 -2
- data/test/helpers/test_link_to.rb +5 -6
- data/test/helpers/test_rendering.rb +2 -4
- data/test/helpers/test_tagging.rb +9 -11
- data/test/helpers/test_text.rb +6 -8
- data/test/helpers/test_xml_sitemap.rb +11 -13
- data/test/tasks/test_clean.rb +0 -2
- data/test/test_gem.rb +1 -3
- metadata +15 -14
- data/Gemfile.lock +0 -252
- data/lib/nanoc/base/core_ext/date.rb +0 -29
- data/lib/nanoc/base/ordered_hash.rb +0 -228
- data/lib/nanoc/extra/core_ext/enumerable.rb +0 -33
- data/test/base/core_ext/date_spec.rb +0 -15
- data/test/extra/core_ext/test_enumerable.rb +0 -28
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
class Nanoc::CLI::Commands::SyncTest < Nanoc::TestCase
|
|
2
|
-
|
|
3
2
|
def test_run
|
|
4
3
|
with_site do
|
|
5
4
|
File.open('lib/foo_data_source.rb', 'w') do |io|
|
|
@@ -25,5 +24,4 @@ class Nanoc::CLI::Commands::SyncTest < Nanoc::TestCase
|
|
|
25
24
|
assert_equal File.read('foo_source_data.yaml'), 'sync: true'
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
|
-
|
|
29
27
|
end
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
class Nanoc::CLI::Commands::WatchTest < Nanoc::TestCase
|
|
4
|
-
|
|
5
4
|
def test_run
|
|
6
|
-
with_site do |
|
|
5
|
+
with_site do |_s|
|
|
7
6
|
watch_thread = Thread.new do
|
|
8
7
|
Nanoc::CLI.run %w( watch )
|
|
9
8
|
end
|
|
@@ -19,7 +18,7 @@ class Nanoc::CLI::Commands::WatchTest < Nanoc::TestCase
|
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
def test_notify
|
|
22
|
-
with_site do |
|
|
21
|
+
with_site do |_s|
|
|
23
22
|
watch_thread = Thread.new do
|
|
24
23
|
Nanoc::CLI.run %w( watch )
|
|
25
24
|
end
|
|
@@ -50,7 +49,7 @@ class Nanoc::CLI::Commands::WatchTest < Nanoc::TestCase
|
|
|
50
49
|
sleep 0.5
|
|
51
50
|
end
|
|
52
51
|
unless File.file?(filename)
|
|
53
|
-
raise
|
|
52
|
+
raise "Expected #{filename} to appear but it didn't :("
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
|
|
@@ -64,7 +63,7 @@ class Nanoc::CLI::Commands::WatchTest < Nanoc::TestCase
|
|
|
64
63
|
|
|
65
64
|
actual_content = File.read(filename)
|
|
66
65
|
if actual_content != expected_content
|
|
67
|
-
raise
|
|
66
|
+
raise "Expected #{filename} to have " \
|
|
68
67
|
"content #{expected_content.inspect} but it had " \
|
|
69
68
|
"content #{actual_content.inspect} instead :("
|
|
70
69
|
end
|
|
@@ -72,5 +71,4 @@ class Nanoc::CLI::Commands::WatchTest < Nanoc::TestCase
|
|
|
72
71
|
# Ugly, but seems to be necessary or changes are not picked up. :(
|
|
73
72
|
sleep 0.5
|
|
74
73
|
end
|
|
75
|
-
|
|
76
74
|
end
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
class Nanoc::CLI::CleaningStreamTest < Nanoc::TestCase
|
|
4
|
-
|
|
5
4
|
class Stream
|
|
6
|
-
|
|
7
5
|
attr_accessor :called_methods
|
|
8
6
|
|
|
9
7
|
def initialize
|
|
10
8
|
@called_methods = Set.new
|
|
11
9
|
end
|
|
12
10
|
|
|
13
|
-
def method_missing(symbol, *
|
|
11
|
+
def method_missing(symbol, *_args)
|
|
14
12
|
@called_methods << symbol
|
|
15
13
|
end
|
|
16
|
-
|
|
17
14
|
end
|
|
18
15
|
|
|
19
16
|
def test_forward
|
|
@@ -51,10 +48,11 @@ class Nanoc::CLI::CleaningStreamTest < Nanoc::TestCase
|
|
|
51
48
|
|
|
52
49
|
def test_broken_pipe
|
|
53
50
|
stream = StringIO.new
|
|
54
|
-
def stream.write(
|
|
51
|
+
def stream.write(_s)
|
|
52
|
+
raise Errno::EPIPE.new
|
|
53
|
+
end
|
|
55
54
|
|
|
56
55
|
cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
|
|
57
56
|
cleaning_stream.write('lol')
|
|
58
57
|
end
|
|
59
|
-
|
|
60
58
|
end
|
data/test/cli/test_cli.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
class Nanoc::CLITest < Nanoc::TestCase
|
|
4
|
-
|
|
5
4
|
COMMAND_CODE = <<EOS
|
|
6
5
|
# encoding: utf-8
|
|
7
6
|
|
|
@@ -119,18 +118,24 @@ EOS
|
|
|
119
118
|
}
|
|
120
119
|
with_env_vars(new_env_diff) do
|
|
121
120
|
io = StringIO.new
|
|
122
|
-
def io.tty
|
|
121
|
+
def io.tty?
|
|
122
|
+
true
|
|
123
|
+
end
|
|
123
124
|
refute Nanoc::CLI.enable_utf8?(io)
|
|
124
125
|
|
|
125
126
|
io = StringIO.new
|
|
126
|
-
def io.tty
|
|
127
|
+
def io.tty?
|
|
128
|
+
false
|
|
129
|
+
end
|
|
127
130
|
assert Nanoc::CLI.enable_utf8?(io)
|
|
128
131
|
end
|
|
129
132
|
end
|
|
130
133
|
|
|
131
134
|
def test_enable_utf8
|
|
132
135
|
io = StringIO.new
|
|
133
|
-
def io.tty
|
|
136
|
+
def io.tty?
|
|
137
|
+
true
|
|
138
|
+
end
|
|
134
139
|
|
|
135
140
|
new_env_diff = {
|
|
136
141
|
'LC_ALL' => 'en_US.ISO-8859-1',
|
|
@@ -153,5 +158,4 @@ EOS
|
|
|
153
158
|
with_env_vars({ 'LANG' => 'en_US.utf8' }) { assert Nanoc::CLI.enable_utf8?(io) }
|
|
154
159
|
end
|
|
155
160
|
end
|
|
156
|
-
|
|
157
161
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
class Nanoc::CLI::ErrorHandlerTest < Nanoc::TestCase
|
|
4
|
-
|
|
5
4
|
def setup
|
|
6
5
|
super
|
|
7
6
|
@handler = Nanoc::CLI::ErrorHandler.new
|
|
@@ -13,13 +12,17 @@ class Nanoc::CLI::ErrorHandlerTest < Nanoc::TestCase
|
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
def test_resolution_for_with_known_gem_without_bundler
|
|
16
|
-
def @handler.using_bundler
|
|
15
|
+
def @handler.using_bundler?
|
|
16
|
+
false
|
|
17
|
+
end
|
|
17
18
|
error = LoadError.new('no such file to load -- kramdown')
|
|
18
19
|
assert_match(/^Install the 'kramdown' gem using `gem install kramdown`./, @handler.send(:resolution_for, error))
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
def test_resolution_for_with_known_gem_with_bundler
|
|
22
|
-
def @handler.using_bundler
|
|
23
|
+
def @handler.using_bundler?
|
|
24
|
+
true
|
|
25
|
+
end
|
|
23
26
|
error = LoadError.new('no such file to load -- kramdown')
|
|
24
27
|
assert_match(/^Make sure the gem is added to Gemfile/, @handler.send(:resolution_for, error))
|
|
25
28
|
end
|
|
@@ -33,15 +36,15 @@ class Nanoc::CLI::ErrorHandlerTest < Nanoc::TestCase
|
|
|
33
36
|
error = new_error(20)
|
|
34
37
|
|
|
35
38
|
stream = StringIO.new
|
|
36
|
-
@handler.send(:write_stack_trace, stream, error, :
|
|
39
|
+
@handler.send(:write_stack_trace, stream, error, verbose: false)
|
|
37
40
|
assert_match(/See full crash log for details./, stream.string)
|
|
38
41
|
|
|
39
42
|
stream = StringIO.new
|
|
40
|
-
@handler.send(:write_stack_trace, stream, error, :
|
|
43
|
+
@handler.send(:write_stack_trace, stream, error, verbose: false)
|
|
41
44
|
assert_match(/See full crash log for details./, stream.string)
|
|
42
45
|
|
|
43
46
|
stream = StringIO.new
|
|
44
|
-
@handler.send(:write_stack_trace, stream, error, :
|
|
47
|
+
@handler.send(:write_stack_trace, stream, error, verbose: true)
|
|
45
48
|
refute_match(/See full crash log for details./, stream.string)
|
|
46
49
|
end
|
|
47
50
|
|
|
@@ -60,5 +63,4 @@ class Nanoc::CLI::ErrorHandlerTest < Nanoc::TestCase
|
|
|
60
63
|
return e
|
|
61
64
|
end
|
|
62
65
|
end
|
|
63
|
-
|
|
64
66
|
end
|
data/test/cli/test_logger.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
4
|
-
|
|
5
4
|
class SampleFilesystemDataSource < Nanoc::DataSource
|
|
6
5
|
include Nanoc::DataSources::Filesystem
|
|
7
6
|
end
|
|
@@ -71,7 +70,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
|
71
70
|
|
|
72
71
|
def test_all_split_files_in_allowing_periods_in_identifiers
|
|
73
72
|
# Create data source
|
|
74
|
-
data_source = Nanoc::DataSources::FilesystemCompact.new(nil, nil, nil, { :
|
|
73
|
+
data_source = Nanoc::DataSources::FilesystemCompact.new(nil, nil, nil, { allow_periods_in_identifiers: true })
|
|
75
74
|
|
|
76
75
|
# Write sample files
|
|
77
76
|
FileUtils.mkdir_p('foo')
|
|
@@ -86,7 +85,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
|
86
85
|
|
|
87
86
|
# Get all files
|
|
88
87
|
output_expected = {
|
|
89
|
-
'./foo' =>
|
|
88
|
+
'./foo' => %w(yaml html),
|
|
90
89
|
'./bar.entry' => [nil, 'html'],
|
|
91
90
|
'./foo/qux' => ['yaml', nil]
|
|
92
91
|
}
|
|
@@ -113,7 +112,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
|
113
112
|
|
|
114
113
|
# Get all files
|
|
115
114
|
output_expected = {
|
|
116
|
-
'./foo' =>
|
|
115
|
+
'./foo' => %w(yaml html),
|
|
117
116
|
'./bar' => [nil, 'html.erb'],
|
|
118
117
|
'./foo/qux' => ['yaml', nil]
|
|
119
118
|
}
|
|
@@ -159,7 +158,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
|
159
158
|
|
|
160
159
|
def test_basename_of_allowing_periods_in_identifiers
|
|
161
160
|
# Create data source
|
|
162
|
-
data_source = Nanoc::DataSources::FilesystemCompact.new(nil, nil, nil, { :
|
|
161
|
+
data_source = Nanoc::DataSources::FilesystemCompact.new(nil, nil, nil, { allow_periods_in_identifiers: true })
|
|
163
162
|
|
|
164
163
|
# Get input and expected output
|
|
165
164
|
expected = {
|
|
@@ -219,7 +218,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
|
219
218
|
|
|
220
219
|
def test_ext_of_allowing_periods_in_identifiers
|
|
221
220
|
# Create data source
|
|
222
|
-
data_source = Nanoc::DataSources::FilesystemCompact.new(nil, nil, nil, { :
|
|
221
|
+
data_source = Nanoc::DataSources::FilesystemCompact.new(nil, nil, nil, { allow_periods_in_identifiers: true })
|
|
223
222
|
|
|
224
223
|
# Get input and expected output
|
|
225
224
|
expected = {
|
|
@@ -417,14 +416,14 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
|
417
416
|
|
|
418
417
|
def test_parse_utf8_bom
|
|
419
418
|
File.open('test.html', 'w') do |io|
|
|
420
|
-
io.write [0xEF, 0xBB, 0xBF].map
|
|
419
|
+
io.write [0xEF, 0xBB, 0xBF].map(&:chr).join
|
|
421
420
|
io.write "-----\n"
|
|
422
421
|
io.write "utf8bomawareness: high\n"
|
|
423
422
|
io.write "-----\n"
|
|
424
423
|
io.write "content goes here\n"
|
|
425
424
|
end
|
|
426
425
|
|
|
427
|
-
data_source = Nanoc::DataSources::FilesystemCombined.new(nil, nil, nil, :
|
|
426
|
+
data_source = Nanoc::DataSources::FilesystemCombined.new(nil, nil, nil, encoding: 'utf-8')
|
|
428
427
|
|
|
429
428
|
result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
|
|
430
429
|
assert_equal({ 'utf8bomawareness' => 'high' }, result[0])
|
|
@@ -476,8 +475,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
|
476
475
|
|
|
477
476
|
# Parse it
|
|
478
477
|
result = data_source.instance_eval { parse('test.html', 'test.yaml', 'foobar') }
|
|
479
|
-
assert_equal({ 'foo' => 'bar'}, result[0])
|
|
478
|
+
assert_equal({ 'foo' => 'bar' }, result[0])
|
|
480
479
|
assert_equal('blah blah', result[1])
|
|
481
480
|
end
|
|
482
|
-
|
|
483
481
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
4
|
-
|
|
5
4
|
def new_data_source(params = nil)
|
|
6
5
|
# Mock site
|
|
7
6
|
site = Nanoc::Site.new({})
|
|
@@ -16,7 +15,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
16
15
|
def test_create_object_not_at_root
|
|
17
16
|
# Create item
|
|
18
17
|
data_source = new_data_source
|
|
19
|
-
data_source.send(:create_object, 'foobar', 'content here', { :
|
|
18
|
+
data_source.send(:create_object, 'foobar', 'content here', { foo: 'bar' }, '/asdf/')
|
|
20
19
|
|
|
21
20
|
# Check file existance
|
|
22
21
|
assert File.directory?('foobar')
|
|
@@ -32,7 +31,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
32
31
|
def test_create_object_at_root
|
|
33
32
|
# Create item
|
|
34
33
|
data_source = new_data_source
|
|
35
|
-
data_source.send(:create_object, 'foobar', 'content here', { :
|
|
34
|
+
data_source.send(:create_object, 'foobar', 'content here', { foo: 'bar' }, '/')
|
|
36
35
|
|
|
37
36
|
# Check file existance
|
|
38
37
|
assert File.directory?('foobar')
|
|
@@ -55,6 +54,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
55
54
|
def initialize(*stuff)
|
|
56
55
|
@stuff = stuff
|
|
57
56
|
end
|
|
57
|
+
|
|
58
58
|
def ==(other)
|
|
59
59
|
@stuff == other.stuff
|
|
60
60
|
end
|
|
@@ -77,30 +77,30 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
77
77
|
'test 1',
|
|
78
78
|
{ 'num' => 1, :filename => 'foo/bar.html', :extension => 'html', :file => File.open('foo/bar.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
84
|
{ 'num' => 2, :filename => 'foo/b.c.html', :extension => 'c.html', :file => File.open('foo/b.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
90
|
{ 'num' => 3, :filename => 'foo/a/b/c.html', :extension => 'html', :file => File.open('foo/a/b/c.html') },
|
|
91
91
|
'/a/b/c/',
|
|
92
|
-
:
|
|
92
|
+
binary: false, mtime: File.mtime('foo/a/b/c.html')
|
|
93
93
|
)
|
|
94
94
|
]
|
|
95
95
|
actual_out = data_source.send(:load_objects, 'foo', 'The Foo', klass).sort_by { |i| i.stuff[0] }
|
|
96
96
|
|
|
97
97
|
# Check
|
|
98
|
-
(0..expected_out.size-1).each do |i|
|
|
98
|
+
(0..expected_out.size - 1).each do |i|
|
|
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
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
|
|
103
|
+
expected_out[i].stuff[1][:file].close
|
|
104
104
|
actual_out[i].stuff[1][:file].close
|
|
105
105
|
['num', :filename, :extension].each do |key|
|
|
106
106
|
assert_equal expected_out[i].stuff[1][key], actual_out[i].stuff[1][key], "attribute key #{key} must match"
|
|
@@ -142,7 +142,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
142
142
|
|
|
143
143
|
def test_identifier_for_filename_allowing_periods_in_identifiers
|
|
144
144
|
# Create data source
|
|
145
|
-
data_source = new_data_source(:
|
|
145
|
+
data_source = new_data_source(allow_periods_in_identifiers: true)
|
|
146
146
|
|
|
147
147
|
# Get input and expected output
|
|
148
148
|
expected = {
|
|
@@ -198,7 +198,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
198
198
|
'foo/blah_index.yaml' => '/foo/blah_index/'
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
data_source = new_data_source(:
|
|
201
|
+
data_source = new_data_source(allow_periods_in_identifiers: true)
|
|
202
202
|
expectations.each_pair do |meta_filename, expected_identifier|
|
|
203
203
|
content_filename = meta_filename.sub(/yaml$/, 'html')
|
|
204
204
|
[meta_filename, content_filename].each do |filename|
|
|
@@ -246,7 +246,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
246
246
|
'/foo/index' => '/foo/',
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
data_source = new_data_source(:
|
|
249
|
+
data_source = new_data_source(allow_periods_in_identifiers: true)
|
|
250
250
|
expected.each_pair do |input, expected_output|
|
|
251
251
|
actual_output = data_source.send(:identifier_for_filename, input)
|
|
252
252
|
assert_equal(
|
|
@@ -278,7 +278,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
278
278
|
|
|
279
279
|
def test_load_objects_allowing_periods_in_identifiers
|
|
280
280
|
# Create data source
|
|
281
|
-
data_source = new_data_source(:
|
|
281
|
+
data_source = new_data_source(allow_periods_in_identifiers: true)
|
|
282
282
|
|
|
283
283
|
# Create a fake class
|
|
284
284
|
klass = Class.new do
|
|
@@ -286,6 +286,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
286
286
|
def initialize(*stuff)
|
|
287
287
|
@stuff = stuff
|
|
288
288
|
end
|
|
289
|
+
|
|
289
290
|
def ==(other)
|
|
290
291
|
@stuff == other.stuff
|
|
291
292
|
end
|
|
@@ -316,7 +317,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
316
317
|
:file => nil
|
|
317
318
|
},
|
|
318
319
|
'/a/b/c/',
|
|
319
|
-
:
|
|
320
|
+
binary: false, mtime: File.mtime('foo/a/b/c.yaml')
|
|
320
321
|
),
|
|
321
322
|
klass.new(
|
|
322
323
|
'test 2',
|
|
@@ -328,18 +329,18 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
328
329
|
:file => File.open('foo/b.c.html')
|
|
329
330
|
},
|
|
330
331
|
'/b.c/',
|
|
331
|
-
:
|
|
332
|
+
binary: false, mtime: File.mtime('foo/b.c.html') > File.mtime('foo/b.c.yaml') ? File.mtime('foo/b.c.html') : File.mtime('foo/b.c.yaml')
|
|
332
333
|
),
|
|
333
334
|
klass.new(
|
|
334
335
|
'test 3',
|
|
335
336
|
{
|
|
336
|
-
:
|
|
337
|
-
:
|
|
338
|
-
:
|
|
339
|
-
:
|
|
337
|
+
content_filename: 'foo/car.html',
|
|
338
|
+
meta_filename: nil,
|
|
339
|
+
extension: 'html',
|
|
340
|
+
file: File.open('foo/car.html')
|
|
340
341
|
},
|
|
341
342
|
'/car/',
|
|
342
|
-
:
|
|
343
|
+
binary: false, mtime: File.mtime('foo/car.html')
|
|
343
344
|
)
|
|
344
345
|
]
|
|
345
346
|
|
|
@@ -347,7 +348,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
347
348
|
actual_out = data_source.send(:load_objects, 'foo', 'The Foo', klass).sort_by { |i| i.stuff[2] }
|
|
348
349
|
|
|
349
350
|
# Check
|
|
350
|
-
(0..expected_out.size-1).each do |i|
|
|
351
|
+
(0..expected_out.size - 1).each do |i|
|
|
351
352
|
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0], 'content must match'
|
|
352
353
|
assert_equal expected_out[i].stuff[2], actual_out[i].stuff[2], 'identifier must match'
|
|
353
354
|
assert_equal expected_out[i].stuff[3][:mtime], actual_out[i].stuff[3][:mtime], 'mtime must match'
|
|
@@ -374,6 +375,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
374
375
|
def initialize(*stuff)
|
|
375
376
|
@stuff = stuff
|
|
376
377
|
end
|
|
378
|
+
|
|
377
379
|
def ==(other)
|
|
378
380
|
@stuff == other.stuff
|
|
379
381
|
end
|
|
@@ -404,7 +406,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
404
406
|
:file => nil
|
|
405
407
|
},
|
|
406
408
|
'/a/b/c/',
|
|
407
|
-
:
|
|
409
|
+
binary: false, mtime: File.mtime('foo/a/b/c.yaml')
|
|
408
410
|
),
|
|
409
411
|
klass.new(
|
|
410
412
|
'test 2',
|
|
@@ -416,18 +418,18 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
416
418
|
:file => File.open('foo/b.html.erb')
|
|
417
419
|
},
|
|
418
420
|
'/b/',
|
|
419
|
-
:
|
|
421
|
+
binary: false, mtime: File.mtime('foo/b.html.erb') > File.mtime('foo/b.yaml') ? File.mtime('foo/b.html.erb') : File.mtime('foo/b.yaml')
|
|
420
422
|
),
|
|
421
423
|
klass.new(
|
|
422
424
|
'test 3',
|
|
423
425
|
{
|
|
424
|
-
:
|
|
425
|
-
:
|
|
426
|
-
:
|
|
427
|
-
:
|
|
426
|
+
content_filename: 'foo/car.html',
|
|
427
|
+
meta_filename: nil,
|
|
428
|
+
extension: 'html',
|
|
429
|
+
file: File.open('foo/car.html')
|
|
428
430
|
},
|
|
429
431
|
'/car/',
|
|
430
|
-
:
|
|
432
|
+
binary: false, mtime: File.mtime('foo/car.html')
|
|
431
433
|
)
|
|
432
434
|
]
|
|
433
435
|
|
|
@@ -435,7 +437,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
435
437
|
actual_out = data_source.send(:load_objects, 'foo', 'The Foo', klass).sort_by { |i| i.stuff[2] }
|
|
436
438
|
|
|
437
439
|
# Check
|
|
438
|
-
(0..expected_out.size-1).each do |i|
|
|
440
|
+
(0..expected_out.size - 1).each do |i|
|
|
439
441
|
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0], 'content must match'
|
|
440
442
|
assert_equal expected_out[i].stuff[2], actual_out[i].stuff[2], 'identifier must match'
|
|
441
443
|
assert_equal expected_out[i].stuff[3][:mtime], actual_out[i].stuff[3][:mtime], 'mtime must match'
|
|
@@ -454,17 +456,17 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
454
456
|
|
|
455
457
|
def test_create_object_allowing_periods_in_identifiers
|
|
456
458
|
# Create data source
|
|
457
|
-
data_source = new_data_source(:
|
|
459
|
+
data_source = new_data_source(allow_periods_in_identifiers: true)
|
|
458
460
|
|
|
459
461
|
# Create object without period
|
|
460
|
-
data_source.send(:create_object, 'foo', 'some content', { :
|
|
462
|
+
data_source.send(:create_object, 'foo', 'some content', { some: 'attributes' }, '/asdf/')
|
|
461
463
|
assert File.file?('foo/asdf.html')
|
|
462
464
|
data = data_source.send(:parse, 'foo/asdf.html', nil, 'moo')
|
|
463
465
|
assert_equal({ 'some' => 'attributes' }, data[0])
|
|
464
466
|
assert_equal('some content', data[1])
|
|
465
467
|
|
|
466
468
|
# Create object with period
|
|
467
|
-
data_source.send(:create_object, 'foo', 'some content', { :
|
|
469
|
+
data_source.send(:create_object, 'foo', 'some content', { some: 'attributes' }, '/as.df/')
|
|
468
470
|
assert File.file?('foo/as.df.html')
|
|
469
471
|
data = data_source.send(:parse, 'foo/as.df.html', nil, 'moo')
|
|
470
472
|
assert_equal({ 'some' => 'attributes' }, data[0])
|
|
@@ -476,7 +478,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
476
478
|
data_source = new_data_source
|
|
477
479
|
|
|
478
480
|
# Create object without period
|
|
479
|
-
data_source.send(:create_object, 'foo', 'some content', { :
|
|
481
|
+
data_source.send(:create_object, 'foo', 'some content', { some: 'attributes' }, '/asdf/')
|
|
480
482
|
assert File.file?('foo/asdf.html')
|
|
481
483
|
data = data_source.send(:parse, 'foo/asdf.html', nil, 'moo')
|
|
482
484
|
assert_equal({ 'some' => 'attributes' }, data[0])
|
|
@@ -484,7 +486,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
484
486
|
|
|
485
487
|
# Create object with period
|
|
486
488
|
assert_raises(RuntimeError) do
|
|
487
|
-
data_source.send(:create_object, 'foo', 'some content', { :
|
|
489
|
+
data_source.send(:create_object, 'foo', 'some content', { some: 'attributes' }, '/as.df/')
|
|
488
490
|
end
|
|
489
491
|
end
|
|
490
492
|
|
|
@@ -568,5 +570,4 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
|
568
570
|
assert_equal 1, items.size
|
|
569
571
|
assert_equal Encoding.find('UTF-8'), items[0].raw_content.encoding
|
|
570
572
|
end
|
|
571
|
-
|
|
572
573
|
end
|