nanoc 4.8.9 → 4.8.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -4
- data/Gemfile +2 -1
- data/NEWS.md +7 -0
- data/README.md +1 -1
- data/lib/nanoc.rb +2 -6
- data/lib/nanoc/base/entities/site.rb +9 -5
- data/lib/nanoc/base/repos/data_source.rb +0 -15
- data/lib/nanoc/base/repos/outdatedness_store.rb +17 -15
- data/lib/nanoc/base/services/compilation_context.rb +4 -4
- data/lib/nanoc/base/services/compiler.rb +102 -103
- data/lib/nanoc/base/services/compiler/stages/build_reps.rb +7 -7
- data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +4 -2
- data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +25 -7
- data/lib/nanoc/base/services/compiler/stages/postprocess.rb +3 -3
- data/lib/nanoc/base/services/compiler/stages/preprocess.rb +3 -0
- data/lib/nanoc/base/services/compiler_loader.rb +1 -4
- data/lib/nanoc/base/views.rb +13 -6
- data/lib/nanoc/base/views/{item_rep_collection_view.rb → basic_item_rep_collection_view.rb} +6 -6
- data/lib/nanoc/base/views/{item_rep_view.rb → basic_item_rep_view.rb} +8 -29
- data/lib/nanoc/base/views/{item_without_reps_view.rb → basic_item_view.rb} +3 -3
- data/lib/nanoc/base/views/compilation_item_rep_collection_view.rb +10 -0
- data/lib/nanoc/base/views/compilation_item_rep_view.rb +42 -0
- data/lib/nanoc/base/views/{mixins/with_reps_view_mixin.rb → compilation_item_view.rb} +3 -3
- data/lib/nanoc/base/views/item_collection_with_reps_view.rb +1 -1
- data/lib/nanoc/base/views/item_collection_without_reps_view.rb +1 -1
- data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +1 -1
- data/lib/nanoc/base/views/mutable_item_view.rb +1 -1
- data/lib/nanoc/base/views/post_compile_item_rep_collection_view.rb +1 -1
- data/lib/nanoc/base/views/post_compile_item_rep_view.rb +7 -2
- data/lib/nanoc/base/views/post_compile_item_view.rb +1 -1
- data/lib/nanoc/base/views/{view_context.rb → view_context_for_compilation.rb} +10 -1
- data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +18 -0
- data/lib/nanoc/base/views/view_context_for_shell.rb +23 -0
- data/lib/nanoc/checking/check.rb +5 -1
- data/lib/nanoc/checking/runner.rb +1 -1
- data/lib/nanoc/cli.rb +1 -0
- data/lib/nanoc/cli/command_runner.rb +1 -7
- data/lib/nanoc/cli/commands/check.rb +2 -2
- data/lib/nanoc/cli/commands/compile.rb +8 -47
- data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +9 -0
- data/lib/nanoc/cli/commands/compile_listeners/aggregate.rb +49 -0
- data/lib/nanoc/cli/commands/deploy.rb +2 -1
- data/lib/nanoc/cli/commands/prune.rb +5 -4
- data/lib/nanoc/cli/commands/shell.rb +4 -6
- data/lib/nanoc/cli/commands/show-data.rb +20 -27
- data/lib/nanoc/cli/commands/show-rules.rb +20 -22
- data/lib/nanoc/cli/error_handler.rb +0 -17
- data/lib/nanoc/data_sources/filesystem.rb +4 -2
- data/lib/nanoc/deploying/deployers/fog.rb +4 -1
- data/lib/nanoc/helpers/link_to.rb +1 -1
- data/lib/nanoc/rule_dsl/action_provider.rb +8 -11
- data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +14 -5
- data/lib/nanoc/rule_dsl/recording_executor.rb +4 -0
- data/lib/nanoc/rule_dsl/rule.rb +14 -9
- data/lib/nanoc/rule_dsl/rule_context.rb +4 -4
- data/lib/nanoc/spec.rb +27 -19
- data/lib/nanoc/version.rb +1 -1
- data/spec/nanoc/base/checksummer_spec.rb +19 -11
- data/spec/nanoc/base/compiler_spec.rb +18 -14
- data/spec/nanoc/base/filter_spec.rb +7 -6
- data/spec/nanoc/base/repos/outdatedness_store_spec.rb +3 -32
- data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +2 -1
- data/spec/nanoc/base/services/compiler/stages/determine_outdatedness_spec.rb +148 -0
- data/spec/nanoc/base/services/compiler/stages/preprocess_spec.rb +110 -0
- data/spec/nanoc/base/services/executor_spec.rb +6 -6
- data/spec/nanoc/base/views/basic_item_rep_collection_view_spec.rb +8 -0
- data/spec/nanoc/base/views/basic_item_rep_view_spec.rb +9 -0
- data/spec/nanoc/base/views/compilation_item_rep_collection_view_spec.rb +8 -0
- data/spec/nanoc/base/views/compilation_item_rep_view_spec.rb +136 -0
- data/spec/nanoc/base/views/config_view_spec.rb +5 -5
- data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +4 -2
- data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +4 -2
- data/spec/nanoc/base/views/item_view_spec.rb +13 -11
- data/spec/nanoc/base/views/layout_collection_view_spec.rb +3 -1
- data/spec/nanoc/base/views/layout_view_spec.rb +3 -1
- data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +5 -2
- data/spec/nanoc/base/views/mutable_item_view_spec.rb +2 -0
- data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +5 -2
- data/spec/nanoc/base/views/mutable_layout_view_spec.rb +2 -0
- data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +2 -0
- data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +9 -3
- data/spec/nanoc/base/views/{document_view_spec.rb → support/document_view_examples.rb} +5 -5
- data/spec/nanoc/base/views/{identifiable_collection_view_spec.rb → support/identifiable_collection_view_examples.rb} +4 -4
- data/spec/nanoc/base/views/{item_rep_collection_view_spec.rb → support/item_rep_collection_view_examples.rb} +3 -8
- data/spec/nanoc/base/views/{item_rep_view_spec.rb → support/item_rep_view_examples.rb} +10 -111
- data/spec/nanoc/base/views/{mutable_document_view_spec.rb → support/mutable_document_view_examples.rb} +7 -6
- data/spec/nanoc/base/views/{mutable_identifiable_collection_view_spec.rb → support/mutable_identifiable_collection_view_examples.rb} +1 -1
- data/spec/nanoc/cli/commands/compile/abstract_spec.rb +80 -0
- data/spec/nanoc/cli/commands/compile_spec.rb +30 -51
- data/spec/nanoc/cli/commands/show_data_spec.rb +2 -23
- data/spec/nanoc/cli/commands/show_rules_spec.rb +4 -2
- data/spec/nanoc/regressions/gh_767_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_776_spec.rb +2 -1
- data/spec/nanoc/rule_dsl/action_sequence_calculator_spec.rb +25 -12
- data/spec/nanoc/rule_dsl/rule_context_spec.rb +16 -6
- data/test/base/test_data_source.rb +0 -18
- data/test/checking/checks/test_external_links.rb +4 -6
- data/test/checking/checks/test_internal_links.rb +6 -9
- data/test/cli/commands/test_compile.rb +0 -35
- data/test/cli/test_cleaning_stream.rb +1 -1
- data/test/data_sources/test_filesystem.rb +16 -0
- data/test/filters/test_kramdown.rb +4 -4
- data/test/filters/test_sass.rb +1 -1
- data/test/filters/test_slim.rb +7 -5
- data/test/filters/test_xsl.rb +10 -8
- data/test/helpers/test_blogging.rb +5 -5
- data/test/helpers/test_capturing.rb +8 -6
- data/test/helpers/test_link_to.rb +4 -4
- data/test/helpers/test_xml_sitemap.rb +19 -19
- metadata +25 -15
- data/lib/nanoc/base/views/item_with_reps_view.rb +0 -7
- data/spec/nanoc/base/core_ext/pathname_spec.rb +0 -0
@@ -58,7 +58,7 @@ describe Nanoc::CLI::Commands::ShowRules, stdio: true, site: true do
|
|
58
58
|
let(:config) { Nanoc::Int::Configuration.new }
|
59
59
|
|
60
60
|
let(:action_provider) { double(:action_provider, rules_collection: rules_collection) }
|
61
|
-
let(:compiler) { double(:compiler
|
61
|
+
let(:compiler) { double(:compiler) }
|
62
62
|
|
63
63
|
let(:rules_collection) do
|
64
64
|
Nanoc::RuleDSL::RulesCollection.new.tap do |rc|
|
@@ -105,7 +105,9 @@ describe Nanoc::CLI::Commands::ShowRules, stdio: true, site: true do
|
|
105
105
|
|
106
106
|
it 'writes item and layout rules to stdout' do
|
107
107
|
expect(runner).to receive(:load_site).and_return(site)
|
108
|
-
expect(
|
108
|
+
expect(Nanoc::Int::Compiler).to receive(:new_for).with(site).and_return(compiler)
|
109
|
+
expect(compiler).to receive(:run_until_reps_built).and_return(reps: reps)
|
110
|
+
expect(Nanoc::RuleDSL::ActionProvider).to receive(:for).with(site).and_return(action_provider)
|
109
111
|
expect { subject }.to output(expected_out).to_stdout
|
110
112
|
end
|
111
113
|
|
@@ -16,6 +16,6 @@ EOS
|
|
16
16
|
|
17
17
|
it 'does not expose #path on @item' do
|
18
18
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
19
|
-
expect { site.compile }.to raise_error(NoMethodError, /undefined method .*path.* for .*Nanoc::
|
19
|
+
expect { site.compile }.to raise_error(NoMethodError, /undefined method .*path.* for .*Nanoc::BasicItemView/)
|
20
20
|
end
|
21
21
|
end
|
@@ -30,7 +30,8 @@ EOS
|
|
30
30
|
|
31
31
|
context 'with pruning' do
|
32
32
|
before do
|
33
|
-
Nanoc::
|
33
|
+
res = Nanoc::Int::Compiler.new_for(site).run_until_reps_built
|
34
|
+
Nanoc::Pruner.new(site.config, res.fetch(:reps)).run
|
34
35
|
end
|
35
36
|
|
36
37
|
it 'does not prune written snapshots' do
|
@@ -6,7 +6,31 @@ describe(Nanoc::RuleDSL::ActionSequenceCalculator) do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:rules_collection) { Nanoc::RuleDSL::RulesCollection.new }
|
9
|
-
|
9
|
+
|
10
|
+
let(:config) { Nanoc::Int::Configuration.new.with_defaults }
|
11
|
+
let(:items) { Nanoc::Int::ItemCollection.new(config) }
|
12
|
+
let(:layouts) { Nanoc::Int::LayoutCollection.new(config) }
|
13
|
+
|
14
|
+
let(:data_source_class) do
|
15
|
+
Class.new(Nanoc::DataSource) do
|
16
|
+
def items
|
17
|
+
@config.fetch(:items)
|
18
|
+
end
|
19
|
+
|
20
|
+
def layouts
|
21
|
+
@config.fetch(:layouts)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:data_source) do
|
27
|
+
data_source_config = { items: items, layouts: layouts }
|
28
|
+
data_source_class.new(config, '/', '/', data_source_config)
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:site) do
|
32
|
+
Nanoc::Int::Site.new(config: config, code_snippets: [], data_source: data_source)
|
33
|
+
end
|
10
34
|
|
11
35
|
describe '#[]' do
|
12
36
|
subject { action_sequence_calculator[obj] }
|
@@ -15,17 +39,6 @@ describe(Nanoc::RuleDSL::ActionSequenceCalculator) do
|
|
15
39
|
let(:obj) { Nanoc::Int::ItemRep.new(item, :csv) }
|
16
40
|
|
17
41
|
let(:item) { Nanoc::Int::Item.new('content', {}, Nanoc::Identifier.from('/list.md')) }
|
18
|
-
let(:config) { Nanoc::Int::Configuration.new.with_defaults }
|
19
|
-
let(:items) { Nanoc::Int::ItemCollection.new(config) }
|
20
|
-
let(:layouts) { Nanoc::Int::LayoutCollection.new(config) }
|
21
|
-
let(:site) { double(:site, items: items, layouts: layouts, config: config, compiler: compiler) }
|
22
|
-
let(:compiler) { double(:compiler, compilation_context: compilation_context) }
|
23
|
-
let(:compilation_context) { double(:compilation_context) }
|
24
|
-
let(:view_context) { double(:view_context) }
|
25
|
-
|
26
|
-
before do
|
27
|
-
expect(compilation_context).to receive(:create_view_context).and_return(view_context)
|
28
|
-
end
|
29
42
|
|
30
43
|
context 'no rules exist' do
|
31
44
|
it 'raises error' do
|
@@ -16,14 +16,24 @@ describe(Nanoc::RuleDSL::RuleContext) do
|
|
16
16
|
let(:executor) { double(:executor) }
|
17
17
|
let(:reps) { double(:reps) }
|
18
18
|
let(:compilation_context) { double(:compilation_context) }
|
19
|
-
|
19
|
+
|
20
|
+
let(:view_context) do
|
21
|
+
Nanoc::ViewContextForCompilation.new(
|
22
|
+
reps: Nanoc::Int::ItemRepRepo.new,
|
23
|
+
items: items,
|
24
|
+
dependency_tracker: dependency_tracker,
|
25
|
+
compilation_context: compilation_context,
|
26
|
+
snapshot_repo: snapshot_repo,
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
20
30
|
let(:dependency_tracker) { double(:dependency_tracker) }
|
21
31
|
let(:snapshot_repo) { double(:snapshot_repo) }
|
22
32
|
|
23
33
|
describe '#initialize' do
|
24
34
|
it 'wraps objects in view classes' do
|
25
|
-
expect(subject.rep.class).to eql(Nanoc::
|
26
|
-
expect(subject.item.class).to eql(Nanoc::
|
35
|
+
expect(subject.rep.class).to eql(Nanoc::BasicItemRepView)
|
36
|
+
expect(subject.item.class).to eql(Nanoc::BasicItemView)
|
27
37
|
expect(subject.config.class).to eql(Nanoc::ConfigView)
|
28
38
|
expect(subject.layouts.class).to eql(Nanoc::LayoutCollectionView)
|
29
39
|
expect(subject.items.class).to eql(Nanoc::ItemCollectionWithoutRepsView)
|
@@ -42,7 +52,7 @@ describe(Nanoc::RuleDSL::RuleContext) do
|
|
42
52
|
subject { rule_context.item }
|
43
53
|
|
44
54
|
it 'is a view without reps access' do
|
45
|
-
expect(subject.class).to eql(Nanoc::
|
55
|
+
expect(subject.class).to eql(Nanoc::BasicItemView)
|
46
56
|
end
|
47
57
|
|
48
58
|
it 'contains the right item' do
|
@@ -67,7 +77,7 @@ describe(Nanoc::RuleDSL::RuleContext) do
|
|
67
77
|
end
|
68
78
|
|
69
79
|
it 'wraps the parent in a view without reps access' do
|
70
|
-
expect(subject.parent.class).to eql(Nanoc::
|
80
|
+
expect(subject.parent.class).to eql(Nanoc::BasicItemView)
|
71
81
|
expect(subject.parent).not_to respond_to(:compiled_content)
|
72
82
|
expect(subject.parent).not_to respond_to(:path)
|
73
83
|
expect(subject.parent).not_to respond_to(:reps)
|
@@ -78,7 +88,7 @@ describe(Nanoc::RuleDSL::RuleContext) do
|
|
78
88
|
end
|
79
89
|
|
80
90
|
it 'wraps the children in a view without reps access' do
|
81
|
-
expect(subject.children.map(&:class)).to eql([Nanoc::
|
91
|
+
expect(subject.children.map(&:class)).to eql([Nanoc::BasicItemView])
|
82
92
|
expect(subject.children[0]).not_to respond_to(:compiled_content)
|
83
93
|
expect(subject.children[0]).not_to respond_to(:path)
|
84
94
|
expect(subject.children[0]).not_to respond_to(:reps)
|
@@ -3,24 +3,6 @@
|
|
3
3
|
require 'helper'
|
4
4
|
|
5
5
|
class Nanoc::DataSourceTest < Nanoc::TestCase
|
6
|
-
def test_loading
|
7
|
-
# Create data source
|
8
|
-
data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
|
9
|
-
data_source.expects(:up).times(1)
|
10
|
-
data_source.expects(:down).times(1)
|
11
|
-
|
12
|
-
# Test nested loading
|
13
|
-
assert_equal(0, data_source.instance_eval { @references })
|
14
|
-
data_source.loading do
|
15
|
-
assert_equal(1, data_source.instance_eval { @references })
|
16
|
-
data_source.loading do
|
17
|
-
assert_equal(2, data_source.instance_eval { @references })
|
18
|
-
end
|
19
|
-
assert_equal(1, data_source.instance_eval { @references })
|
20
|
-
end
|
21
|
-
assert_equal(0, data_source.instance_eval { @references })
|
22
|
-
end
|
23
|
-
|
24
6
|
def test_not_implemented
|
25
7
|
# Create data source
|
26
8
|
data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
|
@@ -65,11 +65,10 @@ class Nanoc::Checking::Checks::ExternalLinksTest < Nanoc::TestCase
|
|
65
65
|
|
66
66
|
def test_excluded
|
67
67
|
with_site do |site|
|
68
|
-
# Create check
|
69
|
-
check = Nanoc::Checking::Checks::ExternalLinks.create(site)
|
70
68
|
site.config.update(checks: { external_links: { exclude: ['^http://excluded.com$'] } })
|
71
69
|
|
72
|
-
|
70
|
+
check = Nanoc::Checking::Checks::ExternalLinks.create(site)
|
71
|
+
|
73
72
|
assert check.send(:excluded?, 'http://excluded.com')
|
74
73
|
refute check.send(:excluded?, 'http://excluded.com/notexcluded')
|
75
74
|
refute check.send(:excluded?, 'http://notexcluded.com')
|
@@ -78,11 +77,10 @@ class Nanoc::Checking::Checks::ExternalLinksTest < Nanoc::TestCase
|
|
78
77
|
|
79
78
|
def test_excluded_file
|
80
79
|
with_site do |site|
|
81
|
-
# Create check
|
82
|
-
check = Nanoc::Checking::Checks::ExternalLinks.create(site)
|
83
80
|
site.config.update(checks: { external_links: { exclude_files: ['blog/page'] } })
|
84
81
|
|
85
|
-
|
82
|
+
check = Nanoc::Checking::Checks::ExternalLinks.create(site)
|
83
|
+
|
86
84
|
assert check.send(:excluded_file?, 'output/blog/page1/index.html')
|
87
85
|
refute check.send(:excluded_file?, 'output/blog/pag1/index.html')
|
88
86
|
end
|
@@ -71,11 +71,10 @@ class Nanoc::Checking::Checks::InternalLinksTest < Nanoc::TestCase
|
|
71
71
|
|
72
72
|
def test_exclude
|
73
73
|
with_site do |site|
|
74
|
-
# Create check
|
75
|
-
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
76
74
|
site.config.update(checks: { internal_links: { exclude: ['^/excluded\d+'] } })
|
77
75
|
|
78
|
-
|
76
|
+
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
77
|
+
|
79
78
|
assert check.send(:valid?, '/excluded1', 'output/origin')
|
80
79
|
assert check.send(:valid?, '/excluded2', 'output/origin')
|
81
80
|
assert !check.send(:valid?, '/excluded_not', 'output/origin')
|
@@ -84,11 +83,10 @@ class Nanoc::Checking::Checks::InternalLinksTest < Nanoc::TestCase
|
|
84
83
|
|
85
84
|
def test_exclude_targets
|
86
85
|
with_site do |site|
|
87
|
-
# Create check
|
88
|
-
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
89
86
|
site.config.update(checks: { internal_links: { exclude_targets: ['^/excluded\d+'] } })
|
90
87
|
|
91
|
-
|
88
|
+
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
89
|
+
|
92
90
|
assert check.send(:valid?, '/excluded1', 'output/origin')
|
93
91
|
assert check.send(:valid?, '/excluded2', 'output/origin')
|
94
92
|
assert !check.send(:valid?, '/excluded_not', 'output/origin')
|
@@ -97,11 +95,10 @@ class Nanoc::Checking::Checks::InternalLinksTest < Nanoc::TestCase
|
|
97
95
|
|
98
96
|
def test_exclude_origins
|
99
97
|
with_site do |site|
|
100
|
-
# Create check
|
101
|
-
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
102
98
|
site.config.update(checks: { internal_links: { exclude_origins: ['^/excluded'] } })
|
103
99
|
|
104
|
-
|
100
|
+
check = Nanoc::Checking::Checks::InternalLinks.create(site)
|
101
|
+
|
105
102
|
assert check.send(:valid?, '/foo', 'output/excluded')
|
106
103
|
assert !check.send(:valid?, '/foo', 'output/not_excluded')
|
107
104
|
end
|
@@ -129,41 +129,6 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
def test_setup_and_teardown_listeners
|
133
|
-
with_site do
|
134
|
-
test_listener_class = Class.new(::Nanoc::CLI::Commands::CompileListeners::Abstract) do
|
135
|
-
def start
|
136
|
-
@started = true
|
137
|
-
end
|
138
|
-
|
139
|
-
def stop
|
140
|
-
@stopped = true
|
141
|
-
end
|
142
|
-
|
143
|
-
def started?
|
144
|
-
@started
|
145
|
-
end
|
146
|
-
|
147
|
-
def stopped?
|
148
|
-
@stopped
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
options = {}
|
153
|
-
arguments = []
|
154
|
-
cmd = nil
|
155
|
-
cmd_runner = Nanoc::CLI::Commands::Compile.new(options, arguments, cmd)
|
156
|
-
cmd_runner.listener_classes = [test_listener_class]
|
157
|
-
|
158
|
-
cmd_runner.run
|
159
|
-
|
160
|
-
listeners = cmd_runner.send(:listeners)
|
161
|
-
assert listeners.size == 1
|
162
|
-
assert listeners.first.started?
|
163
|
-
assert listeners.first.stopped?
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
132
|
def test_file_action_printer_normal
|
168
133
|
# Create data
|
169
134
|
item = Nanoc::Int::Item.new('content', {}, '/a')
|
@@ -88,7 +88,7 @@ class Nanoc::CLI::CleaningStreamTest < Nanoc::TestCase
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_invalid_string
|
91
|
-
s =
|
91
|
+
s = [128].pack('C').force_encoding('UTF-8')
|
92
92
|
stream = StringIO.new
|
93
93
|
cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
|
94
94
|
cleaning_stream << s
|
@@ -1004,6 +1004,22 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
1004
1004
|
end
|
1005
1005
|
end
|
1006
1006
|
|
1007
|
+
def test_parse_internal_four_dashes
|
1008
|
+
content = \
|
1009
|
+
"----\n" \
|
1010
|
+
"fav_animal: donkey\n" \
|
1011
|
+
"----\n" \
|
1012
|
+
"blah blah\n"
|
1013
|
+
|
1014
|
+
File.open('test.html', 'w') { |io| io.write(content) }
|
1015
|
+
|
1016
|
+
data_source = Nanoc::DataSources::Filesystem.new(nil, nil, nil, nil)
|
1017
|
+
|
1018
|
+
result = data_source.instance_eval { parse('test.html', nil) }
|
1019
|
+
assert_equal({}, result.attributes)
|
1020
|
+
assert_equal(content, result.content)
|
1021
|
+
end
|
1022
|
+
|
1007
1023
|
def test_parse_external_bad_metadata
|
1008
1024
|
File.open('test.html', 'w') { |io| io.write('blah blah') }
|
1009
1025
|
File.open('test.yaml', 'w') { |io| io.write('Hello world!') }
|
@@ -18,9 +18,9 @@ class Nanoc::Filters::KramdownTest < Nanoc::TestCase
|
|
18
18
|
if_have 'kramdown' do
|
19
19
|
# Create item
|
20
20
|
item = Nanoc::Int::Item.new('foo', {}, '/foo.md')
|
21
|
-
item_view = Nanoc::
|
21
|
+
item_view = Nanoc::CompilationItemView.new(item, nil)
|
22
22
|
item_rep = Nanoc::Int::ItemRep.new(item, :default)
|
23
|
-
item_rep_view = Nanoc::
|
23
|
+
item_rep_view = Nanoc::CompilationItemRepView.new(item_rep, nil)
|
24
24
|
|
25
25
|
# Create filter
|
26
26
|
filter = ::Nanoc::Filters::Kramdown.new(item: item_view, item_rep: item_rep_view)
|
@@ -38,9 +38,9 @@ class Nanoc::Filters::KramdownTest < Nanoc::TestCase
|
|
38
38
|
if_have 'kramdown' do
|
39
39
|
# Create item
|
40
40
|
item = Nanoc::Int::Item.new('foo', {}, '/foo.md')
|
41
|
-
item_view = Nanoc::
|
41
|
+
item_view = Nanoc::CompilationItemView.new(item, nil)
|
42
42
|
item_rep = Nanoc::Int::ItemRep.new(item, :default)
|
43
|
-
item_rep_view = Nanoc::
|
43
|
+
item_rep_view = Nanoc::CompilationItemRepView.new(item_rep, nil)
|
44
44
|
|
45
45
|
# Create filter
|
46
46
|
filter = ::Nanoc::Filters::Kramdown.new(item: item_view, item_rep: item_rep_view)
|
data/test/filters/test_sass.rb
CHANGED
@@ -300,7 +300,7 @@ class Nanoc::Filters::SassTest < Nanoc::TestCase
|
|
300
300
|
File.open('content/xyzzy.sass', 'w') { |io| io.write('p\n color: green') }
|
301
301
|
|
302
302
|
items = [
|
303
|
-
Nanoc::
|
303
|
+
Nanoc::CompilationItemView.new(
|
304
304
|
Nanoc::Int::Item.new(
|
305
305
|
'blah',
|
306
306
|
{ content_filename: 'content/xyzzy.sass' },
|
data/test/filters/test_slim.rb
CHANGED
@@ -32,12 +32,14 @@ class Nanoc::Filters::SlimTest < Nanoc::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def new_view_context
|
35
|
-
Nanoc::
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
config = Nanoc::Int::Configuration.new
|
36
|
+
|
37
|
+
Nanoc::ViewContextForCompilation.new(
|
38
|
+
reps: Nanoc::Int::ItemRepRepo.new,
|
39
|
+
items: Nanoc::Int::ItemCollection.new(config),
|
40
|
+
dependency_tracker: :__irrelevant_dependency_tracker,
|
39
41
|
compilation_context: :__irrelevat_compiler,
|
40
|
-
snapshot_repo:
|
42
|
+
snapshot_repo: :__irrelevant_snapshot_repo,
|
41
43
|
)
|
42
44
|
end
|
43
45
|
|
data/test/filters/test_xsl.rb
CHANGED
@@ -101,12 +101,14 @@ EOS
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def new_view_context
|
104
|
-
Nanoc::
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
config = Nanoc::Int::Configuration.new
|
105
|
+
|
106
|
+
Nanoc::ViewContextForCompilation.new(
|
107
|
+
reps: Nanoc::Int::ItemRepRepo.new,
|
108
|
+
items: Nanoc::Int::ItemCollection.new(config),
|
109
|
+
dependency_tracker: @dependency_tracker,
|
108
110
|
compilation_context: :__irrelevat_compiler,
|
109
|
-
snapshot_repo:
|
111
|
+
snapshot_repo: :__irrelevant_snapshot_repo,
|
110
112
|
)
|
111
113
|
end
|
112
114
|
|
@@ -114,7 +116,7 @@ EOS
|
|
114
116
|
if_have 'nokogiri' do
|
115
117
|
# Create our data objects
|
116
118
|
item = Nanoc::Int::Item.new(SAMPLE_XML_IN, {}, '/content')
|
117
|
-
item = Nanoc::
|
119
|
+
item = Nanoc::CompilationItemView.new(item, new_view_context)
|
118
120
|
layout = Nanoc::Int::Layout.new(SAMPLE_XSL, {}, '/layout')
|
119
121
|
layout = Nanoc::LayoutView.new(layout, new_view_context)
|
120
122
|
|
@@ -140,7 +142,7 @@ EOS
|
|
140
142
|
if_have 'nokogiri' do
|
141
143
|
# Create our data objects
|
142
144
|
item = Nanoc::Int::Item.new(SAMPLE_XML_IN_WITH_PARAMS, {}, '/content')
|
143
|
-
item = Nanoc::
|
145
|
+
item = Nanoc::CompilationItemView.new(item, new_view_context)
|
144
146
|
layout = Nanoc::Int::Layout.new(SAMPLE_XSL_WITH_PARAMS, {}, '/layout')
|
145
147
|
layout = Nanoc::LayoutView.new(layout, new_view_context)
|
146
148
|
|
@@ -166,7 +168,7 @@ EOS
|
|
166
168
|
if_have 'nokogiri' do
|
167
169
|
# Create our data objects
|
168
170
|
item = Nanoc::Int::Item.new(SAMPLE_XML_IN_WITH_OMIT_XML_DECL, {}, '/content')
|
169
|
-
item = Nanoc::
|
171
|
+
item = Nanoc::CompilationItemView.new(item, new_view_context)
|
170
172
|
layout = Nanoc::Int::Layout.new(SAMPLE_XSL_WITH_OMIT_XML_DECL, {}, '/layout')
|
171
173
|
layout = Nanoc::LayoutView.new(layout, new_view_context)
|
172
174
|
|
@@ -37,12 +37,12 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
37
37
|
dep_store = Nanoc::Int::DependencyStore.new(items, layouts, config)
|
38
38
|
dependency_tracker = Nanoc::Int::DependencyTracker.new(dep_store)
|
39
39
|
|
40
|
-
@view_context = Nanoc::
|
41
|
-
reps:
|
42
|
-
items:
|
43
|
-
dependency_tracker:
|
40
|
+
@view_context = Nanoc::ViewContextForCompilation.new(
|
41
|
+
reps: Nanoc::Int::ItemRepRepo.new,
|
42
|
+
items: Nanoc::Int::ItemCollection.new(config),
|
43
|
+
dependency_tracker: dependency_tracker,
|
44
44
|
compilation_context: :__irrelevant__,
|
45
|
-
snapshot_repo:
|
45
|
+
snapshot_repo: :__irrelevant_snapshot_repo,
|
46
46
|
)
|
47
47
|
end
|
48
48
|
|
@@ -12,12 +12,14 @@ class Nanoc::Helpers::CapturingTest < Nanoc::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def view_context_for(item)
|
15
|
-
Nanoc::
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
config = Nanoc::Int::Configuration.new
|
16
|
+
|
17
|
+
Nanoc::ViewContextForCompilation.new(
|
18
|
+
reps: item_rep_repo_for(item),
|
19
|
+
items: Nanoc::Int::ItemCollection.new(config),
|
20
|
+
dependency_tracker: :__irrelevant__,
|
19
21
|
compilation_context: :__irrelevant__,
|
20
|
-
snapshot_repo:
|
22
|
+
snapshot_repo: snapshot_repo,
|
21
23
|
)
|
22
24
|
end
|
23
25
|
|
@@ -82,7 +84,7 @@ EOS
|
|
82
84
|
|
83
85
|
item = Nanoc::Int::Item.new('content', {}, '/asdf')
|
84
86
|
view_context = view_context_for(item)
|
85
|
-
@item = Nanoc::
|
87
|
+
@item = Nanoc::CompilationItemView.new(item, view_context_for(item))
|
86
88
|
@config = Nanoc::ConfigView.new(Nanoc::Int::Configuration.new, view_context)
|
87
89
|
|
88
90
|
result = ::ERB.new(content).result(binding)
|