nanoc3 3.2.2 → 3.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.md +7 -0
- data/README.md +1 -0
- data/lib/nanoc3/base/source_data/item.rb +4 -0
- data/lib/nanoc3/cli/commands/create_site.rb +10 -1
- data/lib/nanoc3/cli/error_handler.rb +3 -4
- data/lib/nanoc3/filters/colorize_syntax.rb +8 -2
- data/lib/nanoc3.rb +1 -1
- data/test/base/test_item.rb +1 -1
- data/test/base/test_layout.rb +1 -1
- data/test/data_sources/test_filesystem_unified.rb +4 -4
- data/test/filters/test_coderay.rb +1 -1
- data/test/filters/test_colorize_syntax.rb +36 -6
- data/test/helpers/test_filtering.rb +1 -1
- metadata +15 -14
data/NEWS.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# nanoc news
|
2
2
|
|
3
|
+
## 3.2.3 (2011-10-31)
|
4
|
+
|
5
|
+
* Made syntax colorizer only strip trailing blank lines instead of all blanks
|
6
|
+
* Improved Ruby 1.9.x compatibility
|
7
|
+
* Made default rakefile require rubygems if necessary
|
8
|
+
* Made filename/content argument of `Nanoc3::Item#initialize` mandatory
|
9
|
+
|
3
10
|
## 3.2.2 (2011-09-04)
|
4
11
|
|
5
12
|
* Fixed command usage printing
|
data/README.md
CHANGED
@@ -70,6 +70,10 @@ module Nanoc3
|
|
70
70
|
params = { :mtime => params } if params.is_a?(Time)
|
71
71
|
params[:binary] = false unless params.has_key?(:binary)
|
72
72
|
|
73
|
+
if raw_content_or_raw_filename.nil?
|
74
|
+
raise "attempted to create an item with no content/filename (identifier #{identifier})"
|
75
|
+
end
|
76
|
+
|
73
77
|
# Get type and raw content or raw filename
|
74
78
|
@is_binary = params[:binary]
|
75
79
|
if @is_binary
|
@@ -281,6 +281,15 @@ EOS
|
|
281
281
|
</div>
|
282
282
|
</body>
|
283
283
|
</html>
|
284
|
+
EOS
|
285
|
+
|
286
|
+
DEFAULT_RAKEFILE = <<EOS
|
287
|
+
begin
|
288
|
+
require 'nanoc3/tasks'
|
289
|
+
rescue LoadError
|
290
|
+
require 'rubygems'
|
291
|
+
require 'nanoc3/tasks'
|
292
|
+
end
|
284
293
|
EOS
|
285
294
|
|
286
295
|
def run
|
@@ -336,7 +345,7 @@ EOS
|
|
336
345
|
|
337
346
|
# Create rakefile
|
338
347
|
File.open('Rakefile', 'w') do |io|
|
339
|
-
io.write
|
348
|
+
io.write DEFAULT_RAKEFILE.make_compatible_with_env
|
340
349
|
end
|
341
350
|
Nanoc3::NotificationCenter.post(:file_created, 'Rakefile')
|
342
351
|
|
@@ -169,10 +169,9 @@ module Nanoc3::CLI
|
|
169
169
|
case error
|
170
170
|
when LoadError
|
171
171
|
# Get gem name
|
172
|
-
matches = error.message.match(/no such file to load -- ([^\s]+)/)
|
173
|
-
return nil if matches.
|
174
|
-
|
175
|
-
gem_name = GEM_NAMES[$1]
|
172
|
+
matches = error.message.match(/(no such file to load|cannot load such file) -- ([^\s]+)/)
|
173
|
+
return nil if matches.nil?
|
174
|
+
gem_name = GEM_NAMES[matches[2]]
|
176
175
|
|
177
176
|
# Build message
|
178
177
|
if gem_name
|
@@ -111,8 +111,9 @@ module Nanoc3::Filters
|
|
111
111
|
next if language.nil?
|
112
112
|
|
113
113
|
# Highlight
|
114
|
-
|
115
|
-
|
114
|
+
raw = strip(element.inner_text)
|
115
|
+
highlighted_code = highlight(raw, language, params)
|
116
|
+
element.inner_html = strip(highlighted_code)
|
116
117
|
|
117
118
|
# Add class
|
118
119
|
unless has_class
|
@@ -131,6 +132,11 @@ module Nanoc3::Filters
|
|
131
132
|
|
132
133
|
KNOWN_COLORIZERS = [ :coderay, :dummy, :pygmentize, :simon_highlight ]
|
133
134
|
|
135
|
+
# Removes the first blank lines and any whitespace at the end.
|
136
|
+
def strip(s)
|
137
|
+
s.lines.drop_while { |line| line.strip.empty? }.join.rstrip
|
138
|
+
end
|
139
|
+
|
134
140
|
def highlight(code, language, params={})
|
135
141
|
colorizer = @colorizers[language.to_sym]
|
136
142
|
if KNOWN_COLORIZERS.include?(colorizer)
|
data/lib/nanoc3.rb
CHANGED
data/test/base/test_item.rb
CHANGED
@@ -25,7 +25,7 @@ class Nanoc3::ItemTest < MiniTest::Unit::TestCase
|
|
25
25
|
item.identifier.chop!
|
26
26
|
rescue => error
|
27
27
|
raised = true
|
28
|
-
|
28
|
+
assert_match /^can't modify frozen [Ss]tring$/, error.message
|
29
29
|
end
|
30
30
|
assert raised, 'Should have raised when trying to modify a frozen string'
|
31
31
|
end
|
data/test/base/test_layout.rb
CHANGED
@@ -22,7 +22,7 @@ class Nanoc3::LayoutTest < MiniTest::Unit::TestCase
|
|
22
22
|
layout.identifier.chop!
|
23
23
|
rescue => error
|
24
24
|
raised = true
|
25
|
-
|
25
|
+
assert_match /^can't modify frozen [Ss]tring$/, error.message
|
26
26
|
end
|
27
27
|
assert raised, 'Should have raised when trying to modify a frozen string'
|
28
28
|
end
|
@@ -27,8 +27,8 @@ class Nanoc3::DataSources::FilesystemUnifiedTest < MiniTest::Unit::TestCase
|
|
27
27
|
assert File.file?('foobar/asdf.html')
|
28
28
|
|
29
29
|
# Check file content
|
30
|
-
expected =
|
31
|
-
|
30
|
+
expected = /^--- ?\nfoo: bar\n---\n\ncontent here$/
|
31
|
+
assert_match expected, File.read('foobar/asdf.html')
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_create_object_at_root
|
@@ -43,8 +43,8 @@ class Nanoc3::DataSources::FilesystemUnifiedTest < MiniTest::Unit::TestCase
|
|
43
43
|
assert File.file?('foobar/index.html')
|
44
44
|
|
45
45
|
# Check file content
|
46
|
-
expected =
|
47
|
-
|
46
|
+
expected = /^--- ?\nfoo: bar\n---\n\ncontent here$/
|
47
|
+
assert_match expected, File.read('foobar/index.html')
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_load_objects
|
@@ -25,7 +25,7 @@ class Nanoc3::Filters::CodeRayTest < MiniTest::Unit::TestCase
|
|
25
25
|
# Run filter
|
26
26
|
code = "def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end"
|
27
27
|
result = filter.run(code, :language => 'ruby')
|
28
|
-
assert_match %r{^<span class="
|
28
|
+
assert_match %r{^<span class="keyword">def</span> <span class="function">some_function</span>}, result
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -11,7 +11,7 @@ class Nanoc3::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
11
11
|
|
12
12
|
# Get input and expected output
|
13
13
|
input = '<pre title="moo"><code class="language-ruby"># comment</code></pre>'
|
14
|
-
expected_output = '<pre title="moo"><code class="language-ruby"><span class="
|
14
|
+
expected_output = '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>'
|
15
15
|
|
16
16
|
# Run filter
|
17
17
|
actual_output = filter.run(input)
|
@@ -26,7 +26,7 @@ class Nanoc3::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
26
26
|
|
27
27
|
# Get input and expected output
|
28
28
|
input = %[<pre title="moo"><code>#!ruby\n# comment</code></pre>]
|
29
|
-
expected_output = '<pre title="moo"><code class="language-ruby"><span class="
|
29
|
+
expected_output = '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>'
|
30
30
|
|
31
31
|
# Run filter
|
32
32
|
actual_output = filter.run(input)
|
@@ -41,7 +41,7 @@ class Nanoc3::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
41
41
|
|
42
42
|
# Get input and expected output
|
43
43
|
input = %[<pre title="moo"><code class="language-ruby">#!ruby\n# comment</code></pre>]
|
44
|
-
expected_output = %[<pre title="moo"><code class="language-ruby"><span class="
|
44
|
+
expected_output = %[<pre title="moo"><code class="language-ruby"><span class="doctype">#!ruby</span>\n<span class="comment"># comment</span></code></pre>]
|
45
45
|
|
46
46
|
# Run filter
|
47
47
|
actual_output = filter.run(input)
|
@@ -56,7 +56,7 @@ class Nanoc3::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
56
56
|
|
57
57
|
# Get input and expected output
|
58
58
|
input = '<pre title="moo"><code class="abc language-ruby xyz"># comment</code></pre>'
|
59
|
-
expected_output = '<pre title="moo"><code class="abc language-ruby xyz"><span class="
|
59
|
+
expected_output = '<pre title="moo"><code class="abc language-ruby xyz"><span class="comment"># comment</span></code></pre>'
|
60
60
|
|
61
61
|
# Run filter
|
62
62
|
actual_output = filter.run(input)
|
@@ -239,8 +239,38 @@ after
|
|
239
239
|
EOS
|
240
240
|
expected_output = <<EOS
|
241
241
|
before
|
242
|
-
<pre><code class=\"language-ruby\"><span class=\"
|
243
|
-
puts <span class=\"
|
242
|
+
<pre><code class=\"language-ruby\"><span class=\"doctype\">#!/usr/bin/env ruby</span>
|
243
|
+
puts <span class=\"string\"><span class=\"delimiter\">'</span><span class=\"content\">hi!</span><span class=\"delimiter\">'</span></span></code></pre>
|
244
|
+
after
|
245
|
+
EOS
|
246
|
+
|
247
|
+
# Run filter
|
248
|
+
actual_output = filter.run(input)
|
249
|
+
assert_equal(expected_output, actual_output)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_strip
|
254
|
+
if_have 'coderay', 'nokogiri' do
|
255
|
+
# Create filter
|
256
|
+
filter = ::Nanoc3::Filters::ColorizeSyntax.new
|
257
|
+
|
258
|
+
# Simple test
|
259
|
+
assert_equal " bar", filter.send(:strip, "\n bar")
|
260
|
+
|
261
|
+
# Get input and expected output
|
262
|
+
input = <<EOS
|
263
|
+
before
|
264
|
+
<pre><code class="language-ruby">
|
265
|
+
def foo
|
266
|
+
end
|
267
|
+
</code></pre>
|
268
|
+
after
|
269
|
+
EOS
|
270
|
+
expected_output = <<EOS
|
271
|
+
before
|
272
|
+
<pre><code class="language-ruby"> <span class=\"keyword\">def</span> <span class=\"function\">foo</span>
|
273
|
+
<span class=\"keyword\">end</span></code></pre>
|
244
274
|
after
|
245
275
|
EOS
|
246
276
|
|
@@ -81,7 +81,7 @@ class Nanoc3::Helpers::FilteringTest < MiniTest::Unit::TestCase
|
|
81
81
|
|
82
82
|
# Evaluate content
|
83
83
|
result = ::ERB.new(content).result(binding)
|
84
|
-
assert_match(%r{<span class="
|
84
|
+
assert_match(%r{<span class="keyword">def</span> <span class="function">some_function</span>}, result)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.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: 2011-
|
12
|
+
date: 2011-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cri
|
16
|
-
requirement: &
|
16
|
+
requirement: &70345936282400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70345936282400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: minitest
|
27
|
-
requirement: &
|
27
|
+
requirement: &70345936281900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70345936281900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mocha
|
38
|
-
requirement: &
|
38
|
+
requirement: &70345936281040 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70345936281040
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &70345936280540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70345936280540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdiscount
|
60
|
-
requirement: &
|
60
|
+
requirement: &70345936279920 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70345936279920
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &70345936279240 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70345936279240
|
80
80
|
description: nanoc is a simple but very flexible static site generator written in
|
81
81
|
Ruby. It operates on local files, and therefore does not run on the server. nanoc
|
82
82
|
“compiles” the local source files into HTML (usually), by evaluating eRuby, Markdown,
|
@@ -354,3 +354,4 @@ specification_version: 3
|
|
354
354
|
summary: a web publishing system written in Ruby for building small to medium-sized
|
355
355
|
websites.
|
356
356
|
test_files: []
|
357
|
+
has_rdoc:
|