nanoc 3.7.3 → 3.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +71 -46
- data/NEWS.md +14 -0
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base/checksummer.rb +1 -1
- data/lib/nanoc/base/compilation/checksum_store.rb +1 -1
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +1 -1
- data/lib/nanoc/base/compilation/compiler.rb +11 -10
- data/lib/nanoc/base/compilation/compiler_dsl.rb +4 -4
- data/lib/nanoc/base/compilation/dependency_tracker.rb +7 -7
- data/lib/nanoc/base/compilation/filter.rb +1 -1
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +6 -5
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +8 -7
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +6 -6
- data/lib/nanoc/base/compilation/rule.rb +1 -1
- data/lib/nanoc/base/compilation/rule_memory_store.rb +1 -1
- data/lib/nanoc/base/compilation/rules_collection.rb +5 -5
- data/lib/nanoc/base/context.rb +1 -1
- data/lib/nanoc/base/core_ext/array.rb +1 -1
- data/lib/nanoc/base/core_ext/date.rb +1 -1
- data/lib/nanoc/base/core_ext/hash.rb +1 -1
- data/lib/nanoc/base/directed_graph.rb +3 -3
- data/lib/nanoc/base/memoization.rb +1 -1
- data/lib/nanoc/base/notification_center.rb +1 -1
- data/lib/nanoc/base/ordered_hash.rb +1 -1
- data/lib/nanoc/base/plugin_registry.rb +3 -3
- data/lib/nanoc/base/result_data/item_rep.rb +13 -11
- data/lib/nanoc/base/source_data/code_snippet.rb +2 -2
- data/lib/nanoc/base/source_data/data_source.rb +3 -3
- data/lib/nanoc/base/source_data/item.rb +8 -8
- data/lib/nanoc/base/source_data/item_array.rb +1 -1
- data/lib/nanoc/base/source_data/layout.rb +1 -1
- data/lib/nanoc/base/source_data/site.rb +27 -18
- data/lib/nanoc/base/store.rb +3 -3
- data/lib/nanoc/base/temp_filename_factory.rb +2 -2
- data/lib/nanoc/cli.rb +6 -6
- data/lib/nanoc/cli/cleaning_stream.rb +1 -1
- data/lib/nanoc/cli/command_runner.rb +4 -3
- data/lib/nanoc/cli/commands/autocompile.rb +3 -3
- data/lib/nanoc/cli/commands/check.rb +3 -3
- data/lib/nanoc/cli/commands/compile.rb +23 -23
- data/lib/nanoc/cli/commands/create-item.rb +5 -5
- data/lib/nanoc/cli/commands/create-layout.rb +14 -14
- data/lib/nanoc/cli/commands/create-site.rb +6 -6
- data/lib/nanoc/cli/commands/deploy.rb +8 -8
- data/lib/nanoc/cli/commands/nanoc.rb +3 -3
- data/lib/nanoc/cli/commands/prune.rb +3 -3
- data/lib/nanoc/cli/commands/shell.rb +4 -4
- data/lib/nanoc/cli/commands/show-data.rb +5 -5
- data/lib/nanoc/cli/commands/show-plugins.rb +5 -5
- data/lib/nanoc/cli/commands/show-rules.rb +4 -4
- data/lib/nanoc/cli/commands/sync.rb +1 -1
- data/lib/nanoc/cli/commands/update.rb +13 -13
- data/lib/nanoc/cli/commands/validate-css.rb +3 -3
- data/lib/nanoc/cli/commands/validate-html.rb +3 -3
- data/lib/nanoc/cli/commands/validate-links.rb +6 -6
- data/lib/nanoc/cli/commands/view.rb +4 -4
- data/lib/nanoc/cli/commands/watch.rb +11 -11
- data/lib/nanoc/cli/error_handler.rb +10 -10
- data/lib/nanoc/cli/logger.rb +1 -1
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -1
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +5 -5
- data/lib/nanoc/data_sources/deprecated/twitter.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +16 -16
- data/lib/nanoc/data_sources/filesystem_unified.rb +1 -1
- data/lib/nanoc/data_sources/filesystem_verbose.rb +1 -1
- data/lib/nanoc/data_sources/static.rb +1 -1
- data/lib/nanoc/extra/auto_compiler.rb +2 -2
- data/lib/nanoc/extra/checking/check.rb +11 -1
- data/lib/nanoc/extra/checking/checks/external_links.rb +15 -7
- data/lib/nanoc/extra/checking/checks/internal_links.rb +3 -3
- data/lib/nanoc/extra/checking/checks/stale.rb +6 -6
- data/lib/nanoc/extra/checking/runner.rb +10 -9
- data/lib/nanoc/extra/chick.rb +2 -2
- data/lib/nanoc/extra/core_ext/enumerable.rb +1 -1
- data/lib/nanoc/extra/deployers/fog.rb +2 -2
- data/lib/nanoc/extra/deployers/rsync.rb +3 -3
- data/lib/nanoc/extra/file_proxy.rb +3 -3
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -1
- data/lib/nanoc/extra/link_collector.rb +3 -3
- data/lib/nanoc/extra/piper.rb +2 -2
- data/lib/nanoc/extra/pruner.rb +4 -3
- data/lib/nanoc/extra/validators/links.rb +2 -2
- data/lib/nanoc/extra/validators/w3c.rb +1 -1
- data/lib/nanoc/extra/vcs.rb +5 -5
- data/lib/nanoc/extra/vcses/dummy.rb +1 -1
- data/lib/nanoc/filters/asciidoc.rb +1 -1
- data/lib/nanoc/filters/bluecloth.rb +1 -1
- data/lib/nanoc/filters/coffeescript.rb +1 -1
- data/lib/nanoc/filters/colorize_syntax.rb +19 -21
- data/lib/nanoc/filters/erubis.rb +1 -1
- data/lib/nanoc/filters/handlebars.rb +1 -1
- data/lib/nanoc/filters/less.rb +2 -2
- data/lib/nanoc/filters/markaby.rb +1 -1
- data/lib/nanoc/filters/mustache.rb +1 -1
- data/lib/nanoc/filters/rdoc.rb +1 -1
- data/lib/nanoc/filters/relativize_paths.rb +5 -5
- data/lib/nanoc/filters/rubypants.rb +1 -1
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
- data/lib/nanoc/filters/typogruby.rb +1 -1
- data/lib/nanoc/filters/xsl.rb +1 -1
- data/lib/nanoc/helpers/blogging.rb +12 -12
- data/lib/nanoc/helpers/capturing.rb +3 -3
- data/lib/nanoc/helpers/html_escape.rb +6 -6
- data/lib/nanoc/helpers/tagging.rb +1 -1
- data/lib/nanoc/helpers/xml_sitemap.rb +4 -4
- data/lib/nanoc/tasks/clean.rake +1 -1
- data/lib/nanoc/tasks/clean.rb +1 -1
- data/lib/nanoc/tasks/deploy/rsync.rake +2 -2
- data/lib/nanoc/version.rb +1 -1
- data/tasks/rubocop.rake +1 -0
- data/test/base/core_ext/array_spec.rb +7 -7
- data/test/base/core_ext/hash_spec.rb +1 -1
- data/test/base/test_checksum_store.rb +1 -1
- data/test/base/test_compiler.rb +14 -14
- data/test/base/test_compiler_dsl.rb +13 -13
- data/test/base/test_context.rb +2 -2
- data/test/base/test_dependency_tracker.rb +42 -42
- data/test/base/test_directed_graph.rb +102 -102
- data/test/base/test_item.rb +21 -21
- data/test/base/test_item_array.rb +19 -19
- data/test/base/test_item_rep.rb +50 -50
- data/test/base/test_layout.rb +6 -6
- data/test/base/test_outdatedness_checker.rb +2 -2
- data/test/base/test_rule_context.rb +2 -2
- data/test/base/test_site.rb +5 -5
- data/test/cli/commands/test_compile.rb +7 -7
- data/test/cli/commands/test_create_site.rb +2 -2
- data/test/cli/commands/test_deploy.rb +10 -10
- data/test/cli/commands/test_prune.rb +2 -2
- data/test/cli/commands/test_sync.rb +1 -1
- data/test/cli/commands/test_watch.rb +7 -7
- data/test/cli/test_cleaning_stream.rb +4 -4
- data/test/cli/test_cli.rb +3 -3
- data/test/cli/test_error_handler.rb +3 -3
- data/test/data_sources/test_filesystem.rb +19 -19
- data/test/data_sources/test_filesystem_unified.rb +30 -30
- data/test/data_sources/test_filesystem_verbose.rb +3 -3
- data/test/data_sources/test_static.rb +9 -9
- data/test/extra/checking/checks/test_stale.rb +8 -8
- data/test/extra/checking/test_check.rb +11 -1
- data/test/extra/checking/test_dsl.rb +1 -1
- data/test/extra/core_ext/test_enumerable.rb +2 -2
- data/test/extra/deployers/test_fog.rb +10 -10
- data/test/extra/deployers/test_rsync.rb +2 -2
- data/test/extra/test_auto_compiler.rb +28 -28
- data/test/extra/test_filesystem_tools.rb +3 -3
- data/test/extra/test_link_collector.rb +39 -20
- data/test/extra/validators/test_w3c.rb +5 -5
- data/test/filters/test_asciidoc.rb +2 -2
- data/test/filters/test_bluecloth.rb +1 -1
- data/test/filters/test_coffeescript.rb +1 -1
- data/test/filters/test_colorize_syntax.rb +20 -13
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_kramdown.rb +1 -1
- data/test/filters/test_less.rb +10 -10
- data/test/filters/test_markaby.rb +2 -2
- data/test/filters/test_maruku.rb +2 -2
- data/test/filters/test_pandoc.rb +3 -3
- data/test/filters/test_rainpress.rb +4 -4
- data/test/filters/test_rdiscount.rb +2 -2
- data/test/filters/test_rdoc.rb +1 -1
- data/test/filters/test_redcarpet.rb +5 -5
- data/test/filters/test_redcloth.rb +5 -5
- data/test/filters/test_relativize_paths.rb +33 -31
- data/test/filters/test_rubypants.rb +2 -2
- data/test/filters/test_sass.rb +8 -8
- data/test/filters/test_slim.rb +3 -3
- data/test/filters/test_uglify_js.rb +1 -1
- data/test/filters/test_yui_compressor.rb +3 -3
- data/test/gem_loader.rb +1 -1
- data/test/helper.rb +14 -16
- data/test/helpers/test_blogging.rb +28 -28
- data/test/helpers/test_breadcrumbs.rb +12 -12
- data/test/helpers/test_capturing.rb +7 -7
- data/test/helpers/test_filtering.rb +16 -16
- data/test/helpers/test_link_to.rb +3 -3
- data/test/helpers/test_rendering.rb +1 -1
- data/test/helpers/test_tagging.rb +11 -11
- data/test/helpers/test_xml_sitemap.rb +18 -18
- data/test/tasks/test_clean.rb +8 -8
- metadata +2 -2
@@ -101,7 +101,7 @@ module Nanoc::Helpers
|
|
101
101
|
if block_given? # Set content
|
102
102
|
# Get args
|
103
103
|
if args.size != 1
|
104
|
-
raise ArgumentError, 'expected 1 argument (the name '
|
104
|
+
raise ArgumentError, 'expected 1 argument (the name ' \
|
105
105
|
"of the capture) but got #{args.size} instead"
|
106
106
|
end
|
107
107
|
name = args[0]
|
@@ -112,7 +112,7 @@ module Nanoc::Helpers
|
|
112
112
|
else # Get content
|
113
113
|
# Get args
|
114
114
|
if args.size != 2
|
115
|
-
raise ArgumentError, 'expected 2 arguments (the item '
|
115
|
+
raise ArgumentError, 'expected 2 arguments (the item ' \
|
116
116
|
"and the name of the capture) but got #{args.size} instead"
|
117
117
|
end
|
118
118
|
item = args[0]
|
@@ -128,7 +128,7 @@ module Nanoc::Helpers
|
|
128
128
|
# item from which we use content. For this, we need to manually edit
|
129
129
|
# the content attribute to reset it. :(
|
130
130
|
# FIXME clean this up
|
131
|
-
|
131
|
+
unless @site.captures_store_compiled_items.include? item
|
132
132
|
@site.captures_store_compiled_items << item
|
133
133
|
item.forced_outdated = true
|
134
134
|
item.reps.each do |r|
|
@@ -38,13 +38,13 @@ module Nanoc::Helpers
|
|
38
38
|
buffer = eval('_erbout', block.binding)
|
39
39
|
buffer << escaped_data
|
40
40
|
elsif string
|
41
|
-
string.gsub('&', '&')
|
42
|
-
gsub('<', '<')
|
43
|
-
gsub('>', '>')
|
44
|
-
gsub('"', '"')
|
41
|
+
string.gsub('&', '&')
|
42
|
+
.gsub('<', '<')
|
43
|
+
.gsub('>', '>')
|
44
|
+
.gsub('"', '"')
|
45
45
|
else
|
46
|
-
raise
|
47
|
-
|
46
|
+
raise 'The #html_escape or #h function needs either a ' \
|
47
|
+
'string or a block to HTML-escape, but neither a string nor a block was given'
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -63,7 +63,7 @@ module Nanoc::Helpers
|
|
63
63
|
#
|
64
64
|
# @return [String] A link for the given tag and the given base URL
|
65
65
|
def link_for_tag(tag, base_url)
|
66
|
-
%
|
66
|
+
%(<a href="#{h base_url}#{h tag}" rel="tag">#{h tag}</a>)
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -64,10 +64,10 @@ module Nanoc::Helpers
|
|
64
64
|
reps.reject! { |r| !select_proc[r] } if select_proc
|
65
65
|
reps.sort_by { |r| r.name.to_s }.each do |rep|
|
66
66
|
xml.url do
|
67
|
-
xml.loc
|
68
|
-
xml.lastmod
|
69
|
-
xml.changefreq
|
70
|
-
xml.priority
|
67
|
+
xml.loc @site.config[:base_url] + rep.path
|
68
|
+
xml.lastmod item[:mtime].to_iso8601_date unless item[:mtime].nil?
|
69
|
+
xml.changefreq item[:changefreq] unless item[:changefreq].nil?
|
70
|
+
xml.priority item[:priority] unless item[:priority].nil?
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
data/lib/nanoc/tasks/clean.rake
CHANGED
@@ -5,7 +5,7 @@ task :clean do
|
|
5
5
|
# Load site
|
6
6
|
site = Nanoc::Site.new('.')
|
7
7
|
if site.nil?
|
8
|
-
$stderr.puts 'The current working directory does not seem to be a '
|
8
|
+
$stderr.puts 'The current working directory does not seem to be a ' \
|
9
9
|
'valid/complete nanoc site directory; aborting.'
|
10
10
|
exit 1
|
11
11
|
end
|
data/lib/nanoc/tasks/clean.rb
CHANGED
@@ -6,10 +6,10 @@ namespace :deploy do
|
|
6
6
|
|
7
7
|
desc 'Upload the compiled site using rsync'
|
8
8
|
task :rsync do
|
9
|
-
dry_run =
|
9
|
+
dry_run = ENV['dry_run']
|
10
10
|
config_name = ENV['config'] || :default
|
11
11
|
|
12
|
-
cmd = [
|
12
|
+
cmd = ['deploy', '-t', config_name]
|
13
13
|
cmd << '-n' if dry_run
|
14
14
|
|
15
15
|
Nanoc::CLI.run cmd
|
data/lib/nanoc/version.rb
CHANGED
data/tasks/rubocop.rake
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
describe 'Array#symbolize_keys_recursively' do
|
4
4
|
|
5
5
|
it 'should convert keys to symbols' do
|
6
|
-
array_old = [
|
7
|
-
array_new = [
|
6
|
+
array_old = [:abc, 'xyz', { 'foo' => 'bar', :baz => :qux }]
|
7
|
+
array_new = [:abc, 'xyz', { :foo => 'bar', :baz => :qux }]
|
8
8
|
array_old.symbolize_keys_recursively.must_equal array_new
|
9
9
|
end
|
10
10
|
|
@@ -13,8 +13,8 @@ end
|
|
13
13
|
describe 'Array#stringify_keys_recursively' do
|
14
14
|
|
15
15
|
it 'should convert keys to strings' do
|
16
|
-
array_old = [
|
17
|
-
array_new = [
|
16
|
+
array_old = [:abc, 'xyz', { :foo => 'bar', 'baz' => :qux }]
|
17
|
+
array_new = [:abc, 'xyz', { 'foo' => 'bar', 'baz' => :qux }]
|
18
18
|
array_old.stringify_keys_recursively.must_equal array_new
|
19
19
|
end
|
20
20
|
|
@@ -25,7 +25,7 @@ describe 'Array#freeze_recursively' do
|
|
25
25
|
include Nanoc::TestHelpers
|
26
26
|
|
27
27
|
it 'should prevent first-level elements from being modified' do
|
28
|
-
array = [
|
28
|
+
array = [:a, [:b, :c], :d]
|
29
29
|
array.freeze_recursively
|
30
30
|
|
31
31
|
assert_raises_frozen_error do
|
@@ -34,7 +34,7 @@ describe 'Array#freeze_recursively' do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should prevent second-level elements from being modified' do
|
37
|
-
array = [
|
37
|
+
array = [:a, [:b, :c], :d]
|
38
38
|
array.freeze_recursively
|
39
39
|
|
40
40
|
assert_raises_frozen_error do
|
@@ -59,7 +59,7 @@ describe 'Array#checksum' do
|
|
59
59
|
|
60
60
|
it 'should work' do
|
61
61
|
expectation = 'CEUlNvu/3DUmlbtpFRiLHU8oHA0='
|
62
|
-
[
|
62
|
+
[[:foo, 123]].checksum.must_equal expectation
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|
@@ -9,7 +9,7 @@ class Nanoc::ChecksumStoreTest < Nanoc::TestCase
|
|
9
9
|
FileUtils.mkdir_p('tmp')
|
10
10
|
pstore = PStore.new('tmp/checksums')
|
11
11
|
pstore.transaction do
|
12
|
-
pstore[:data] = { [
|
12
|
+
pstore[:data] = { [:item, '/moo/'] => 'zomg' }
|
13
13
|
pstore[:version] = 1
|
14
14
|
end
|
15
15
|
|
data/test/base/test_compiler.rb
CHANGED
@@ -4,7 +4,7 @@ class Nanoc::CompilerTest < Nanoc::TestCase
|
|
4
4
|
|
5
5
|
def test_compilation_rule_for
|
6
6
|
# Mock rules
|
7
|
-
rules = [
|
7
|
+
rules = [mock, mock, mock]
|
8
8
|
rules[0].expects(:applicable_to?).returns(false)
|
9
9
|
rules[1].expects(:applicable_to?).returns(true)
|
10
10
|
rules[1].expects(:rep_name).returns('wrong')
|
@@ -27,7 +27,7 @@ class Nanoc::CompilerTest < Nanoc::TestCase
|
|
27
27
|
|
28
28
|
def test_routing_rule_for
|
29
29
|
# Mock rules
|
30
|
-
rules = [
|
30
|
+
rules = [mock, mock, mock]
|
31
31
|
rules[0].expects(:applicable_to?).returns(false)
|
32
32
|
rules[1].expects(:applicable_to?).returns(true)
|
33
33
|
rules[1].expects(:rep_name).returns('wrong')
|
@@ -54,14 +54,14 @@ class Nanoc::CompilerTest < Nanoc::TestCase
|
|
54
54
|
|
55
55
|
# Create compiler
|
56
56
|
compiler = Nanoc::Compiler.new(site)
|
57
|
-
compiler.rules_collection.layout_filter_mapping[/.*/] = [
|
57
|
+
compiler.rules_collection.layout_filter_mapping[/.*/] = [:erb, { :foo => 'bar' }]
|
58
58
|
|
59
59
|
# Mock layout
|
60
60
|
layout = MiniTest::Mock.new
|
61
61
|
layout.expect(:identifier, '/some_layout/')
|
62
62
|
|
63
63
|
# Check
|
64
|
-
assert_equal([
|
64
|
+
assert_equal([:erb, { :foo => 'bar' }], compiler.rules_collection.filter_for_layout(layout))
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_filter_for_layout_with_existant_layout_and_unknown_filter
|
@@ -70,14 +70,14 @@ class Nanoc::CompilerTest < Nanoc::TestCase
|
|
70
70
|
|
71
71
|
# Create compiler
|
72
72
|
compiler = Nanoc::Compiler.new(site)
|
73
|
-
compiler.rules_collection.layout_filter_mapping[/.*/] = [
|
73
|
+
compiler.rules_collection.layout_filter_mapping[/.*/] = [:some_unknown_filter, { :foo => 'bar' }]
|
74
74
|
|
75
75
|
# Mock layout
|
76
76
|
layout = MiniTest::Mock.new
|
77
77
|
layout.expect(:identifier, '/some_layout/')
|
78
78
|
|
79
79
|
# Check
|
80
|
-
assert_equal([
|
80
|
+
assert_equal([:some_unknown_filter, { :foo => 'bar' }], compiler.rules_collection.filter_for_layout(layout))
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_filter_for_layout_with_nonexistant_layout
|
@@ -86,7 +86,7 @@ class Nanoc::CompilerTest < Nanoc::TestCase
|
|
86
86
|
|
87
87
|
# Create compiler
|
88
88
|
compiler = Nanoc::Compiler.new(site)
|
89
|
-
compiler.rules_collection.layout_filter_mapping[%r{^/foo/$}] = [
|
89
|
+
compiler.rules_collection.layout_filter_mapping[%r{^/foo/$}] = [:erb, { :foo => 'bar' }]
|
90
90
|
|
91
91
|
# Mock layout
|
92
92
|
layout = MiniTest::Mock.new
|
@@ -102,13 +102,13 @@ class Nanoc::CompilerTest < Nanoc::TestCase
|
|
102
102
|
|
103
103
|
# Create compiler
|
104
104
|
compiler = Nanoc::Compiler.new(site)
|
105
|
-
compiler.rules_collection.layout_filter_mapping[%r{^/a/b/c/.*/$}] = [
|
106
|
-
compiler.rules_collection.layout_filter_mapping[%r{^/a/.*/$}] = [
|
107
|
-
compiler.rules_collection.layout_filter_mapping[%r{^/a/b/.*/$}] = [
|
108
|
-
compiler.rules_collection.layout_filter_mapping[%r{^/.*/$}] = [
|
105
|
+
compiler.rules_collection.layout_filter_mapping[%r{^/a/b/c/.*/$}] = [:erb, { :char => 'd' }]
|
106
|
+
compiler.rules_collection.layout_filter_mapping[%r{^/a/.*/$}] = [:erb, { :char => 'b' }]
|
107
|
+
compiler.rules_collection.layout_filter_mapping[%r{^/a/b/.*/$}] = [:erb, { :char => 'c' }] # never used!
|
108
|
+
compiler.rules_collection.layout_filter_mapping[%r{^/.*/$}] = [:erb, { :char => 'a' }]
|
109
109
|
|
110
110
|
# Mock layout
|
111
|
-
layouts = [
|
111
|
+
layouts = [mock, mock, mock, mock]
|
112
112
|
layouts[0].stubs(:identifier).returns('/a/b/c/d/')
|
113
113
|
layouts[1].stubs(:identifier).returns('/a/b/c/')
|
114
114
|
layouts[2].stubs(:identifier).returns('/a/b/')
|
@@ -159,12 +159,12 @@ class Nanoc::CompilerTest < Nanoc::TestCase
|
|
159
159
|
site = mock
|
160
160
|
site.stubs(:config).returns({})
|
161
161
|
site.stubs(:items).returns([])
|
162
|
-
site.stubs(:layouts).returns([
|
162
|
+
site.stubs(:layouts).returns([layout])
|
163
163
|
|
164
164
|
# Create compiler
|
165
165
|
compiler = Nanoc::Compiler.new(site)
|
166
166
|
compiler.rules_collection.expects(:compilation_rule_for).times(2).with(rep).returns(rule)
|
167
|
-
compiler.rules_collection.layout_filter_mapping[%r{^/blah/$}] = [
|
167
|
+
compiler.rules_collection.layout_filter_mapping[%r{^/blah/$}] = [:erb, {}]
|
168
168
|
site.stubs(:compiler).returns(compiler)
|
169
169
|
|
170
170
|
# Compile
|
@@ -106,7 +106,7 @@ EOS
|
|
106
106
|
# Create items
|
107
107
|
assert Dir['content/*'].empty?
|
108
108
|
File.open('content/robots.txt', 'w') do |io|
|
109
|
-
io.write
|
109
|
+
io.write 'Hello I am robots'
|
110
110
|
end
|
111
111
|
|
112
112
|
# Compile
|
@@ -114,7 +114,7 @@ EOS
|
|
114
114
|
site.compile
|
115
115
|
|
116
116
|
# Check paths
|
117
|
-
assert_equal [
|
117
|
+
assert_equal ['output/robots.txt'], Dir['output/*']
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -130,7 +130,7 @@ EOS
|
|
130
130
|
# Create items
|
131
131
|
assert Dir['content/*'].empty?
|
132
132
|
File.open('content/foo', 'w') do |io|
|
133
|
-
io.write
|
133
|
+
io.write 'Hello I am foo'
|
134
134
|
end
|
135
135
|
|
136
136
|
# Compile
|
@@ -138,7 +138,7 @@ EOS
|
|
138
138
|
site.compile
|
139
139
|
|
140
140
|
# Check paths
|
141
|
-
assert_equal [
|
141
|
+
assert_equal ['output/foo'], Dir['output/*']
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
@@ -160,7 +160,7 @@ EOS
|
|
160
160
|
# Create items
|
161
161
|
FileUtils.mkdir_p('static')
|
162
162
|
File.open('static/foo.txt', 'w') do |io|
|
163
|
-
io.write
|
163
|
+
io.write 'Hello I am foo'
|
164
164
|
end
|
165
165
|
|
166
166
|
# Compile
|
@@ -168,7 +168,7 @@ EOS
|
|
168
168
|
site.compile
|
169
169
|
|
170
170
|
# Check paths
|
171
|
-
assert_equal [
|
171
|
+
assert_equal ['output/foo.txt'], Dir['output/*']
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -200,8 +200,8 @@ EOS
|
|
200
200
|
site.compile
|
201
201
|
|
202
202
|
# Check paths
|
203
|
-
assert_equal [
|
204
|
-
assert_equal [
|
203
|
+
assert_equal ['output/foo'], Dir['output/*']
|
204
|
+
assert_equal ['output/foo/index.html'], Dir['output/foo/*']
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
@@ -219,11 +219,11 @@ EOS
|
|
219
219
|
# Create items
|
220
220
|
assert Dir['content/*'].empty?
|
221
221
|
File.open('content/lame.txt', 'w') do |io|
|
222
|
-
io.write
|
222
|
+
io.write 'Hello I am lame'
|
223
223
|
end
|
224
224
|
|
225
225
|
File.open('content/notlame.txt', 'w') do |io|
|
226
|
-
io.write
|
226
|
+
io.write 'Hello I am not lame'
|
227
227
|
end
|
228
228
|
|
229
229
|
# Compile
|
@@ -231,7 +231,7 @@ EOS
|
|
231
231
|
site.compile
|
232
232
|
|
233
233
|
# Check paths
|
234
|
-
assert_equal [
|
234
|
+
assert_equal ['output/notlame.txt'], Dir['output/*']
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
@@ -263,8 +263,8 @@ EOS
|
|
263
263
|
site.compile
|
264
264
|
|
265
265
|
# Check paths
|
266
|
-
assert_equal [
|
267
|
-
assert_equal [
|
266
|
+
assert_equal ['output/foo'], Dir['output/*']
|
267
|
+
assert_equal ['output/foo/index.html'], Dir['output/foo/*']
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
data/test/base/test_context.rb
CHANGED
@@ -7,7 +7,7 @@ class Nanoc::ContextTest < Nanoc::TestCase
|
|
7
7
|
context = Nanoc::Context.new({ :foo => 'bar', :baz => 'quux' })
|
8
8
|
|
9
9
|
# Ensure correct evaluation
|
10
|
-
assert_equal('bar', eval(
|
10
|
+
assert_equal('bar', eval('@foo', context.get_binding))
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_context_with_instance_method
|
@@ -15,7 +15,7 @@ class Nanoc::ContextTest < Nanoc::TestCase
|
|
15
15
|
context = Nanoc::Context.new({ :foo => 'bar', :baz => 'quux' })
|
16
16
|
|
17
17
|
# Ensure correct evaluation
|
18
|
-
assert_equal('bar', eval(
|
18
|
+
assert_equal('bar', eval('foo', context.get_binding))
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_example
|
@@ -4,7 +4,7 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
4
4
|
|
5
5
|
def test_initialize
|
6
6
|
# Mock items
|
7
|
-
items = [
|
7
|
+
items = [mock, mock]
|
8
8
|
|
9
9
|
# Create
|
10
10
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -16,7 +16,7 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
16
16
|
|
17
17
|
def test_record_dependency
|
18
18
|
# Mock items
|
19
|
-
items = [
|
19
|
+
items = [mock, mock]
|
20
20
|
|
21
21
|
# Create
|
22
22
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -25,12 +25,12 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
25
25
|
tracker.record_dependency(items[0], items[1])
|
26
26
|
|
27
27
|
# Verify dependencies
|
28
|
-
assert_contains_exactly [
|
28
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_record_dependency_no_self
|
32
32
|
# Mock items
|
33
|
-
items = [
|
33
|
+
items = [mock, mock]
|
34
34
|
|
35
35
|
# Create
|
36
36
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -40,12 +40,12 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
40
40
|
tracker.record_dependency(items[0], items[1])
|
41
41
|
|
42
42
|
# Verify dependencies
|
43
|
-
assert_contains_exactly [
|
43
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_record_dependency_no_doubles
|
47
47
|
# Mock items
|
48
|
-
items = [
|
48
|
+
items = [mock, mock]
|
49
49
|
|
50
50
|
# Create
|
51
51
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -56,12 +56,12 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
56
56
|
tracker.record_dependency(items[0], items[1])
|
57
57
|
|
58
58
|
# Verify dependencies
|
59
|
-
assert_contains_exactly [
|
59
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_objects_causing_outdatedness_of
|
63
63
|
# Mock items
|
64
|
-
items = [
|
64
|
+
items = [mock, mock, mock]
|
65
65
|
|
66
66
|
# Create
|
67
67
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -71,12 +71,12 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
71
71
|
tracker.record_dependency(items[1], items[2])
|
72
72
|
|
73
73
|
# Verify dependencies
|
74
|
-
assert_contains_exactly [
|
74
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
75
75
|
end
|
76
76
|
|
77
77
|
def test_objects_outdated_due_to
|
78
78
|
# Mock items
|
79
|
-
items = [
|
79
|
+
items = [mock, mock, mock]
|
80
80
|
|
81
81
|
# Create
|
82
82
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -86,12 +86,12 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
86
86
|
tracker.record_dependency(items[1], items[2])
|
87
87
|
|
88
88
|
# Verify dependencies
|
89
|
-
assert_contains_exactly [
|
89
|
+
assert_contains_exactly [items[0]], tracker.objects_outdated_due_to(items[1])
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_start_and_stop
|
93
93
|
# Mock items
|
94
|
-
items = [
|
94
|
+
items = [mock, mock]
|
95
95
|
|
96
96
|
# Create
|
97
97
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -105,18 +105,18 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
105
105
|
tracker.stop
|
106
106
|
|
107
107
|
# Verify dependencies
|
108
|
-
assert_contains_exactly [
|
108
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
109
109
|
assert_empty tracker.objects_causing_outdatedness_of(items[1])
|
110
110
|
end
|
111
111
|
|
112
112
|
def test_store_graph_and_load_graph_simple
|
113
113
|
# Mock items
|
114
|
-
items = [
|
114
|
+
items = [mock('0'), mock('1'), mock('2'), mock('3')]
|
115
115
|
items.each { |i| i.stubs(:type).returns(:item) }
|
116
|
-
items[0].stubs(:reference).returns([
|
117
|
-
items[1].stubs(:reference).returns([
|
118
|
-
items[2].stubs(:reference).returns([
|
119
|
-
items[3].stubs(:reference).returns([
|
116
|
+
items[0].stubs(:reference).returns([:item, '/aaa/'])
|
117
|
+
items[1].stubs(:reference).returns([:item, '/bbb/'])
|
118
|
+
items[2].stubs(:reference).returns([:item, '/ccc/'])
|
119
|
+
items[3].stubs(:reference).returns([:item, '/ddd/'])
|
120
120
|
|
121
121
|
# Create
|
122
122
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -137,24 +137,24 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
137
137
|
tracker.load_graph
|
138
138
|
|
139
139
|
# Check loaded graph
|
140
|
-
assert_contains_exactly [
|
141
|
-
assert_contains_exactly [
|
140
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
141
|
+
assert_contains_exactly [items[2], items[3]], tracker.objects_causing_outdatedness_of(items[1])
|
142
142
|
assert_empty tracker.objects_causing_outdatedness_of(items[2])
|
143
143
|
assert_empty tracker.objects_causing_outdatedness_of(items[3])
|
144
144
|
end
|
145
145
|
|
146
146
|
def test_store_graph_and_load_graph_with_removed_items
|
147
147
|
# Mock items
|
148
|
-
items = [
|
148
|
+
items = [mock('0'), mock('1'), mock('2'), mock('3')]
|
149
149
|
items.each { |i| i.stubs(:type).returns(:item) }
|
150
|
-
items[0].stubs(:reference).returns([
|
151
|
-
items[1].stubs(:reference).returns([
|
152
|
-
items[2].stubs(:reference).returns([
|
153
|
-
items[3].stubs(:reference).returns([
|
150
|
+
items[0].stubs(:reference).returns([:item, '/aaa/'])
|
151
|
+
items[1].stubs(:reference).returns([:item, '/bbb/'])
|
152
|
+
items[2].stubs(:reference).returns([:item, '/ccc/'])
|
153
|
+
items[3].stubs(:reference).returns([:item, '/ddd/'])
|
154
154
|
|
155
155
|
# Create new and old lists
|
156
|
-
old_items = [
|
157
|
-
new_items = [
|
156
|
+
old_items = [items[0], items[1], items[2], items[3]]
|
157
|
+
new_items = [items[0], items[1], items[2]]
|
158
158
|
|
159
159
|
# Create
|
160
160
|
tracker = Nanoc::DependencyTracker.new(old_items)
|
@@ -175,18 +175,18 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
175
175
|
tracker.load_graph
|
176
176
|
|
177
177
|
# Check loaded graph
|
178
|
-
assert_contains_exactly [
|
179
|
-
assert_contains_exactly [
|
178
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
179
|
+
assert_contains_exactly [items[2], nil], tracker.objects_causing_outdatedness_of(items[1])
|
180
180
|
assert_empty tracker.objects_causing_outdatedness_of(items[2])
|
181
181
|
end
|
182
182
|
|
183
183
|
def test_store_graph_with_nils_in_dst
|
184
184
|
# Mock items
|
185
|
-
items = [
|
185
|
+
items = [mock('0'), mock('1'), mock('2')]
|
186
186
|
items.each { |i| i.stubs(:type).returns(:item) }
|
187
|
-
items[0].stubs(:reference).returns([
|
188
|
-
items[1].stubs(:reference).returns([
|
189
|
-
items[2].stubs(:reference).returns([
|
187
|
+
items[0].stubs(:reference).returns([:item, '/aaa/'])
|
188
|
+
items[1].stubs(:reference).returns([:item, '/bbb/'])
|
189
|
+
items[2].stubs(:reference).returns([:item, '/ccc/'])
|
190
190
|
|
191
191
|
# Create
|
192
192
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -206,17 +206,17 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
206
206
|
tracker.load_graph
|
207
207
|
|
208
208
|
# Check loaded graph
|
209
|
-
assert_contains_exactly [
|
210
|
-
assert_contains_exactly [
|
209
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
210
|
+
assert_contains_exactly [nil], tracker.objects_causing_outdatedness_of(items[1])
|
211
211
|
end
|
212
212
|
|
213
213
|
def test_store_graph_with_nils_in_src
|
214
214
|
# Mock items
|
215
|
-
items = [
|
215
|
+
items = [mock('0'), mock('1'), mock('2')]
|
216
216
|
items.each { |i| i.stubs(:type).returns(:item) }
|
217
|
-
items[0].stubs(:reference).returns([
|
218
|
-
items[1].stubs(:reference).returns([
|
219
|
-
items[2].stubs(:reference).returns([
|
217
|
+
items[0].stubs(:reference).returns([:item, '/aaa/'])
|
218
|
+
items[1].stubs(:reference).returns([:item, '/bbb/'])
|
219
|
+
items[2].stubs(:reference).returns([:item, '/ccc/'])
|
220
220
|
|
221
221
|
# Create
|
222
222
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -236,13 +236,13 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
236
236
|
tracker.load_graph
|
237
237
|
|
238
238
|
# Check loaded graph
|
239
|
-
assert_contains_exactly [
|
239
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
240
240
|
assert_empty tracker.objects_causing_outdatedness_of(items[1])
|
241
241
|
end
|
242
242
|
|
243
243
|
def test_forget_dependencies_for
|
244
244
|
# Mock items
|
245
|
-
items = [
|
245
|
+
items = [mock, mock, mock]
|
246
246
|
|
247
247
|
# Create
|
248
248
|
tracker = Nanoc::DependencyTracker.new(items)
|
@@ -250,7 +250,7 @@ class Nanoc::DependencyTrackerTest < Nanoc::TestCase
|
|
250
250
|
# Record some dependencies
|
251
251
|
tracker.record_dependency(items[0], items[1])
|
252
252
|
tracker.record_dependency(items[1], items[2])
|
253
|
-
assert_contains_exactly [
|
253
|
+
assert_contains_exactly [items[1]], tracker.objects_causing_outdatedness_of(items[0])
|
254
254
|
|
255
255
|
# Forget dependencies
|
256
256
|
tracker.forget_dependencies_for(items[0])
|