nanoc 4.7.5 → 4.7.6
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 +4 -3
- data/Gemfile.lock +18 -13
- data/NEWS.md +7 -1
- data/Rakefile +2 -2
- data/lib/nanoc/base/entities/action_sequence.rb +3 -12
- data/lib/nanoc/base/entities/configuration.rb +3 -3
- data/lib/nanoc/base/entities/identifiable_collection.rb +2 -4
- data/lib/nanoc/base/memoization.rb +1 -0
- data/lib/nanoc/base/repos/config_loader.rb +1 -1
- data/lib/nanoc/base/services/compilation_context.rb +3 -3
- data/lib/nanoc/base/services/compiler.rb +2 -3
- data/lib/nanoc/base/services/compiler/stages/cleanup.rb +1 -1
- data/lib/nanoc/base/services/filter.rb +4 -12
- data/lib/nanoc/base/services/item_rep_router.rb +3 -3
- data/lib/nanoc/base/services/outdatedness_checker.rb +1 -2
- data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +1 -2
- data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +1 -2
- data/lib/nanoc/base/services/outdatedness_rules/configuration_modified.rb +1 -2
- data/lib/nanoc/base/services/outdatedness_rules/paths_modified.rb +5 -5
- data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +3 -3
- data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +4 -4
- data/lib/nanoc/checking/checks/external_links.rb +0 -2
- data/lib/nanoc/cli.rb +1 -1
- data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +7 -5
- data/lib/nanoc/cli/commands/create-site.rb +1 -1
- data/lib/nanoc/cli/commands/nanoc.rb +1 -4
- data/lib/nanoc/cli/commands/show-plugins.rb +1 -1
- data/lib/nanoc/cli/error_handler.rb +2 -1
- data/lib/nanoc/deploying/deployers/git.rb +7 -7
- data/lib/nanoc/extra/link_collector.rb +2 -2
- data/lib/nanoc/filters/asciidoc.rb +1 -1
- data/lib/nanoc/filters/colorize_syntax.rb +46 -19
- data/lib/nanoc/filters/relativize_paths.rb +33 -9
- data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +15 -7
- data/lib/nanoc/version.rb +1 -1
- data/nanoc.gemspec +1 -1
- data/spec/nanoc/base/checksummer_spec.rb +2 -2
- data/spec/nanoc/base/entities/action_sequence_spec.rb +0 -36
- data/spec/nanoc/base/entities/identifier_spec.rb +1 -1
- data/spec/nanoc/base/entities/outdatedness_status_spec.rb +1 -1
- data/spec/nanoc/base/entities/processing_actions/snapshot_spec.rb +1 -1
- data/spec/nanoc/base/entities/props_spec.rb +13 -13
- data/spec/nanoc/base/memoization_spec.rb +31 -0
- data/spec/nanoc/base/services/executor_spec.rb +2 -2
- data/spec/nanoc/base/services/item_rep_selector_spec.rb +12 -12
- data/spec/nanoc/base/services/outdatedness_checker_spec.rb +23 -23
- data/spec/nanoc/base/views/post_compile_item_view_spec.rb +1 -1
- data/spec/nanoc/cli/commands/deploy_spec.rb +8 -8
- data/spec/nanoc/filters/less_spec.rb +11 -11
- data/spec/nanoc/helpers/capturing_spec.rb +2 -2
- data/spec/nanoc/helpers/tagging_spec.rb +5 -5
- data/spec/nanoc/integration/outdatedness_integration_spec.rb +29 -29
- data/spec/nanoc/integration/partial_recompilation_spec.rb +8 -8
- data/spec/nanoc/regressions/gh_1015_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1022_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1031_spec.rb +3 -3
- data/spec/nanoc/regressions/gh_1035_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1037a_spec.rb +2 -2
- data/spec/nanoc/regressions/gh_1037b_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1040_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1045_spec.rb +3 -3
- data/spec/nanoc/regressions/gh_1047_spec.rb +3 -3
- data/spec/nanoc/regressions/gh_1064_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1067_spec.rb +3 -3
- data/spec/nanoc/regressions/gh_1082a_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1082b_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1082c_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1082d_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1093_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1094_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1097_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1100_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1102_spec.rb +3 -3
- data/spec/nanoc/regressions/gh_1107_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1130_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_1134_spec.rb +2 -2
- data/spec/nanoc/regressions/gh_1145_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_804_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_809_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_841_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_867_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_882_spec.rb +3 -3
- data/spec/nanoc/regressions/gh_885_spec.rb +2 -2
- data/spec/nanoc/regressions/gh_891_spec.rb +2 -2
- data/spec/nanoc/regressions/gh_913_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_924_spec.rb +2 -2
- data/spec/nanoc/regressions/gh_928_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_937_spec.rb +2 -2
- data/spec/nanoc/regressions/gh_942_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_947_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_948_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_951_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_954_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_970a_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_970b_spec.rb +7 -7
- data/spec/nanoc/regressions/gh_974_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_981_spec.rb +3 -3
- data/spec/nanoc/rule_dsl/action_sequence_calculator_spec.rb +43 -4
- data/test/base/core_ext/array_spec.rb +2 -2
- data/test/base/test_compiler.rb +6 -6
- data/test/base/test_filter.rb +0 -8
- data/test/base/test_site.rb +1 -1
- data/test/checking/test_runner.rb +2 -2
- data/test/cli/commands/test_check.rb +2 -2
- data/test/cli/commands/test_compile.rb +6 -6
- data/test/cli/commands/test_create_site.rb +12 -12
- data/test/cli/commands/test_help.rb +2 -2
- data/test/cli/commands/test_info.rb +1 -1
- data/test/cli/commands/test_prune.rb +6 -6
- data/test/cli/test_cleaning_stream.rb +1 -1
- data/test/cli/test_cli.rb +9 -9
- data/test/data_sources/test_filesystem.rb +8 -8
- data/test/extra/core_ext/test_pathname.rb +1 -1
- data/test/extra/test_link_collector.rb +3 -3
- data/test/extra/test_piper.rb +3 -3
- data/test/filters/colorize_syntax/test_common.rb +25 -1
- data/test/filters/test_relativize_paths.rb +38 -0
- data/test/helper.rb +1 -1
- data/test/helpers/test_capturing.rb +8 -8
- data/test/rule_dsl/test_action_provider.rb +2 -2
- data/test/rule_dsl/test_rule.rb +1 -1
- data/test/test_gem.rb +1 -1
- metadata +4 -4
|
@@ -11,11 +11,11 @@ EOS
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it 'creates at first' do
|
|
14
|
-
expect { Nanoc::CLI.run(%w
|
|
14
|
+
expect { Nanoc::CLI.run(%w[compile --verbose]) }.to output(%r{create.*output/foo\.html$}).to_stdout
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'skips the item on second try' do
|
|
18
|
-
Nanoc::CLI.run(%w
|
|
19
|
-
expect { Nanoc::CLI.run(%w
|
|
18
|
+
Nanoc::CLI.run(%w[compile])
|
|
19
|
+
expect { Nanoc::CLI.run(%w[compile --verbose]) }.to output(%r{skip.*output/foo\.html$}).to_stdout
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -67,7 +67,7 @@ describe(Nanoc::RuleDSL::ActionSequenceCalculator) do
|
|
|
67
67
|
expect(subject[4].params).to eql({})
|
|
68
68
|
|
|
69
69
|
expect(subject[5]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
|
|
70
|
-
expect(subject[5].snapshot_names).to eql(%i
|
|
70
|
+
expect(subject[5].snapshot_names).to eql(%i[post last])
|
|
71
71
|
expect(subject[5].paths).to be_empty
|
|
72
72
|
|
|
73
73
|
expect(subject.size).to eql(6)
|
|
@@ -85,7 +85,7 @@ describe(Nanoc::RuleDSL::ActionSequenceCalculator) do
|
|
|
85
85
|
subject
|
|
86
86
|
|
|
87
87
|
expect(subject[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
|
|
88
|
-
expect(subject[0].snapshot_names).to eql(%i
|
|
88
|
+
expect(subject[0].snapshot_names).to eql(%i[raw last pre])
|
|
89
89
|
expect(subject[0].paths).to be_empty
|
|
90
90
|
|
|
91
91
|
expect(subject.size).to eql(1)
|
|
@@ -107,7 +107,7 @@ describe(Nanoc::RuleDSL::ActionSequenceCalculator) do
|
|
|
107
107
|
subject
|
|
108
108
|
|
|
109
109
|
expect(subject[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
|
|
110
|
-
expect(subject[0].snapshot_names).to eql(%i
|
|
110
|
+
expect(subject[0].snapshot_names).to eql(%i[raw last pre])
|
|
111
111
|
expect(subject[0].paths).to eq(['/foo.md'])
|
|
112
112
|
|
|
113
113
|
expect(subject.size).to eql(1)
|
|
@@ -129,7 +129,7 @@ describe(Nanoc::RuleDSL::ActionSequenceCalculator) do
|
|
|
129
129
|
subject
|
|
130
130
|
|
|
131
131
|
expect(subject[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
|
|
132
|
-
expect(subject[0].snapshot_names).to eql(%i
|
|
132
|
+
expect(subject[0].snapshot_names).to eql(%i[raw last pre])
|
|
133
133
|
expect(subject[0].paths).to be_empty
|
|
134
134
|
|
|
135
135
|
expect(subject.size).to eql(1)
|
|
@@ -171,4 +171,43 @@ describe(Nanoc::RuleDSL::ActionSequenceCalculator) do
|
|
|
171
171
|
end
|
|
172
172
|
end
|
|
173
173
|
end
|
|
174
|
+
|
|
175
|
+
describe '#compact_snapshots' do
|
|
176
|
+
subject { action_sequence_calculator.compact_snapshots(action_sequence) }
|
|
177
|
+
|
|
178
|
+
let(:action_sequence) { Nanoc::Int::ActionSequence.new(rep) }
|
|
179
|
+
let(:rep) { double(:rep) }
|
|
180
|
+
|
|
181
|
+
before do
|
|
182
|
+
action_sequence.add_snapshot(:a1, nil)
|
|
183
|
+
action_sequence.add_snapshot(:a2, '/a2.md')
|
|
184
|
+
action_sequence.add_snapshot(:a3, nil)
|
|
185
|
+
action_sequence.add_filter(:erb, awesomeness: 'high')
|
|
186
|
+
action_sequence.add_snapshot(:b1, '/b1.md')
|
|
187
|
+
action_sequence.add_snapshot(:b2, nil)
|
|
188
|
+
action_sequence.add_snapshot(:b3, '/b3.md')
|
|
189
|
+
action_sequence.add_filter(:erb, awesomeness: 'high')
|
|
190
|
+
action_sequence.add_snapshot(:c, nil)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
example do
|
|
194
|
+
expect(subject[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
|
|
195
|
+
expect(subject[0].snapshot_names).to eql(%i[a1 a2 a3])
|
|
196
|
+
expect(subject[0].paths).to eql(['/a2.md'])
|
|
197
|
+
|
|
198
|
+
expect(subject[1]).to be_a(Nanoc::Int::ProcessingActions::Filter)
|
|
199
|
+
|
|
200
|
+
expect(subject[2]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
|
|
201
|
+
expect(subject[2].snapshot_names).to eql(%i[b1 b2 b3])
|
|
202
|
+
expect(subject[2].paths).to eql(['/b1.md', '/b3.md'])
|
|
203
|
+
|
|
204
|
+
expect(subject[3]).to be_a(Nanoc::Int::ProcessingActions::Filter)
|
|
205
|
+
|
|
206
|
+
expect(subject[4]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
|
|
207
|
+
expect(subject[4].snapshot_names).to eql([:c])
|
|
208
|
+
expect(subject[4].paths).to be_empty
|
|
209
|
+
|
|
210
|
+
expect(subject.size).to eql(5)
|
|
211
|
+
end
|
|
212
|
+
end
|
|
174
213
|
end
|
|
@@ -12,7 +12,7 @@ describe 'Array#__nanoc_freeze_recursively' do
|
|
|
12
12
|
include Nanoc::TestHelpers
|
|
13
13
|
|
|
14
14
|
it 'should prevent first-level elements from being modified' do
|
|
15
|
-
array = [:a, %i
|
|
15
|
+
array = [:a, %i[b c], :d]
|
|
16
16
|
array.__nanoc_freeze_recursively
|
|
17
17
|
|
|
18
18
|
assert_raises_frozen_error do
|
|
@@ -21,7 +21,7 @@ describe 'Array#__nanoc_freeze_recursively' do
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'should prevent second-level elements from being modified' do
|
|
24
|
-
array = [:a, %i
|
|
24
|
+
array = [:a, %i[b c], :d]
|
|
25
25
|
array.__nanoc_freeze_recursively
|
|
26
26
|
|
|
27
27
|
assert_raises_frozen_error do
|
data/test/base/test_compiler.rb
CHANGED
|
@@ -122,7 +122,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
|
|
|
122
122
|
|
|
123
123
|
def test_disallow_routes_not_starting_with_slash
|
|
124
124
|
# Create site
|
|
125
|
-
Nanoc::CLI.run %w
|
|
125
|
+
Nanoc::CLI.run %w[create_site bar]
|
|
126
126
|
|
|
127
127
|
FileUtils.cd('bar') do
|
|
128
128
|
# Create routes
|
|
@@ -149,7 +149,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
|
|
|
149
149
|
|
|
150
150
|
def test_disallow_duplicate_routes
|
|
151
151
|
# Create site
|
|
152
|
-
Nanoc::CLI.run %w
|
|
152
|
+
Nanoc::CLI.run %w[create_site bar]
|
|
153
153
|
|
|
154
154
|
FileUtils.cd('bar') do
|
|
155
155
|
# Create routes
|
|
@@ -176,7 +176,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
|
|
|
176
176
|
|
|
177
177
|
def test_disallow_multiple_snapshots_with_the_same_name
|
|
178
178
|
# Create site
|
|
179
|
-
Nanoc::CLI.run %w
|
|
179
|
+
Nanoc::CLI.run %w[create_site bar]
|
|
180
180
|
|
|
181
181
|
FileUtils.cd('bar') do
|
|
182
182
|
# Create routes
|
|
@@ -398,8 +398,8 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
|
|
|
398
398
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
|
399
399
|
site.compile
|
|
400
400
|
|
|
401
|
-
assert_equal Set.new(%w
|
|
402
|
-
assert_equal Set.new(%w
|
|
401
|
+
assert_equal Set.new(%w[content/blah.dat]), Set.new(Dir['content/*'])
|
|
402
|
+
assert_equal Set.new(%w[output/blah.dat]), Set.new(Dir['output/*'])
|
|
403
403
|
end
|
|
404
404
|
end
|
|
405
405
|
|
|
@@ -420,7 +420,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
|
|
|
420
420
|
end
|
|
421
421
|
|
|
422
422
|
def test_find_layouts_by_glob
|
|
423
|
-
Nanoc::CLI.run %w
|
|
423
|
+
Nanoc::CLI.run %w[create_site bar]
|
|
424
424
|
FileUtils.cd('bar') do
|
|
425
425
|
File.open('Rules', 'w') do |io|
|
|
426
426
|
io.write "compile '/**/*' do\n"
|
data/test/base/test_filter.rb
CHANGED
|
@@ -9,14 +9,6 @@ class Nanoc::FilterTest < Nanoc::TestCase
|
|
|
9
9
|
assert_equal({}, filter.instance_eval { @assigns })
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def test_assigns
|
|
13
|
-
# Create filter
|
|
14
|
-
filter = Nanoc::Filter.new(foo: 'bar')
|
|
15
|
-
|
|
16
|
-
# Check assigns
|
|
17
|
-
assert_equal('bar', filter.assigns[:foo])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
12
|
def test_assigns_with_instance_variables
|
|
21
13
|
# Create filter
|
|
22
14
|
filter = Nanoc::Filter.new(foo: 'bar')
|
data/test/base/test_site.rb
CHANGED
|
@@ -5,7 +5,7 @@ class Nanoc::Checking::RunnerTest < Nanoc::TestCase
|
|
|
5
5
|
with_site do |site|
|
|
6
6
|
File.open('output/blah', 'w') { |io| io.write('I am stale! Haha!') }
|
|
7
7
|
runner = Nanoc::Checking::Runner.new(site)
|
|
8
|
-
runner.run_specific(%w
|
|
8
|
+
runner.run_specific(%w[stale])
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ class Nanoc::Checking::RunnerTest < Nanoc::TestCase
|
|
|
17
17
|
|
|
18
18
|
runner = Nanoc::Checking::Runner.new(site)
|
|
19
19
|
ios = capturing_stdio do
|
|
20
|
-
runner.run_specific(%w
|
|
20
|
+
runner.run_specific(%w[my_foo_check])
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
assert ios[:stdout].include?('I AM FOO!')
|
|
@@ -6,12 +6,12 @@ class Nanoc::CLI::Commands::CheckTest < Nanoc::TestCase
|
|
|
6
6
|
FileUtils.mkdir_p('output')
|
|
7
7
|
|
|
8
8
|
# Should not raise now
|
|
9
|
-
Nanoc::CLI.run %w
|
|
9
|
+
Nanoc::CLI.run %w[check stale]
|
|
10
10
|
|
|
11
11
|
# Should raise now
|
|
12
12
|
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
|
13
13
|
assert_raises Nanoc::Int::Errors::GenericTrivial do
|
|
14
|
-
Nanoc::CLI.run %w
|
|
14
|
+
Nanoc::CLI.run %w[check stale]
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -23,7 +23,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
|
23
23
|
io.write "layout '*', :erb\n"
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
Nanoc::CLI.run %w
|
|
26
|
+
Nanoc::CLI.run %w[compile --verbose]
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -60,7 +60,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
assert File.file?('output/stray.html')
|
|
63
|
-
Nanoc::CLI.run %w
|
|
63
|
+
Nanoc::CLI.run %w[compile]
|
|
64
64
|
assert File.file?('output/stray.html')
|
|
65
65
|
|
|
66
66
|
File.open('nanoc.yaml', 'w') do |io|
|
|
@@ -70,7 +70,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
assert File.file?('output/stray.html')
|
|
73
|
-
Nanoc::CLI.run %w
|
|
73
|
+
Nanoc::CLI.run %w[compile]
|
|
74
74
|
refute File.file?('output/stray.html')
|
|
75
75
|
end
|
|
76
76
|
end
|
|
@@ -110,7 +110,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
assert File.file?('output/stray.html')
|
|
113
|
-
Nanoc::CLI.run %w
|
|
113
|
+
Nanoc::CLI.run %w[compile]
|
|
114
114
|
assert File.file?('output/stray.html')
|
|
115
115
|
|
|
116
116
|
File.open('nanoc.yaml', 'w') do |io|
|
|
@@ -121,7 +121,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
assert File.file?('output/stray.html')
|
|
124
|
-
Nanoc::CLI.run %w
|
|
124
|
+
Nanoc::CLI.run %w[compile]
|
|
125
125
|
refute File.file?('output/stray.html')
|
|
126
126
|
assert File.directory?('output/excluded_dir'), 'excluded_dir should still be there'
|
|
127
127
|
end
|
|
@@ -207,7 +207,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
|
|
|
207
207
|
def new_file_action_printer(reps)
|
|
208
208
|
# Ensure CLI is loaded
|
|
209
209
|
begin
|
|
210
|
-
Nanoc::CLI.run(%w
|
|
210
|
+
Nanoc::CLI.run(%w[help %])
|
|
211
211
|
rescue SystemExit
|
|
212
212
|
end
|
|
213
213
|
|
|
@@ -2,14 +2,14 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
4
4
|
def test_create_site_with_existing_name
|
|
5
|
-
Nanoc::CLI.run %w
|
|
5
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
6
6
|
assert_raises(::Nanoc::Int::Errors::GenericTrivial) do
|
|
7
|
-
Nanoc::CLI.run %w
|
|
7
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def test_can_compile_new_site
|
|
12
|
-
Nanoc::CLI.run %w
|
|
12
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
13
13
|
|
|
14
14
|
FileUtils.cd('foo') do
|
|
15
15
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
|
@@ -21,14 +21,14 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
|
21
21
|
FileUtils.mkdir('foo')
|
|
22
22
|
|
|
23
23
|
FileUtils.cd('foo') do
|
|
24
|
-
Nanoc::CLI.run %w
|
|
24
|
+
Nanoc::CLI.run %w[create_site ./]
|
|
25
25
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
|
26
26
|
site.compile
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def test_can_compile_new_site_with_binary_items
|
|
31
|
-
Nanoc::CLI.run %w
|
|
31
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
32
32
|
|
|
33
33
|
FileUtils.cd('foo') do
|
|
34
34
|
File.open('content/blah', 'w') { |io| io << 'asdf' }
|
|
@@ -42,7 +42,7 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
|
42
42
|
def test_can_compile_site_in_nonempty_directory
|
|
43
43
|
FileUtils.mkdir('foo')
|
|
44
44
|
FileUtils.touch(File.join('foo', 'SomeFile.txt'))
|
|
45
|
-
Nanoc::CLI.run %w
|
|
45
|
+
Nanoc::CLI.run %w[create_site foo --force]
|
|
46
46
|
|
|
47
47
|
FileUtils.cd('foo') do
|
|
48
48
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
|
@@ -53,7 +53,7 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
|
53
53
|
def test_compiled_site_output
|
|
54
54
|
FileUtils.mkdir('foo')
|
|
55
55
|
FileUtils.touch(File.join('foo', 'SomeFile.txt'))
|
|
56
|
-
Nanoc::CLI.run %w
|
|
56
|
+
Nanoc::CLI.run %w[create_site foo --force]
|
|
57
57
|
|
|
58
58
|
FileUtils.cd('foo') do
|
|
59
59
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
|
@@ -72,7 +72,7 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
|
72
72
|
original_encoding = Encoding.default_external
|
|
73
73
|
Encoding.default_external = 'ISO-8859-1' # ew!
|
|
74
74
|
|
|
75
|
-
Nanoc::CLI.run %w
|
|
75
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
76
76
|
|
|
77
77
|
FileUtils.cd('foo') do
|
|
78
78
|
# Try with encoding = default encoding = utf-8
|
|
@@ -99,9 +99,9 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def test_new_site_has_correct_stylesheets
|
|
102
|
-
Nanoc::CLI.run %w
|
|
102
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
103
103
|
FileUtils.cd('foo') do
|
|
104
|
-
Nanoc::CLI.run %w
|
|
104
|
+
Nanoc::CLI.run %w[compile]
|
|
105
105
|
|
|
106
106
|
assert File.file?('content/stylesheet.css')
|
|
107
107
|
assert_match(/\/stylesheet.css/, File.read('output/index.html'))
|
|
@@ -111,12 +111,12 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
|
|
|
111
111
|
def test_new_site_prunes_by_default
|
|
112
112
|
FileUtils.mkdir('foo')
|
|
113
113
|
FileUtils.touch(File.join('foo', 'SomeFile.txt'))
|
|
114
|
-
Nanoc::CLI.run %w
|
|
114
|
+
Nanoc::CLI.run %w[create_site foo --force]
|
|
115
115
|
|
|
116
116
|
FileUtils.cd('foo') do
|
|
117
117
|
File.write('output/blah.txt', 'stuff')
|
|
118
118
|
|
|
119
|
-
Nanoc::CLI.run %w
|
|
119
|
+
Nanoc::CLI.run %w[compile]
|
|
120
120
|
|
|
121
121
|
refute File.file?('output/blah.txt')
|
|
122
122
|
end
|
|
@@ -15,7 +15,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
|
|
|
15
15
|
File.open('output2/index.html', 'w') { |io| io.write 'this is a index.' }
|
|
16
16
|
|
|
17
17
|
assert_raises SystemExit do
|
|
18
|
-
Nanoc::CLI.run %w
|
|
18
|
+
Nanoc::CLI.run %w[prune]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
assert File.file?('output2/index.html')
|
|
@@ -43,7 +43,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
|
|
|
43
43
|
File.open('output2/foo.html', 'w') { |io| io.write 'this is a foo.' }
|
|
44
44
|
File.open('output2/index.html', 'w') { |io| io.write 'this is a index.' }
|
|
45
45
|
|
|
46
|
-
Nanoc::CLI.run %w
|
|
46
|
+
Nanoc::CLI.run %w[prune --yes]
|
|
47
47
|
|
|
48
48
|
assert File.file?('output2/index.html')
|
|
49
49
|
assert !File.file?('output2/foo.html')
|
|
@@ -63,7 +63,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
|
|
|
63
63
|
File.open('output2/foo.html', 'w') { |io| io.write 'this is a foo.' }
|
|
64
64
|
File.open('output2/index.html', 'w') { |io| io.write 'this is a index.' }
|
|
65
65
|
|
|
66
|
-
Nanoc::CLI.run %w
|
|
66
|
+
Nanoc::CLI.run %w[prune --dry-run]
|
|
67
67
|
|
|
68
68
|
assert File.file?('output2/index.html')
|
|
69
69
|
assert File.file?('output2/foo.html')
|
|
@@ -96,7 +96,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
|
|
|
96
96
|
File.open('output/bad-dir/blah', 'w') { |io| io.write 'stuff' }
|
|
97
97
|
File.open('output/index.html', 'w') { |io| io.write 'stuff' }
|
|
98
98
|
|
|
99
|
-
Nanoc::CLI.run %w
|
|
99
|
+
Nanoc::CLI.run %w[prune --yes]
|
|
100
100
|
|
|
101
101
|
assert File.file?('output/index.html')
|
|
102
102
|
assert File.file?('output/good-dir/blah')
|
|
@@ -126,7 +126,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
|
|
|
126
126
|
File.open('output-real/some-file.html', 'w') { |io| io.write 'stuff' }
|
|
127
127
|
File.open('output-real/index.html', 'w') { |io| io.write 'stuff' }
|
|
128
128
|
|
|
129
|
-
Nanoc::CLI.run %w
|
|
129
|
+
Nanoc::CLI.run %w[prune --yes]
|
|
130
130
|
|
|
131
131
|
assert File.file?('output-real/index.html')
|
|
132
132
|
assert !File.directory?('output-real/some-dir')
|
|
@@ -144,7 +144,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
|
|
|
144
144
|
FileUtils.mkdir_p('output/a/b/c')
|
|
145
145
|
File.open('output/a/b/c/index.html', 'w') { |io| io.write 'stuff' }
|
|
146
146
|
|
|
147
|
-
Nanoc::CLI.run %w
|
|
147
|
+
Nanoc::CLI.run %w[prune --yes]
|
|
148
148
|
|
|
149
149
|
assert !File.file?('output/a/b/c/index.html')
|
|
150
150
|
assert !File.directory?('output/a/b/c')
|
|
@@ -20,7 +20,7 @@ class Nanoc::CLI::CleaningStreamTest < Nanoc::TestCase
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def test_forward
|
|
23
|
-
methods = %i
|
|
23
|
+
methods = %i[write << tty? tty? flush tell print puts string reopen exist? exists? close]
|
|
24
24
|
|
|
25
25
|
s = Stream.new
|
|
26
26
|
cs = Nanoc::CLI::CleaningStream.new(s)
|
data/test/cli/test_cli.rb
CHANGED
|
@@ -22,7 +22,7 @@ end
|
|
|
22
22
|
EOS
|
|
23
23
|
|
|
24
24
|
def test_load_custom_commands
|
|
25
|
-
Nanoc::CLI.run %w
|
|
25
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
26
26
|
|
|
27
27
|
FileUtils.cd('foo') do
|
|
28
28
|
# Create command
|
|
@@ -31,7 +31,7 @@ EOS
|
|
|
31
31
|
|
|
32
32
|
# Run command
|
|
33
33
|
begin
|
|
34
|
-
Nanoc::CLI.run %w
|
|
34
|
+
Nanoc::CLI.run %w[_test]
|
|
35
35
|
rescue SystemExit
|
|
36
36
|
assert false, 'Running _test should not cause system exit'
|
|
37
37
|
end
|
|
@@ -43,7 +43,7 @@ EOS
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def test_load_custom_commands_nested
|
|
46
|
-
Nanoc::CLI.run %w
|
|
46
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
47
47
|
FileUtils.cd('foo') do
|
|
48
48
|
# Create command
|
|
49
49
|
FileUtils.mkdir_p('commands')
|
|
@@ -59,7 +59,7 @@ EOS
|
|
|
59
59
|
|
|
60
60
|
# Run command
|
|
61
61
|
begin
|
|
62
|
-
Nanoc::CLI.run %w
|
|
62
|
+
Nanoc::CLI.run %w[_test _sub]
|
|
63
63
|
rescue SystemExit
|
|
64
64
|
assert false, 'Running _test sub should not cause system exit'
|
|
65
65
|
end
|
|
@@ -71,7 +71,7 @@ EOS
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def test_load_custom_commands_non_default_commands_dirs
|
|
74
|
-
Nanoc::CLI.run %w
|
|
74
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
75
75
|
FileUtils.cd('foo') do
|
|
76
76
|
File.open('nanoc.yaml', 'w') { |io| io.write('commands_dirs: [commands, commands_alt]') }
|
|
77
77
|
|
|
@@ -89,7 +89,7 @@ EOS
|
|
|
89
89
|
|
|
90
90
|
# Run command
|
|
91
91
|
begin
|
|
92
|
-
Nanoc::CLI.run %w
|
|
92
|
+
Nanoc::CLI.run %w[_test _sub]
|
|
93
93
|
rescue SystemExit
|
|
94
94
|
assert false, 'Running _test sub should not cause system exit'
|
|
95
95
|
end
|
|
@@ -101,7 +101,7 @@ EOS
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def test_load_custom_commands_broken
|
|
104
|
-
Nanoc::CLI.run %w
|
|
104
|
+
Nanoc::CLI.run %w[create_site foo]
|
|
105
105
|
|
|
106
106
|
FileUtils.cd('foo') do
|
|
107
107
|
# Create command
|
|
@@ -112,11 +112,11 @@ EOS
|
|
|
112
112
|
position_before = $stderr.tell
|
|
113
113
|
Nanoc::CLI::ErrorHandler.disable
|
|
114
114
|
assert_raises RuntimeError do
|
|
115
|
-
Nanoc::CLI.run %w
|
|
115
|
+
Nanoc::CLI.run %w[_test]
|
|
116
116
|
end
|
|
117
117
|
Nanoc::CLI::ErrorHandler.enable
|
|
118
118
|
assert_raises SystemExit do
|
|
119
|
-
Nanoc::CLI.run %w
|
|
119
|
+
Nanoc::CLI.run %w[_test]
|
|
120
120
|
end
|
|
121
121
|
position_after = $stderr.tell
|
|
122
122
|
|