nanoc 4.7.0 → 4.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/NEWS.md +12 -1
  4. data/README.md +1 -1
  5. data/lib/nanoc/base/entities/directed_graph.rb +16 -0
  6. data/lib/nanoc/base/entities/identifiable_collection.rb +24 -8
  7. data/lib/nanoc/base/entities/outdatedness_reasons.rb +5 -0
  8. data/lib/nanoc/base/errors.rb +11 -6
  9. data/lib/nanoc/base/memoization.rb +6 -23
  10. data/lib/nanoc/base/services/compiler/phases/abstract.rb +3 -3
  11. data/lib/nanoc/base/services/compiler/phases/cache.rb +1 -3
  12. data/lib/nanoc/base/services/compiler/phases/mark_done.rb +1 -3
  13. data/lib/nanoc/base/services/compiler/phases/recalculate.rb +1 -3
  14. data/lib/nanoc/base/services/compiler/phases/resume.rb +1 -3
  15. data/lib/nanoc/base/services/compiler/phases/write.rb +1 -3
  16. data/lib/nanoc/base/services/filter.rb +15 -0
  17. data/lib/nanoc/base/services/item_rep_selector.rb +1 -1
  18. data/lib/nanoc/base/services/outdatedness_checker.rb +3 -1
  19. data/lib/nanoc/base/services/outdatedness_rule.rb +7 -0
  20. data/lib/nanoc/base/services/outdatedness_rules.rb +16 -0
  21. data/lib/nanoc/cli/commands/compile.rb +12 -411
  22. data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +30 -0
  23. data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +34 -0
  24. data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +91 -0
  25. data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +61 -0
  26. data/lib/nanoc/cli/commands/compile_listeners/stack_prof_profiler.rb +22 -0
  27. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +174 -0
  28. data/lib/nanoc/filters/xsl.rb +2 -0
  29. data/lib/nanoc/version.rb +1 -1
  30. data/spec/nanoc/base/directed_graph_spec.rb +54 -0
  31. data/spec/nanoc/base/errors/dependency_cycle_spec.rb +32 -0
  32. data/spec/nanoc/base/filter_spec.rb +36 -0
  33. data/spec/nanoc/base/services/compiler/phases/abstract_spec.rb +23 -11
  34. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +41 -0
  35. data/spec/nanoc/cli/commands/compile/file_action_printer_spec.rb +1 -1
  36. data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +124 -54
  37. data/spec/nanoc/cli/commands/compile_spec.rb +1 -1
  38. data/spec/nanoc/regressions/gh_1040_spec.rb +1 -1
  39. data/spec/nanoc/regressions/gh_924_spec.rb +89 -0
  40. data/test/base/test_compiler.rb +1 -1
  41. data/test/base/test_memoization.rb +6 -0
  42. data/test/cli/commands/test_compile.rb +2 -2
  43. metadata +12 -3
@@ -1,4 +1,4 @@
1
- describe Nanoc::CLI::Commands::Compile::Listener do
1
+ describe Nanoc::CLI::Commands::CompileListeners::Abstract do
2
2
  let(:klass) do
3
3
  Class.new(described_class) do
4
4
  attr_reader :started
@@ -17,6 +17,6 @@ EOS
17
17
  end
18
18
 
19
19
  it 'errors' do
20
- expect { Nanoc::CLI.run(%w(compile)) }.to raise_error(Nanoc::Int::Errors::RecursiveCompilation)
20
+ expect { Nanoc::CLI.run(%w(compile)) }.to raise_error(Nanoc::Int::Errors::DependencyCycle)
21
21
  end
22
22
  end
@@ -0,0 +1,89 @@
1
+ describe 'GH-924', site: true, stdio: true do
2
+ before do
3
+ File.write('nanoc.yaml', <<EOS)
4
+ text_extensions: [ 'xml', 'xsl' ]
5
+ EOS
6
+
7
+ File.write('content/index.xml', '<root/>')
8
+
9
+ File.write('layouts/default.xsl', <<EOS)
10
+ <?xml version="1.0" encoding="UTF-8" ?>
11
+ <xsl:stylesheet version="1.0"
12
+ xmlns="http://www.w3.org/1999/xhtml"
13
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
14
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15
+ exclude-result-prefixes="xhtml">
16
+ <xsl:output encoding="UTF-8"
17
+ doctype-public="-//W3C//DTD XHTML 1.1//EN"
18
+ doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
19
+ indent="yes" />
20
+ <xsl:strip-space elements="*" />
21
+
22
+ <xsl:include href='layouts/snippet.xsl' />
23
+
24
+ </xsl:stylesheet>
25
+ EOS
26
+
27
+ File.write('layouts/snippet.xsl', <<EOS)
28
+ <?xml version="1.0" encoding="UTF-8" ?>
29
+ <xsl:stylesheet version="1.0"
30
+ xmlns="http://www.w3.org/1999/xhtml"
31
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
32
+ exclude-result-prefixes="xhtml">
33
+
34
+ <xsl:template match="/root">
35
+ <html>
36
+ <head>
37
+ <title>Original Title</title>
38
+ </head>
39
+ <body>
40
+ <p>Test Body</p>
41
+ </body>
42
+ </html>
43
+ </xsl:template>
44
+
45
+ </xsl:stylesheet>
46
+ EOS
47
+
48
+ File.write('Rules', <<EOS)
49
+ compile '/index.xml' do
50
+ layout '/default.xsl'
51
+ write '/index.xhtml'
52
+ end
53
+
54
+ layout '/**/*.xsl', :xsl
55
+ EOS
56
+ end
57
+
58
+ before do
59
+ Nanoc::CLI.run(%w(compile))
60
+ end
61
+
62
+ example do
63
+ File.write('layouts/snippet.xsl', <<EOS)
64
+ <?xml version="1.0" encoding="UTF-8" ?>
65
+ <xsl:stylesheet version="1.0"
66
+ xmlns="http://www.w3.org/1999/xhtml"
67
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
68
+ exclude-result-prefixes="xhtml">
69
+
70
+ <xsl:template match="/root">
71
+ <html>
72
+ <head>
73
+ <title>Changed Title</title>
74
+ </head>
75
+ <body>
76
+ <p>Test Body</p>
77
+ </body>
78
+ </html>
79
+ </xsl:template>
80
+
81
+ </xsl:stylesheet>
82
+ EOS
83
+
84
+ expect { Nanoc::CLI.run(%w(compile)) }
85
+ .to change { File.read('output/index.xhtml') }
86
+ .from(/<title>Original Title/)
87
+ .to(/<title>Changed Title/)
88
+ end
89
+ end
@@ -114,7 +114,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
114
114
  end
