nanoc 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -2
- data/Gemfile.lock +20 -21
- data/NEWS.md +17 -0
- data/README.md +4 -0
- data/lib/nanoc/base/compilation/compiler_dsl.rb +1 -1
- data/lib/nanoc/base/plugin_registry.rb +3 -0
- data/lib/nanoc/base/source_data/site.rb +2 -1
- data/lib/nanoc/cli/cleaning_stream.rb +16 -1
- data/lib/nanoc/cli/commands/compile.rb +40 -19
- data/lib/nanoc/cli/error_handler.rb +10 -0
- data/lib/nanoc/cli.rb +7 -1
- data/lib/nanoc/filters/relativize_paths.rb +14 -4
- data/lib/nanoc/filters/slim.rb +6 -1
- data/lib/nanoc/helpers/capturing.rb +5 -1
- data/lib/nanoc.rb +1 -1
- data/test/base/test_compiler_dsl.rb +28 -0
- data/test/cli/commands/test_compile.rb +41 -0
- data/test/cli/test_cleaning_stream.rb +45 -0
- data/test/filters/test_relativize_paths.rb +98 -0
- data/test/filters/test_uglify_js.rb +2 -2
- metadata +3 -2
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem '
|
5
|
+
gem 'adsf'
|
6
6
|
gem 'bluecloth'
|
7
7
|
gem 'builder'
|
8
8
|
gem 'coderay'
|
@@ -16,7 +16,7 @@ gem 'markaby'
|
|
16
16
|
gem 'maruku'
|
17
17
|
gem 'mime-types'
|
18
18
|
gem 'mustache'
|
19
|
-
gem 'nokogiri'
|
19
|
+
gem 'nokogiri', '~> 1.5.5'
|
20
20
|
gem 'pygments.rb'
|
21
21
|
gem 'rack'
|
22
22
|
gem 'rake'
|
data/Gemfile.lock
CHANGED
@@ -8,12 +8,12 @@ GEM
|
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
RedCloth (4.2.9)
|
11
|
-
|
12
|
-
|
11
|
+
adsf (1.1.1)
|
12
|
+
rack (>= 1.0.0)
|
13
13
|
blankslate (2.1.2.4)
|
14
14
|
bluecloth (2.2.0)
|
15
15
|
builder (3.0.0)
|
16
|
-
coderay (1.0.
|
16
|
+
coderay (1.0.7)
|
17
17
|
coffee-script (2.2.0)
|
18
18
|
coffee-script-source
|
19
19
|
execjs
|
@@ -23,13 +23,13 @@ GEM
|
|
23
23
|
cri (2.3.0)
|
24
24
|
colored (>= 1.2)
|
25
25
|
erubis (2.7.0)
|
26
|
-
excon (0.
|
26
|
+
excon (0.16.2)
|
27
27
|
execjs (1.4.0)
|
28
28
|
multi_json (~> 1.0)
|
29
29
|
ffi (1.0.11)
|
30
|
-
fog (1.
|
30
|
+
fog (1.5.0)
|
31
31
|
builder
|
32
|
-
excon (~> 0.
|
32
|
+
excon (~> 0.14)
|
33
33
|
formatador (~> 0.2.0)
|
34
34
|
mime-types
|
35
35
|
multi_json (~> 1.0)
|
@@ -38,8 +38,8 @@ GEM
|
|
38
38
|
nokogiri (~> 1.5.0)
|
39
39
|
ruby-hmac
|
40
40
|
formatador (0.2.3)
|
41
|
-
haml (3.1.
|
42
|
-
json (1.7.
|
41
|
+
haml (3.1.7)
|
42
|
+
json (1.7.5)
|
43
43
|
kramdown (0.13.7)
|
44
44
|
less (2.2.1)
|
45
45
|
commonjs (~> 0.2.6)
|
@@ -48,18 +48,17 @@ GEM
|
|
48
48
|
maruku (0.6.0)
|
49
49
|
syntax (>= 1.0.0)
|
50
50
|
metaclass (0.0.1)
|
51
|
-
mime-types (1.
|
52
|
-
minitest (3.0
|
53
|
-
mocha (0.
|
51
|
+
mime-types (1.19)
|
52
|
+
minitest (3.3.0)
|
53
|
+
mocha (0.12.3)
|
54
54
|
metaclass (~> 0.0.1)
|
55
55
|
multi_json (1.3.6)
|
56
56
|
mustache (0.99.4)
|
57
57
|
net-scp (1.0.4)
|
58
58
|
net-ssh (>= 1.99.1)
|
59
59
|
net-ssh (2.5.2)
|
60
|
-
nokogiri (1.5.
|
61
|
-
|
62
|
-
pygments.rb (0.2.12)
|
60
|
+
nokogiri (1.5.5)
|
61
|
+
pygments.rb (0.2.13)
|
63
62
|
rubypython (~> 0.5.3)
|
64
63
|
rack (1.4.1)
|
65
64
|
rainpress (1.0)
|
@@ -73,23 +72,23 @@ GEM
|
|
73
72
|
rubypython (0.5.3)
|
74
73
|
blankslate (>= 2.1.2.3)
|
75
74
|
ffi (~> 1.0.7)
|
76
|
-
sass (3.1
|
77
|
-
slim (1.2.
|
75
|
+
sass (3.2.1)
|
76
|
+
slim (1.2.2)
|
78
77
|
temple (~> 0.4.0)
|
79
78
|
tilt (~> 1.3.3)
|
80
79
|
syntax (1.0.0)
|
81
|
-
systemu (2.5.
|
80
|
+
systemu (2.5.2)
|
82
81
|
temple (0.4.0)
|
83
82
|
tilt (1.3.3)
|
84
83
|
typogruby (1.0.15)
|
85
84
|
rubypants
|
86
|
-
uglifier (1.2.
|
85
|
+
uglifier (1.2.7)
|
87
86
|
execjs (>= 0.3.0)
|
88
|
-
multi_json (
|
87
|
+
multi_json (~> 1.3)
|
89
88
|
w3c_validators (1.2)
|
90
89
|
json
|
91
90
|
nokogiri
|
92
|
-
yard (0.8.2)
|
91
|
+
yard (0.8.2.1)
|
93
92
|
yuicompressor (1.2.0)
|
94
93
|
|
95
94
|
PLATFORMS
|
@@ -97,7 +96,7 @@ PLATFORMS
|
|
97
96
|
|
98
97
|
DEPENDENCIES
|
99
98
|
RedCloth
|
100
|
-
|
99
|
+
adsf
|
101
100
|
bluecloth
|
102
101
|
builder
|
103
102
|
coderay
|
data/NEWS.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# nanoc news
|
2
2
|
|
3
|
+
## 3.4.1 (2012-09-22)
|
4
|
+
|
5
|
+
Fixes:
|
6
|
+
|
7
|
+
* Fixed auto-pruning
|
8
|
+
* Made slim filter work with the capturing helper [Bil Bas]
|
9
|
+
|
10
|
+
Improvements:
|
11
|
+
|
12
|
+
* Made several speed improvements
|
13
|
+
* Added prune configuration to config.yaml
|
14
|
+
* Made nanoc check for presence of nanoc in Gemfile
|
15
|
+
* Made compile command not show identicals (use `--verbose` if you want them)
|
16
|
+
* Made relativize_paths filter recognise more paths to relativize [Arnau Siches]
|
17
|
+
* Fixed #passthrough for items without extensions [Justin Hileman]
|
18
|
+
* Added more IO/File proxy methods to cleaning streams
|
19
|
+
|
3
20
|
## 3.4 (2012-06-09)
|
4
21
|
|
5
22
|
* Improved error output and added crash log
|
data/README.md
CHANGED
@@ -16,6 +16,10 @@ the following places will help you out:
|
|
16
16
|
* The [discussion group](http://groups.google.com/group/nanoc)
|
17
17
|
* The [IRC channel](irc://chat.freenode.net/#nanoc)
|
18
18
|
|
19
|
+
## Versioning
|
20
|
+
|
21
|
+
nanoc uses [Semantic Versioning](semver.org).
|
22
|
+
|
19
23
|
## Source Code Documentation
|
20
24
|
|
21
25
|
The source code is located in `lib/nanoc` and is structured in a few
|
@@ -184,7 +184,7 @@ module Nanoc
|
|
184
184
|
|
185
185
|
# Create routing rule
|
186
186
|
routing_block = proc do
|
187
|
-
item.identifier.chop + '.' + item[:extension]
|
187
|
+
item[:extension].nil? ? item.identifier.chop : item.identifier.chop + '.' + item[:extension]
|
188
188
|
end
|
189
189
|
routing_rule = Rule.new(identifier_to_regex(identifier), rep_name, routing_block)
|
190
190
|
@rules_collection.add_item_routing_rule(routing_rule, :before)
|
@@ -7,6 +7,8 @@ module Nanoc
|
|
7
7
|
# ({Nanoc::Extra::VCS}).
|
8
8
|
class PluginRegistry
|
9
9
|
|
10
|
+
extend Nanoc::Memoization
|
11
|
+
|
10
12
|
# A module that contains class methods for plugins. It provides functions
|
11
13
|
# for setting identifiers, registering plugins and finding plugins. Plugin
|
12
14
|
# classes should extend this module.
|
@@ -178,6 +180,7 @@ module Nanoc
|
|
178
180
|
class_or_name
|
179
181
|
end
|
180
182
|
end
|
183
|
+
memoize :resolve
|
181
184
|
|
182
185
|
end
|
183
186
|
|
@@ -36,7 +36,8 @@ module Nanoc
|
|
36
36
|
:output_dir => 'output',
|
37
37
|
:data_sources => [ {} ],
|
38
38
|
:index_filenames => [ 'index.html' ],
|
39
|
-
:enable_output_diff => false
|
39
|
+
:enable_output_diff => false,
|
40
|
+
:prune => { :auto_prune => false, :exclude => [ '.git', '.hg', '.svn', 'CVS' ] }
|
40
41
|
}
|
41
42
|
|
42
43
|
# Creates a site object for the site specified by the given
|
@@ -51,7 +51,7 @@ module Nanoc::CLI
|
|
51
51
|
|
52
52
|
# @see IO#tty?
|
53
53
|
def tty?
|
54
|
-
@stream.tty?
|
54
|
+
@cached_is_tty ||= @stream.tty?
|
55
55
|
end
|
56
56
|
|
57
57
|
# @see IO#flush
|
@@ -79,6 +79,21 @@ module Nanoc::CLI
|
|
79
79
|
@stream.string
|
80
80
|
end
|
81
81
|
|
82
|
+
# @see IO#reopen
|
83
|
+
def reopen(*a)
|
84
|
+
@stream.reopen(*a)
|
85
|
+
end
|
86
|
+
|
87
|
+
# @see File#exist?
|
88
|
+
def exist?
|
89
|
+
@stream.exist?
|
90
|
+
end
|
91
|
+
|
92
|
+
# @see File.exists?
|
93
|
+
def exists?
|
94
|
+
@stream.exists?
|
95
|
+
end
|
96
|
+
|
82
97
|
protected
|
83
98
|
|
84
99
|
def clean(s)
|
@@ -50,9 +50,17 @@ module Nanoc::CLI::Commands
|
|
50
50
|
@filter_times = {}
|
51
51
|
setup_notifications
|
52
52
|
|
53
|
+
# Set up progress indicator threads
|
54
|
+
@progress_locks = {}
|
55
|
+
@progress_threads = {}
|
56
|
+
|
53
57
|
# Prepare for generating diffs
|
54
58
|
setup_diffs
|
55
59
|
|
60
|
+
# Set up GC control
|
61
|
+
@gc_lock = Mutex.new
|
62
|
+
@gc_count = 0
|
63
|
+
|
56
64
|
# Compile
|
57
65
|
self.site.compile
|
58
66
|
|
@@ -72,7 +80,7 @@ module Nanoc::CLI::Commands
|
|
72
80
|
teardown_diffs
|
73
81
|
|
74
82
|
# Prune
|
75
|
-
if self.site.config[:auto_prune]
|
83
|
+
if self.site.config[:prune][:auto_prune]
|
76
84
|
Nanoc::Extra::Pruner.new(self.site).run
|
77
85
|
end
|
78
86
|
|
@@ -106,8 +114,9 @@ module Nanoc::CLI::Commands
|
|
106
114
|
# File notifications
|
107
115
|
Nanoc::NotificationCenter.on(:rep_written) do |rep, path, is_created, is_modified|
|
108
116
|
action = (is_created ? :create : (is_modified ? :update : :identical))
|
117
|
+
level = (is_created ? :high : (is_modified ? :high : :low))
|
109
118
|
duration = Time.now - @rep_times[rep.raw_path] if @rep_times[rep.raw_path]
|
110
|
-
Nanoc::CLI::Logger.instance.file(
|
119
|
+
Nanoc::CLI::Logger.instance.file(level, action, path, duration)
|
111
120
|
end
|
112
121
|
|
113
122
|
# Debug notifications
|
@@ -144,6 +153,12 @@ module Nanoc::CLI::Commands
|
|
144
153
|
|
145
154
|
# Timing notifications
|
146
155
|
Nanoc::NotificationCenter.on(:compilation_started) do |rep|
|
156
|
+
if @gc_count % 20 == 0 && !ENV.has_key?('TRAVIS')
|
157
|
+
GC.enable
|
158
|
+
GC.start
|
159
|
+
GC.disable
|
160
|
+
end
|
161
|
+
@gc_count += 1
|
147
162
|
@rep_times[rep.raw_path] = Time.now
|
148
163
|
end
|
149
164
|
Nanoc::NotificationCenter.on(:compilation_ended) do |rep|
|
@@ -217,27 +232,30 @@ module Nanoc::CLI::Commands
|
|
217
232
|
# Only show progress on terminals
|
218
233
|
return if !$stdout.tty?
|
219
234
|
|
220
|
-
@
|
221
|
-
|
222
|
-
|
235
|
+
@progress_locks[rep.inspect + filter_name.inspect] = lock = Mutex.new
|
236
|
+
lock.synchronize do
|
237
|
+
@progress_threads[rep.inspect + filter_name.inspect] = Thread.new do
|
238
|
+
delay = 1.0
|
239
|
+
step = 0
|
223
240
|
|
224
|
-
|
241
|
+
text = "Running #{filter_name} filter… "
|
225
242
|
|
226
|
-
|
227
|
-
|
243
|
+
while !Thread.current[:stopped]
|
244
|
+
sleep 0.1
|
228
245
|
|
229
|
-
|
230
|
-
|
231
|
-
|
246
|
+
# Wait for a while before showing text
|
247
|
+
delay -= 0.1
|
248
|
+
next if delay > 0.05
|
232
249
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
250
|
+
# Print progress
|
251
|
+
$stdout.print text + %w( | / - \\ )[step] + "\r"
|
252
|
+
step = (step + 1) % 4
|
253
|
+
end
|
237
254
|
|
238
|
-
|
239
|
-
|
240
|
-
|
255
|
+
# Clear text
|
256
|
+
if delay < 0.05
|
257
|
+
$stdout.print ' ' * (text.length + 1 + 1) + "\r"
|
258
|
+
end
|
241
259
|
end
|
242
260
|
end
|
243
261
|
end
|
@@ -246,7 +264,10 @@ module Nanoc::CLI::Commands
|
|
246
264
|
# Only show progress on terminals
|
247
265
|
return if !$stdout.tty?
|
248
266
|
|
249
|
-
@
|
267
|
+
lock = @progress_locks[rep.inspect + filter_name.inspect]
|
268
|
+
lock.synchronize do
|
269
|
+
@progress_threads[rep.inspect + filter_name.inspect][:stopped] = true
|
270
|
+
end
|
250
271
|
end
|
251
272
|
|
252
273
|
def print_profiling_feedback(reps)
|
@@ -201,6 +201,16 @@ module Nanoc::CLI
|
|
201
201
|
stream.puts Nanoc.version_information
|
202
202
|
stream.puts
|
203
203
|
|
204
|
+
# System information
|
205
|
+
begin
|
206
|
+
uname = `uname -a`
|
207
|
+
stream.puts '=== SYSTEM INFORMATION:'
|
208
|
+
stream.puts
|
209
|
+
stream.puts uname
|
210
|
+
stream.puts
|
211
|
+
rescue Errno::ENOENT
|
212
|
+
end
|
213
|
+
|
204
214
|
# Installed gems
|
205
215
|
stream.puts '=== INSTALLED GEMS:'
|
206
216
|
stream.puts
|
data/lib/nanoc/cli.rb
CHANGED
@@ -6,7 +6,7 @@ module Nanoc::Filters
|
|
6
6
|
require 'nanoc/helpers/link_to'
|
7
7
|
include Nanoc::Helpers::LinkTo
|
8
8
|
|
9
|
-
SELECTORS = [ '
|
9
|
+
SELECTORS = [ '*/@href', '*/@src', 'object/@data', 'param[@name="movie"]/@content', 'comment()' ]
|
10
10
|
|
11
11
|
# Relativizes all paths in the given content, which can be HTML, XHTML, XML
|
12
12
|
# or CSS. This filter is quite useful if a site needs to be hosted in a
|
@@ -20,8 +20,8 @@ module Nanoc::Filters
|
|
20
20
|
# `:html`, `:xhtml`, `:xml` or `:css`.
|
21
21
|
#
|
22
22
|
# @option params [Array] :select The XPath expressions that matches the
|
23
|
-
# nodes to modify. This param is useful only for the `:xml` and
|
24
|
-
# types.
|
23
|
+
# nodes to modify. This param is useful only for the `:html`, `:xml` and
|
24
|
+
# `:xhtml` types.
|
25
25
|
#
|
26
26
|
# @option params [Hash] :namespaces The pairs `prefix => uri` to define
|
27
27
|
# any namespace you want to use in the XPath expressions. This param
|
@@ -76,7 +76,16 @@ module Nanoc::Filters
|
|
76
76
|
doc = content =~ /<html[\s>]/ ? klass.parse(content) : klass.fragment(content)
|
77
77
|
selectors.map { |sel| "descendant-or-self::#{sel}" }.each do |selector|
|
78
78
|
doc.xpath(selector, namespaces).each do |node|
|
79
|
-
if
|
79
|
+
if node.name == 'comment'
|
80
|
+
content = node.content.dup
|
81
|
+
content = content.sub(%r{^(\s*\[.+?\]>\s*)(.+?)(\s*<!\[endif\])}m) do |m|
|
82
|
+
fragment = nokogiri_process($2, selectors, namespaces, klass, type)
|
83
|
+
$1 + fragment + $3
|
84
|
+
end
|
85
|
+
comment = Nokogiri::XML::Comment.new(doc, content)
|
86
|
+
# Works w/ Nokogiri 1.5.5 but fails w/ Nokogiri 1.5.2
|
87
|
+
node.replace(comment)
|
88
|
+
elsif self.path_is_relativizable?(node.content)
|
80
89
|
node.content = relative_path_to(node.content)
|
81
90
|
end
|
82
91
|
end
|
@@ -97,3 +106,4 @@ module Nanoc::Filters
|
|
97
106
|
|
98
107
|
end
|
99
108
|
end
|
109
|
+
|
data/lib/nanoc/filters/slim.rb
CHANGED
@@ -14,10 +14,15 @@ module Nanoc::Filters
|
|
14
14
|
#
|
15
15
|
# @return [String] The filtered content
|
16
16
|
def run(content, params={})
|
17
|
+
params = {
|
18
|
+
:disable_capture => true, # Capture managed by nanoc
|
19
|
+
:buffer => '_erbout', # Force slim to output to the buffer used by nanoc
|
20
|
+
}.merge params
|
21
|
+
|
17
22
|
# Create context
|
18
23
|
context = ::Nanoc::Context.new(assigns)
|
19
24
|
|
20
|
-
::Slim::Template.new { content }.render(context) { assigns[:content] }
|
25
|
+
::Slim::Template.new(params) { content }.render(context) { assigns[:content] }
|
21
26
|
end
|
22
27
|
|
23
28
|
end
|
@@ -162,7 +162,11 @@ module Nanoc::Helpers
|
|
162
162
|
# Remove addition
|
163
163
|
erbout[erbout_length..-1] = ''
|
164
164
|
|
165
|
-
#
|
165
|
+
# Depending on how the filter outputs, the result might be a
|
166
|
+
# single string or an array of strings (slim outputs the latter).
|
167
|
+
erbout_addition = erbout_addition.join if erbout_addition.is_a? Array
|
168
|
+
|
169
|
+
# Done.
|
166
170
|
erbout_addition
|
167
171
|
end
|
168
172
|
|
data/lib/nanoc.rb
CHANGED
@@ -44,6 +44,34 @@ class Nanoc::CompilerDSLTest < MiniTest::Unit::TestCase
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_passthrough_no_ext
|
48
|
+
# Create site
|
49
|
+
Nanoc::CLI.run %w( create_site bar)
|
50
|
+
FileUtils.cd('bar') do
|
51
|
+
# Create rep
|
52
|
+
item = Nanoc::Item.new('foo', { :extension => nil }, '/foo/')
|
53
|
+
rep = Nanoc::ItemRep.new(item, :default)
|
54
|
+
|
55
|
+
# Create other necessary stuff
|
56
|
+
site = Nanoc::Site.new('.')
|
57
|
+
site.items << item
|
58
|
+
compiler = site.compiler
|
59
|
+
dsl = site.compiler.rules_collection.dsl
|
60
|
+
|
61
|
+
# Create rule
|
62
|
+
dsl.passthrough '/foo/'
|
63
|
+
|
64
|
+
# Route and compile
|
65
|
+
rule = compiler.rules_collection.routing_rule_for(rep)
|
66
|
+
path = rule.apply_to(rep, :compiler => compiler)
|
67
|
+
compiler.send :compile_rep, rep
|
68
|
+
|
69
|
+
# Check result
|
70
|
+
assert_equal 'foo', rep.compiled_content
|
71
|
+
assert_equal '/foo', path
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
47
75
|
def test_identifier_to_regex_without_wildcards
|
48
76
|
# Create compiler DSL
|
49
77
|
compiler_dsl = Nanoc::CompilerDSL.new(nil, {})
|
@@ -30,4 +30,45 @@ class Nanoc::CLI::Commands::CompileTest < MiniTest::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_auto_prune
|
34
|
+
with_site do |site|
|
35
|
+
Nanoc::CLI.run %w( create_item foo )
|
36
|
+
Nanoc::CLI.run %w( create_item bar )
|
37
|
+
Nanoc::CLI.run %w( create_item baz )
|
38
|
+
|
39
|
+
File.open('Rules', 'w') do |io|
|
40
|
+
io.write "compile '*' do\n"
|
41
|
+
io.write " filter :erb\n"
|
42
|
+
io.write "end\n"
|
43
|
+
io.write "\n"
|
44
|
+
io.write "route '*' do\n"
|
45
|
+
io.write " if item.binary?\n"
|
46
|
+
io.write " item.identifier.chop + '.' + item[:extension]\n"
|
47
|
+
io.write " else\n"
|
48
|
+
io.write " item.identifier + 'index.html'\n"
|
49
|
+
io.write " end\n"
|
50
|
+
io.write "end\n"
|
51
|
+
io.write "\n"
|
52
|
+
io.write "layout '*', :erb\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
File.open('output/stray.html', 'w') do |io|
|
56
|
+
io.write 'I am a stray file and I am about to be deleted!'
|
57
|
+
end
|
58
|
+
|
59
|
+
assert File.file?('output/stray.html')
|
60
|
+
Nanoc::CLI.run %w( compile )
|
61
|
+
assert File.file?('output/stray.html')
|
62
|
+
|
63
|
+
File.open('config.yaml', 'w') do |io|
|
64
|
+
io.write "prune:\n"
|
65
|
+
io.write " auto_prune: true\n"
|
66
|
+
end
|
67
|
+
|
68
|
+
assert File.file?('output/stray.html')
|
69
|
+
Nanoc::CLI.run %w( compile )
|
70
|
+
refute File.file?('output/stray.html')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
33
74
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Nanoc::CLI::CleaningStreamTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include Nanoc::TestHelpers
|
6
|
+
|
7
|
+
class Stream
|
8
|
+
|
9
|
+
attr_accessor :called_methods
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@called_methods = Set.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def method_missing(symbol, *args)
|
16
|
+
@called_methods << symbol
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_forward
|
22
|
+
methods = [ :write, :<<, :tty?, :flush, :tell, :print, :puts, :string, :reopen, :exist?, :exists? ]
|
23
|
+
|
24
|
+
s = Stream.new
|
25
|
+
cs = Nanoc::CLI::CleaningStream.new(s)
|
26
|
+
|
27
|
+
cs.write('aaa')
|
28
|
+
cs << 'bb'
|
29
|
+
cs.tty?
|
30
|
+
cs.flush
|
31
|
+
cs.tell
|
32
|
+
cs.print('cc')
|
33
|
+
cs.puts('dd')
|
34
|
+
cs.string
|
35
|
+
cs.reopen('/dev/null', 'r')
|
36
|
+
cs.exist?
|
37
|
+
cs.exists?
|
38
|
+
|
39
|
+
methods.each do |m|
|
40
|
+
assert s.called_methods.include?(m), "expected #{m} to be called"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
@@ -305,6 +305,32 @@ EOS
|
|
305
305
|
assert_equal(expected_content, actual_content)
|
306
306
|
end
|
307
307
|
|
308
|
+
|
309
|
+
def test_filter_html_object_with_relative_path
|
310
|
+
# Create filter with mock item
|
311
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
312
|
+
|
313
|
+
# Mock item
|
314
|
+
filter.instance_eval do
|
315
|
+
@item_rep = Nanoc::ItemRep.new(
|
316
|
+
Nanoc::Item.new(
|
317
|
+
'content',
|
318
|
+
{},
|
319
|
+
'/foo/bar/baz/'),
|
320
|
+
:blah)
|
321
|
+
@item_rep.path = '/woof/meow/'
|
322
|
+
end
|
323
|
+
|
324
|
+
# Set content
|
325
|
+
raw_content = %[<object data="/example"><param name="movie" content="/example"></object>]
|
326
|
+
expected_content = %[<object data="../../example"><param name="movie" content="../../example"></object>]
|
327
|
+
|
328
|
+
# Test
|
329
|
+
actual_content = filter.run(raw_content, :type => :html)
|
330
|
+
assert_equal(expected_content, actual_content)
|
331
|
+
end
|
332
|
+
|
333
|
+
|
308
334
|
def test_filter_implicit
|
309
335
|
# Create filter with mock item
|
310
336
|
filter = Nanoc::Filters::RelativizePaths.new
|
@@ -659,5 +685,77 @@ XML
|
|
659
685
|
end
|
660
686
|
end
|
661
687
|
|
688
|
+
def test_filter_fragment_xhtml_with_comments
|
689
|
+
if_have 'nokogiri' do
|
690
|
+
# Create filter with mock item
|
691
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
692
|
+
|
693
|
+
# Mock item
|
694
|
+
filter.instance_eval do
|
695
|
+
@item_rep = Nanoc::ItemRep.new(
|
696
|
+
Nanoc::Item.new(
|
697
|
+
'content',
|
698
|
+
{},
|
699
|
+
'/foo/baz/'),
|
700
|
+
:blah)
|
701
|
+
@item_rep.path = '/foo/baz/'
|
702
|
+
end
|
703
|
+
|
704
|
+
# Set content
|
705
|
+
raw_content = %[
|
706
|
+
<link rel="stylesheet" href="/foo.css" />
|
707
|
+
<!--[if lt IE 9]>
|
708
|
+
<script src="/js/lib/html5shiv.js"></script>
|
709
|
+
<![endif]-->
|
710
|
+
]
|
711
|
+
|
712
|
+
expected_content = %[
|
713
|
+
<link rel="stylesheet" href="../../foo.css" />
|
714
|
+
<!--[if lt IE 9]>
|
715
|
+
<script src="../../js/lib/html5shiv.js"></script>
|
716
|
+
<![endif]-->
|
717
|
+
]
|
718
|
+
|
719
|
+
# Test
|
720
|
+
actual_content = filter.run(raw_content.freeze, :type => :xhtml)
|
721
|
+
assert_equal(expected_content, actual_content)
|
722
|
+
end
|
723
|
+
end
|
724
|
+
|
725
|
+
|
726
|
+
def test_filter_fragment_html_with_comments
|
727
|
+
if_have 'nokogiri' do
|
728
|
+
# Create filter with mock item
|
729
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
730
|
+
|
731
|
+
# Mock item
|
732
|
+
filter.instance_eval do
|
733
|
+
@item_rep = Nanoc::ItemRep.new(
|
734
|
+
Nanoc::Item.new(
|
735
|
+
'content',
|
736
|
+
{},
|
737
|
+
'/foo/baz/'),
|
738
|
+
:blah)
|
739
|
+
@item_rep.path = '/foo/baz/'
|
740
|
+
end
|
741
|
+
|
742
|
+
# Set content
|
743
|
+
raw_content = %[
|
744
|
+
<!--[if lt IE 9]>
|
745
|
+
<script src="/js/lib/html5shiv.js"></script>
|
746
|
+
<![endif]-->
|
747
|
+
]
|
748
|
+
|
749
|
+
expected_content = %[
|
750
|
+
<!--[if lt IE 9]>
|
751
|
+
<script src="../../js/lib/html5shiv.js"></script>
|
752
|
+
<![endif]-->]
|
753
|
+
|
754
|
+
# Test
|
755
|
+
actual_content = filter.run(raw_content.freeze, :type => :html)
|
756
|
+
assert_equal(expected_content, actual_content)
|
757
|
+
end
|
758
|
+
end
|
759
|
+
|
662
760
|
|
663
761
|
end
|
@@ -11,7 +11,7 @@ class Nanoc::Filters::UglifyJSTest < MiniTest::Unit::TestCase
|
|
11
11
|
|
12
12
|
# Run filter
|
13
13
|
result = filter.run("foo = 1; (function(bar) { if (true) alert(bar); })(foo)")
|
14
|
-
|
14
|
+
assert_match(/foo=1,function\((.)\){alert\(\1\)}\(foo\);/, result)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -23,7 +23,7 @@ class Nanoc::Filters::UglifyJSTest < MiniTest::Unit::TestCase
|
|
23
23
|
|
24
24
|
# Run filter
|
25
25
|
result = filter.run("foo = 1; (function(bar) { if (true) alert(bar); })(foo)", :toplevel => true)
|
26
|
-
|
26
|
+
assert_match(/foo=1,function\((.)\){alert\(\1\)}\(foo\);/, result)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
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.1
|
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-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cri
|
@@ -308,6 +308,7 @@ files:
|
|
308
308
|
- test/cli/commands/test_info.rb
|
309
309
|
- test/cli/commands/test_prune.rb
|
310
310
|
- test/cli/commands/test_update.rb
|
311
|
+
- test/cli/test_cleaning_stream.rb
|
311
312
|
- test/cli/test_cli.rb
|
312
313
|
- test/cli/test_error_handler.rb
|
313
314
|
- test/cli/test_logger.rb
|