nanoc 3.4.1 → 3.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +24 -26
- data/NEWS.md +17 -0
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base/compilation/compiler_dsl.rb +3 -3
- data/lib/nanoc/base/compilation/rules_collection.rb +4 -24
- data/lib/nanoc/base/errors.rb +10 -0
- data/lib/nanoc/base/result_data/item_rep.rb +5 -0
- data/lib/nanoc/cli.rb +22 -9
- data/lib/nanoc/cli/commands/compile.rb +32 -27
- data/lib/nanoc/cli/commands/create-site.rb +5 -5
- data/lib/nanoc/cli/commands/show-plugins.rb +2 -2
- data/lib/nanoc/cli/commands/watch.rb +7 -3
- data/lib/nanoc/extra/checking/checker_cli.rb +151 -0
- data/lib/nanoc/extra/deployers/fog.rb +10 -7
- data/lib/nanoc/filters/colorize_syntax.rb +35 -2
- data/lib/nanoc/helpers/blogging.rb +4 -1
- data/test/base/test_compiler_dsl.rb +70 -42
- data/test/base/test_item_rep.rb +8 -0
- data/test/cli/commands/test_compile.rb +45 -0
- data/test/cli/commands/test_watch.rb +51 -0
- data/test/extra/deployers/test_fog.rb +36 -0
- data/test/filters/test_colorize_syntax.rb +11 -8
- metadata +4 -2
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.1)
|
5
5
|
cri (~> 2.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -10,10 +10,9 @@ GEM
|
|
10
10
|
RedCloth (4.2.9)
|
11
11
|
adsf (1.1.1)
|
12
12
|
rack (>= 1.0.0)
|
13
|
-
blankslate (2.1.2.4)
|
14
13
|
bluecloth (2.2.0)
|
15
|
-
builder (3.
|
16
|
-
coderay (1.0.
|
14
|
+
builder (3.1.4)
|
15
|
+
coderay (1.0.8)
|
17
16
|
coffee-script (2.2.0)
|
18
17
|
coffee-script-source
|
19
18
|
execjs
|
@@ -23,11 +22,10 @@ GEM
|
|
23
22
|
cri (2.3.0)
|
24
23
|
colored (>= 1.2)
|
25
24
|
erubis (2.7.0)
|
26
|
-
excon (0.16.
|
25
|
+
excon (0.16.7)
|
27
26
|
execjs (1.4.0)
|
28
27
|
multi_json (~> 1.0)
|
29
|
-
|
30
|
-
fog (1.5.0)
|
28
|
+
fog (1.6.0)
|
31
29
|
builder
|
32
30
|
excon (~> 0.14)
|
33
31
|
formatador (~> 0.2.0)
|
@@ -40,55 +38,55 @@ GEM
|
|
40
38
|
formatador (0.2.3)
|
41
39
|
haml (3.1.7)
|
42
40
|
json (1.7.5)
|
43
|
-
kramdown (0.
|
44
|
-
less (2.2.
|
41
|
+
kramdown (0.14.0)
|
42
|
+
less (2.2.2)
|
45
43
|
commonjs (~> 0.2.6)
|
46
44
|
markaby (0.7.2)
|
47
45
|
builder (>= 2.0.0)
|
48
|
-
maruku (0.6.
|
46
|
+
maruku (0.6.1)
|
49
47
|
syntax (>= 1.0.0)
|
50
48
|
metaclass (0.0.1)
|
51
49
|
mime-types (1.19)
|
52
|
-
minitest (
|
53
|
-
mocha (0.12.
|
50
|
+
minitest (4.1.0)
|
51
|
+
mocha (0.12.7)
|
54
52
|
metaclass (~> 0.0.1)
|
55
53
|
multi_json (1.3.6)
|
56
54
|
mustache (0.99.4)
|
57
55
|
net-scp (1.0.4)
|
58
56
|
net-ssh (>= 1.99.1)
|
59
|
-
net-ssh (2.
|
57
|
+
net-ssh (2.6.1)
|
60
58
|
nokogiri (1.5.5)
|
61
|
-
|
62
|
-
|
59
|
+
posix-spawn (0.3.6)
|
60
|
+
pygments.rb (0.3.2)
|
61
|
+
posix-spawn (~> 0.3.6)
|
62
|
+
yajl-ruby (~> 1.1.0)
|
63
63
|
rack (1.4.1)
|
64
64
|
rainpress (1.0)
|
65
65
|
rake (0.9.2.2)
|
66
66
|
rdiscount (1.6.8)
|
67
67
|
rdoc (3.12)
|
68
68
|
json (~> 1.4)
|
69
|
-
redcarpet (2.
|
69
|
+
redcarpet (2.2.2)
|
70
70
|
ruby-hmac (0.4.0)
|
71
71
|
rubypants (0.2.0)
|
72
|
-
rubypython (0.5.3)
|
73
|
-
blankslate (>= 2.1.2.3)
|
74
|
-
ffi (~> 1.0.7)
|
75
72
|
sass (3.2.1)
|
76
|
-
slim (1.
|
77
|
-
temple (~> 0.
|
73
|
+
slim (1.3.3)
|
74
|
+
temple (~> 0.5.5)
|
78
75
|
tilt (~> 1.3.3)
|
79
76
|
syntax (1.0.0)
|
80
77
|
systemu (2.5.2)
|
81
|
-
temple (0.
|
78
|
+
temple (0.5.5)
|
82
79
|
tilt (1.3.3)
|
83
80
|
typogruby (1.0.15)
|
84
81
|
rubypants
|
85
|
-
uglifier (1.
|
82
|
+
uglifier (1.3.0)
|
86
83
|
execjs (>= 0.3.0)
|
87
|
-
multi_json (~> 1.
|
84
|
+
multi_json (~> 1.0, >= 1.0.2)
|
88
85
|
w3c_validators (1.2)
|
89
86
|
json
|
90
87
|
nokogiri
|
91
|
-
|
88
|
+
yajl-ruby (1.1.0)
|
89
|
+
yard (0.8.3)
|
92
90
|
yuicompressor (1.2.0)
|
93
91
|
|
94
92
|
PLATFORMS
|
@@ -113,7 +111,7 @@ DEPENDENCIES
|
|
113
111
|
mocha
|
114
112
|
mustache
|
115
113
|
nanoc!
|
116
|
-
nokogiri
|
114
|
+
nokogiri (~> 1.5.5)
|
117
115
|
pygments.rb
|
118
116
|
rack
|
119
117
|
rainpress
|
data/NEWS.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# nanoc news
|
2
2
|
|
3
|
+
## 3.4.2 (2012-11-01)
|
4
|
+
|
5
|
+
Fixes:
|
6
|
+
|
7
|
+
* Made passthrough rules be inserted in the right place [Gregory Pakosz]
|
8
|
+
* Fixed crashes in the progress indicator when compiling
|
9
|
+
* Made auto-pruning honor excluded files [Greg Karékinian]
|
10
|
+
* Made lack of which/where not crash watch command
|
11
|
+
|
12
|
+
Improvements:
|
13
|
+
|
14
|
+
* Fixed constant reinitialization warnings [Damien Pollet]
|
15
|
+
* Made UTF-8 not be decomposed when outputting to a file from a non-UTF-8 terminal
|
16
|
+
* Made syntax colorizer wrap CodeRay output in required CodeRay divs
|
17
|
+
* Made fog delete after upload, not before [Go Maeda]
|
18
|
+
* Made requesting compiled content of binary item impossible
|
19
|
+
|
3
20
|
## 3.4.1 (2012-09-22)
|
4
21
|
|
5
22
|
Fixes:
|
data/lib/nanoc.rb
CHANGED
@@ -180,14 +180,14 @@ module Nanoc
|
|
180
180
|
# Create compilation rule
|
181
181
|
compilation_block = proc { }
|
182
182
|
compilation_rule = Rule.new(identifier_to_regex(identifier), rep_name, compilation_block)
|
183
|
-
@rules_collection.add_item_compilation_rule(compilation_rule
|
183
|
+
@rules_collection.add_item_compilation_rule(compilation_rule)
|
184
184
|
|
185
185
|
# Create routing rule
|
186
186
|
routing_block = proc do
|
187
187
|
item[:extension].nil? ? item.identifier.chop : item.identifier.chop + '.' + item[:extension]
|
188
188
|
end
|
189
|
-
routing_rule = Rule.new(identifier_to_regex(identifier), rep_name, routing_block)
|
190
|
-
@rules_collection.add_item_routing_rule(routing_rule
|
189
|
+
routing_rule = Rule.new(identifier_to_regex(identifier), rep_name, routing_block, :snapshot_name => :last)
|
190
|
+
@rules_collection.add_item_routing_rule(routing_rule)
|
191
191
|
end
|
192
192
|
|
193
193
|
private
|
@@ -40,38 +40,18 @@ module Nanoc
|
|
40
40
|
#
|
41
41
|
# @param [Nanoc::Rule] rule The item compilation rule to add
|
42
42
|
#
|
43
|
-
# @param [:before, :after] position The place where the rule should be
|
44
|
-
# added (either at the beginning or the end of the list of rules)
|
45
|
-
#
|
46
43
|
# @return [void]
|
47
|
-
def add_item_compilation_rule(rule
|
48
|
-
|
49
|
-
when :before
|
50
|
-
@item_compilation_rules.unshift(rule)
|
51
|
-
when :after
|
52
|
-
@item_compilation_rules << rule
|
53
|
-
else
|
54
|
-
raise "#add_item_routing_rule expected position to be :after or :before"
|
55
|
-
end
|
44
|
+
def add_item_compilation_rule(rule)
|
45
|
+
@item_compilation_rules << rule
|
56
46
|
end
|
57
47
|
|
58
48
|
# Add the given rule to the list of item routing rules.
|
59
49
|
#
|
60
50
|
# @param [Nanoc::Rule] rule The item routing rule to add
|
61
51
|
#
|
62
|
-
# @param [:before, :after] position The place where the rule should be
|
63
|
-
# added (either at the beginning or the end of the list of rules)
|
64
|
-
#
|
65
52
|
# @return [void]
|
66
|
-
def add_item_routing_rule(rule
|
67
|
-
|
68
|
-
when :before
|
69
|
-
@item_routing_rules.unshift(rule)
|
70
|
-
when :after
|
71
|
-
@item_routing_rules << rule
|
72
|
-
else
|
73
|
-
raise "#add_item_routing_rule expected position to be :after or :before"
|
74
|
-
end
|
53
|
+
def add_item_routing_rule(rule)
|
54
|
+
@item_routing_rules << rule
|
75
55
|
end
|
76
56
|
|
77
57
|
# @param [Nanoc::Item] item The item for which the compilation rules
|
data/lib/nanoc/base/errors.rb
CHANGED
@@ -202,6 +202,16 @@ module Nanoc
|
|
202
202
|
|
203
203
|
end
|
204
204
|
|
205
|
+
# Error that is raised when the compiled content of a binary item is attempted to be accessed.
|
206
|
+
class CannotGetCompiledContentOfBinaryItem < Generic
|
207
|
+
|
208
|
+
# @param [Nanoc::ItemRep] rep The binary item representation whose compiled content was attempted to be accessed
|
209
|
+
def initialize(rep)
|
210
|
+
super("You cannot access the compiled content of a binary item representation (but you can access the path). The offending item rep is #{rep.inspect}.")
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
205
215
|
# @deprecated No longer necessary, but kept for backwards compatibility.
|
206
216
|
class DataNotYetAvailable < Generic
|
207
217
|
|
@@ -240,6 +240,11 @@ module Nanoc
|
|
240
240
|
# @return [String] The compiled content at the given snapshot (or the
|
241
241
|
# default snapshot if no snapshot is specified)
|
242
242
|
def compiled_content(params={})
|
243
|
+
# Make sure we're not binary
|
244
|
+
if self.item.binary?
|
245
|
+
raise Nanoc::Errors::CannotGetCompiledContentOfBinaryItem.new(self)
|
246
|
+
end
|
247
|
+
|
243
248
|
# Notify
|
244
249
|
Nanoc::NotificationCenter.post(:visit_started, self.item)
|
245
250
|
Nanoc::NotificationCenter.post(:visit_ended, self.item)
|
data/lib/nanoc/cli.rb
CHANGED
@@ -49,7 +49,6 @@ module Nanoc::CLI
|
|
49
49
|
def self.run(args)
|
50
50
|
Nanoc::CLI::ErrorHandler.handle_while do
|
51
51
|
self.setup
|
52
|
-
self.load_custom_commands
|
53
52
|
self.root_command.run(args)
|
54
53
|
end
|
55
54
|
end
|
@@ -65,13 +64,19 @@ module Nanoc::CLI
|
|
65
64
|
|
66
65
|
protected
|
67
66
|
|
68
|
-
# Makes the commandline interface ready for
|
67
|
+
# Makes the commandline interface ready for use.
|
69
68
|
#
|
70
69
|
# @return [void]
|
71
70
|
def self.setup
|
72
|
-
# Set up output streams
|
73
71
|
self.setup_cleaning_streams
|
72
|
+
self.setup_commands
|
73
|
+
self.load_custom_commands
|
74
|
+
end
|
74
75
|
|
76
|
+
# Sets up the root command and base subcommands.
|
77
|
+
#
|
78
|
+
# @return [void]
|
79
|
+
def self.setup_commands
|
75
80
|
# Reinit
|
76
81
|
@root_command = nil
|
77
82
|
|
@@ -88,7 +93,7 @@ protected
|
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
91
|
-
# Loads
|
96
|
+
# Loads site-specific commands in `commands/`.
|
92
97
|
#
|
93
98
|
# @return [void]
|
94
99
|
def self.load_custom_commands
|
@@ -153,25 +158,33 @@ protected
|
|
153
158
|
$stdout = Nanoc::CLI::CleaningStream.new($stdout)
|
154
159
|
$stderr = Nanoc::CLI::CleaningStream.new($stderr)
|
155
160
|
|
156
|
-
if !self.enable_utf8?
|
161
|
+
if !self.enable_utf8?($stdout)
|
157
162
|
$stdout.add_stream_cleaner(Nanoc::CLI::StreamCleaners::UTF8)
|
163
|
+
end
|
164
|
+
|
165
|
+
if !self.enable_utf8?($stderr)
|
158
166
|
$stderr.add_stream_cleaner(Nanoc::CLI::StreamCleaners::UTF8)
|
159
167
|
end
|
160
168
|
|
161
|
-
if !self.enable_ansi_colors?
|
169
|
+
if !self.enable_ansi_colors?($stdout)
|
162
170
|
$stdout.add_stream_cleaner(Nanoc::CLI::StreamCleaners::ANSIColors)
|
171
|
+
end
|
172
|
+
|
173
|
+
if !self.enable_ansi_colors?($stderr)
|
163
174
|
$stderr.add_stream_cleaner(Nanoc::CLI::StreamCleaners::ANSIColors)
|
164
175
|
end
|
165
176
|
end
|
166
177
|
|
167
178
|
# @return [Boolean] true if UTF-8 support is present, false if not
|
168
|
-
def self.enable_utf8?
|
179
|
+
def self.enable_utf8?(io)
|
180
|
+
return true if !io.tty?
|
181
|
+
|
169
182
|
%w( LC_ALL LC_CTYPE LANG ).any? { |e| ENV[e] =~ /UTF/ }
|
170
183
|
end
|
171
184
|
|
172
185
|
# @return [Boolean] true if color support is present, false if not
|
173
|
-
def self.enable_ansi_colors?
|
174
|
-
return false if
|
186
|
+
def self.enable_ansi_colors?(io)
|
187
|
+
return false if !io.tty?
|
175
188
|
|
176
189
|
begin
|
177
190
|
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /mswin|mingw/
|
@@ -22,11 +22,12 @@ option :f, :force, '(ignored)'
|
|
22
22
|
|
23
23
|
module Nanoc::CLI::Commands
|
24
24
|
|
25
|
+
# FIXME this command is horribly long and complicated and does way too much. plz cleanup thx.
|
25
26
|
class Compile < ::Nanoc::CLI::CommandRunner
|
26
27
|
|
27
28
|
def run
|
28
29
|
# Make sure we are in a nanoc site directory
|
29
|
-
puts "Loading site data
|
30
|
+
puts "Loading site data…"
|
30
31
|
self.require_site
|
31
32
|
|
32
33
|
# Check presence of --all option
|
@@ -42,7 +43,7 @@ module Nanoc::CLI::Commands
|
|
42
43
|
end
|
43
44
|
|
44
45
|
# Give feedback
|
45
|
-
puts "Compiling site
|
46
|
+
puts "Compiling site…"
|
46
47
|
|
47
48
|
# Initialize profiling stuff
|
48
49
|
time_before = Time.now
|
@@ -50,10 +51,6 @@ module Nanoc::CLI::Commands
|
|
50
51
|
@filter_times = {}
|
51
52
|
setup_notifications
|
52
53
|
|
53
|
-
# Set up progress indicator threads
|
54
|
-
@progress_locks = {}
|
55
|
-
@progress_threads = {}
|
56
|
-
|
57
54
|
# Prepare for generating diffs
|
58
55
|
setup_diffs
|
59
56
|
|
@@ -81,7 +78,7 @@ module Nanoc::CLI::Commands
|
|
81
78
|
|
82
79
|
# Prune
|
83
80
|
if self.site.config[:prune][:auto_prune]
|
84
|
-
Nanoc::Extra::Pruner.new(self.site).run
|
81
|
+
Nanoc::Extra::Pruner.new(self.site, :exclude => self.prune_config_exclude).run
|
85
82
|
end
|
86
83
|
|
87
84
|
# Give general feedback
|
@@ -232,31 +229,32 @@ module Nanoc::CLI::Commands
|
|
232
229
|
# Only show progress on terminals
|
233
230
|
return if !$stdout.tty?
|
234
231
|
|
235
|
-
@
|
236
|
-
|
237
|
-
|
238
|
-
delay = 1.0
|
239
|
-
step = 0
|
232
|
+
@progress_thread = Thread.new do
|
233
|
+
delay = 1.0
|
234
|
+
step = 0
|
240
235
|
|
241
|
-
|
236
|
+
text = " running #{filter_name} filter… "
|
242
237
|
|
243
|
-
|
244
|
-
|
238
|
+
loop do
|
239
|
+
if Thread.current[:stopped]
|
240
|
+
# Clear
|
241
|
+
if delay < 0.1
|
242
|
+
$stdout.print ' ' * (text.length + 3) + "\r"
|
243
|
+
end
|
245
244
|
|
246
|
-
|
247
|
-
|
248
|
-
next if delay > 0.05
|
245
|
+
break
|
246
|
+
end
|
249
247
|
|
250
|
-
|
248
|
+
# Show progress
|
249
|
+
if delay < 0.1
|
251
250
|
$stdout.print text + %w( | / - \\ )[step] + "\r"
|
252
251
|
step = (step + 1) % 4
|
253
252
|
end
|
254
253
|
|
255
|
-
|
256
|
-
|
257
|
-
$stdout.print ' ' * (text.length + 1 + 1) + "\r"
|
258
|
-
end
|
254
|
+
sleep 0.1
|
255
|
+
delay -= 0.1
|
259
256
|
end
|
257
|
+
|
260
258
|
end
|
261
259
|
end
|
262
260
|
|
@@ -264,10 +262,7 @@ module Nanoc::CLI::Commands
|
|
264
262
|
# Only show progress on terminals
|
265
263
|
return if !$stdout.tty?
|
266
264
|
|
267
|
-
|
268
|
-
lock.synchronize do
|
269
|
-
@progress_threads[rep.inspect + filter_name.inspect][:stopped] = true
|
270
|
-
end
|
265
|
+
@progress_thread[:stopped] = true
|
271
266
|
end
|
272
267
|
|
273
268
|
def print_profiling_feedback(reps)
|
@@ -311,6 +306,16 @@ module Nanoc::CLI::Commands
|
|
311
306
|
end
|
312
307
|
end
|
313
308
|
|
309
|
+
protected
|
310
|
+
|
311
|
+
def prune_config
|
312
|
+
self.site.config[:prune] || {}
|
313
|
+
end
|
314
|
+
|
315
|
+
def prune_config_exclude
|
316
|
+
self.prune_config[:exclude] || {}
|
317
|
+
end
|
318
|
+
|
314
319
|
end
|
315
320
|
|
316
321
|
end
|
@@ -24,7 +24,7 @@ module Nanoc::CLI::Commands
|
|
24
24
|
|
25
25
|
end
|
26
26
|
|
27
|
-
DEFAULT_CONFIG = <<EOS
|
27
|
+
DEFAULT_CONFIG = <<EOS unless defined? DEFAULT_CONFIG
|
28
28
|
# A list of file extensions that nanoc will consider to be textual rather than
|
29
29
|
# binary. If an item with an extension not in this list is found, the file
|
30
30
|
# will be considered as binary.
|
@@ -104,7 +104,7 @@ watcher:
|
|
104
104
|
notify_on_compilation_failure: true
|
105
105
|
EOS
|
106
106
|
|
107
|
-
DEFAULT_RULES = <<EOS
|
107
|
+
DEFAULT_RULES = <<EOS unless defined? DEFAULT_RULES
|
108
108
|
#!/usr/bin/env ruby
|
109
109
|
|
110
110
|
# A few helpful tips about the Rules file:
|
@@ -150,7 +150,7 @@ end
|
|
150
150
|
layout '*', :erb
|
151
151
|
EOS
|
152
152
|
|
153
|
-
DEFAULT_ITEM = <<EOS
|
153
|
+
DEFAULT_ITEM = <<EOS unless defined? DEFAULT_ITEM
|
154
154
|
<h1>A Brand New nanoc Site</h1>
|
155
155
|
|
156
156
|
<p>You’ve just created a new nanoc site. The page you are looking at right now is the home page for your site. To get started, consider replacing this default homepage with your own customized homepage. Some pointers on how to do so:</p>
|
@@ -163,7 +163,7 @@ EOS
|
|
163
163
|
<p>If you need any help with customizing your nanoc web site, be sure to check out the documentation (see sidebar), and be sure to subscribe to the discussion group (also see sidebar). Enjoy!</p>
|
164
164
|
EOS
|
165
165
|
|
166
|
-
DEFAULT_STYLESHEET = <<EOS
|
166
|
+
DEFAULT_STYLESHEET = <<EOS unless defined? DEFAULT_STYLESHEET
|
167
167
|
* {
|
168
168
|
margin: 0;
|
169
169
|
padding: 0;
|
@@ -267,7 +267,7 @@ a:hover {
|
|
267
267
|
}
|
268
268
|
EOS
|
269
269
|
|
270
|
-
DEFAULT_LAYOUT = <<EOS
|
270
|
+
DEFAULT_LAYOUT = <<EOS unless defined? DEFAULT_LAYOUT
|
271
271
|
<!DOCTYPE HTML>
|
272
272
|
<html lang="en">
|
273
273
|
<head>
|
@@ -78,14 +78,14 @@ module Nanoc::CLI::Commands
|
|
78
78
|
Nanoc::Extra::VCS,
|
79
79
|
Nanoc::DataSource,
|
80
80
|
Nanoc::Extra::Deployer
|
81
|
-
]
|
81
|
+
] unless defined? PLUGIN_CLASS_ORDER
|
82
82
|
|
83
83
|
PLUGIN_CLASSES = {
|
84
84
|
Nanoc::Filter => 'Filters',
|
85
85
|
Nanoc::DataSource => 'Data Sources',
|
86
86
|
Nanoc::Extra::VCS => 'VCSes',
|
87
87
|
Nanoc::Extra::Deployer => 'Deployers'
|
88
|
-
}
|
88
|
+
} unless defined? PLUGIN_CLASSES
|
89
89
|
|
90
90
|
def name_for_plugin_class(klass)
|
91
91
|
PLUGIN_CLASSES[klass]
|
@@ -87,10 +87,10 @@ module Nanoc::CLI::Commands
|
|
87
87
|
class Notifier
|
88
88
|
|
89
89
|
# A list of commandline tool names that can be used to send notifications
|
90
|
-
TOOLS = %w( growlnotify notify-send )
|
90
|
+
TOOLS = %w( growlnotify notify-send ) unless defined? TOOLS
|
91
91
|
|
92
92
|
# The tool to use for discovering binaries' locations
|
93
|
-
FIND_BINARY_COMMAND = RUBY_PLATFORM =~ /mingw|mswin/ ? "where" : "which"
|
93
|
+
FIND_BINARY_COMMAND = RUBY_PLATFORM =~ /mingw|mswin/ ? "where" : "which" unless defined? FIND_BINARY_COMMAND
|
94
94
|
|
95
95
|
# Send a notification. If no notifier is found, no notification will be
|
96
96
|
# created.
|
@@ -104,7 +104,11 @@ module Nanoc::CLI::Commands
|
|
104
104
|
private
|
105
105
|
|
106
106
|
def tool
|
107
|
-
@tool ||=
|
107
|
+
@tool ||= begin
|
108
|
+
TOOLS.find { |t| !`#{FIND_BINARY_COMMAND} #{t}`.empty? }
|
109
|
+
rescue Errno::ENOENT
|
110
|
+
nil
|
111
|
+
end
|
108
112
|
end
|
109
113
|
|
110
114
|
def growlnotify(message)
|
@@ -0,0 +1,151 @@
|
|
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
|
+
|
@@ -64,25 +64,28 @@ module Nanoc::Extra::Deployers
|
|
64
64
|
truncated = set.is_truncated
|
65
65
|
files = files + set
|
66
66
|
end
|
67
|
-
|
68
|
-
# Delete all the files in the bucket
|
69
|
-
puts "Removing remote files"
|
70
|
-
files.all.each do |file|
|
71
|
-
file.destroy
|
72
|
-
end
|
67
|
+
keys_to_destroy = files.all.map {|file| file.key}
|
73
68
|
|
74
69
|
# Upload all the files in the output folder to the clouds
|
75
70
|
puts "Uploading local files"
|
76
71
|
FileUtils.cd(src) do
|
77
72
|
files = Dir['**/*'].select { |f| File.file?(f) }
|
78
73
|
files.each do |file_path|
|
74
|
+
key = "#{path}#{file_path}"
|
79
75
|
directory.files.create(
|
80
|
-
:key =>
|
76
|
+
:key => key,
|
81
77
|
:body => File.open(file_path),
|
82
78
|
:public => true)
|
79
|
+
keys_to_destroy.delete(key)
|
83
80
|
end
|
84
81
|
end
|
85
82
|
|
83
|
+
# delete extraneous remote files
|
84
|
+
puts "Removing remote files"
|
85
|
+
keys_to_destroy.each do |key|
|
86
|
+
directory.files.get(key).destroy
|
87
|
+
end
|
88
|
+
|
86
89
|
puts "Done!"
|
87
90
|
end
|
88
91
|
|
@@ -130,13 +130,15 @@ module Nanoc::Filters
|
|
130
130
|
highlighted_code = highlight(raw, language, params)
|
131
131
|
element.children = Nokogiri::HTML.fragment(strip(highlighted_code), 'utf-8')
|
132
132
|
|
133
|
-
# Add class
|
133
|
+
# Add language-something class
|
134
134
|
unless has_class
|
135
135
|
klass = element['class'] || ''
|
136
136
|
klass << ' ' unless [' ', nil].include?(klass[-1,1])
|
137
137
|
klass << "language-#{language}"
|
138
138
|
element['class'] = klass
|
139
139
|
end
|
140
|
+
|
141
|
+
self.highlight_postprocess(language, element.parent)
|
140
142
|
end
|
141
143
|
|
142
144
|
method = "to_#{syntax}".to_sym
|
@@ -273,10 +275,29 @@ module Nanoc::Filters
|
|
273
275
|
stdout.read
|
274
276
|
end
|
275
277
|
|
276
|
-
|
278
|
+
protected
|
277
279
|
|
278
280
|
KNOWN_COLORIZERS = [ :coderay, :dummy, :pygmentize, :pygmentsrb, :simon_highlight ]
|
279
281
|
|
282
|
+
# Wraps the element in <div class="CodeRay"><div class="code">
|
283
|
+
def coderay_postprocess(language, element)
|
284
|
+
# Skip if we're a free <code>
|
285
|
+
return if element.parent.nil?
|
286
|
+
|
287
|
+
# <div class="code">
|
288
|
+
div_inner = Nokogiri::XML::Node.new('div', element.document)
|
289
|
+
div_inner['class'] = 'code'
|
290
|
+
div_inner.children = element.dup
|
291
|
+
|
292
|
+
# <div class="CodeRay">
|
293
|
+
div_outer = Nokogiri::XML::Node.new('div', element.document)
|
294
|
+
div_outer['class'] = 'CodeRay'
|
295
|
+
div_outer.children = div_inner
|
296
|
+
|
297
|
+
# orig element
|
298
|
+
element.swap div_outer
|
299
|
+
end
|
300
|
+
|
280
301
|
# Removes the first blank lines and any whitespace at the end.
|
281
302
|
def strip(s)
|
282
303
|
s.lines.drop_while { |line| line.strip.empty? }.join.rstrip
|
@@ -291,6 +312,18 @@ module Nanoc::Filters
|
|
291
312
|
end
|
292
313
|
end
|
293
314
|
|
315
|
+
def highlight_postprocess(language, element)
|
316
|
+
colorizer = @colorizers[language.to_sym]
|
317
|
+
if KNOWN_COLORIZERS.include?(colorizer)
|
318
|
+
sym = (colorizer.to_s + '_postprocess').to_sym
|
319
|
+
if self.respond_to?(sym)
|
320
|
+
self.send(sym, language, element)
|
321
|
+
end
|
322
|
+
else
|
323
|
+
raise RuntimeError, "I don’t know how to highlight code using the “#{colorizer}” colorizer"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
294
327
|
def check_availability(*cmd)
|
295
328
|
systemu cmd
|
296
329
|
raise "Could not spawn #{cmd.join(' ')}" if $?.exitstatus != 0
|
@@ -49,7 +49,10 @@ module Nanoc::Helpers
|
|
49
49
|
#
|
50
50
|
# * `title` - The title of the blog post
|
51
51
|
#
|
52
|
-
# * `
|
52
|
+
# * `created_at` (described above)
|
53
|
+
#
|
54
|
+
# * `kind` (described above) *unless* you are passing an explicit list of
|
55
|
+
# articles using the `:articles` parameter
|
53
56
|
#
|
54
57
|
# The following attributes can optionally be set on blog articles to
|
55
58
|
# change the behaviour of the Atom feed:
|
@@ -17,58 +17,86 @@ class Nanoc::CompilerDSLTest < MiniTest::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_passthrough
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
with_site do
|
21
|
+
# Create rules
|
22
|
+
File.open('Rules', 'w') do |io|
|
23
|
+
io.write <<EOS
|
24
|
+
passthrough "/robots/"
|
25
|
+
|
26
|
+
compile '*' do ; end
|
27
|
+
route '*' do ; item.identifier.chop + '-xyz' + item[:extension] ; end
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
|
31
|
+
# Create items
|
32
|
+
assert Dir['content/*'].empty?
|
33
|
+
File.open('content/robots.txt', 'w') do |io|
|
34
|
+
io.write "Hello I am robots"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Compile
|
28
38
|
site = Nanoc::Site.new('.')
|
29
|
-
site.
|
30
|
-
compiler = site.compiler
|
31
|
-
dsl = site.compiler.rules_collection.dsl
|
39
|
+
site.compile
|
32
40
|
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
# Route and compile
|
37
|
-
rule = compiler.rules_collection.routing_rule_for(rep)
|
38
|
-
path = rule.apply_to(rep, :compiler => compiler)
|
39
|
-
compiler.send :compile_rep, rep
|
40
|
-
|
41
|
-
# Check result
|
42
|
-
assert_equal 'foo', rep.compiled_content
|
43
|
-
assert_equal '/foo.bar', path
|
41
|
+
# Check paths
|
42
|
+
assert_equal [ 'output/robots.txt' ], Dir['output/*']
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
46
|
def test_passthrough_no_ext
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
with_site do
|
48
|
+
# Create rules
|
49
|
+
File.open('Rules', 'w') do |io|
|
50
|
+
io.write <<EOS
|
51
|
+
passthrough "/foo/"
|
52
|
+
EOS
|
53
|
+
end
|
54
|
+
|
55
|
+
# Create items
|
56
|
+
assert Dir['content/*'].empty?
|
57
|
+
File.open('content/foo', 'w') do |io|
|
58
|
+
io.write "Hello I am foo"
|
59
|
+
end
|
60
|
+
|
61
|
+
# Compile
|
56
62
|
site = Nanoc::Site.new('.')
|
57
|
-
site.
|
58
|
-
|
59
|
-
|
63
|
+
site.compile
|
64
|
+
|
65
|
+
# Check paths
|
66
|
+
assert_equal [ 'output/foo' ], Dir['output/*']
|
67
|
+
end
|
68
|
+
end
|
60
69
|
|
61
|
-
|
62
|
-
|
70
|
+
def test_passthrough_priority
|
71
|
+
with_site do
|
72
|
+
# Create rules
|
73
|
+
File.open('Rules', 'w') do |io|
|
74
|
+
io.write <<EOS
|
75
|
+
compile '*' do
|
76
|
+
filter :erb
|
77
|
+
end
|
63
78
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
79
|
+
route '*' do
|
80
|
+
item.identifier + 'index.html'
|
81
|
+
end
|
82
|
+
|
83
|
+
passthrough "/foo/"
|
84
|
+
EOS
|
85
|
+
end
|
86
|
+
|
87
|
+
# Create items
|
88
|
+
assert Dir['content/*'].empty?
|
89
|
+
File.open('content/foo.txt', 'w') do |io|
|
90
|
+
io.write "Hello I am <%= 'foo' %>"
|
91
|
+
end
|
92
|
+
|
93
|
+
# Compile
|
94
|
+
site = Nanoc::Site.new('.')
|
95
|
+
site.compile
|
68
96
|
|
69
|
-
# Check
|
70
|
-
assert_equal 'foo',
|
71
|
-
assert_equal '/foo',
|
97
|
+
# Check paths
|
98
|
+
assert_equal [ 'output/foo' ], Dir['output/*']
|
99
|
+
assert_equal [ 'output/foo/index.html' ], Dir['output/foo/*']
|
72
100
|
end
|
73
101
|
end
|
74
102
|
|
data/test/base/test_item_rep.rb
CHANGED
@@ -528,6 +528,14 @@ class Nanoc::ItemRepTest < MiniTest::Unit::TestCase
|
|
528
528
|
assert_equal [ items[1] ], dt.objects_causing_outdatedness_of(items[0])
|
529
529
|
end
|
530
530
|
|
531
|
+
def test_access_compiled_content_of_binary_item
|
532
|
+
item = Nanoc::Item.new("content/somefile.dat", {}, '/somefile/', :binary => true)
|
533
|
+
item_rep = Nanoc::ItemRep.new(item, :foo)
|
534
|
+
assert_raises(Nanoc::Errors::CannotGetCompiledContentOfBinaryItem) do
|
535
|
+
item_rep.compiled_content
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
531
539
|
private
|
532
540
|
|
533
541
|
def create_binary_item
|
@@ -71,4 +71,49 @@ class Nanoc::CLI::Commands::CompileTest < MiniTest::Unit::TestCase
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
def test_auto_prune_with_exclude
|
75
|
+
with_site do |site|
|
76
|
+
Nanoc::CLI.run %w( create_item foo )
|
77
|
+
Nanoc::CLI.run %w( create_item bar )
|
78
|
+
Nanoc::CLI.run %w( create_item baz )
|
79
|
+
|
80
|
+
File.open('Rules', 'w') do |io|
|
81
|
+
io.write "compile '*' do\n"
|
82
|
+
io.write " filter :erb\n"
|
83
|
+
io.write "end\n"
|
84
|
+
io.write "\n"
|
85
|
+
io.write "route '*' do\n"
|
86
|
+
io.write " if item.binary?\n"
|
87
|
+
io.write " item.identifier.chop + '.' + item[:extension]\n"
|
88
|
+
io.write " else\n"
|
89
|
+
io.write " item.identifier + 'index.html'\n"
|
90
|
+
io.write " end\n"
|
91
|
+
io.write "end\n"
|
92
|
+
io.write "\n"
|
93
|
+
io.write "layout '*', :erb\n"
|
94
|
+
end
|
95
|
+
|
96
|
+
Dir.mkdir('output/excluded_dir')
|
97
|
+
|
98
|
+
File.open('output/stray.html', 'w') do |io|
|
99
|
+
io.write 'I am a stray file and I am about to be deleted!'
|
100
|
+
end
|
101
|
+
|
102
|
+
assert File.file?('output/stray.html')
|
103
|
+
Nanoc::CLI.run %w( compile )
|
104
|
+
assert File.file?('output/stray.html')
|
105
|
+
|
106
|
+
File.open('config.yaml', 'w') do |io|
|
107
|
+
io.write "prune:\n"
|
108
|
+
io.write " auto_prune: true\n"
|
109
|
+
io.write " exclude: [ 'excluded_dir' ]\n"
|
110
|
+
end
|
111
|
+
|
112
|
+
assert File.file?('output/stray.html')
|
113
|
+
Nanoc::CLI.run %w( compile )
|
114
|
+
refute File.file?('output/stray.html')
|
115
|
+
assert File.directory?('output/excluded_dir'),
|
116
|
+
'excluded_dir should still be there'
|
117
|
+
end
|
118
|
+
end
|
74
119
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::CLI::Commands::WatchTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@@warned ||= begin
|
10
|
+
STDERR.puts "\n(fssm deprecation warning can be ignored; master branch uses guard/listen)"
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_run
|
16
|
+
with_site do |s|
|
17
|
+
watch_thread = Thread.new do
|
18
|
+
Nanoc::CLI.run %w( watch )
|
19
|
+
end
|
20
|
+
sleep 1
|
21
|
+
|
22
|
+
File.open('content/index.html', 'w') { |io| io.write('Hello there!') }
|
23
|
+
sleep 1
|
24
|
+
assert_equal 'Hello there!', File.read('output/index.html')
|
25
|
+
|
26
|
+
File.open('content/index.html', 'w') { |io| io.write('Hello there again!') }
|
27
|
+
sleep 1
|
28
|
+
assert_equal 'Hello there again!', File.read('output/index.html')
|
29
|
+
|
30
|
+
watch_thread.kill
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_notify
|
35
|
+
old_path = ENV['PATH']
|
36
|
+
with_site do |s|
|
37
|
+
watch_thread = Thread.new do
|
38
|
+
Nanoc::CLI.run %w( watch )
|
39
|
+
end
|
40
|
+
sleep 1
|
41
|
+
|
42
|
+
ENV['PATH'] = '.' # so that neither which nor where can be found
|
43
|
+
File.open('content/index.html', 'w') { |io| io.write('Hello there!') }
|
44
|
+
sleep 1
|
45
|
+
assert_equal 'Hello there!', File.read('output/index.html')
|
46
|
+
end
|
47
|
+
ensure
|
48
|
+
ENV['PATH'] = old_path
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -64,4 +64,40 @@ class Nanoc::Extra::Deployers::FogTest < MiniTest::Unit::TestCase
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def test_run_delete_stray
|
68
|
+
if_have 'fog' do
|
69
|
+
# Create deployer
|
70
|
+
fog = Nanoc::Extra::Deployers::Fog.new(
|
71
|
+
'output/',
|
72
|
+
{
|
73
|
+
:bucket => 'mybucket',
|
74
|
+
:provider => 'local',
|
75
|
+
:local_root => 'mylocalcloud'})
|
76
|
+
|
77
|
+
# Setup fake local cloud
|
78
|
+
FileUtils.mkdir_p('mylocalcloud/mybucket')
|
79
|
+
File.open('mylocalcloud/mybucket/etc', 'w') { |io| io.write('meh-etc') }
|
80
|
+
File.open('mylocalcloud/mybucket/meow', 'w') { |io| io.write('meh-meow') }
|
81
|
+
File.open('mylocalcloud/mybucket/bark', 'w') { |io| io.write('meh-bark') }
|
82
|
+
|
83
|
+
# Create site
|
84
|
+
FileUtils.mkdir_p('output')
|
85
|
+
File.open('output/meow', 'w') { |io| io.write "I am a cat!" }
|
86
|
+
File.open('output/bark', 'w') { |io| io.write "I am a dog!" }
|
87
|
+
|
88
|
+
# Create local cloud (but not bucket)
|
89
|
+
FileUtils.mkdir_p('mylocalcloud')
|
90
|
+
|
91
|
+
# Run
|
92
|
+
fog.run
|
93
|
+
|
94
|
+
# Check
|
95
|
+
refute File.file?('mylocalcloud/mybucket/etc')
|
96
|
+
assert File.file?('mylocalcloud/mybucket/meow')
|
97
|
+
assert File.file?('mylocalcloud/mybucket/bark')
|
98
|
+
assert_equal "I am a cat!", File.read('mylocalcloud/mybucket/meow')
|
99
|
+
assert_equal "I am a dog!", File.read('mylocalcloud/mybucket/bark')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
67
103
|
end
|
@@ -4,6 +4,9 @@ class Nanoc::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
4
4
|
|
5
5
|
include Nanoc::TestHelpers
|
6
6
|
|
7
|
+
CODERAY_PRE = '<div class="CodeRay"><div class="code">'
|
8
|
+
CODERAY_POST = '</div></div>'
|
9
|
+
|
7
10
|
def test_coderay_simple
|
8
11
|
if_have 'coderay', 'nokogiri' do
|
9
12
|
# Create filter
|
@@ -11,7 +14,7 @@ class Nanoc::Filters::ColorizeSyntaxTest < MiniTest::Unit::TestCase
|
|
11
14
|
|
12
15
|
# Get input and expected output
|
13
16
|
input = '<pre title="moo"><code class="language-ruby"># comment</code></pre>'
|
14
|
-
expected_output = '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>'
|
17
|
+
expected_output = CODERAY_PRE + '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>' + CODERAY_POST
|
15
18
|
|
16
19
|
# Run filter
|
17
20
|
actual_output = filter.run(input)
|
@@ -77,7 +80,7 @@ EOS
|
|
77
80
|
|
78
81
|
# Get input and expected output
|
79
82
|
input = %[<pre title="moo"><code>#!ruby\n# comment</code></pre>]
|
80
|
-
expected_output = '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>'
|
83
|
+
expected_output = CODERAY_PRE + '<pre title="moo"><code class="language-ruby"><span class="comment"># comment</span></code></pre>' + CODERAY_POST
|
81
84
|
|
82
85
|
# Run filter
|
83
86
|
actual_output = filter.run(input)
|
@@ -92,7 +95,7 @@ EOS
|
|
92
95
|
|
93
96
|
# Get input and expected output
|
94
97
|
input = %[<pre title="moo"><code class="language-ruby">#!ruby\n# comment</code></pre>]
|
95
|
-
expected_output = %[<pre title="moo"><code class="language-ruby"><span class="doctype">#!ruby</span>\n<span class="comment"># comment</span></code></pre>]
|
98
|
+
expected_output = CODERAY_PRE + %[<pre title="moo"><code class="language-ruby"><span class="doctype">#!ruby</span>\n<span class="comment"># comment</span></code></pre>] + CODERAY_POST
|
96
99
|
|
97
100
|
# Run filter
|
98
101
|
actual_output = filter.run(input)
|
@@ -107,7 +110,7 @@ EOS
|
|
107
110
|
|
108
111
|
# Get input and expected output
|
109
112
|
input = '<pre title="moo"><code class="abc language-ruby xyz"># comment</code></pre>'
|
110
|
-
expected_output = '<pre title="moo"><code class="abc language-ruby xyz"><span class="comment"># comment</span></code></pre>'
|
113
|
+
expected_output = CODERAY_PRE + '<pre title="moo"><code class="abc language-ruby xyz"><span class="comment"># comment</span></code></pre>' + CODERAY_POST
|
111
114
|
|
112
115
|
# Run filter
|
113
116
|
actual_output = filter.run(input)
|
@@ -305,8 +308,8 @@ after
|
|
305
308
|
EOS
|
306
309
|
expected_output = <<EOS
|
307
310
|
before
|
308
|
-
<pre><code class=\"language-ruby\"><span class=\"doctype\">#!/usr/bin/env ruby</span>
|
309
|
-
puts <span class=\"string\"><span class=\"delimiter\">'</span><span class=\"content\">hi!</span><span class=\"delimiter\">'</span></span></code></pre
|
311
|
+
#{CODERAY_PRE}<pre><code class=\"language-ruby\"><span class=\"doctype\">#!/usr/bin/env ruby</span>
|
312
|
+
puts <span class=\"string\"><span class=\"delimiter\">'</span><span class=\"content\">hi!</span><span class=\"delimiter\">'</span></span></code></pre>#{CODERAY_POST}
|
310
313
|
after
|
311
314
|
EOS
|
312
315
|
|
@@ -365,8 +368,8 @@ after
|
|
365
368
|
EOS
|
366
369
|
expected_output = <<EOS
|
367
370
|
before
|
368
|
-
<pre><code class="language-ruby"> <span class=\"keyword\">def</span> <span class=\"function\">foo</span>
|
369
|
-
<span class=\"keyword\">end</span></code></pre
|
371
|
+
#{CODERAY_PRE}<pre><code class="language-ruby"> <span class=\"keyword\">def</span> <span class=\"function\">foo</span>
|
372
|
+
<span class=\"keyword\">end</span></code></pre>#{CODERAY_POST}
|
370
373
|
after
|
371
374
|
EOS
|
372
375
|
|
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.2
|
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-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cri
|
@@ -202,6 +202,7 @@ 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
|
205
206
|
- lib/nanoc/extra/chick.rb
|
206
207
|
- lib/nanoc/extra/core_ext/enumerable.rb
|
207
208
|
- lib/nanoc/extra/core_ext/pathname.rb
|
@@ -308,6 +309,7 @@ files:
|
|
308
309
|
- test/cli/commands/test_info.rb
|
309
310
|
- test/cli/commands/test_prune.rb
|
310
311
|
- test/cli/commands/test_update.rb
|
312
|
+
- test/cli/commands/test_watch.rb
|
311
313
|
- test/cli/test_cleaning_stream.rb
|
312
314
|
- test/cli/test_cli.rb
|
313
315
|
- test/cli/test_error_handler.rb
|