nanoc 4.6.2 → 4.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb5ae7fdab33a2274afd361558045fdac7c5c2f9
4
- data.tar.gz: 636a45cd39ba85dc37c2fc6abbb43af2e6e98e16
3
+ metadata.gz: 2be981505c54e8c257e032a6bd08d7be8be95135
4
+ data.tar.gz: db527143c17a425809740641b4344b225c35fc43
5
5
  SHA512:
6
- metadata.gz: 98f9a4d6fb54b47bdee2a1c4bef5f7fc141daa1d63d28048076596ce5b88959b5522d1000898873256e46b06b4693f9049bad09809e198110b0ec755c43bfd54
7
- data.tar.gz: bec451e9af2fa9782c224df87f53629e6e4a3d9dc715d7cc145ce467c813bf33d221adf6a540b063e8ad7a0febf13dcee0a4f619ac096305e2ce60edb038e693
6
+ metadata.gz: f1b3ed7df2c66ed6eab2b67081b1b828942fa5ce474e85d2c088dc6b439ccffbf36a1cedad89fef84334b2e5033ce561a98e1bc48b5f94f176358a9b913d1426
7
+ data.tar.gz: ad5c1d8f749f3b10f8167f4faa45a41cbcc18ba64ca2ad73220a4afc49f606399349de87d05599d462d4eebf819f5ead745e3c9c42883ba3b71bf2c2038b54e0
data/Gemfile.lock CHANGED
@@ -27,7 +27,7 @@ GIT
27
27
  PATH
28
28
  remote: .
29
29
  specs:
30
- nanoc (4.6.2)
30
+ nanoc (4.6.3)
31
31
  cri (~> 2.3)
32
32
  ddplugin (~> 1.0)
33
33
  hamster (~> 3.0)