115
115
 
116
116
  site = Nanoc::Int::SiteLoader.new.new_from_cwd
117
- assert_raises Nanoc::Int::Errors::RecursiveCompilation do
117
+ assert_raises Nanoc::Int::Errors::DependencyCycle do
118
118
  site.compile
119
119
  end
120
120
  end
@@ -50,6 +50,12 @@ class Nanoc::Int::MemoizationTest < Nanoc::TestCase
50
50
  end
51
51
  end
52
52
 
53
+ def test_frozen
54
+ sample = Sample1.new(10)
55
+ sample.freeze
56
+ sample.run(5)
57
+ end
58
+
53
59
  def test_weak_inspect
54
60
  upcaser = Upcaser.new
55
61
  10_000.times do |i|
@@ -129,7 +129,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
129
129
 
130
130
  def test_setup_and_teardown_listeners
131
131
  with_site do
132
- test_listener_class = Class.new(::Nanoc::CLI::Commands::Compile::Listener) do
132
+ test_listener_class = Class.new(::Nanoc::CLI::Commands::CompileListeners::Abstract) do
133
133
  def start
134
134
  @started = true
135
135
  end
@@ -211,7 +211,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
211
211
  rescue SystemExit
212
212
  end
213
213
 
214
- listener = Nanoc::CLI::Commands::Compile::FileActionPrinter.new(reps: reps)
214
+ listener = Nanoc::CLI::Commands::CompileListeners::FileActionPrinter.new(reps: reps)
215
215
 
216
216
  def listener.log(level, action, path, duration)
217
217
  @events ||= []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 4.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-15 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -251,6 +251,12 @@ files:
251
251
  - lib/nanoc/cli/command_runner.rb
252
252
  - lib/nanoc/cli/commands/check.rb
253
253
  - lib/nanoc/cli/commands/compile.rb
254
+ - lib/nanoc/cli/commands/compile_listeners/abstract.rb
255
+ - lib/nanoc/cli/commands/compile_listeners/debug_printer.rb
256
+ - lib/nanoc/cli/commands/compile_listeners/diff_generator.rb
257
+ - lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb
258
+ - lib/nanoc/cli/commands/compile_listeners/stack_prof_profiler.rb
259
+ - lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb
254
260
  - lib/nanoc/cli/commands/create-site.rb
255
261
  - lib/nanoc/cli/commands/deploy.rb
256
262
  - lib/nanoc/cli/commands/nanoc.rb
@@ -348,6 +354,7 @@ files:
348
354
  - spec/contributors_spec.rb
349
355
  - spec/nanoc/base/checksummer_spec.rb
350
356
  - spec/nanoc/base/compiler_spec.rb
357
+ - spec/nanoc/base/directed_graph_spec.rb
351
358
  - spec/nanoc/base/entities/configuration_spec.rb
352
359
  - spec/nanoc/base/entities/content_spec.rb
353
360
  - spec/nanoc/base/entities/document_spec.rb
@@ -366,6 +373,7 @@ files:
366
373
  - spec/nanoc/base/entities/props_spec.rb
367
374
  - spec/nanoc/base/entities/rule_memory_spec.rb
368
375
  - spec/nanoc/base/entities/site_spec.rb
376
+ - spec/nanoc/base/errors/dependency_cycle_spec.rb
369
377
  - spec/nanoc/base/feature_spec.rb
370
378
  - spec/nanoc/base/filter_spec.rb
371
379
  - spec/nanoc/base/item_rep_writer_spec.rb
@@ -477,6 +485,7 @@ files:
477
485
  - spec/nanoc/regressions/gh_885_spec.rb
478
486
  - spec/nanoc/regressions/gh_891_spec.rb
479
487
  - spec/nanoc/regressions/gh_913_spec.rb
488
+ - spec/nanoc/regressions/gh_924_spec.rb
480
489
  - spec/nanoc/regressions/gh_928_spec.rb
481
490
  - spec/nanoc/regressions/gh_937_spec.rb
482
491
  - spec/nanoc/regressions/gh_942_spec.rb
@@ -616,7 +625,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
616
625
  version: '0'
617
626
  requirements: []
618
627
  rubyforge_project:
619
- rubygems_version: 2.6.10
628
+ rubygems_version: 2.6.11
620
629
  signing_key:
621
630
  specification_version: 4
622
631
  summary: A static-site generator with a focus on flexibility.