nanoc 4.2.2 → 4.2.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
  SHA1:
3
- metadata.gz: ebe690aeb8d31bf2425569f41d9df2e5b8dcbe81
4
- data.tar.gz: 8b41f5683d233d963a3fd6a9c5384052d7265d8e
3
+ metadata.gz: 308b361e14b750d6171037c0167935bf806c7a5f
4
+ data.tar.gz: bf2db4108dc18dd6fa2602a3451ed5a2636af11e
5
5
  SHA512:
6
- metadata.gz: 4527c9d34fbe098dc58cac90906a1f1e643b595736006c92d18a222c0558c2965226f06db271cb01ca1ce8f939b05ea13013f1b0650293b53a659fcf8bd10fbd
7
- data.tar.gz: 59dbc24916845b1c98adfac716162fdc1c9b0984564d307741377da08c34c9ef3057574192ce9cd620eb89ed34d45bb45820dcde999f6f07bf23a77dedefbce3
6
+ metadata.gz: 820db95cb94318cca8afc1e6942f33e4131beb2bcc53eb0e4866079180dab65f6164e274117c53b88799b29bab3e069d245250b972a630bb5386dd3036f3a287
7
+ data.tar.gz: bdff99a92e4a2ff4ea4c6486bc3341728986ef259f5fe9c270c80355bf49d38d1cae5cf2f1c9b3178bce2c573313a423faca57009b7717ca1332abcab01019f1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanoc (4.2.2)
4
+ nanoc (4.2.3)
5
5
  cri (~> 2.3)
6
6
  hamster (~> 3.0)
7
7
 
data/NEWS.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.2.3 (2016-07-03)
4
+
5
+ Fixes:
6
+
7
+ * Fixed issue with `#inspect` raising a `WeakRef::RefError` (#877, #897)
8
+
9
+ Enhancements:
10
+
11
+ * Sped up compiler (#894)
12
+ * Improved `#inspect` output of some classes (#896)
13
+ * Deprecated `Item#modified` and replaced it with `Item#modified_reps` (#898)
14
+
3
15
  ## 4.2.2 (2016-07-02)
4
16
 
5
17
  Fixes:
@@ -20,6 +20,9 @@ module Nanoc
20
20
  end
21
21
  end
22
22
 
23
+ # Load external dependencies
24
+ require 'hamster'
25
+
23
26
  # Load general requirements
24
27
  require 'digest'
25
28
  require 'enumerator'
@@ -1,5 +1,3 @@
1
- require 'hamster'
2
-
3
1
  module Nanoc::Int
4
2
  # Creates checksums for given objects.
5
3
  #
@@ -191,7 +191,8 @@ module Nanoc::Int
191
191
  end
192
192
 
193
193
  # 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)
195
196
  selector.each do |rep|
196
197
  @stack = []
197
198
  compile_rep(rep)
@@ -136,7 +136,7 @@ module Nanoc::Int
136
136
  # indefinitely. It should not be necessary to pass this a custom value.
137
137
  #
138
138
  # @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)
140
140
  # Convert from rep to item if necessary
141
141
  obj = obj.item if obj.is_a?(Nanoc::Int::ItemRep)
142
142
 
@@ -8,6 +8,20 @@ module Nanoc::Int
8
8
  # @since 3.2.0
9
9
  module Memoization
10
10
  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
11
25
  attr_reader :value
12
26
 
13
27
  def initialize(value)
@@ -63,7 +77,7 @@ module Nanoc::Int
63
77
  if method_cache.key?(args)
64
78
  value =
65
79
  begin
66
- method_cache[args].value
80
+ method_cache[args].ref.value
67
81
  rescue WeakRef::RefError
68
82
  NONE
69
83
  end
@@ -71,7 +85,7 @@ module Nanoc::Int
71
85
 
72
86
  if value.equal?(NONE)
73
87
  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)))
75
89
  end
76
90
  else
77
91
  value
@@ -196,9 +196,7 @@ module Nanoc::Int
196
196
 
197
197
  def resolve(class_or_name, _klass)
198
198
  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)
