nanoc 4.4.4 → 4.4.5
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 +9 -8
- data/NEWS.md +10 -0
- data/lib/nanoc/base.rb +0 -3
- data/lib/nanoc/base/contracts_support.rb +55 -2
- data/lib/nanoc/base/core_ext/array.rb +0 -2
- data/lib/nanoc/base/core_ext/hash.rb +0 -2
- data/lib/nanoc/base/entities.rb +1 -0
- data/lib/nanoc/base/entities/context.rb +1 -4
- data/lib/nanoc/base/entities/directed_graph.rb +0 -10
- data/lib/nanoc/base/entities/identifiable_collection.rb +1 -2
- data/lib/nanoc/base/entities/identifier.rb +6 -8
- data/lib/nanoc/base/entities/item_rep.rb +12 -18
- data/lib/nanoc/base/{compilation → entities}/outdatedness_reasons.rb +0 -0
- data/lib/nanoc/base/entities/site.rb +3 -19
- data/lib/nanoc/base/errors.rb +9 -0
- data/lib/nanoc/base/memoization.rb +0 -2
- data/lib/nanoc/base/repos/checksum_store.rb +21 -14
- data/lib/nanoc/base/repos/compiled_content_cache.rb +11 -15
- data/lib/nanoc/base/repos/dependency_store.rb +8 -27
- data/lib/nanoc/base/services.rb +3 -0
- data/lib/nanoc/base/services/compiler.rb +379 -0
- data/lib/nanoc/base/services/compiler_loader.rb +3 -1
- data/lib/nanoc/base/services/executor.rb +27 -41
- data/lib/nanoc/base/services/item_rep_builder.rb +4 -0
- data/lib/nanoc/base/services/item_rep_writer.rb +5 -2
- data/lib/nanoc/base/{compilation → services}/outdatedness_checker.rb +1 -1
- data/lib/nanoc/base/views/post_compile_item_rep_view.rb +1 -1
- data/lib/nanoc/base/views/view_context.rb +3 -3
- data/lib/nanoc/checking/check.rb +1 -1
- data/lib/nanoc/checking/checks/external_links.rb +1 -1
- data/lib/nanoc/cli.rb +0 -4
- data/lib/nanoc/cli/commands/compile.rb +2 -2
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +10 -20
- data/lib/nanoc/data_sources/filesystem/errors.rb +55 -0
- data/lib/nanoc/filters/asciidoc.rb +0 -2
- data/lib/nanoc/filters/coffeescript.rb +0 -2
- data/lib/nanoc/filters/colorize_syntax.rb +0 -2
- data/lib/nanoc/filters/handlebars.rb +0 -2
- data/lib/nanoc/filters/mustache.rb +0 -2
- data/lib/nanoc/filters/redcarpet.rb +0 -4
- data/lib/nanoc/filters/slim.rb +0 -2
- data/lib/nanoc/filters/typogruby.rb +0 -2
- data/lib/nanoc/filters/xsl.rb +0 -2
- data/lib/nanoc/filters/yui_compressor.rb +0 -2
- data/lib/nanoc/helpers/capturing.rb +22 -19
- data/lib/nanoc/helpers/link_to.rb +3 -7
- data/lib/nanoc/helpers/rendering.rb +1 -1
- data/lib/nanoc/rule_dsl/action_provider.rb +2 -2
- data/lib/nanoc/rule_dsl/compiler_dsl.rb +0 -2
- data/lib/nanoc/rule_dsl/recording_executor.rb +6 -6
- data/lib/nanoc/rule_dsl/rule.rb +0 -2
- data/lib/nanoc/rule_dsl/rule_context.rb +3 -3
- data/lib/nanoc/rule_dsl/rule_memory_calculator.rb +5 -5
- data/lib/nanoc/spec.rb +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/test/base/test_compiler.rb +3 -1
- data/test/base/test_dependency_tracker.rb +0 -19
- data/test/base/test_item_rep.rb +3 -0
- data/test/cli/commands/test_create_site.rb +1 -1
- data/test/data_sources/test_filesystem.rb +5 -5
- data/test/filters/test_coffeescript.rb +2 -0
- data/test/filters/test_handlebars.rb +4 -0
- data/test/filters/test_uglify_js.rb +4 -0
- data/test/filters/test_xsl.rb +1 -1
- data/test/helper.rb +6 -0
- data/test/helpers/test_capturing.rb +6 -1
- data/test/helpers/test_xml_sitemap.rb +1 -1
- metadata +6 -6
- data/lib/nanoc/base/compilation/compiler.rb +0 -295
- data/test/base/test_checksum_store.rb +0 -28
@@ -250,8 +250,6 @@ module Nanoc::Filters
|
|
250
250
|
|
251
251
|
# Runs the content through [Highlight](http://www.andre-simon.de/doku/highlight/en/highlight.html).
|
252
252
|
#
|
253
|
-
# @since 3.2.0
|
254
|
-
#
|
255
253
|
# @param [String] code The code to colorize
|
256
254
|
#
|
257
255
|
# @param [String] language The language the code is written in
|
@@ -1,6 +1,4 @@
|
|
1
1
|
module Nanoc::Filters
|
2
|
-
# @since 3.2.0
|
3
|
-
#
|
4
2
|
# @api private
|
5
3
|
class Redcarpet < Nanoc::Filter
|
6
4
|
requires 'redcarpet'
|
@@ -23,8 +21,6 @@ module Nanoc::Filters
|
|
23
21
|
#
|
24
22
|
# For Redcarpet 2.x
|
25
23
|
#
|
26
|
-
# @since 3.2.4
|
27
|
-
#
|
28
24
|
# @param [String] content The content to filter
|
29
25
|
#
|
30
26
|
# @option params [Hash] :options ({}) A list of options to pass on to
|
data/lib/nanoc/filters/slim.rb
CHANGED
data/lib/nanoc/filters/xsl.rb
CHANGED
@@ -27,30 +27,32 @@ module Nanoc::Helpers
|
|
27
27
|
existing_behavior = params.fetch(:existing, :error)
|
28
28
|
|
29
29
|
# Capture
|
30
|
-
|
30
|
+
content_string = capture(&block)
|
31
31
|
|
32
|
-
#
|
32
|
+
# Get existing contents and prep for store
|
33
33
|
snapshot_contents = @item.reps[:default].unwrap.snapshot_contents
|
34
34
|
capture_name = "__capture_#{name}".to_sym
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
old_content_string =
|
36
|
+
case existing_behavior
|
37
|
+
when :overwrite
|
38
|
+
''
|
39
|
+
when :append
|
40
|
+
c = snapshot_contents[capture_name]
|
41
|
+
c ? c.string : ''
|
42
|
+
when :error
|
43
|
+
if snapshot_contents[capture_name] && snapshot_contents[capture_name].string != content_string
|
44
|
+
# FIXME: get proper exception
|
45
|
+
raise "a capture named #{name.inspect} for #{@item.identifier} already exists"
|
46
|
+
else
|
47
|
+
''
|
48
|
+
end
|
44
49
|
else
|
45
|
-
|
50
|
+
raise ArgumentError, 'expected :existing_behavior param to #content_for to be one of ' \
|
51
|
+
":overwrite, :append, or :error, but #{existing_behavior.inspect} was given"
|
46
52
|
end
|
47
|
-
else
|
48
|
-
raise ArgumentError, 'expected :existing_behavior param to #content_for to be one of ' \
|
49
|
-
":overwrite, :append, or :error, but #{existing_behavior.inspect} was given"
|
50
|
-
end
|
51
53
|
|
52
54
|
# Store
|
53
|
-
snapshot_contents[capture_name]
|
55
|
+
snapshot_contents[capture_name] = Nanoc::Int::TextualContent.new(old_content_string + content_string)
|
54
56
|
else # Get content
|
55
57
|
if args.size != 2
|
56
58
|
raise ArgumentError, 'expected 2 arguments (the item ' \
|
@@ -72,7 +74,8 @@ module Nanoc::Helpers
|
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
|
-
rep.snapshot_contents["__capture_#{name}".to_sym]
|
77
|
+
content = rep.snapshot_contents["__capture_#{name}".to_sym]
|
78
|
+
content ? content.string : nil
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
@@ -93,7 +96,7 @@ module Nanoc::Helpers
|
|
93
96
|
|
94
97
|
# Depending on how the filter outputs, the result might be a
|
95
98
|
# single string or an array of strings (slim outputs the latter).
|
96
|
-
erbout_addition = erbout_addition.join if erbout_addition.is_a? Array
|
99
|
+
erbout_addition = erbout_addition.join('') if erbout_addition.is_a? Array
|
97
100
|
|
98
101
|
# Done.
|
99
102
|
erbout_addition
|
@@ -78,15 +78,11 @@ module Nanoc::Helpers
|
|
78
78
|
|
79
79
|
# Calculate the relative path (method depends on whether destination is
|
80
80
|
# a directory or not).
|
81
|
-
|
82
|
-
|
83
|
-
dst_path.relative_path_from(src_path.dirname).to_s
|
84
|
-
else
|
85
|
-
dst_path.relative_path_from(src_path).to_s
|
86
|
-
end
|
81
|
+
from = src_path.to_s.end_with?('/') ? src_path : src_path.dirname
|
82
|
+
relative_path = dst_path.relative_path_from(from).to_s
|
87
83
|
|
88
84
|
# Add trailing slash if necessary
|
89
|
-
if dst_path.to_s
|
85
|
+
if dst_path.to_s.end_with?('/')
|
90
86
|
relative_path << '/'
|
91
87
|
end
|
92
88
|
|
@@ -37,7 +37,7 @@ module Nanoc::Helpers
|
|
37
37
|
}.merge(other_assigns)
|
38
38
|
|
39
39
|
# Get filter name
|
40
|
-
filter_name, filter_args = *@config._context.
|
40
|
+
filter_name, filter_args = *@config._context.compilation_context.filter_name_and_args_for_layout(layout)
|
41
41
|
raise Nanoc::Int::Errors::CannotDetermineFilter.new(layout.identifier) if filter_name.nil?
|
42
42
|
|
43
43
|
# Get filter class
|
@@ -55,7 +55,7 @@ module Nanoc::RuleDSL
|
|
55
55
|
reps: reps,
|
56
56
|
items: site.items,
|
57
57
|
dependency_tracker: dependency_tracker,
|
58
|
-
|
58
|
+
compilation_context: site.compiler.compilation_context,
|
59
59
|
)
|
60
60
|
ctx = new_postprocessor_context(site, view_context)
|
61
61
|
|
@@ -72,7 +72,7 @@ module Nanoc::RuleDSL
|
|
72
72
|
reps: nil,
|
73
73
|
items: nil,
|
74
74
|
dependency_tracker: dependency_tracker,
|
75
|
-
|
75
|
+
compilation_context: nil,
|
76
76
|
)
|
77
77
|
|
78
78
|
Nanoc::Int::Context.new(
|
@@ -19,11 +19,11 @@ module Nanoc
|
|
19
19
|
@rule_memory = Nanoc::Int::RuleMemory.new(item_rep)
|
20
20
|
end
|
21
21
|
|
22
|
-
def filter(
|
22
|
+
def filter(filter_name, filter_args = {})
|
23
23
|
@rule_memory.add_filter(filter_name, filter_args)
|
24
24
|
end
|
25
25
|
|
26
|
-
def layout(
|
26
|
+
def layout(layout_identifier, extra_filter_args = {})
|
27
27
|
unless layout_identifier.is_a?(String)
|
28
28
|
raise ArgumentError.new('The layout passed to #layout must be a string')
|
29
29
|
end
|
@@ -36,9 +36,9 @@ module Nanoc
|
|
36
36
|
end
|
37
37
|
|
38
38
|
Pathlike = C::Maybe[C::Or[String, Nanoc::Identifier]]
|
39
|
-
contract
|
40
|
-
def snapshot(
|
41
|
-
pathlike = final ? (path || basic_path_from_rules_for(
|
39
|
+
contract Symbol, C::KeywordArgs[path: C::Optional[Pathlike], final: C::Optional[C::Bool]] => nil
|
40
|
+
def snapshot(snapshot_name, final: true, path: nil)
|
41
|
+
pathlike = final ? (path || basic_path_from_rules_for(@item_rep, snapshot_name)) : nil
|
42
42
|
actual_path = pathlike && pathlike.to_s
|
43
43
|
@rule_memory.add_snapshot(snapshot_name, final, actual_path)
|
44
44
|
nil
|
@@ -50,7 +50,7 @@ module Nanoc
|
|
50
50
|
return nil if routing_rule.nil?
|
51
51
|
|
52
52
|
dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
|
53
|
-
view_context = Nanoc::ViewContext.new(reps: nil, items: nil, dependency_tracker: dependency_tracker,
|
53
|
+
view_context = Nanoc::ViewContext.new(reps: nil, items: nil, dependency_tracker: dependency_tracker, compilation_context: nil)
|
54
54
|
basic_path = routing_rule.apply_to(rep, executor: nil, site: @site, view_context: view_context)
|
55
55
|
if basic_path && !basic_path.start_with?('/')
|
56
56
|
raise PathWithoutInitialSlashError.new(rep, basic_path)
|
data/lib/nanoc/rule_dsl/rule.rb
CHANGED
@@ -35,7 +35,7 @@ module Nanoc::RuleDSL
|
|
35
35
|
#
|
36
36
|
# @return [void]
|
37
37
|
def filter(filter_name, filter_args = {})
|
38
|
-
@_executor.filter(
|
38
|
+
@_executor.filter(filter_name, filter_args)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Layouts the current representation (calls {Nanoc::Int::ItemRep#layout} with
|
@@ -48,7 +48,7 @@ module Nanoc::RuleDSL
|
|
48
48
|
#
|
49
49
|
# @return [void]
|
50
50
|
def layout(layout_identifier, extra_filter_args = nil)
|
51
|
-
@_executor.layout(
|
51
|
+
@_executor.layout(layout_identifier, extra_filter_args)
|
52
52
|
end
|
53
53
|
|
54
54
|
# Creates a snapshot of the current compiled item content. Calls
|
@@ -62,7 +62,7 @@ module Nanoc::RuleDSL
|
|
62
62
|
#
|
63
63
|
# @return [void]
|
64
64
|
def snapshot(snapshot_name, path: nil)
|
65
|
-
@_executor.snapshot(
|
65
|
+
@_executor.snapshot(snapshot_name, path: path)
|
66
66
|
end
|
67
67
|
|
68
68
|
# Creates a snapshot named :last the current compiled item content, with
|
@@ -66,7 +66,7 @@ module Nanoc::RuleDSL
|
|
66
66
|
# @return [Nanoc::Int::RuleMemory]
|
67
67
|
def new_rule_memory_for_rep(rep)
|
68
68
|
dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
|
69
|
-
view_context = @site.compiler.create_view_context(dependency_tracker)
|
69
|
+
view_context = @site.compiler.compilation_context.create_view_context(dependency_tracker)
|
70
70
|
|
71
71
|
executor = Nanoc::RuleDSL::RecordingExecutor.new(rep, @rules_collection, @site)
|
72
72
|
rule = @rules_collection.compilation_rule_for(rep)
|
@@ -75,14 +75,14 @@ module Nanoc::RuleDSL
|
|
75
75
|
raise NoRuleMemoryForItemRepException.new(rep)
|
76
76
|
end
|
77
77
|
|
78
|
-
executor.snapshot(
|
79
|
-
executor.snapshot(
|
78
|
+
executor.snapshot(:raw)
|
79
|
+
executor.snapshot(:pre, final: false)
|
80
80
|
rule.apply_to(rep, executor: executor, site: @site, view_context: view_context)
|
81
81
|
if executor.rule_memory.any_layouts?
|
82
|
-
executor.snapshot(
|
82
|
+
executor.snapshot(:post)
|
83
83
|
end
|
84
84
|
unless executor.rule_memory.snapshot_actions.any? { |sa| sa.snapshot_name == :last }
|
85
|
-
executor.snapshot(
|
85
|
+
executor.snapshot(:last)
|
86
86
|
end
|
87
87
|
|
88
88
|
executor.rule_memory
|
data/lib/nanoc/spec.rb
CHANGED
data/lib/nanoc/version.rb
CHANGED
data/test/base/test_compiler.rb
CHANGED
@@ -11,9 +11,11 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
|
|
11
11
|
|
12
12
|
action_provider = Nanoc::Int::ActionProvider.named(:rule_dsl).for(site)
|
13
13
|
|
14
|
+
objects = site.items.to_a + site.layouts.to_a
|
15
|
+
|
14
16
|
params = {
|
15
17
|
compiled_content_cache: Nanoc::Int::CompiledContentCache.new(items: site.items),
|
16
|
-
checksum_store: Nanoc::Int::ChecksumStore.new(site: site),
|
18
|
+
checksum_store: Nanoc::Int::ChecksumStore.new(site: site, objects: objects),
|
17
19
|
rule_memory_store: Nanoc::Int::RuleMemoryStore.new,
|
18
20
|
dependency_store: Nanoc::Int::DependencyStore.new(
|
19
21
|
site.items.to_a + site.layouts.to_a,
|
@@ -87,25 +87,6 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
|
|
87
87
|
assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
|
88
88
|
end
|
89
89
|
|
90
|
-
def test_objects_outdated_due_to
|
91
|
-
# Mock items
|
92
|
-
items = [
|
93
|
-
Nanoc::Int::Item.new('a', {}, '/a.md'),
|
94
|
-
Nanoc::Int::Item.new('b', {}, '/b.md'),
|
95
|
-
Nanoc::Int::Item.new('c', {}, '/c.md'),
|
96
|
-
]
|
97
|
-
|
98
|
-
# Create
|
99
|
-
store = Nanoc::Int::DependencyStore.new(items)
|
100
|
-
|
101
|
-
# Record some dependencies
|
102
|
-
store.record_dependency(items[0], items[1])
|
103
|
-
store.record_dependency(items[1], items[2])
|
104
|
-
|
105
|
-
# Verify dependencies
|
106
|
-
assert_contains_exactly [items[0]], store.objects_outdated_due_to(items[1])
|
107
|
-
end
|
108
|
-
|
109
90
|
def test_store_graph_and_load_graph_simple
|
110
91
|
# Mock items
|
111
92
|
items = [
|
data/test/base/test_item_rep.rb
CHANGED
@@ -139,7 +139,10 @@ class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
|
139
139
|
def test_access_compiled_content_of_binary_item
|
140
140
|
content = Nanoc::Int::BinaryContent.new(File.expand_path('content/somefile.dat'))
|
141
141
|
item = Nanoc::Int::Item.new(content, {}, '/somefile/')
|
142
|
+
|
142
143
|
item_rep = Nanoc::Int::ItemRep.new(item, :foo)
|
144
|
+
item_rep.expects(:compiled?).returns(true)
|
145
|
+
|
143
146
|
assert_raises(Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem) do
|
144
147
|
item_rep.compiled_content
|
145
148
|
end
|
@@ -75,7 +75,7 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
75
75
|
FileUtils.cd('foo') do
|
76
76
|
# Try with encoding = default encoding = utf-8
|
77
77
|
File.open('content/index.html', 'w') { |io| io.write('Hello ' + 0xD6.chr + "!\n") }
|
78
|
-
exception = assert_raises(
|
78
|
+
exception = assert_raises(Nanoc::DataSources::Filesystem::Errors::InvalidEncoding) do
|
79
79
|
Nanoc::Int::SiteLoader.new.new_from_cwd
|
80
80
|
end
|
81
81
|
assert_equal 'Could not read content/index.html because the file is not valid UTF-8.', exception.message
|
@@ -135,7 +135,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
135
135
|
File.open('foo/stuff.dat', 'w') { |io| io.write('random binary data') }
|
136
136
|
|
137
137
|
# Load
|
138
|
-
assert_raises(
|
138
|
+
assert_raises(Nanoc::DataSources::Filesystem::Errors::BinaryLayout) do
|
139
139
|
data_source.send(:load_objects, 'foo', Nanoc::Int::Layout)
|
140
140
|
end
|
141
141
|
end
|
@@ -642,7 +642,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
642
642
|
end
|
643
643
|
|
644
644
|
# Check
|
645
|
-
assert_raises
|
645
|
+
assert_raises(Nanoc::DataSources::Filesystem::Errors::MultipleContentFiles) do
|
646
646
|
data_source.send(:all_split_files_in, '.')
|
647
647
|
end
|
648
648
|
end
|
@@ -829,7 +829,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
829
829
|
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil, nil)
|
830
830
|
|
831
831
|
# Parse it
|
832
|
-
assert_raises(
|
832
|
+
assert_raises(Nanoc::DataSources::Filesystem::Errors::InvalidFormat) do
|
833
833
|
data_source.instance_eval { parse('test.html', nil) }
|
834
834
|
end
|
835
835
|
end
|
@@ -981,7 +981,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
981
981
|
|
982
982
|
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil, nil)
|
983
983
|
|
984
|
-
assert_raises(Nanoc::DataSources::Filesystem::
|
984
|
+
assert_raises(Nanoc::DataSources::Filesystem::Errors::InvalidMetadata) do
|
985
985
|
data_source.instance_eval { parse('test.html', nil) }
|
986
986
|
end
|
987
987
|
end
|
@@ -992,7 +992,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
992
992
|
|
993
993
|
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil, nil)
|
994
994
|
|
995
|
-
assert_raises(Nanoc::DataSources::Filesystem::
|
995
|
+
assert_raises(Nanoc::DataSources::Filesystem::Errors::InvalidMetadata) do
|
996
996
|
data_source.instance_eval { parse('test.html', 'test.yaml') }
|
997
997
|
end
|
998
998
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class Nanoc::Filters::HandlebarsTest < Nanoc::TestCase
|
2
2
|
def test_filter
|
3
|
+
skip_v8_on_ruby24
|
4
|
+
|
3
5
|
if_have 'handlebars' do
|
4
6
|
# Create data
|
5
7
|
item = Nanoc::Int::Item.new(
|
@@ -34,6 +36,8 @@ class Nanoc::Filters::HandlebarsTest < Nanoc::TestCase
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def test_filter_without_layout
|
39
|
+
skip_v8_on_ruby24
|
40
|
+
|
37
41
|
if_have 'handlebars' do
|
38
42
|
# Create data
|
39
43
|
item = Nanoc::Int::Item.new(
|