nanoc 4.10.2 → 4.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfb2cbc0d64311d9e3b14715a1f05d0c45d0dc49020b929fb9d528429393a4b6
4
- data.tar.gz: 88014c7a2d2f9f48e1c616f55a10401679e1bb7f069f324ccdd13d1560f67975
3
+ metadata.gz: 29fff0fd45abb2f33fe2ecd8b80531a166163bfea453b2f4633bd7796847624d
4
+ data.tar.gz: 8795f5b0c4d192c4d02cc3febc198a5af78410d073ba6df41c8ffbe32ad94f54
5
5
  SHA512:
6
- metadata.gz: 70430b8f328bbcc2b537bd02bce5b094d9060545e5e1bb70dbc34e575a01812b6845f9624ea0dbce6af0e2c7739dbe4174572c8283df0e595c7d792bdd26ee54
7
- data.tar.gz: 92d75e7db1a2bbacc5364c449a7ef1499a88ac35f9c28fc07d58be43a5fc932e999447a4897ff0d96f6b577a3ec6c1260979e7eb83f6fd97c36b04e25c590694
6
+ metadata.gz: d208e075e74aa527b9384aa902a98b52d35ee0fc7432fc2ed93c142ebf66dd02ade7ecf169fce4a1ded36c680428afcf36b675d5de158553beb5d3e256850fcc
7
+ data.tar.gz: 5a8b4e5c7f3c367620fcf568491665d509dc6ccfab035994bb896962bf83403309b6b116d221836babf82afba750b8b944f38c9ef462d7c45a964fa82afd1877
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.10.3 (2018-10-28)
4
+
5
+ Fixes:
6
+
7
+ * Fixed an issue which could cause `write nil` to still invoke the routing rule (#1374, #1375)
8
+
3
9
  ## 4.10.2 (2018-10-21)
4
10
 
5
11
  Fixes:
@@ -23,7 +23,7 @@ module Nanoc::Int::ProcessingActions
23
23
 
24
24
  contract C::KeywordArgs[snapshot_names: C::Optional[C::IterOf[Symbol]], paths: C::Optional[C::IterOf[String]]] => self
25
25
  def update(snapshot_names: [], paths: [])
26
- self.class.new(@snapshot_names + snapshot_names, @paths + paths)
26
+ self.class.new(@snapshot_names + snapshot_names.to_a, @paths + paths.to_a)
27
27
  end
28
28
 
29
29
  contract C::None => String
@@ -12,7 +12,7 @@ module Nanoc
12
12
  @any_layouts = false
13
13
  @last_snapshot = false
14
14
  @pre_snapshot = false
15
- @skip_routing_rule = false
15
+ @snapshots_for_which_to_skip_routing_rule = Set.new
16
16
  end
17
17
 
18
18
  def inspect
@@ -40,7 +40,9 @@ module Nanoc
40
40
  MaybePathlike = C::Or[nil, Nanoc::UNDEFINED, String, Nanoc::Identifier]
41
41
  contract Symbol, C::KeywordArgs[path: C::Optional[MaybePathlike]] => nil
42
42
  def snapshot(snapshot_name, path: Nanoc::UNDEFINED)
43
- @skip_routing_rule = path.nil?
43
+ unless Nanoc::UNDEFINED.equal?(path)
44
+ @snapshots_for_which_to_skip_routing_rule << snapshot_name
45
+ end
44
46
 
45
47
  path =
46
48
  if Nanoc::UNDEFINED.equal?(path) || path.nil?
@@ -69,9 +71,9 @@ module Nanoc
69
71
  @any_layouts
70
72
  end
71
73
 
72
- contract C::None => C::Bool
73
- def skip_routing_rule?
74
- @skip_routing_rule
74
+ contract C::None => Set
75
+ def snapshots_for_which_to_skip_routing_rule
76
+ @snapshots_for_which_to_skip_routing_rule
75
77
  end
76
78
 
77
79
  contract C::None => C::Bool
@@ -69,7 +69,11 @@ module Nanoc::RuleDSL
69
69
  recorder.snapshot(:last) unless recorder.last_snapshot?
70
70
  recorder.snapshot(:pre) unless recorder.pre_snapshot?
71
71
 
72
- copy_paths_from_routing_rules(compact_snapshots(recorder.action_sequence), rep: rep)
72
+ copy_paths_from_routing_rules(
73
+ compact_snapshots(recorder.action_sequence),
74
+ recorder.snapshots_for_which_to_skip_routing_rule,
75
+ rep: rep,
76
+ )
73
77
  end
74
78
 
75
79
  # @param [Nanoc::Int::Layout] layout
@@ -99,26 +103,25 @@ module Nanoc::RuleDSL
99
103
  Nanoc::Int::ActionSequence.new(seq.item_rep, actions: actions)
100
104
  end
101
105
 
102
- def copy_paths_from_routing_rules(seq, rep:)
106
+ def copy_paths_from_routing_rules(seq, snapshots_for_which_to_skip_routing_rule, rep:)
107
+ # NOTE: This assumes that `seq` is compacted, i.e. there are no two consecutive snapshot actions.
108
+
103
109
  seq.map do |action|
104
- if action.is_a?(Nanoc::Int::ProcessingActions::Snapshot) && action.paths.empty?
105
- copy_path_from_routing_rule(action, rep: rep)
106
- else
107
- action
108
- end
109
- end
110
- end
110
+ # Only potentially modify snapshot actions
111
+ next action unless action.is_a?(Nanoc::Int::ProcessingActions::Snapshot)
111
112
 
112
- def copy_path_from_routing_rule(action, rep:)
113
- paths_from_rules =
114
- action.snapshot_names.map do |snapshot_name|
115
- basic_path_from_rules_for(rep, snapshot_name)
116
- end.compact
113
+ # If any of the action’s snapshot are explicitly marked as excluded from
114
+ # getting a path from a routing rule, then ignore routing rules.
115
+ next action if snapshots_for_which_to_skip_routing_rule.intersect?(Set.new(action.snapshot_names))
117
116
 
118
- if paths_from_rules.any?
119
- action.update(paths: paths_from_rules.map(&:to_s))
120
- else
121
- action
117
+ # If this action already has paths that don’t come from routing rules,
118
+ # then don’t add more to them.
119
+ next action unless action.paths.empty?
120
+
121
+ # For each snapshot name, find a path from a routing rule. The routing
122
+ # rule might return nil, so we need #compact.
123
+ paths = action.snapshot_names.map { |sn| basic_path_from_rules_for(rep, sn) }.compact
124
+ action.update(snapshot_names: [], paths: paths)
122
125
  end
123
126
  end
124
127
 
data/lib/nanoc/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current Nanoc version.
5
- VERSION = '4.10.2'
5
+ VERSION = '4.10.3'
6
6
  end
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.10.2
4
+ version: 4.10.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: 2018-10-21 00:00:00.000000000 Z
11
+ date: 2018-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable