Skip to content

Commit 249d7c9

Browse files
committed
Merge branch 'release-4.2.x'
2 parents 2984eb5 + 22ee434 commit 249d7c9

26 files changed

Lines changed: 250 additions & 28 deletions

lib/nanoc.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def self.on_windows?
2020
end
2121
end
2222

23+
# Load external dependencies
24+
require 'hamster'
25+
2326
# Load general requirements
2427
require 'digest'
2528
require 'enumerator'

lib/nanoc/base/checksummer.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'hamster'
2-
31
module Nanoc::Int
42
# Creates checksums for given objects.
53
#

lib/nanoc/base/compilation/compiler.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ def compile_reps
191191
end
192192

193193
# Find item reps to compile and compile them
194-
selector = Nanoc::Int::ItemRepSelector.new(@reps)
194+
outdated_reps = @reps.select { |r| outdatedness_checker.outdated?(r) }
195+
selector = Nanoc::Int::ItemRepSelector.new(outdated_reps)
195196
selector.each do |rep|
196197
@stack = []
197198
compile_rep(rep)

lib/nanoc/base/compilation/outdatedness_checker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def basic_outdatedness_reason_for(obj)
136136
# indefinitely. It should not be necessary to pass this a custom value.
137137
#
138138
# @return [Boolean] true if the object is outdated, false otherwise
139-
def outdated_due_to_dependencies?(obj, processed = Set.new)
139+
def outdated_due_to_dependencies?(obj, processed = Hamster::Set.new)
140140
# Convert from rep to item if necessary
141141
obj = obj.item if obj.is_a?(Nanoc::Int::ItemRep)
142142

lib/nanoc/base/memoization.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ module Nanoc::Int
88
# @since 3.2.0
99
module Memoization
1010
class Wrapper
11+
attr_reader :ref
12+
13+
def initialize(ref)
14+
@ref = ref
15+
end
16+
17+
def inspect
18+
@ref.inspect
19+
rescue WeakRef::RefError
20+
'<weak ref collected>'
21+
end
22+
end
23+
24+
class Value
1125
attr_reader :value
1226

1327
def initialize(value)
@@ -63,15 +77,15 @@ def memoize(method_name)
6377
if method_cache.key?(args)
6478
value =
6579
begin
66-
method_cache[args].value
80+
method_cache[args].ref.value
6781
rescue WeakRef::RefError
6882
NONE
6983
end
7084
end
7185

7286
if value.equal?(NONE)
7387
send(original_method_name, *args).tap do |r|
74-
method_cache[args] = WeakRef.new(Wrapper.new(r))
88+
method_cache[args] = Wrapper.new(WeakRef.new(Value.new(r)))
7589
end
7690
else
7791
value

lib/nanoc/base/plugin_registry.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ def all
196196

197197
def resolve(class_or_name, _klass)
198198
if class_or_name.is_a?(String)
199-
class_or_name.scan(/\w+/).reduce(Kernel) do |memo, part|
200-
memo.const_get(part)
201-
end
199+
Kernel.const_get(class_or_name)
202200
else
203201
class_or_name
204202
end

lib/nanoc/base/views/item_rep_view.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,9 @@ def raw_path(snapshot: :last)
7777
def binary?
7878
@item_rep.binary?
7979
end
80+
81+
def inspect
82+
"<#{self.class} item.identifier=#{item.identifier} name=#{name}>"
83+
end
8084
end
8185
end

lib/nanoc/base/views/mixins/document_view_mixin.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,9 @@ def reference
7676
def raw_content
7777
unwrap.content.string
7878
end
79+
80+
def inspect
81+
"<#{self.class} identifier=#{unwrap.identifier}>"
82+
end
7983
end
8084
end
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
module Nanoc
22
class PostCompileItemView < Nanoc::ItemWithRepsView
3+
# @deprecated Use {#modified_reps} instead
34
def modified
4-
reps.select { |rep| rep.unwrap.modified }
5+
modified_reps
6+
end
7+
8+
def modified_reps
9+
reps.select { |rep| rep.unwrap.modified? }
510
end
611
end
712
end

lib/nanoc/base/views/view.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@ def unwrap
2323
def frozen?
2424
unwrap.frozen?
2525
end
26+
27+
def inspect
28+
"<#{self.class}>"
29+
end
2630
end
2731
end

0 commit comments

Comments
 (0)