nanoc 3.4.2 → 3.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/Gemfile.lock +15 -13
- data/NEWS.md +16 -0
- data/README.md +4 -0
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base/compilation/compiler.rb +5 -3
- data/lib/nanoc/base/compilation/rule_context.rb +7 -6
- data/lib/nanoc/cli/cleaning_stream.rb +5 -0
- data/lib/nanoc/extra/pruner.rb +1 -1
- data/lib/nanoc/filters/handlebars.rb +3 -1
- data/lib/nanoc/filters/sass.rb +2 -2
- data/lib/nanoc/helpers/xml_sitemap.rb +2 -2
- data/nanoc.gemspec +1 -1
- data/test/base/core_ext/array_spec.rb +2 -2
- data/test/base/core_ext/hash_spec.rb +2 -2
- data/test/base/test_checksum_store.rb +0 -1
- data/test/base/test_compiler.rb +32 -1
- 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_memoization.rb +8 -8
- data/test/base/test_site.rb +1 -1
- data/test/cli/commands/test_deploy.rb +5 -6
- data/test/cli/commands/test_prune.rb +23 -1
- data/test/cli/commands/test_watch.rb +27 -7
- data/test/cli/test_cleaning_stream.rb +11 -2
- data/test/cli/test_error_handler.rb +1 -1
- data/test/extra/test_auto_compiler.rb +4 -4
- data/test/filters/test_colorize_syntax.rb +2 -2
- data/test/filters/test_handlebars.rb +0 -3
- data/test/filters/test_less.rb +5 -5
- data/test/filters/test_sass.rb +6 -10
- data/test/helper.rb +3 -2
- data/test/helpers/test_filtering.rb +1 -1
- data/test/helpers/test_xml_sitemap.rb +82 -66
- data/test/test_gem.rb +42 -0
- metadata +3 -4
- data/.gemtest +0 -0
- data/lib/nanoc/extra/checking/checker_cli.rb +0 -151
data/Gemfile
CHANGED
@@ -9,6 +9,7 @@ gem 'coderay'
|
|
9
9
|
gem 'coffee-script'
|
10
10
|
gem 'erubis'
|
11
11
|
gem 'fog'
|
12
|
+
gem 'fssm'
|
12
13
|
gem 'haml'
|
13
14
|
gem 'kramdown'
|
14
15
|
gem 'less', '~> 2.0'
|
@@ -26,7 +27,7 @@ gem 'rdoc'
|
|
26
27
|
gem 'redcarpet'
|
27
28
|
gem 'RedCloth'
|
28
29
|
gem 'rubypants'
|
29
|
-
gem 'sass', '~> 3.
|
30
|
+
gem 'sass', '~> 3.2.2'
|
30
31
|
gem 'slim'
|
31
32
|
gem 'systemu'
|
32
33
|
gem 'typogruby'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nanoc (3.4.
|
4
|
+
nanoc (3.4.2)
|
5
5
|
cri (~> 2.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -16,16 +16,16 @@ GEM
|
|
16
16
|
coffee-script (2.2.0)
|
17
17
|
coffee-script-source
|
18
18
|
execjs
|
19
|
-
coffee-script-source (1.
|
19
|
+
coffee-script-source (1.4.0)
|
20
20
|
colored (1.2)
|
21
21
|
commonjs (0.2.6)
|
22
22
|
cri (2.3.0)
|
23
23
|
colored (>= 1.2)
|
24
24
|
erubis (2.7.0)
|
25
|
-
excon (0.16.
|
25
|
+
excon (0.16.10)
|
26
26
|
execjs (1.4.0)
|
27
27
|
multi_json (~> 1.0)
|
28
|
-
fog (1.
|
28
|
+
fog (1.7.0)
|
29
29
|
builder
|
30
30
|
excon (~> 0.14)
|
31
31
|
formatador (~> 0.2.0)
|
@@ -35,7 +35,8 @@ GEM
|
|
35
35
|
net-ssh (>= 2.1.3)
|
36
36
|
nokogiri (~> 1.5.0)
|
37
37
|
ruby-hmac
|
38
|
-
formatador (0.2.
|
38
|
+
formatador (0.2.4)
|
39
|
+
fssm (0.2.9)
|
39
40
|
haml (3.1.7)
|
40
41
|
json (1.7.5)
|
41
42
|
kramdown (0.14.0)
|
@@ -47,14 +48,14 @@ GEM
|
|
47
48
|
syntax (>= 1.0.0)
|
48
49
|
metaclass (0.0.1)
|
49
50
|
mime-types (1.19)
|
50
|
-
minitest (4.1
|
51
|
-
mocha (0.
|
51
|
+
minitest (4.3.1)
|
52
|
+
mocha (0.13.0)
|
52
53
|
metaclass (~> 0.0.1)
|
53
|
-
multi_json (1.3.
|
54
|
+
multi_json (1.3.7)
|
54
55
|
mustache (0.99.4)
|
55
56
|
net-scp (1.0.4)
|
56
57
|
net-ssh (>= 1.99.1)
|
57
|
-
net-ssh (2.6.
|
58
|
+
net-ssh (2.6.2)
|
58
59
|
nokogiri (1.5.5)
|
59
60
|
posix-spawn (0.3.6)
|
60
61
|
pygments.rb (0.3.2)
|
@@ -62,15 +63,15 @@ GEM
|
|
62
63
|
yajl-ruby (~> 1.1.0)
|
63
64
|
rack (1.4.1)
|
64
65
|
rainpress (1.0)
|
65
|
-
rake (0.
|
66
|
+
rake (10.0.2)
|
66
67
|
rdiscount (1.6.8)
|
67
68
|
rdoc (3.12)
|
68
69
|
json (~> 1.4)
|
69
70
|
redcarpet (2.2.2)
|
70
71
|
ruby-hmac (0.4.0)
|
71
72
|
rubypants (0.2.0)
|
72
|
-
sass (3.2.
|
73
|
-
slim (1.3.
|
73
|
+
sass (3.2.3)
|
74
|
+
slim (1.3.4)
|
74
75
|
temple (~> 0.5.5)
|
75
76
|
tilt (~> 1.3.3)
|
76
77
|
syntax (1.0.0)
|
@@ -101,6 +102,7 @@ DEPENDENCIES
|
|
101
102
|
coffee-script
|
102
103
|
erubis
|
103
104
|
fog
|
105
|
+
fssm
|
104
106
|
haml
|
105
107
|
kramdown
|
106
108
|
less (~> 2.0)
|
@@ -120,7 +122,7 @@ DEPENDENCIES
|
|
120
122
|
rdoc
|
121
123
|
redcarpet
|
122
124
|
rubypants
|
123
|
-
sass (~> 3.
|
125
|
+
sass (~> 3.2.2)
|
124
126
|
slim
|
125
127
|
systemu
|
126
128
|
typogruby
|
data/NEWS.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# nanoc news
|
2
2
|
|
3
|
+
## 3.4.3 (2012-12-09)
|
4
|
+
|
5
|
+
Improvements:
|
6
|
+
|
7
|
+
* Item reps are now accessible in a consistent way: in Rules and during
|
8
|
+
compilation, they can be accessed using both `@rep` and `@item_rep`
|
9
|
+
|
10
|
+
Fixes:
|
11
|
+
|
12
|
+
* Made cleaning streams (stdout/stderr as used by nanoc) compatible with
|
13
|
+
Ruby’s built-in Logger
|
14
|
+
* Made prune work when the output directory is a symlink
|
15
|
+
* Made Handlebars filter compatible with the latest version
|
16
|
+
* Made `show-data` command show more accurate dependencies [Stefan Bühler]
|
17
|
+
* Restored compatibility with Sass 3.2.2
|
18
|
+
|
3
19
|
## 3.4.2 (2012-11-01)
|
4
20
|
|
5
21
|
Fixes:
|
data/README.md
CHANGED
@@ -96,14 +96,18 @@ may be interested in the development dependencies:
|
|
96
96
|
* Starr Horne
|
97
97
|
* Daniel Hofstetter
|
98
98
|
* Tuomas Kareinen
|
99
|
+
* Greg Karékinian
|
99
100
|
* Matt Keveney
|
100
101
|
* Kevin Lynagh
|
102
|
+
* Go Maeda
|
101
103
|
* Nikhil Marathe
|
102
104
|
* Daniel Mendler
|
103
105
|
* Ale Muñoz
|
104
106
|
* John Nishinaga
|
107
|
+
* Gregory Pakosz
|
105
108
|
* Nicky Peeters
|
106
109
|
* Christian Plessl
|
110
|
+
* Damien Pollet
|
107
111
|
* Šime Ramov
|
108
112
|
* Xavier Shay
|
109
113
|
* Arnau Siches
|
data/lib/nanoc.rb
CHANGED
@@ -81,6 +81,10 @@ module Nanoc
|
|
81
81
|
# Compile reps
|
82
82
|
load
|
83
83
|
@site.freeze
|
84
|
+
|
85
|
+
# Determine which reps need to be recompiled
|
86
|
+
forget_dependencies_if_outdated(items)
|
87
|
+
|
84
88
|
dependency_tracker.start
|
85
89
|
compile_reps(reps)
|
86
90
|
dependency_tracker.stop
|
@@ -121,9 +125,6 @@ module Nanoc
|
|
121
125
|
# Load auxiliary stores
|
122
126
|
stores.each { |s| s.load }
|
123
127
|
|
124
|
-
# Determine which reps need to be recompiled
|
125
|
-
forget_dependencies_if_outdated(items)
|
126
|
-
|
127
128
|
@loaded = true
|
128
129
|
rescue => e
|
129
130
|
unload
|
@@ -272,6 +273,7 @@ module Nanoc
|
|
272
273
|
|
273
274
|
content_or_filename_assigns.merge({
|
274
275
|
:item => rep.item,
|
276
|
+
:rep => rep,
|
275
277
|
:item_rep => rep,
|
276
278
|
:items => site.items,
|
277
279
|
:layouts => site.layouts,
|
@@ -29,12 +29,13 @@ module Nanoc
|
|
29
29
|
compiler = params[:compiler] or raise ArgumentError, "Required :compiler option is missing"
|
30
30
|
|
31
31
|
super({
|
32
|
-
:rep
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
32
|
+
:rep => rep,
|
33
|
+
:item_rep => rep,
|
34
|
+
:item => rep.item,
|
35
|
+
:site => compiler.site,
|
36
|
+
:config => compiler.site.config,
|
37
|
+
:items => compiler.site.items,
|
38
|
+
:layouts => compiler.site.layouts
|
38
39
|
})
|
39
40
|
end
|
40
41
|
|
data/lib/nanoc/extra/pruner.rb
CHANGED
@@ -35,7 +35,7 @@ module Nanoc::Extra
|
|
35
35
|
|
36
36
|
# Get present files and dirs
|
37
37
|
present_files_and_dirs = Set.new
|
38
|
-
Find.find(self.site.config[:output_dir]) do |f|
|
38
|
+
Find.find(self.site.config[:output_dir] + '/') do |f|
|
39
39
|
present_files_and_dirs << f
|
40
40
|
end
|
41
41
|
present_files = present_files_and_dirs.select { |f| File.file?(f) }
|
@@ -22,7 +22,9 @@ module Nanoc::Filters
|
|
22
22
|
context[:config] = assigns[:config]
|
23
23
|
context[:yield] = assigns[:content]
|
24
24
|
|
25
|
-
::Handlebars.
|
25
|
+
handlebars = ::Handlebars::Context.new
|
26
|
+
template = handlebars.compile(content)
|
27
|
+
template.call(context)
|
26
28
|
end
|
27
29
|
|
28
30
|
end
|
data/lib/nanoc/filters/sass.rb
CHANGED
@@ -19,10 +19,10 @@ module Nanoc::Filters
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def _find(dir, name, options)
|
22
|
-
full_filename, syntax = find_real_file(dir, name)
|
22
|
+
full_filename, syntax = ::Sass::Util.destructure(find_real_file(dir, name, options))
|
23
23
|
return unless full_filename && File.readable?(full_filename)
|
24
24
|
|
25
|
-
filter = Nanoc::Filters::Sass.current
|
25
|
+
filter = Nanoc::Filters::Sass.current # FIXME ew global
|
26
26
|
item = filter.imported_filename_to_item(full_filename)
|
27
27
|
filter.depend_on([ item ]) unless item.nil?
|
28
28
|
|
@@ -40,7 +40,7 @@ module Nanoc::Helpers
|
|
40
40
|
require 'builder'
|
41
41
|
|
42
42
|
# Extract parameters
|
43
|
-
items = params
|
43
|
+
items = params.fetch(:items) { @items.reject { |i| i[:is_hidden] } }
|
44
44
|
|
45
45
|
# Create builder
|
46
46
|
buffer = ''
|
@@ -59,7 +59,7 @@ module Nanoc::Helpers
|
|
59
59
|
item.reps.reject { |r| r.raw_path.nil? }.each do |rep|
|
60
60
|
xml.url do
|
61
61
|
xml.loc @site.config[:base_url] + rep.path
|
62
|
-
xml.lastmod item
|
62
|
+
xml.lastmod item[:mtime].to_iso8601_date unless item[:mtime].nil?
|
63
63
|
xml.changefreq item[:changefreq] unless item[:changefreq].nil?
|
64
64
|
xml.priority item[:priority] unless item[:priority].nil?
|
65
65
|
end
|
data/nanoc.gemspec
CHANGED
@@ -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
|
@@ -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
@@ -275,7 +275,7 @@ class Nanoc::CompilerTest < MiniTest::Unit::TestCase
|
|
275
275
|
error = assert_raises(RuntimeError) do
|
276
276
|
site.compile
|
277
277
|
end
|
278
|
-
assert_match
|
278
|
+
assert_match(/^The path returned for the.*does not start with a slash. Please ensure that all routing rules return a path that starts with a slash./, error.message)
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
@@ -488,4 +488,35 @@ class Nanoc::CompilerTest < MiniTest::Unit::TestCase
|
|
488
488
|
end
|
489
489
|
end
|
490
490
|
|
491
|
+
def test_rep_assigns
|
492
|
+
with_site do |site|
|
493
|
+
# Create item
|
494
|
+
File.open('content/index.html', 'w') do |io|
|
495
|
+
io.write('@rep.name = <%= @rep.name %> - @item_rep.name = <%= @item_rep.name %>')
|
496
|
+
end
|
497
|
+
|
498
|
+
# Create routes
|
499
|
+
File.open('Rules', 'w') do |io|
|
500
|
+
io.write "compile '*' do\n"
|
501
|
+
io.write " if @rep.name == :default && @item_rep.name == :default\n"
|
502
|
+
io.write " filter :erb\n"
|
503
|
+
io.write " end\n"
|
504
|
+
io.write "end\n"
|
505
|
+
io.write "\n"
|
506
|
+
io.write "route '*' do\n"
|
507
|
+
io.write " '/index.html'\n"
|
508
|
+
io.write "end\n"
|
509
|
+
io.write "\n"
|
510
|
+
io.write "layout '*', :erb\n"
|
511
|
+
end
|
512
|
+
|
513
|
+
# Compile
|
514
|
+
site = Nanoc::Site.new('.')
|
515
|
+
site.compile
|
516
|
+
|
517
|
+
# Check
|
518
|
+
assert_equal '@rep.name = default - @item_rep.name = default', File.read('output/index.html')
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
491
522
|
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
|
@@ -68,10 +68,10 @@ class Nanoc::MemoizationTest < MiniTest::Unit::TestCase
|
|
68
68
|
sample2b = Sample2.new(25)
|
69
69
|
|
70
70
|
3.times do
|
71
|
-
assert_equal
|
72
|
-
assert_equal
|
73
|
-
assert_equal
|
74
|
-
assert_equal
|
71
|
+
assert_equal 10*10+5, sample1a.run(5)
|
72
|
+
assert_equal 10*15+7, sample1b.run(7)
|
73
|
+
assert_equal 100*20+5, sample2a.run(5)
|
74
|
+
assert_equal 100*25+7, sample2b.run(7)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -80,10 +80,10 @@ class Nanoc::MemoizationTest < MiniTest::Unit::TestCase
|
|
80
80
|
sample2 = EqualSample.new(3)
|
81
81
|
|
82
82
|
3.times do
|
83
|
-
assert_equal
|
84
|
-
assert_equal
|
85
|
-
assert_equal
|
86
|
-
assert_equal
|
83
|
+
assert_equal 2*10+5, sample1.run(5)
|
84
|
+
assert_equal 2*10+3, sample1.run(3)
|
85
|
+
assert_equal 3*10+5, sample2.run(5)
|
86
|
+
assert_equal 3*10+3, sample2.run(3)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
data/test/base/test_site.rb
CHANGED
@@ -107,18 +107,17 @@ class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
107
107
|
FileUtils.mkdir_p('output')
|
108
108
|
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
109
109
|
|
110
|
-
|
111
|
-
assert_raises
|
110
|
+
capturing_stdio do
|
111
|
+
err = assert_raises Nanoc::Errors::GenericTrivial do
|
112
112
|
Nanoc::CLI.run %w( deploy )
|
113
113
|
end
|
114
|
+
assert_equal 'The site configuration has no deploy configuration for default.', err.message
|
114
115
|
end
|
115
|
-
|
116
|
-
assert ios[:stderr].include?('The site configuration has no deploy configuration for default.')
|
117
116
|
end
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
121
|
-
def
|
120
|
+
def test_deploy_without_target_with_default
|
122
121
|
if_have 'systemu' do
|
123
122
|
with_site do |site|
|
124
123
|
File.open('config.yaml', 'w') do |io|
|
@@ -130,7 +129,7 @@ class Nanoc::CLI::Commands::DeployTest < MiniTest::Unit::TestCase
|
|
130
129
|
FileUtils.mkdir_p('output')
|
131
130
|
File.open('output/blah.html', 'w') { |io| io.write 'moo' }
|
132
131
|
|
133
|
-
|
132
|
+
capturing_stdio do
|
134
133
|
Nanoc::CLI.run %w( deploy )
|
135
134
|
end
|
136
135
|
|
@@ -94,5 +94,27 @@ class Nanoc::CLI::Commands::PruneTest < MiniTest::Unit::TestCase
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
def test_run_with_symlink_to_output_dir
|
98
|
+
with_site do |site|
|
99
|
+
# Set output dir
|
100
|
+
FileUtils.rm_rf('output')
|
101
|
+
FileUtils.mkdir_p('output-real')
|
102
|
+
File.symlink('output-real', 'output')
|
103
|
+
|
104
|
+
# Create source files
|
105
|
+
File.open('content/index.html', 'w') { |io| io.write 'stuff' }
|
106
|
+
|
107
|
+
# Create output files
|
108
|
+
FileUtils.mkdir_p('output-real/some-dir')
|
109
|
+
File.open('output-real/some-file.html', 'w') { |io| io.write 'stuff' }
|
110
|
+
File.open('output-real/index.html', 'w') { |io| io.write 'stuff' }
|
111
|
+
|
112
|
+
Nanoc::CLI.run %w( prune --yes )
|
98
113
|
|
114
|
+
assert File.file?('output-real/index.html')
|
115
|
+
assert !File.directory?('output-real/some-dir')
|
116
|
+
assert !File.file?('output-real/some-file.html')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -17,15 +17,12 @@ class Nanoc::CLI::Commands::WatchTest < MiniTest::Unit::TestCase
|
|
17
17
|
watch_thread = Thread.new do
|
18
18
|
Nanoc::CLI.run %w( watch )
|
19
19
|
end
|
20
|
-
sleep 1
|
21
20
|
|
22
21
|
File.open('content/index.html', 'w') { |io| io.write('Hello there!') }
|
23
|
-
|
24
|
-
assert_equal 'Hello there!', File.read('output/index.html')
|
22
|
+
self.wait_until_content_equals('content/index.html', 'Hello there!')
|
25
23
|
|
26
24
|
File.open('content/index.html', 'w') { |io| io.write('Hello there again!') }
|
27
|
-
|
28
|
-
assert_equal 'Hello there again!', File.read('output/index.html')
|
25
|
+
self.wait_until_content_equals('content/index.html', 'Hello there again!')
|
29
26
|
|
30
27
|
watch_thread.kill
|
31
28
|
end
|
@@ -37,15 +34,38 @@ class Nanoc::CLI::Commands::WatchTest < MiniTest::Unit::TestCase
|
|
37
34
|
watch_thread = Thread.new do
|
38
35
|
Nanoc::CLI.run %w( watch )
|
39
36
|
end
|
40
|
-
sleep 1
|
41
37
|
|
42
38
|
ENV['PATH'] = '.' # so that neither which nor where can be found
|
43
39
|
File.open('content/index.html', 'w') { |io| io.write('Hello there!') }
|
44
|
-
|
40
|
+
self.wait_until_exists('output/index.html')
|
45
41
|
assert_equal 'Hello there!', File.read('output/index.html')
|
42
|
+
|
43
|
+
watch_thread.kill
|
46
44
|
end
|
47
45
|
ensure
|
48
46
|
ENV['PATH'] = old_path
|
49
47
|
end
|
50
48
|
|
49
|
+
def wait_until_exists(filename)
|
50
|
+
20.times do
|
51
|
+
break if File.file?(filename)
|
52
|
+
sleep 0.5
|
53
|
+
end
|
54
|
+
if !File.file?(filename)
|
55
|
+
raise RuntimeError, "Expected #{filename} to appear but it didn't :("
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def wait_until_content_equals(filename, content)
|
60
|
+
self.wait_until_exists(filename)
|
61
|
+
|
62
|
+
20.times do
|
63
|
+
break if File.read(filename) == content
|
64
|
+
sleep 0.5
|
65
|
+
end
|
66
|
+
if File.read(filename) != content
|
67
|
+
raise RuntimeError, "Expected #{filename} to have content #{content} but it doesn't :("
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
51
71
|
end
|
@@ -19,7 +19,7 @@ class Nanoc::CLI::CleaningStreamTest < MiniTest::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_forward
|
22
|
-
methods = [ :write, :<<, :tty?, :flush, :tell, :print, :puts, :string, :reopen, :exist?, :exists
|
22
|
+
methods = [ :write, :<<, :tty?, :flush, :tell, :print, :puts, :string, :reopen, :exist?, :exists?, :close ]
|
23
23
|
|
24
24
|
s = Stream.new
|
25
25
|
cs = Nanoc::CLI::CleaningStream.new(s)
|
@@ -35,11 +35,20 @@ class Nanoc::CLI::CleaningStreamTest < MiniTest::Unit::TestCase
|
|
35
35
|
cs.reopen('/dev/null', 'r')
|
36
36
|
cs.exist?
|
37
37
|
cs.exists?
|
38
|
+
cs.close
|
38
39
|
|
39
40
|
methods.each do |m|
|
40
41
|
assert s.called_methods.include?(m), "expected #{m} to be called"
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
|
-
|
45
|
+
def test_works_with_logger
|
46
|
+
require 'logger'
|
47
|
+
stream = StringIO.new
|
48
|
+
cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
|
49
|
+
logger = Logger.new(cleaning_stream)
|
50
|
+
logger.info("Some info")
|
51
|
+
logger.warn("Something could start going wrong!")
|
52
|
+
end
|
45
53
|
|
54
|
+
end
|
@@ -12,7 +12,7 @@ class Nanoc::CLI::ErrorHandlerTest < MiniTest::Unit::TestCase
|
|
12
12
|
def test_resolution_for_with_known_gem
|
13
13
|
$loud = true
|
14
14
|
error = LoadError.new('no such file to load -- kramdown')
|
15
|
-
assert_match
|
15
|
+
assert_match(/^Try installing /, handler.send(:resolution_for, error))
|
16
16
|
ensure
|
17
17
|
$loud = false
|
18
18
|
end
|
@@ -59,7 +59,7 @@ class Nanoc::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
|
|
59
59
|
autocompiler.stubs(:site).returns(site)
|
60
60
|
|
61
61
|
# Serve
|
62
|
-
status,
|
62
|
+
status, _, _ = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/afjwiagoawf.html') }
|
63
63
|
|
64
64
|
# Check response
|
65
65
|
assert_equal(404, status)
|
@@ -377,7 +377,7 @@ class Nanoc::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
|
|
377
377
|
# Check
|
378
378
|
status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
|
379
379
|
body.each do |b|
|
380
|
-
assert_match
|
380
|
+
assert_match(/The Grand Value of Configuration is Foo!/, b)
|
381
381
|
end
|
382
382
|
|
383
383
|
# Set config to 2nd value
|
@@ -389,7 +389,7 @@ class Nanoc::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
|
|
389
389
|
# Check
|
390
390
|
status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
|
391
391
|
body.each do |b|
|
392
|
-
assert_match
|
392
|
+
assert_match(/The Grand Value of Configuration is Bar!/, b)
|
393
393
|
end
|
394
394
|
end
|
395
395
|
end
|
@@ -410,7 +410,7 @@ class Nanoc::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
|
|
410
410
|
# Test
|
411
411
|
result = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/%73oftware')
|
412
412
|
assert_equal 404, result[0]
|
413
|
-
assert_match
|
413
|
+
assert_match("File not found: /software\n", result[2][0])
|
414
414
|
end
|
415
415
|
end
|
416
416
|
|
@@ -249,11 +249,11 @@ EOS
|
|
249
249
|
[ :albino, :pygmentize, :simon_highlight ].each do |colorizer|
|
250
250
|
begin
|
251
251
|
input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
|
252
|
-
|
252
|
+
filter.run(
|
253
253
|
input,
|
254
254
|
:colorizers => { :ruby => colorizer })
|
255
255
|
flunk "expected colorizer to raise if no executable is available"
|
256
|
-
rescue
|
256
|
+
rescue
|
257
257
|
end
|
258
258
|
end
|
259
259
|
ensure
|
@@ -24,7 +24,6 @@ class Nanoc::Filters::HandlebarsTest < MiniTest::Unit::TestCase
|
|
24
24
|
:config => config,
|
25
25
|
:content => 'No Payne No Gayne'
|
26
26
|
}
|
27
|
-
Handlebars.register_helper(:upcase) { |b| b.call.upcase }
|
28
27
|
filter = ::Nanoc::Filters::Handlebars.new(assigns)
|
29
28
|
|
30
29
|
# Run filter
|
@@ -34,8 +33,6 @@ class Nanoc::Filters::HandlebarsTest < MiniTest::Unit::TestCase
|
|
34
33
|
assert_equal('We can’t stop here! This is the Max Payne layout!', result)
|
35
34
|
result = filter.run('It’s raining {{config.animals}} here!')
|
36
35
|
assert_equal('It’s raining cats and dogs here!', result)
|
37
|
-
result = filter.run('I am {{#upcase}}shouting{{/upcase}}!')
|
38
|
-
assert_equal('I am SHOUTING!', result)
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
data/test/filters/test_less.rb
CHANGED
@@ -14,7 +14,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
14
14
|
|
15
15
|
# Run filter
|
16
16
|
result = filter.run('.foo { bar: 1 + 1 }')
|
17
|
-
assert_match
|
17
|
+
assert_match(/\.foo\s*\{\s*bar:\s*2;?\s*\}/, result)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -32,7 +32,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
32
32
|
|
33
33
|
# Run filter
|
34
34
|
result = filter.run('@import "content/foo/bar/imported_file.less";')
|
35
|
-
assert_match
|
35
|
+
assert_match(/p\s*\{\s*color:\s*red;?\s*\}/, result)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -51,7 +51,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
51
51
|
|
52
52
|
# Run filter
|
53
53
|
result = filter.run('@import "bar/imported_file.less";')
|
54
|
-
assert_match
|
54
|
+
assert_match(/p\s*\{\s*color:\s*red;?\s*\}/, result)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -90,7 +90,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
90
90
|
assert Dir['output/*'].size == 1
|
91
91
|
assert File.file?('output/a.css')
|
92
92
|
refute File.file?('output/b.css')
|
93
|
-
assert_match
|
93
|
+
assert_match(/^p\s*\{\s*color:\s*red;?\s*\}/, File.read('output/a.css'))
|
94
94
|
|
95
95
|
# Update included file
|
96
96
|
File.open('content/b.less', 'w') do |io|
|
@@ -105,7 +105,7 @@ class Nanoc::Filters::LessTest < MiniTest::Unit::TestCase
|
|
105
105
|
assert Dir['output/*'].size == 1
|
106
106
|
assert File.file?('output/a.css')
|
107
107
|
refute File.file?('output/b.css')
|
108
|
-
assert_match
|
108
|
+
assert_match(/^p\s*\{\s*color:\s*blue;?\s*\}/, File.read('output/a.css'))
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
data/test/filters/test_sass.rb
CHANGED
@@ -22,11 +22,11 @@ class Nanoc::Filters::SassTest < MiniTest::Unit::TestCase
|
|
22
22
|
|
23
23
|
# Check with compact
|
24
24
|
result = filter.run(".foo #bar\n color: #f00", :style => 'compact')
|
25
|
-
assert_match(/^\.foo #bar[\s
|
25
|
+
assert_match(/^\.foo #bar[\s]*\{[\s]*color:\s*(red|#f00);?[\s]*\}/m, result)
|
26
26
|
|
27
27
|
# Check with compressed
|
28
28
|
result = filter.run(".foo #bar\n color: #f00", :style => 'compressed')
|
29
|
-
assert_match(/^\.foo #bar[\s
|
29
|
+
assert_match(/^\.foo #bar[\s]*\{[\s]*color:\s*(red|#f00);?[\s]*\}/m, result)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -133,8 +133,7 @@ class Nanoc::Filters::SassTest < MiniTest::Unit::TestCase
|
|
133
133
|
assert Dir['output/*'].size == 1
|
134
134
|
assert File.file?('output/a.css')
|
135
135
|
refute File.file?('output/b.css')
|
136
|
-
assert_match
|
137
|
-
File.read('output/a.css')
|
136
|
+
assert_match(/^p\s*\{\s*color:\s*red;?\s*\}/, File.read('output/a.css'))
|
138
137
|
|
139
138
|
# Update included file
|
140
139
|
File.open('content/b.sass', 'w') do |io|
|
@@ -149,8 +148,7 @@ class Nanoc::Filters::SassTest < MiniTest::Unit::TestCase
|
|
149
148
|
assert Dir['output/*'].size == 1
|
150
149
|
assert File.file?('output/a.css')
|
151
150
|
refute File.file?('output/b.css')
|
152
|
-
assert_match
|
153
|
-
File.read('output/a.css')
|
151
|
+
assert_match(/^p\s*\{\s*color:\s*blue;?\s*\}/, File.read('output/a.css'))
|
154
152
|
end
|
155
153
|
end
|
156
154
|
end
|
@@ -190,8 +188,7 @@ class Nanoc::Filters::SassTest < MiniTest::Unit::TestCase
|
|
190
188
|
assert Dir['output/*'].size == 1
|
191
189
|
assert File.file?('output/a.css')
|
192
190
|
refute File.file?('output/b.css')
|
193
|
-
assert_match
|
194
|
-
File.read('output/a.css')
|
191
|
+
assert_match(/^p\s*\{\s*color:\s*red;?\s*\}/, File.read('output/a.css'))
|
195
192
|
|
196
193
|
# Update included file
|
197
194
|
File.open('content/_b.sass', 'w') do |io|
|
@@ -206,8 +203,7 @@ class Nanoc::Filters::SassTest < MiniTest::Unit::TestCase
|
|
206
203
|
assert Dir['output/*'].size == 1
|
207
204
|
assert File.file?('output/a.css')
|
208
205
|
refute File.file?('output/b.css')
|
209
|
-
assert_match
|
210
|
-
File.read('output/a.css')
|
206
|
+
assert_match(/^p\s*\{\s*color:\s*blue;?\s*\}/, File.read('output/a.css'))
|
211
207
|
end
|
212
208
|
end
|
213
209
|
end
|
data/test/helper.rb
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
require 'minitest/unit'
|
9
9
|
require 'minitest/spec'
|
10
10
|
require 'minitest/mock'
|
11
|
-
require 'mocha'
|
11
|
+
require 'mocha/setup'
|
12
12
|
rescue => e
|
13
13
|
$stderr.puts "To run the nanoc unit tests, you need minitest and mocha."
|
14
14
|
raise e
|
@@ -119,6 +119,7 @@ EOS
|
|
119
119
|
|
120
120
|
# Enter tmp
|
121
121
|
FileUtils.mkdir_p('tmp')
|
122
|
+
@orig_wd = FileUtils.pwd
|
122
123
|
FileUtils.cd('tmp')
|
123
124
|
|
124
125
|
# Let us get to the raw errors
|
@@ -130,7 +131,7 @@ EOS
|
|
130
131
|
Nanoc::CLI::ErrorHandler.enable
|
131
132
|
|
132
133
|
# Exit tmp
|
133
|
-
FileUtils.cd(
|
134
|
+
FileUtils.cd(@orig_wd)
|
134
135
|
FileUtils.rm_rf('tmp')
|
135
136
|
|
136
137
|
# Go unquiet
|
@@ -63,7 +63,7 @@ class Nanoc::Helpers::FilteringTest < MiniTest::Unit::TestCase
|
|
63
63
|
"<% end %>\n"
|
64
64
|
|
65
65
|
# Evaluate content
|
66
|
-
|
66
|
+
assert_raises(Nanoc::Errors::UnknownFilter) do
|
67
67
|
::ERB.new(content).result(binding)
|
68
68
|
end
|
69
69
|
end
|
@@ -6,98 +6,114 @@ class Nanoc::Helpers::XMLSitemapTest < MiniTest::Unit::TestCase
|
|
6
6
|
|
7
7
|
include Nanoc::Helpers::XMLSitemap
|
8
8
|
|
9
|
+
def teardown
|
10
|
+
@items = nil
|
11
|
+
@item = nil
|
12
|
+
@site = nil
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
9
16
|
def test_xml_sitemap
|
10
|
-
if_have 'builder' do
|
17
|
+
if_have 'builder', 'nokogiri' do
|
11
18
|
# Create items
|
12
|
-
@items = [
|
13
|
-
|
14
|
-
# Create item 0
|
15
|
-
@items[0].expects(:[]).with(:is_hidden).returns(false)
|
16
|
-
@items[0].expects(:mtime).times(2).returns(nil)
|
17
|
-
@items[0].expects(:[]).times(2).with(:changefreq).returns(nil)
|
18
|
-
@items[0].expects(:[]).times(2).with(:priority).returns(nil)
|
19
|
-
item_reps = [ mock, mock ]
|
20
|
-
item_reps[0].expects(:path).returns('/kkk/')
|
21
|
-
item_reps[0].expects(:raw_path).returns('output/kkk/index.html')
|
22
|
-
item_reps[1].expects(:path).returns('/lll/')
|
23
|
-
item_reps[1].expects(:raw_path).returns('output/lll/index.html')
|
24
|
-
@items[0].expects(:reps).returns(item_reps)
|
19
|
+
@items = []
|
25
20
|
|
26
21
|
# Create item 1
|
27
|
-
@items
|
22
|
+
@items << Nanoc::Item.new('some content 1', {}, '/item-one/')
|
23
|
+
self.create_item_rep(@items.last, :one_a, '/item-one/a/')
|
24
|
+
self.create_item_rep(@items.last, :one_b, '/item-one/b/')
|
28
25
|
|
29
26
|
# Create item 2
|
30
|
-
@items
|
31
|
-
@items[2].expects(:mtime).times(4).returns(Time.parse('12/07/2004'))
|
32
|
-
@items[2].expects(:[]).with(:changefreq).times(4).returns('daily')
|
33
|
-
@items[2].expects(:[]).with(:priority).times(4).returns(0.5)
|
34
|
-
item_reps = [ mock, mock ]
|
35
|
-
item_reps[0].expects(:path).returns('/aaa/')
|
36
|
-
item_reps[0].expects(:raw_path).returns('output/aaa/index.html')
|
37
|
-
item_reps[1].expects(:path).returns('/bbb/')
|
38
|
-
item_reps[1].expects(:raw_path).returns('output/bbb/index.html')
|
39
|
-
@items[2].expects(:reps).returns(item_reps)
|
27
|
+
@items << Nanoc::Item.new('some content 2', { :is_hidden => true }, '/item-two/')
|
40
28
|
|
41
29
|
# Create item 3
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@items
|
30
|
+
attrs = { :mtime => Time.parse('2004-07-12'), :changefreq => 'daily', :priority => 0.5 }
|
31
|
+
@items << Nanoc::Item.new('some content 3', attrs, '/item-three/')
|
32
|
+
self.create_item_rep(@items.last, :three_a, '/item-three/a/')
|
33
|
+
self.create_item_rep(@items.last, :three_b, '/item-three/b/')
|
34
|
+
|
35
|
+
# Create item 4
|
36
|
+
@items << Nanoc::Item.new('some content 4', {}, '/item-four/')
|
37
|
+
self.create_item_rep(@items.last, :four_a, nil)
|
46
38
|
|
47
39
|
# Create sitemap item
|
48
|
-
@item =
|
40
|
+
@item = Nanoc::Item.new('sitemap content', {}, '/sitemap/')
|
49
41
|
|
50
42
|
# Create site
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
43
|
+
@site = Nanoc::Site.new({ :base_url => 'http://example.com' })
|
44
|
+
|
45
|
+
# Build sitemap
|
46
|
+
res = xml_sitemap
|
55
47
|
|
56
48
|
# Check
|
57
|
-
|
49
|
+
doc = Nokogiri::XML(res)
|
50
|
+
urlsets = doc.css('> urlset')
|
51
|
+
assert_equal 1, urlsets.size
|
52
|
+
urls = urlsets.css('> url')
|
53
|
+
assert_equal 4, urls.size
|
54
|
+
assert_equal 'http://example.com/item-one/a/', urls[0].css('> loc').inner_text
|
55
|
+
assert_equal 'http://example.com/item-one/b/', urls[1].css('> loc').inner_text
|
56
|
+
assert_equal 'http://example.com/item-three/a/', urls[2].css('> loc').inner_text
|
57
|
+
assert_equal 'http://example.com/item-three/b/', urls[3].css('> loc').inner_text
|
58
|
+
assert_equal '', urls[0].css('> changefreq').inner_text
|
59
|
+
assert_equal '', urls[1].css('> changefreq').inner_text
|
60
|
+
assert_equal 'daily', urls[2].css('> changefreq').inner_text
|
61
|
+
assert_equal 'daily', urls[3].css('> changefreq').inner_text
|
62
|
+
assert_equal '', urls[0].css('> priority').inner_text
|
63
|
+
assert_equal '', urls[1].css('> priority').inner_text
|
64
|
+
assert_equal '0.5', urls[2].css('> priority').inner_text
|
65
|
+
assert_equal '0.5', urls[3].css('> priority').inner_text
|
66
|
+
assert_equal '', urls[0].css('> lastmod').inner_text
|
67
|
+
assert_equal '', urls[1].css('> lastmod').inner_text
|
68
|
+
assert_equal '2004-07-12', urls[2].css('> lastmod').inner_text
|
69
|
+
assert_equal '2004-07-12', urls[3].css('> lastmod').inner_text
|
58
70
|
end
|
59
|
-
ensure
|
60
|
-
@items = nil
|
61
|
-
@item = nil
|
62
|
-
@site = nil
|
63
71
|
end
|
64
72
|
|
65
73
|
def test_sitemap_with_items_as_param
|
66
|
-
if_have 'builder' do
|
74
|
+
if_have 'builder', 'nokogiri' do
|
67
75
|
# Create items
|
68
|
-
@items = [
|
69
|
-
|
70
|
-
|
71
|
-
@items
|
72
|
-
|
73
|
-
|
74
|
-
@items[1].expects(:[]).never
|
75
|
-
|
76
|
-
# Create item 2
|
77
|
-
@items[2].expects(:mtime).times(2).returns(nil)
|
78
|
-
@items[2].expects(:[]).times(2).with(:changefreq).returns(nil)
|
79
|
-
@items[2].expects(:[]).times(2).with(:priority).returns(nil)
|
80
|
-
item_reps = [ mock, mock ]
|
81
|
-
item_reps[0].expects(:path).returns('/kkk/')
|
82
|
-
item_reps[0].expects(:raw_path).returns('output/kkk/index.html')
|
83
|
-
item_reps[1].expects(:path).returns('/lll/')
|
84
|
-
item_reps[1].expects(:raw_path).returns('output/lll/index.html')
|
85
|
-
@items[2].expects(:reps).returns(item_reps)
|
76
|
+
@items = []
|
77
|
+
@items << nil
|
78
|
+
@items << Nanoc::Item.new('some content 1', {}, '/item-one/')
|
79
|
+
self.create_item_rep(@items.last, :one_a, '/item-one/a/')
|
80
|
+
self.create_item_rep(@items.last, :one_b, '/item-one/b/')
|
81
|
+
@items << nil
|
86
82
|
|
87
83
|
# Create sitemap item
|
88
|
-
@item =
|
84
|
+
@item = Nanoc::Item.new('sitemap content', {}, '/sitemap/')
|
89
85
|
|
90
86
|
# Create site
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
87
|
+
@site = Nanoc::Site.new({ :base_url => 'http://example.com' })
|
88
|
+
|
89
|
+
# Build sitemap
|
90
|
+
res = xml_sitemap(:items => [ @items[1] ])
|
95
91
|
|
96
92
|
# Check
|
97
|
-
|
98
|
-
|
99
|
-
|
93
|
+
doc = Nokogiri::XML(res)
|
94
|
+
urlsets = doc.css('> urlset')
|
95
|
+
assert_equal 1, urlsets.size
|
96
|
+
urls = urlsets.css('> url')
|
97
|
+
assert_equal 2, urls.size
|
98
|
+
assert_equal 'http://example.com/item-one/a/', urls[0].css('> loc').inner_text
|
99
|
+
assert_equal 'http://example.com/item-one/b/', urls[1].css('> loc').inner_text
|
100
|
+
assert_equal '', urls[0].css('> changefreq').inner_text
|
101
|
+
assert_equal '', urls[1].css('> changefreq').inner_text
|
102
|
+
assert_equal '', urls[0].css('> priority').inner_text
|
103
|
+
assert_equal '', urls[1].css('> priority').inner_text
|
104
|
+
assert_equal '', urls[0].css('> lastmod').inner_text
|
105
|
+
assert_equal '', urls[1].css('> lastmod').inner_text
|
100
106
|
end
|
101
107
|
end
|
102
108
|
|
109
|
+
protected
|
110
|
+
|
111
|
+
def create_item_rep(item, name, path)
|
112
|
+
rep = Nanoc::ItemRep.new(item, name)
|
113
|
+
rep.paths = { :last => path }
|
114
|
+
rep.raw_paths = { :last => path }
|
115
|
+
item.reps << rep
|
116
|
+
rep
|
117
|
+
end
|
118
|
+
|
103
119
|
end
|
data/test/test_gem.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::GemTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
FileUtils.cd(@orig_wd)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_build
|
13
|
+
require 'systemu'
|
14
|
+
|
15
|
+
# Require clean environment
|
16
|
+
assert_empty Dir['nanoc-*.gem'], "Ensure no nanoc-*.gem files exist"
|
17
|
+
|
18
|
+
# Build
|
19
|
+
files_before = Set.new Dir['**/*']
|
20
|
+
stdout = ''
|
21
|
+
stderr = ''
|
22
|
+
status = systemu(
|
23
|
+
[ 'gem', 'build', 'nanoc.gemspec' ],
|
24
|
+
'stdin' => '',
|
25
|
+
'stdout' => stdout,
|
26
|
+
'stderr' => stderr)
|
27
|
+
assert status.success?
|
28
|
+
files_after = Set.new Dir['**/*']
|
29
|
+
|
30
|
+
# Check new files
|
31
|
+
diff = files_after - files_before
|
32
|
+
assert_equal 1, diff.size
|
33
|
+
assert_match(/^nanoc-.*\.gem$/, diff.to_a[0])
|
34
|
+
|
35
|
+
# Check output
|
36
|
+
assert_match(/Successfully built RubyGem\n Name: nanoc\n Version: .*\n File: nanoc-.*\.gem\n/, stdout)
|
37
|
+
assert_equal '', stderr
|
38
|
+
ensure
|
39
|
+
Dir['nanoc-*.gem'].each { |f| FileUtils.rm(f) }
|
40
|
+
end
|
41
|
+
|
42
|
+
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.4.
|
4
|
+
version: 3.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cri
|
@@ -202,7 +202,6 @@ files:
|
|
202
202
|
- lib/nanoc/data_sources/filesystem_verbose.rb
|
203
203
|
- lib/nanoc/data_sources.rb
|
204
204
|
- lib/nanoc/extra/auto_compiler.rb
|
205
|
-
- lib/nanoc/extra/checking/checker_cli.rb
|
206
205
|
- lib/nanoc/extra/chick.rb
|
207
206
|
- lib/nanoc/extra/core_ext/enumerable.rb
|
208
207
|
- lib/nanoc/extra/core_ext/pathname.rb
|
@@ -368,8 +367,8 @@ files:
|
|
368
367
|
- test/helpers/test_text.rb
|
369
368
|
- test/helpers/test_xml_sitemap.rb
|
370
369
|
- test/tasks/test_clean.rb
|
370
|
+
- test/test_gem.rb
|
371
371
|
- nanoc.gemspec
|
372
|
-
- .gemtest
|
373
372
|
homepage: http://nanoc.stoneship.org/
|
374
373
|
licenses: []
|
375
374
|
post_install_message:
|
data/.gemtest
DELETED
File without changes
|
@@ -1,151 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Nanoc::Extra::Checking
|
4
|
-
|
5
|
-
class CheckerCLI
|
6
|
-
|
7
|
-
def list_all_checkers
|
8
|
-
puts "Available checkers:"
|
9
|
-
puts
|
10
|
-
puts all_checker_classes.map { |i| " " + i.identifier.to_s }.sort.join("\n")
|
11
|
-
end
|
12
|
-
|
13
|
-
def run_all
|
14
|
-
end
|
15
|
-
|
16
|
-
def run(identifiers)
|
17
|
-
end
|
18
|
-
|
19
|
-
def run_for_deploy
|
20
|
-
end
|
21
|
-
|
22
|
-
protected
|
23
|
-
|
24
|
-
def all_checker_classes
|
25
|
-
Nanoc::Extra::Checking::Checker.all.map { |p| p.last }.uniq
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
usage 'check [options] [names]'
|
33
|
-
summary 'run issue checks'
|
34
|
-
description <<-EOS
|
35
|
-
Run the given issue checks (or all, if none are given) on the current site.
|
36
|
-
EOS
|
37
|
-
|
38
|
-
flag :a, :all, 'run all checkers'
|
39
|
-
flag :l, :list, 'list all checkers'
|
40
|
-
flag :d, :deploy, 'run checkers for deployment'
|
41
|
-
|
42
|
-
module Nanoc::CLI::Commands
|
43
|
-
|
44
|
-
class Check < ::Nanoc::CLI::CommandRunner
|
45
|
-
|
46
|
-
def run
|
47
|
-
validate_options_and_arguments
|
48
|
-
|
49
|
-
# Load DSL
|
50
|
-
if File.exist?('Checkers')
|
51
|
-
dsl = Nanoc::Extra::Checking::DSL.from_file('Checkers')
|
52
|
-
end
|
53
|
-
|
54
|
-
# List
|
55
|
-
if options[:list]
|
56
|
-
self.list_checkers
|
57
|
-
return
|
58
|
-
end
|
59
|
-
|
60
|
-
# Make sure we are in a nanoc site directory
|
61
|
-
self.require_site
|
62
|
-
|
63
|
-
# Find and run
|
64
|
-
classes = self.find_checker_classes(dsl)
|
65
|
-
issues = self.run_checkers(classes)
|
66
|
-
self.print_issues(issues)
|
67
|
-
end
|
68
|
-
|
69
|
-
protected
|
70
|
-
|
71
|
-
def validate_options_and_arguments
|
72
|
-
if arguments.empty? && !options[:all] && !options[:deploy] && !options[:list]
|
73
|
-
raise Nanoc::Errors::GenericTrivial,
|
74
|
-
"nothing to do (pass either --all, --deploy or --list or a list of checkers)"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def all_checker_classes
|
79
|
-
Nanoc::Extra::Checking::Checker.all.map { |p| p.last }.uniq
|
80
|
-
end
|
81
|
-
|
82
|
-
def list_checkers
|
83
|
-
puts "Available checkers:"
|
84
|
-
puts
|
85
|
-
puts all_checker_classes.map { |i| " " + i.identifier.to_s }.sort.join("\n")
|
86
|
-
end
|
87
|
-
|
88
|
-
def checker_classes_named(n)
|
89
|
-
classes = n.map do |a|
|
90
|
-
klass = Nanoc::Extra::Checking::Checker.named(a)
|
91
|
-
raise Nanoc::Errors::GenericTrivial, "Unknown checker: #{a}" if klass.nil?
|
92
|
-
klass
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def find_checker_classes(dsl)
|
97
|
-
if options[:all]
|
98
|
-
return self.all_checker_classes
|
99
|
-
elsif options[:deploy]
|
100
|
-
if dsl
|
101
|
-
return self.checker_classes_named(dsl.deploy_checks)
|
102
|
-
end
|
103
|
-
else
|
104
|
-
return self.checker_classes_named(arguments)
|
105
|
-
end
|
106
|
-
|
107
|
-
raise Nanoc::Errors::GenericTrivial, "No checkers to run"
|
108
|
-
end
|
109
|
-
|
110
|
-
def run_checkers(classes)
|
111
|
-
puts
|
112
|
-
checkers = []
|
113
|
-
issues = Set.new
|
114
|
-
length = classes.map { |c| c.identifier.to_s.length }.max + 20
|
115
|
-
classes.each do |klass|
|
116
|
-
print format("%-#{length}s", "Running #{klass.identifier} checker… ")
|
117
|
-
|
118
|
-
checker = klass.new(site)
|
119
|
-
checkers << checker
|
120
|
-
checker.run
|
121
|
-
issues.merge checker.issues
|
122
|
-
|
123
|
-
# TODO report progress
|
124
|
-
|
125
|
-
puts issues.empty? ? 'ok'.green : 'error'.red
|
126
|
-
end
|
127
|
-
issues
|
128
|
-
end
|
129
|
-
|
130
|
-
def print_issues(issues)
|
131
|
-
require 'colored'
|
132
|
-
|
133
|
-
have_issues = false
|
134
|
-
issues.group_by { |i| i.subject }.each_pair do |subject, issues|
|
135
|
-
unless issues.empty?
|
136
|
-
puts unless have_issues
|
137
|
-
have_issues = true
|
138
|
-
puts "#{subject}:"
|
139
|
-
issues.each do |i|
|
140
|
-
puts " [ #{'ERROR'.red} ] #{i.checker_class.identifier} - #{i.description}"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
end
|
149
|
-
|
150
|
-
runner Nanoc::CLI::Commands::Check
|
151
|
-
|