202
200
  else
203
201
  class_or_name
204
202
  end
@@ -77,5 +77,9 @@ module Nanoc
77
77
  def binary?
78
78
  @item_rep.binary?
79
79
  end
80
+
81
+ def inspect
82
+ "<#{self.class} item.identifier=#{item.identifier} name=#{name}>"
83
+ end
80
84
  end
81
85
  end
@@ -76,5 +76,9 @@ module Nanoc
76
76
  def raw_content
77
77
  unwrap.content.string
78
78
  end
79
+
80
+ def inspect
81
+ "<#{self.class} identifier=#{unwrap.identifier}>"
82
+ end
79
83
  end
80
84
  end
@@ -1,7 +1,12 @@
1
1
  module Nanoc
2
2
  class PostCompileItemView < Nanoc::ItemWithRepsView
3
+ # @deprecated Use {#modified_reps} instead
3
4
  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? }
5
10
  end
6
11
  end
7
12
  end
@@ -23,5 +23,9 @@ module Nanoc
23
23
  def frozen?
24
24
  unwrap.frozen?
25
25
  end
26
+
27
+ def inspect
28
+ "<#{self.class}>"
29
+ end
26
30
  end
27
31
  end
@@ -1,4 +1,4 @@
1
1
  module Nanoc
2
2
  # The current Nanoc version.
3
- VERSION = '4.2.2'.freeze
3
+ VERSION = '4.2.3'.freeze
4
4
  end
@@ -208,21 +208,6 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
208
208
  end
209
209
  end
210
210
 
211
- def test_compile_should_recompile_all_reps
212
- Nanoc::CLI.run %w(create_site bar)
213
-
214
- FileUtils.cd('bar') do
215
- Nanoc::CLI.run %w(compile)
216
-
217
- site = Nanoc::Int::SiteLoader.new.new_from_cwd
218
- site.compile
219
-
220
- # At this point, even the already compiled items in the previous pass
221
- # should have their compiled content assigned, so this should work:
222
- site.compiler.reps[site.items['/index.*']][0].compiled_content
223
- end
224
- end
225
-
226
211
  def test_disallow_multiple_snapshots_with_the_same_name
227
212
  # Create site
228
213
  Nanoc::CLI.run %w(create_site bar)
@@ -25,6 +25,15 @@ class Nanoc::Int::MemoizationTest < Nanoc::TestCase
25
25
  memoize :run
26
26
  end
27
27
 
28
+ class Upcaser
29
+ extend Nanoc::Int::Memoization
30
+
31
+ def run(value)
32
+ value.upcase
33
+ end
34
+ memoize :run
35
+ end
36
+
28
37
  def test_normal
29
38
  sample1a = Sample1.new(10)
30
39
  sample1b = Sample1.new(15)
@@ -38,4 +47,17 @@ class Nanoc::Int::MemoizationTest < Nanoc::TestCase
38
47
  assert_equal 100 * 25 + 7, sample2b.run(7)
39
48
  end
40
49
  end
50
+
51
+ def test_weak_inspect
52
+ upcaser = Upcaser.new
53
+ 10_000.times do |i|
54
+ upcaser.run("hello world #{i}")
55
+ end
56
+
57
+ GC.start
58
+ GC.start
59
+
60
+ # Should not raise
61
+ upcaser.inspect
62
+ end
41
63
  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.2.2
4
+ version: 4.2.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: 2016-07-02 00:00:00.000000000 Z
11
+ date: 2016-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -387,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
387
387
  version: '0'
388
388
  requirements: []
389
389
  rubyforge_project:
390
- rubygems_version: 2.6.4
390
+ rubygems_version: 2.6.6
391
391
  signing_key:
392
392
  specification_version: 4
393
393
  summary: A static-site generator with a focus on flexibility.