data/NEWS.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.6.3 (2017-03-05)
4
+
5
+ Fixes:
6
+
7
+ * Fixed `Errno::ENOENT` crash (#1094, #1109)
8
+ * Fixed undefined method `#reverse_each` crash (#1107, #1108)
9
+ * Fixed compilation speed issue introduced in 4.6.2 (#1106)
10
+
3
11
  ## 4.6.2 (2017-03-04)
4
12
 
5
13
  Fixes:
@@ -12,7 +12,7 @@ module Nanoc::Int
12
12
  contract C::Or[Hash, C::Named['Nanoc::Int::Configuration']], C::IterOf[C::RespondTo[:identifier]] => C::Any
13
13
  def initialize(config, objects = [])
14
14
  @config = config
15
- @objects = objects
15
+ @objects = Hamster::Vector.new(objects)
16
16
  end
17
17
 
18
18
  def self.from(enum, config)
@@ -43,7 +43,7 @@ module Nanoc::Int
43
43
 
44
44
  contract C::None => C::ArrayOf[C::RespondTo[:identifier]]
45
45
  def to_a
46
- @objects
46
+ @objects.to_a
47
47
  end
48
48
 
49
49
  contract C::None => C::Bool
@@ -52,7 +52,7 @@ module Nanoc::Int
52
52
  end
53
53
 
54
54
  def add(obj)
55
- self.class.new(@config, @objects + [obj])
55
+ self.class.new(@config, @objects.add(obj))
56
56
  end
57
57
 
58
58
  def reject(&block)
@@ -8,13 +8,17 @@ module Nanoc::Int
8
8
  end
9
9
 
10
10
  def items
11
- objs = @data_sources.flat_map(&:items)
12
- @_items ||= Nanoc::Int::IdentifiableCollection.from(objs, @config)
11
+ @_items ||= begin
12
+ objs = @data_sources.flat_map(&:items)
13
+ Nanoc::Int::IdentifiableCollection.from(objs, @config)
14
+ end
13
15
  end
14
16
 
15
17
  def layouts
16
- objs = @data_sources.flat_map(&:layouts)
17
- @_layouts ||= Nanoc::Int::IdentifiableCollection.from(objs, @config)
18
+ @_layouts ||= begin
19
+ objs = @data_sources.flat_map(&:layouts)
20
+ Nanoc::Int::IdentifiableCollection.from(objs, @config)
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -26,7 +26,12 @@ module Nanoc::Int::Compiler::Phases
26
26
 
27
27
  contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Bool
28
28
  def can_reuse_content_for_rep?(rep, is_outdated:)
29
- !is_outdated && !@compiled_content_cache[rep].nil?
29
+ if is_outdated
30
+ false
31
+ else
32
+ cache = @compiled_content_cache[rep]
33
+ cache ? cache.none? { |_snapshot_name, content| content.binary? } : false
34
+ end
30
35
  end
31
36
  end
32
37
  end
@@ -447,6 +447,7 @@ module Nanoc::CLI::Commands
447
447
  end
448
448
 
449
449
  def teardown_listeners
450
+ return unless @listeners
450
451
  @listeners.reverse_each(&:stop_safely)
451
452
  end
452
453
 
data/lib/nanoc/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Nanoc
2
2
  # The current Nanoc version.
3
- VERSION = '4.6.2'.freeze
3
+ VERSION = '4.6.3'.freeze
4
4
  end
@@ -69,12 +69,12 @@ describe Nanoc::Int::Compiler::Phases::Cache do
69
69
  context 'not outdated' do
70
70
  let(:is_outdated) { false }
71
71
 
72
- context 'cached compiled content available' do
72
+ context 'textual cached compiled content available' do
73
73
  before do
74
74
  compiled_content_cache[rep] = { last: Nanoc::Int::TextualContent.new('cached') }
75
75
  end
76
76
 
77
- it 'reuses content from cache' do
77
+ it 'writes content to cache' do
78
78
  expect { subject }
79
79
  .to change { snapshot_repo.get(rep, :last) }
80
80
  .from(nil)
@@ -99,6 +99,41 @@ describe Nanoc::Int::Compiler::Phases::Cache do
99
99
  end
100
100
  end
101
101
 
102
+ context 'binary cached compiled content available' do
103
+ let(:binary_content) { 'b1n4ry' }
104
+ let(:binary_filename) { Tempfile.open('test') { |fn| fn << binary_content }.path }
105
+
106
+ before do
107
+ compiled_content_cache[rep] = { last: Nanoc::Int::BinaryContent.new(binary_filename) }
108
+ end
109
+
110
+ it 'writes content to cache' do
111
+ expect { subject }
112
+ .to change { snapshot_repo.get(rep, :last) }
113
+ .from(nil)
114
+ .to(some_textual_content('wrapped content'))
115
+ end
116
+
117
+ it 'marks rep as compiled' do
118
+ expect { subject }
119
+ .to change { rep.compiled? }
120
+ .from(false)
121
+ .to(true)
122
+ end
123
+
124
+ it 'changes compiled content cache' do
125
+ expect { subject }
126
+ .to change { compiled_content_cache[rep] }
127
+ .from(last: some_binary_content(binary_content))
128
+ .to(last: some_textual_content('wrapped content'))
129
+ end
130
+
131
+ it 'does not send notification' do
132
+ expect(Nanoc::Int::NotificationCenter).not_to receive(:post).with(:cached_content_used, rep)
133
+ subject
134
+ end
135
+ end
136
+
102
137
  context 'no cached compiled content available' do
103
138
  include_examples 'calls wrapped'
104
139
  end
@@ -0,0 +1,22 @@
1
+ describe 'GH-1094', site: true, stdio: true do
2
+ before do
3
+ File.write('content/a.dat', 'foo')
4
+ File.write('content/index.html', '<%= @items["/*.dat"].compiled_content %>')
5
+
6
+ File.write('Rules', <<EOS)
7
+ compile '/**/*.html' do
8
+ filter :erb
9
+ write item.identifier.to_s
10
+ end
11
+
12
+ passthrough '/**/*.dat'
13
+ EOS
14
+ end
15
+
16
+ it 'raises CannotGetCompiledContentOfBinaryItem twice' do
17
+ 2.times do
18
+ expect { Nanoc::CLI.run(%w(compile)) }
19
+ .to raise_wrapped_error(an_instance_of(Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem))
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ describe 'GH-1107', site: true, stdio: true do
2
+ before do
3
+ File.write('Rules', <<EOS)
4
+ compile '/**/*.html' do
5
+ garbage(data/**/*)
6
+ end
7
+ EOS
8
+ end
9
+
10
+ it 'raises the proper exception' do
11
+ expect { Nanoc::CLI.run(%w(compile --verbose)) }.to raise_error(SyntaxError)
12
+ end
13
+ end
data/spec/spec_helper.rb CHANGED
@@ -174,6 +174,32 @@ RSpec::Matchers.define :yield_from_fiber do |expected|
174
174
  end
175
175
  end
176
176
 
177
+ RSpec::Matchers.define :raise_wrapped_error do |expected|
178
+ supports_block_expectations
179
+
180
+ include RSpec::Matchers::Composable
181
+
182
+ match do |actual|
183
+ begin
184
+ actual.call
185
+ rescue Nanoc::Int::Errors::CompilationError => e
186
+ values_match?(expected, e.unwrap)
187
+ end
188
+ end
189
+
190
+ description do
191
+ "raise wrapped error #{expected.inspect}"
192
+ end
193
+
194
+ failure_message do |_actual|
195
+ "expected that proc would raise wrapped error #{expected.inspect}"
196
+ end
197
+
198
+ failure_message_when_negated do |_actual|
199
+ "expected that proc would not raise wrapped error #{expected.inspect}"
200
+ end
201
+ end
202
+
177
203
  RSpec::Matchers.define :be_some_textual_content do |expected|
178
204
  include RSpec::Matchers::Composable
179
205
 
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.6.2
4
+ version: 4.6.3
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-04 00:00:00.000000000 Z
11
+ date: 2017-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -442,9 +442,11 @@ files:
442
442
  - spec/nanoc/regressions/gh_1082c_spec.rb
443
443
  - spec/nanoc/regressions/gh_1082d_spec.rb
444
444
  - spec/nanoc/regressions/gh_1093_spec.rb
445
+ - spec/nanoc/regressions/gh_1094_spec.rb
445
446
  - spec/nanoc/regressions/gh_1097_spec.rb
446
447
  - spec/nanoc/regressions/gh_1100_spec.rb
447
448
  - spec/nanoc/regressions/gh_1102_spec.rb
449
+ - spec/nanoc/regressions/gh_1107_spec.rb
448
450
  - spec/nanoc/regressions/gh_761_spec.rb
449
451
  - spec/nanoc/regressions/gh_767_spec.rb
450
452
  - spec/nanoc/regressions/gh_769_spec.rb