nanoc 3.3.2 → 3.3.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.
- data/Gemfile.lock +17 -18
- data/NEWS.md +8 -0
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base/compilation/rules_collection.rb +19 -1
- data/lib/nanoc/base/core_ext.rb +1 -0
- data/lib/nanoc/base/core_ext/date.rb +27 -0
- data/lib/nanoc/base/directed_graph.rb +17 -20
- data/lib/nanoc/base/source_data/item.rb +3 -0
- data/lib/nanoc/base/source_data/site.rb +4 -1
- data/lib/nanoc/cli/error_handler.rb +1 -1
- data/lib/nanoc/extra/deployers/rsync.rb +1 -1
- data/lib/nanoc/filters/colorize_syntax.rb +21 -19
- data/lib/nanoc/helpers/capturing.rb +11 -5
- data/lib/nanoc/helpers/xml_sitemap.rb +1 -1
- data/test/base/core_ext/array_spec.rb +2 -2
- data/test/base/core_ext/date_spec.rb +15 -0
- data/test/base/core_ext/hash_spec.rb +2 -2
- data/test/base/test_compiler.rb +54 -0
- data/test/base/test_directed_graph.rb +3 -0
- data/test/base/test_item.rb +3 -3
- data/test/base/test_item_rep.rb +2 -2
- data/test/base/test_layout.rb +1 -1
- data/test/base/test_outdatedness_checker.rb +33 -0
- data/test/extra/deployers/test_rsync.rb +4 -4
- data/test/extra/validators/test_links.rb +3 -4
- data/test/helpers/test_capturing.rb +54 -1
- metadata +47 -15
data/Gemfile.lock
CHANGED
@@ -12,36 +12,35 @@ GEM
|
|
12
12
|
posix-spawn (>= 0.3.6)
|
13
13
|
bluecloth (2.2.0)
|
14
14
|
builder (3.0.0)
|
15
|
-
coderay (1.0.
|
15
|
+
coderay (1.0.6)
|
16
16
|
coffee-script (2.2.0)
|
17
17
|
coffee-script-source
|
18
18
|
execjs
|
19
19
|
coffee-script-source (1.2.0)
|
20
|
-
commonjs (0.2.
|
21
|
-
|
22
|
-
cri (2.2.0)
|
20
|
+
commonjs (0.2.5)
|
21
|
+
cri (2.2.1)
|
23
22
|
erubis (2.7.0)
|
24
23
|
execjs (1.3.0)
|
25
24
|
multi_json (~> 1.0)
|
26
25
|
haml (3.1.4)
|
27
|
-
json (1.6.
|
26
|
+
json (1.6.6)
|
28
27
|
kramdown (0.13.5)
|
29
|
-
less (2.0
|
28
|
+
less (2.1.0)
|
30
29
|
commonjs (~> 0.2.0)
|
31
|
-
therubyracer (~> 0.
|
30
|
+
therubyracer (~> 0.10.0)
|
32
31
|
libv8 (3.3.10.4)
|
33
32
|
markaby (0.7.2)
|
34
33
|
builder (>= 2.0.0)
|
35
34
|
maruku (0.6.0)
|
36
35
|
syntax (>= 1.0.0)
|
37
36
|
metaclass (0.0.1)
|
38
|
-
mime-types (1.
|
39
|
-
minitest (2.
|
37
|
+
mime-types (1.18)
|
38
|
+
minitest (2.12.0)
|
40
39
|
mocha (0.10.5)
|
41
40
|
metaclass (~> 0.0.1)
|
42
|
-
multi_json (1.
|
41
|
+
multi_json (1.2.0)
|
43
42
|
mustache (0.99.4)
|
44
|
-
nokogiri (1.5.
|
43
|
+
nokogiri (1.5.2)
|
45
44
|
posix-spawn (0.3.6)
|
46
45
|
rack (1.4.1)
|
47
46
|
rainpress (1.0)
|
@@ -49,21 +48,21 @@ GEM
|
|
49
48
|
rdiscount (1.6.8)
|
50
49
|
rdoc (3.12)
|
51
50
|
json (~> 1.4)
|
52
|
-
redcarpet (2.1.
|
51
|
+
redcarpet (2.1.1)
|
53
52
|
rubypants (0.2.0)
|
54
53
|
sass (3.1.15)
|
55
|
-
slim (1.
|
54
|
+
slim (1.2.0)
|
56
55
|
temple (~> 0.4.0)
|
57
|
-
tilt (~> 1.3.
|
56
|
+
tilt (~> 1.3.3)
|
58
57
|
syntax (1.0.0)
|
59
|
-
systemu (2.
|
58
|
+
systemu (2.5.0)
|
60
59
|
temple (0.4.0)
|
61
|
-
therubyracer (0.
|
60
|
+
therubyracer (0.10.1)
|
62
61
|
libv8 (~> 3.3.10)
|
63
62
|
tilt (1.3.3)
|
64
|
-
typogruby (1.0.
|
63
|
+
typogruby (1.0.15)
|
65
64
|
rubypants
|
66
|
-
uglifier (1.2.
|
65
|
+
uglifier (1.2.4)
|
67
66
|
execjs (>= 0.3.0)
|
68
67
|
multi_json (>= 1.0.2)
|
69
68
|
w3c_validators (1.2)
|
data/NEWS.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# nanoc news
|
2
2
|
|
3
|
+
## 3.3.3 (2012-04-11)
|
4
|
+
|
5
|
+
* Fixed directed graph implementation on Rubinius
|
6
|
+
* Made capturing helper not remember content between runs
|
7
|
+
* Fixed Date#freeze issue on Ruby 1.8.x
|
8
|
+
* Made it possible to have any kind of object as parameters in the Rules file
|
9
|
+
* Fixed bug which caused changes routes not to cause a recompile
|
10
|
+
|
3
11
|
## 3.3.2 (2012-03-16)
|
4
12
|
|
5
13
|
* Removed bin/nanoc3 (use nanoc3 gem if you want it)
|
data/lib/nanoc.rb
CHANGED
@@ -195,10 +195,28 @@ module Nanoc
|
|
195
195
|
def new_rule_memory_for_rep(rep)
|
196
196
|
recording_proxy = rep.to_recording_proxy
|
197
197
|
compilation_rule_for(rep).apply_to(recording_proxy, :compiler => @compiler)
|
198
|
-
recording_proxy.rule_memory
|
198
|
+
recording_proxy.rule_memory << [ :write, rep.path ]
|
199
|
+
make_rule_memory_serializable(recording_proxy.rule_memory)
|
199
200
|
end
|
200
201
|
memoize :new_rule_memory_for_rep
|
201
202
|
|
203
|
+
# Makes the given rule memory serializable by calling `#inspect` on the
|
204
|
+
# filter arguments, so that objects such as classes and filenames can be
|
205
|
+
# serialized.
|
206
|
+
#
|
207
|
+
# @param [Array] rs The rule memory for a certain item rep
|
208
|
+
#
|
209
|
+
# @return [Array] The serializable rule memory
|
210
|
+
def make_rule_memory_serializable(rs)
|
211
|
+
rs.map do |r|
|
212
|
+
if r[0] == :filter
|
213
|
+
[ r[0], r[1], r[2].to_a.sort.map { |a| a.inspect } ]
|
214
|
+
else
|
215
|
+
r
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
202
220
|
# @param [Nanoc::Layout] layout The layout to get the rule memory for
|
203
221
|
#
|
204
222
|
# @return [Array] The rule memory for the given layout
|
data/lib/nanoc/base/core_ext.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
begin
|
4
|
+
d = ::Date.today
|
5
|
+
d.freeze
|
6
|
+
d.year
|
7
|
+
needs_patch = false
|
8
|
+
rescue => e
|
9
|
+
needs_patch = true
|
10
|
+
end
|
11
|
+
|
12
|
+
if needs_patch
|
13
|
+
|
14
|
+
class ::Date
|
15
|
+
|
16
|
+
[ :amjd, :jd, :day_fraction, :mjd, :ld, :civil, :ordinal, :commercial, :weeknum0, :weeknum1, :time, :wday, :julian?, :gregorian?, :leap? ].each do |m|
|
17
|
+
module_eval <<EOS
|
18
|
+
alias_method :__orig_#{m}, :#{m}
|
19
|
+
def #{m}
|
20
|
+
self.frozen? ? self.dup.#{m} : self.send(:__orig_#{m})
|
21
|
+
end
|
22
|
+
EOS
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -31,26 +31,19 @@ module Nanoc
|
|
31
31
|
# # => %w( b c )
|
32
32
|
class DirectedGraph
|
33
33
|
|
34
|
-
# The set of vertices in this graph.
|
35
|
-
#
|
36
|
-
# @return [Set]
|
37
|
-
attr_reader :vertices
|
38
|
-
|
39
34
|
# @group Creating a graph
|
40
35
|
|
41
36
|
# Creates a new directed graph with the given vertices.
|
42
37
|
def initialize(vertices)
|
43
|
-
@vertices =
|
38
|
+
@vertices = {}
|
39
|
+
vertices.each_with_index do |v,i|
|
40
|
+
@vertices[v] = i
|
41
|
+
end
|
44
42
|
|
45
43
|
@from_graph = {}
|
46
44
|
@to_graph = {}
|
47
45
|
|
48
|
-
@
|
49
|
-
@vertices.each_with_index do |v, i|
|
50
|
-
@vertice_indexes[v] = i
|
51
|
-
end
|
52
|
-
|
53
|
-
@roots = Set.new(@vertices)
|
46
|
+
@roots = Set.new(@vertices.keys)
|
54
47
|
|
55
48
|
invalidate_caches
|
56
49
|
end
|
@@ -72,7 +65,7 @@ module Nanoc
|
|
72
65
|
@from_graph[from] << to
|
73
66
|
|
74
67
|
@to_graph[to] ||= Set.new
|
75
|
-
@to_graph[to]
|
68
|
+
@to_graph[to] << from
|
76
69
|
|
77
70
|
@roots.delete(to)
|
78
71
|
|
@@ -109,12 +102,11 @@ module Nanoc
|
|
109
102
|
#
|
110
103
|
# @since 3.2.0
|
111
104
|
def add_vertex(v)
|
112
|
-
return if @vertices.
|
105
|
+
return if @vertices.has_key?(v)
|
113
106
|
|
114
|
-
@vertices
|
115
|
-
@vertice_indexes[v] = @vertices.size-1
|
107
|
+
@vertices[v] = @vertices.size
|
116
108
|
|
117
|
-
@roots
|
109
|
+
@roots << v
|
118
110
|
end
|
119
111
|
|
120
112
|
# Deletes all edges coming from the given vertex.
|
@@ -206,15 +198,20 @@ module Nanoc
|
|
206
198
|
@successors[from] ||= recursively_find_vertices(from, :direct_successors_of)
|
207
199
|
end
|
208
200
|
|
201
|
+
# @return [Array] The list of all vertices in this graph.
|
202
|
+
def vertices
|
203
|
+
@vertices.keys.sort_by { |v| @vertices[v] }
|
204
|
+
end
|
205
|
+
|
209
206
|
# Returns an array of tuples representing the edges. The result of this
|
210
207
|
# method may take a while to compute and should be cached if possible.
|
211
208
|
#
|
212
209
|
# @return [Array] The list of all edges in this graph.
|
213
210
|
def edges
|
214
211
|
result = []
|
215
|
-
@vertices.
|
216
|
-
direct_successors_of(
|
217
|
-
result << [
|
212
|
+
@vertices.each_pair do |v1, i1|
|
213
|
+
direct_successors_of(v1).map { |v2| @vertices[v2] }.each do |i2|
|
214
|
+
result << [ i1, i2 ]
|
218
215
|
end
|
219
216
|
end
|
220
217
|
result
|
@@ -36,6 +36,9 @@ module Nanoc
|
|
36
36
|
# item’s content (only available for binary items)
|
37
37
|
attr_reader :raw_filename
|
38
38
|
|
39
|
+
# @return [Nanoc::Site] The site this item belongs to
|
40
|
+
attr_accessor :site
|
41
|
+
|
39
42
|
# @return [Nanoc::Item, nil] The parent item of this item. This can be
|
40
43
|
# nil even for non-root items.
|
41
44
|
attr_accessor :parent
|
@@ -311,7 +311,10 @@ module Nanoc
|
|
311
311
|
@items = []
|
312
312
|
data_sources.each do |ds|
|
313
313
|
items_in_ds = ds.items
|
314
|
-
items_in_ds.each
|
314
|
+
items_in_ds.each do |i|
|
315
|
+
i.identifier = File.join(ds.items_root, i.identifier)
|
316
|
+
i.site = self
|
317
|
+
end
|
315
318
|
@items.concat(items_in_ds)
|
316
319
|
end
|
317
320
|
end
|
@@ -159,7 +159,7 @@ module Nanoc::CLI
|
|
159
159
|
'rainpress' => 'rainpress',
|
160
160
|
'rdiscount' => 'rdiscount',
|
161
161
|
'redcarpet' => 'redcarpet',
|
162
|
-
'redcloth' => '
|
162
|
+
'redcloth' => 'RedCloth',
|
163
163
|
'rubypants' => 'rubypants',
|
164
164
|
'sass' => 'sass',
|
165
165
|
'systemu' => 'systemu',
|
@@ -143,24 +143,6 @@ module Nanoc::Filters
|
|
143
143
|
doc.send(method, :encoding => 'UTF-8')
|
144
144
|
end
|
145
145
|
|
146
|
-
private
|
147
|
-
|
148
|
-
KNOWN_COLORIZERS = [ :coderay, :dummy, :pygmentize, :pygmentsrb, :simon_highlight ]
|
149
|
-
|
150
|
-
# Removes the first blank lines and any whitespace at the end.
|
151
|
-
def strip(s)
|
152
|
-
s.lines.drop_while { |line| line.strip.empty? }.join.rstrip
|
153
|
-
end
|
154
|
-
|
155
|
-
def highlight(code, language, params={})
|
156
|
-
colorizer = @colorizers[language.to_sym]
|
157
|
-
if KNOWN_COLORIZERS.include?(colorizer)
|
158
|
-
send(colorizer, code, language, params[colorizer] || {})
|
159
|
-
else
|
160
|
-
raise RuntimeError, "I don’t know how to highlight code using the “#{colorizer}” colorizer"
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
146
|
# Runs the code through [CodeRay](http://coderay.rubychan.de/).
|
165
147
|
#
|
166
148
|
# @api private
|
@@ -254,13 +236,15 @@ module Nanoc::Filters
|
|
254
236
|
#
|
255
237
|
# @api private
|
256
238
|
#
|
239
|
+
# @since 3.2.0
|
240
|
+
#
|
257
241
|
# @param [String] code The code to colorize
|
258
242
|
#
|
259
243
|
# @param [String] language The language the code is written in
|
260
244
|
#
|
261
245
|
# @option params [String] :style The style to use
|
262
246
|
#
|
263
|
-
# @
|
247
|
+
# @return [String] The colorized output
|
264
248
|
def simon_highlight(code, language, params={})
|
265
249
|
require 'systemu'
|
266
250
|
|
@@ -289,6 +273,24 @@ module Nanoc::Filters
|
|
289
273
|
stdout.read
|
290
274
|
end
|
291
275
|
|
276
|
+
private
|
277
|
+
|
278
|
+
KNOWN_COLORIZERS = [ :coderay, :dummy, :pygmentize, :pygmentsrb, :simon_highlight ]
|
279
|
+
|
280
|
+
# Removes the first blank lines and any whitespace at the end.
|
281
|
+
def strip(s)
|
282
|
+
s.lines.drop_while { |line| line.strip.empty? }.join.rstrip
|
283
|
+
end
|
284
|
+
|
285
|
+
def highlight(code, language, params={})
|
286
|
+
colorizer = @colorizers[language.to_sym]
|
287
|
+
if KNOWN_COLORIZERS.include?(colorizer)
|
288
|
+
send(colorizer, code, language, params[colorizer] || {})
|
289
|
+
else
|
290
|
+
raise RuntimeError, "I don’t know how to highlight code using the “#{colorizer}” colorizer"
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
292
294
|
def check_availability(*cmd)
|
293
295
|
systemu cmd
|
294
296
|
raise "Could not spawn #{cmd.join(' ')}" if $?.exitstatus != 0
|
@@ -39,9 +39,6 @@ module Nanoc::Helpers
|
|
39
39
|
# @api private
|
40
40
|
class CapturesStore
|
41
41
|
|
42
|
-
require 'singleton'
|
43
|
-
include Singleton
|
44
|
-
|
45
42
|
def initialize
|
46
43
|
@store = {}
|
47
44
|
end
|
@@ -58,6 +55,15 @@ module Nanoc::Helpers
|
|
58
55
|
|
59
56
|
end
|
60
57
|
|
58
|
+
class ::Nanoc::Site
|
59
|
+
|
60
|
+
# @api private
|
61
|
+
def captures_store
|
62
|
+
@captures_store ||= CapturesStore.new
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
61
67
|
# @overload content_for(name, &block)
|
62
68
|
#
|
63
69
|
# Captures the content inside the block and stores it so that it can be
|
@@ -96,7 +102,7 @@ module Nanoc::Helpers
|
|
96
102
|
|
97
103
|
# Capture and store
|
98
104
|
content = capture(&block)
|
99
|
-
|
105
|
+
@site.captures_store[@item, name.to_sym] = content
|
100
106
|
else # Get content
|
101
107
|
# Get args
|
102
108
|
if args.size != 2
|
@@ -107,7 +113,7 @@ module Nanoc::Helpers
|
|
107
113
|
name = args[1]
|
108
114
|
|
109
115
|
# Get content
|
110
|
-
|
116
|
+
@site.captures_store[item, name.to_sym]
|
111
117
|
end
|
112
118
|
end
|
113
119
|
|
@@ -31,7 +31,7 @@ module Nanoc::Helpers
|
|
31
31
|
#
|
32
32
|
# @example Excluding binary items from the sitemap
|
33
33
|
#
|
34
|
-
# <%= xml_sitemap :items => @items.reject{ |i| i[:is_hidden] || i
|
34
|
+
# <%= xml_sitemap :items => @items.reject{ |i| i[:is_hidden] || i.binary? } %>
|
35
35
|
#
|
36
36
|
# @option params [Array] :items A list of items to include in the sitemap
|
37
37
|
#
|
@@ -31,7 +31,7 @@ describe 'Array#freeze_recursively' do
|
|
31
31
|
array[0] = 123
|
32
32
|
rescue => e
|
33
33
|
raised = true
|
34
|
-
assert_match
|
34
|
+
assert_match /(^can't modify frozen |^unable to modify frozen object$)/, e.message
|
35
35
|
end
|
36
36
|
assert raised
|
37
37
|
end
|
@@ -45,7 +45,7 @@ describe 'Array#freeze_recursively' do
|
|
45
45
|
array[1][0] = 123
|
46
46
|
rescue => e
|
47
47
|
raised = true
|
48
|
-
assert_match
|
48
|
+
assert_match /(^can't modify frozen |^unable to modify frozen object$)/, e.message
|
49
49
|
end
|
50
50
|
assert raised
|
51
51
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe 'Date' do
|
4
|
+
|
5
|
+
it 'should not crash when requesting frozen attributes' do
|
6
|
+
# This test will pass without patch on MRI 1.9.x, but on MRI 1.8.x it
|
7
|
+
# crashes. (Untested on other Ruby implementations such as Rubinius and
|
8
|
+
# JRuby).
|
9
|
+
d = Date.today
|
10
|
+
d.freeze
|
11
|
+
d.year
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
@@ -49,7 +49,7 @@ describe 'Hash#freeze_recursively' do
|
|
49
49
|
hash[:a] = 123
|
50
50
|
rescue => e
|
51
51
|
raised = true
|
52
|
-
assert_match
|
52
|
+
assert_match /(^can't modify frozen |^unable to modify frozen object$)/, e.message
|
53
53
|
end
|
54
54
|
assert raised
|
55
55
|
end
|
@@ -63,7 +63,7 @@ describe 'Hash#freeze_recursively' do
|
|
63
63
|
hash[:a][:b] = 123
|
64
64
|
rescue => e
|
65
65
|
raised = true
|
66
|
-
assert_match
|
66
|
+
assert_match /(^can't modify frozen |^unable to modify frozen object$)/, e.message
|
67
67
|
end
|
68
68
|
assert raised
|
69
69
|
end
|
data/test/base/test_compiler.rb
CHANGED
@@ -434,4 +434,58 @@ class Nanoc::CompilerTest < MiniTest::Unit::TestCase
|
|
434
434
|
end
|
435
435
|
end
|
436
436
|
|
437
|
+
def test_change_routing_rule_and_recompile
|
438
|
+
with_site do |site|
|
439
|
+
# Create items
|
440
|
+
File.open('content/a.html', 'w') do |io|
|
441
|
+
io.write('<h1>A</h1>')
|
442
|
+
end
|
443
|
+
File.open('content/b.html', 'w') do |io|
|
444
|
+
io.write('<h1>B</h1>')
|
445
|
+
end
|
446
|
+
|
447
|
+
# Create routes
|
448
|
+
File.open('Rules', 'w') do |io|
|
449
|
+
io.write "compile '*' do\n"
|
450
|
+
io.write "end\n"
|
451
|
+
io.write "\n"
|
452
|
+
io.write "route '/a/' do\n"
|
453
|
+
io.write " '/index.html'\n"
|
454
|
+
io.write "end\n"
|
455
|
+
io.write "\n"
|
456
|
+
io.write "route '*' do\n"
|
457
|
+
io.write " nil\n"
|
458
|
+
io.write "end\n"
|
459
|
+
end
|
460
|
+
|
461
|
+
# Compile
|
462
|
+
site = Nanoc::Site.new('.')
|
463
|
+
site.compile
|
464
|
+
|
465
|
+
# Check
|
466
|
+
assert_equal '<h1>A</h1>', File.read('output/index.html')
|
467
|
+
|
468
|
+
# Create routes
|
469
|
+
File.open('Rules', 'w') do |io|
|
470
|
+
io.write "compile '*' do\n"
|
471
|
+
io.write "end\n"
|
472
|
+
io.write "\n"
|
473
|
+
io.write "route '/b/' do\n"
|
474
|
+
io.write " '/index.html'\n"
|
475
|
+
io.write "end\n"
|
476
|
+
io.write "\n"
|
477
|
+
io.write "route '*' do\n"
|
478
|
+
io.write " nil\n"
|
479
|
+
io.write "end\n"
|
480
|
+
end
|
481
|
+
|
482
|
+
# Compile
|
483
|
+
site = Nanoc::Site.new('.')
|
484
|
+
site.compile
|
485
|
+
|
486
|
+
# Check
|
487
|
+
assert_equal '<h1>B</h1>', File.read('output/index.html')
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
437
491
|
end
|
@@ -54,8 +54,11 @@ class Nanoc::DirectedGraphTest < MiniTest::Unit::TestCase
|
|
54
54
|
|
55
55
|
def test_edges_with_new_vertices
|
56
56
|
graph = Nanoc::DirectedGraph.new([ 1 ])
|
57
|
+
assert_equal [ 1 ], graph.vertices
|
57
58
|
graph.add_edge(1, 2)
|
59
|
+
assert_equal [ 1, 2 ], graph.vertices
|
58
60
|
graph.add_edge(3, 2)
|
61
|
+
assert_equal [ 1, 2, 3 ], graph.vertices
|
59
62
|
|
60
63
|
assert_equal [ [ 0, 1 ], [ 2, 1 ] ], graph.edges.sort
|
61
64
|
end
|
data/test/base/test_item.rb
CHANGED
@@ -25,7 +25,7 @@ class Nanoc::ItemTest < MiniTest::Unit::TestCase
|
|
25
25
|
item.identifier.chop!
|
26
26
|
rescue => error
|
27
27
|
raised = true
|
28
|
-
assert_match
|
28
|
+
assert_match /(^can't modify frozen [Ss]tring|^unable to modify frozen object$)/, error.message
|
29
29
|
end
|
30
30
|
assert raised, 'Should have raised when trying to modify a frozen string'
|
31
31
|
end
|
@@ -149,7 +149,7 @@ class Nanoc::ItemTest < MiniTest::Unit::TestCase
|
|
149
149
|
item[:abc] = '123'
|
150
150
|
rescue => e
|
151
151
|
raised = true
|
152
|
-
assert_match
|
152
|
+
assert_match /(^can't modify frozen |^unable to modify frozen object$)/, e.message
|
153
153
|
end
|
154
154
|
assert raised
|
155
155
|
|
@@ -158,7 +158,7 @@ class Nanoc::ItemTest < MiniTest::Unit::TestCase
|
|
158
158
|
item[:a][:b] = '456'
|
159
159
|
rescue => e
|
160
160
|
raised = true
|
161
|
-
assert_match
|
161
|
+
assert_match /(^can't modify frozen |^unable to modify frozen object$)/, e.message
|
162
162
|
end
|
163
163
|
assert raised
|
164
164
|
end
|
data/test/base/test_item_rep.rb
CHANGED
@@ -459,7 +459,7 @@ class Nanoc::ItemRepTest < MiniTest::Unit::TestCase
|
|
459
459
|
rep.filter(:whatever)
|
460
460
|
rescue => e
|
461
461
|
raised = true
|
462
|
-
assert_match
|
462
|
+
assert_match /(^can't modify frozen |^unable to modify frozen object$)/, e.message
|
463
463
|
end
|
464
464
|
assert raised
|
465
465
|
end
|
@@ -483,7 +483,7 @@ class Nanoc::ItemRepTest < MiniTest::Unit::TestCase
|
|
483
483
|
rep.filter(:whatever)
|
484
484
|
rescue => e
|
485
485
|
raised = true
|
486
|
-
assert_match
|
486
|
+
assert_match /(^can't modify frozen |^unable to modify frozen object$)/, e.message
|
487
487
|
end
|
488
488
|
assert raised
|
489
489
|
end
|
data/test/base/test_layout.rb
CHANGED
@@ -22,7 +22,7 @@ class Nanoc::LayoutTest < MiniTest::Unit::TestCase
|
|
22
22
|
layout.identifier.chop!
|
23
23
|
rescue => error
|
24
24
|
raised = true
|
25
|
-
assert_match
|
25
|
+
assert_match /(^can't modify frozen [Ss]tring|^unable to modify frozen object$)/, error.message
|
26
26
|
end
|
27
27
|
assert raised, 'Should have raised when trying to modify a frozen string'
|
28
28
|
end
|
@@ -391,4 +391,37 @@ class Nanoc::OutdatednessCheckerTest < MiniTest::Unit::TestCase
|
|
391
391
|
end
|
392
392
|
end
|
393
393
|
|
394
|
+
def test_non_serializable_parameters_in_rules_should_be_allowed
|
395
|
+
# Create site
|
396
|
+
with_site(:name => 'foo') do |site|
|
397
|
+
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
398
|
+
File.open('Rules', 'w') do |io|
|
399
|
+
io.write("compile '/' do\n")
|
400
|
+
io.write(" c = Class.new {}\n")
|
401
|
+
io.write(" def c.inspect ; 'I am so classy' ; end\n")
|
402
|
+
io.write(" filter :erb, :stuff => c\n")
|
403
|
+
io.write("end\n")
|
404
|
+
io.write("\n")
|
405
|
+
io.write("route '/' do\n")
|
406
|
+
io.write(" '/index.html'\n")
|
407
|
+
io.write("end\n")
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
# Compile
|
412
|
+
FileUtils.cd('foo') do
|
413
|
+
site = Nanoc::Site.new('.')
|
414
|
+
site.compile
|
415
|
+
end
|
416
|
+
|
417
|
+
# Assert not outdated
|
418
|
+
FileUtils.cd('foo') do
|
419
|
+
site = Nanoc::Site.new('.')
|
420
|
+
outdatedness_checker = site.compiler.outdatedness_checker
|
421
|
+
site.items.each do |item|
|
422
|
+
refute outdatedness_checker.outdated?(item), "item should not be outdated"
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
394
427
|
end
|
@@ -52,7 +52,7 @@ class Nanoc::Extra::Deployers::RsyncTest < MiniTest::Unit::TestCase
|
|
52
52
|
if_have 'systemu' do
|
53
53
|
# Create deployer
|
54
54
|
rsync = Nanoc::Extra::Deployers::Rsync.new(
|
55
|
-
'output
|
55
|
+
'output',
|
56
56
|
{ :dst => 'asdf' })
|
57
57
|
|
58
58
|
# Mock run_shell_cmd
|
@@ -66,7 +66,7 @@ class Nanoc::Extra::Deployers::RsyncTest < MiniTest::Unit::TestCase
|
|
66
66
|
# Check args
|
67
67
|
opts = Nanoc::Extra::Deployers::Rsync::DEFAULT_OPTIONS
|
68
68
|
assert_equal(
|
69
|
-
[ 'rsync', opts,
|
69
|
+
[ 'rsync', opts, 'output/', 'asdf' ].flatten,
|
70
70
|
rsync.instance_eval { @shell_cms_args }
|
71
71
|
)
|
72
72
|
end
|
@@ -76,7 +76,7 @@ class Nanoc::Extra::Deployers::RsyncTest < MiniTest::Unit::TestCase
|
|
76
76
|
if_have 'systemu' do
|
77
77
|
# Create deployer
|
78
78
|
rsync = Nanoc::Extra::Deployers::Rsync.new(
|
79
|
-
'output
|
79
|
+
'output',
|
80
80
|
{ :dst => 'asdf' },
|
81
81
|
:dry_run => true)
|
82
82
|
|
@@ -91,7 +91,7 @@ class Nanoc::Extra::Deployers::RsyncTest < MiniTest::Unit::TestCase
|
|
91
91
|
# Check args
|
92
92
|
opts = Nanoc::Extra::Deployers::Rsync::DEFAULT_OPTIONS
|
93
93
|
assert_equal(
|
94
|
-
[ 'echo', 'rsync', opts,
|
94
|
+
[ 'echo', 'rsync', opts, 'output/', 'asdf' ].flatten,
|
95
95
|
rsync.instance_eval { @shell_cms_args }
|
96
96
|
)
|
97
97
|
end
|
@@ -53,10 +53,9 @@ class Nanoc::Extra::Validators::LinksTest < MiniTest::Unit::TestCase
|
|
53
53
|
validator = Nanoc::Extra::Validators::Links.new('output', [ 'index.html' ])
|
54
54
|
|
55
55
|
# Test
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
assert validator.send(:fetch_http_status_for, URI.parse('http://google.com/foo/bar'), 404)
|
56
|
+
assert_equal 200, validator.send(:fetch_http_status_for, URI.parse('http://www.apple.com/'))
|
57
|
+
assert_equal 200, validator.send(:fetch_http_status_for, URI.parse('https://www.apple.com/'))
|
58
|
+
assert_equal 404, validator.send(:fetch_http_status_for, URI.parse('http://www.apple.com/sdfghgfdsdfgh'))
|
60
59
|
end
|
61
60
|
|
62
61
|
end
|
@@ -14,8 +14,12 @@ class Nanoc::Helpers::CapturingTest < MiniTest::Unit::TestCase
|
|
14
14
|
" <%= 1+2 %>\n" +
|
15
15
|
"<% end %> foot"
|
16
16
|
|
17
|
-
#
|
17
|
+
# Build site
|
18
|
+
@site = Nanoc3::Site.new({})
|
18
19
|
@item = Nanoc::Item.new('moo', {}, '/blah/')
|
20
|
+
@item.site = @site
|
21
|
+
|
22
|
+
# Evaluate content
|
19
23
|
result = ::ERB.new(content).result(binding)
|
20
24
|
|
21
25
|
# Check
|
@@ -27,6 +31,10 @@ class Nanoc::Helpers::CapturingTest < MiniTest::Unit::TestCase
|
|
27
31
|
def test_capture
|
28
32
|
require 'erb'
|
29
33
|
|
34
|
+
# Build site
|
35
|
+
@site = Nanoc3::Site.new({})
|
36
|
+
@item = Nanoc::Item.new('moo', {}, '/blah/')
|
37
|
+
|
30
38
|
# Capture
|
31
39
|
_erbout = 'foo'
|
32
40
|
captured_content = capture do
|
@@ -38,4 +46,49 @@ class Nanoc::Helpers::CapturingTest < MiniTest::Unit::TestCase
|
|
38
46
|
assert_equal 'bar', captured_content
|
39
47
|
end
|
40
48
|
|
49
|
+
def test_content_for_recursively
|
50
|
+
require 'erb'
|
51
|
+
|
52
|
+
content = <<EOS
|
53
|
+
head
|
54
|
+
<% content_for :box do %>
|
55
|
+
basic
|
56
|
+
<% end %>
|
57
|
+
<% content_for :box do %>
|
58
|
+
before <%= content_for @item, :box %> after
|
59
|
+
<% end %>
|
60
|
+
<%= content_for @item, :box %>
|
61
|
+
foot
|
62
|
+
EOS
|
63
|
+
|
64
|
+
@site = Nanoc3::Site.new({})
|
65
|
+
@item = Nanoc::Item.new('content', {}, '/')
|
66
|
+
|
67
|
+
result = ::ERB.new(content).result(binding)
|
68
|
+
|
69
|
+
expected = %w( head before basic after foot )
|
70
|
+
actual = result.scan(/[a-z]+/)
|
71
|
+
assert_equal expected, actual
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_different_sites
|
75
|
+
require 'erb'
|
76
|
+
|
77
|
+
@site = Nanoc3::Site.new({})
|
78
|
+
@item = Nanoc::Item.new('content', {}, '/')
|
79
|
+
content = "<% content_for :a do %>Content One<% end %>"
|
80
|
+
::ERB.new(content).result(binding)
|
81
|
+
|
82
|
+
assert_equal 'Content One', content_for(@item, :a)
|
83
|
+
assert_equal nil, content_for(@item, :b)
|
84
|
+
|
85
|
+
@site = Nanoc3::Site.new({})
|
86
|
+
@item = Nanoc::Item.new('content', {}, '/')
|
87
|
+
content = "<% content_for :b do %>Content Two<% end %>"
|
88
|
+
::ERB.new(content).result(binding)
|
89
|
+
|
90
|
+
assert_equal nil, content_for(@item, :a)
|
91
|
+
assert_equal 'Content Two', content_for(@item, :b)
|
92
|
+
end
|
93
|
+
|
41
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cri
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '2.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.2'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: minitest
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: mocha
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rake
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: rdiscount
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: yard
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,7 +101,12 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
description: nanoc is a simple but very flexible static site generator written in
|
81
111
|
Ruby. It operates on local files, and therefore does not run on the server. nanoc
|
82
112
|
“compiles” the local source files into HTML (usually), by evaluating eRuby, Markdown,
|
@@ -117,6 +147,7 @@ files:
|
|
117
147
|
- lib/nanoc/base/compilation/rules_collection.rb
|
118
148
|
- lib/nanoc/base/context.rb
|
119
149
|
- lib/nanoc/base/core_ext/array.rb
|
150
|
+
- lib/nanoc/base/core_ext/date.rb
|
120
151
|
- lib/nanoc/base/core_ext/hash.rb
|
121
152
|
- lib/nanoc/base/core_ext/pathname.rb
|
122
153
|
- lib/nanoc/base/core_ext/string.rb
|
@@ -233,6 +264,7 @@ files:
|
|
233
264
|
- tasks/doc.rake
|
234
265
|
- tasks/test.rake
|
235
266
|
- test/base/core_ext/array_spec.rb
|
267
|
+
- test/base/core_ext/date_spec.rb
|
236
268
|
- test/base/core_ext/hash_spec.rb
|
237
269
|
- test/base/core_ext/pathname_spec.rb
|
238
270
|
- test/base/core_ext/string_spec.rb
|
@@ -368,7 +400,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
368
400
|
version: '0'
|
369
401
|
requirements: []
|
370
402
|
rubyforge_project:
|
371
|
-
rubygems_version: 1.8.
|
403
|
+
rubygems_version: 1.8.21
|
372
404
|
signing_key:
|
373
405
|
specification_version: 3
|
374
406
|
summary: a web publishing system written in Ruby for building small to medium-sized
|