nanoc 3.5.0 → 3.6.0
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 +1 -0
- data/Gemfile.lock +20 -12
- data/NEWS.md +23 -0
- data/README.md +6 -3
- data/doc/yardoc_templates/default/layout/html/footer.erb +16 -7
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base.rb +1 -0
- data/lib/nanoc/base/compilation/compiler_dsl.rb +31 -0
- data/lib/nanoc/base/compilation/filter.rb +34 -0
- data/lib/nanoc/base/result_data/item_rep.rb +3 -3
- data/lib/nanoc/base/source_data/code_snippet.rb +1 -1
- data/lib/nanoc/base/source_data/data_source.rb +12 -0
- data/lib/nanoc/base/source_data/item.rb +1 -1
- data/lib/nanoc/base/source_data/item_array.rb +62 -0
- data/lib/nanoc/base/source_data/layout.rb +1 -1
- data/lib/nanoc/base/source_data/site.rb +24 -3
- data/lib/nanoc/cli/cleaning_stream.rb +10 -0
- data/lib/nanoc/cli/command_runner.rb +25 -12
- data/lib/nanoc/cli/commands/autocompile.rb +5 -3
- data/lib/nanoc/cli/commands/check.rb +9 -1
- data/lib/nanoc/cli/commands/compile.rb +1 -1
- data/lib/nanoc/cli/commands/create-site.rb +5 -5
- data/lib/nanoc/cli/commands/prune.rb +1 -1
- data/lib/nanoc/cli/commands/shell.rb +37 -0
- data/lib/nanoc/cli/commands/show-data.rb +1 -1
- data/lib/nanoc/cli/commands/sync.rb +34 -0
- data/lib/nanoc/cli/error_handler.rb +11 -2
- data/lib/nanoc/extra/checking/checks/stale.rb +10 -2
- data/lib/nanoc/extra/pruner.rb +14 -11
- data/lib/nanoc/filters/asciidoc.rb +2 -2
- data/lib/nanoc/filters/bluecloth.rb +2 -2
- data/lib/nanoc/filters/coderay.rb +2 -2
- data/lib/nanoc/filters/coffeescript.rb +2 -2
- data/lib/nanoc/filters/colorize_syntax.rb +2 -4
- data/lib/nanoc/filters/erb.rb +2 -2
- data/lib/nanoc/filters/erubis.rb +2 -2
- data/lib/nanoc/filters/haml.rb +2 -2
- data/lib/nanoc/filters/handlebars.rb +2 -2
- data/lib/nanoc/filters/kramdown.rb +2 -2
- data/lib/nanoc/filters/less.rb +2 -2
- data/lib/nanoc/filters/markaby.rb +2 -2
- data/lib/nanoc/filters/maruku.rb +2 -2
- data/lib/nanoc/filters/mustache.rb +2 -2
- data/lib/nanoc/filters/pandoc.rb +2 -2
- data/lib/nanoc/filters/rainpress.rb +2 -2
- data/lib/nanoc/filters/rdiscount.rb +2 -2
- data/lib/nanoc/filters/rdoc.rb +3 -17
- data/lib/nanoc/filters/redcarpet.rb +7 -3
- data/lib/nanoc/filters/redcloth.rb +2 -2
- data/lib/nanoc/filters/rubypants.rb +2 -2
- data/lib/nanoc/filters/sass.rb +2 -3
- data/lib/nanoc/filters/slim.rb +2 -2
- data/lib/nanoc/filters/typogruby.rb +2 -2
- data/lib/nanoc/filters/uglify_js.rb +2 -2
- data/lib/nanoc/filters/xsl.rb +2 -1
- data/lib/nanoc/filters/yui_compressor.rb +2 -2
- data/lib/nanoc/helpers/blogging.rb +1 -1
- data/lib/nanoc/helpers/filtering.rb +1 -1
- data/lib/nanoc/helpers/rendering.rb +1 -1
- data/nanoc.gemspec +2 -2
- data/test/base/core_ext/array_spec.rb +4 -12
- data/test/base/core_ext/hash_spec.rb +4 -12
- data/test/base/test_compiler_dsl.rb +63 -0
- data/test/base/test_item.rb +3 -18
- data/test/base/test_item_array.rb +336 -0
- data/test/base/test_item_rep.rb +2 -12
- data/test/base/test_layout.rb +1 -6
- data/test/base/test_outdatedness_checker.rb +1 -1
- data/test/base/test_site.rb +9 -3
- data/test/cli/commands/test_check.rb +22 -0
- data/test/cli/commands/test_compile.rb +2 -2
- data/test/cli/commands/test_deploy.rb +6 -6
- data/test/cli/commands/test_prune.rb +23 -4
- data/test/cli/commands/test_sync.rb +31 -0
- data/test/cli/test_error_handler.rb +16 -11
- data/test/extra/checking/checks/test_stale.rb +24 -1
- data/test/extra/test_auto_compiler.rb +4 -4
- data/test/filters/test_asciidoc.rb +1 -1
- data/test/filters/test_bluecloth.rb +1 -1
- data/test/filters/test_coderay.rb +3 -3
- data/test/filters/test_coffeescript.rb +1 -1
- data/test/filters/test_colorize_syntax.rb +20 -20
- data/test/filters/test_erb.rb +10 -10
- data/test/filters/test_erubis.rb +6 -6
- data/test/filters/test_haml.rb +10 -10
- data/test/filters/test_handlebars.rb +3 -3
- data/test/filters/test_kramdown.rb +1 -1
- data/test/filters/test_less.rb +4 -4
- data/test/filters/test_markaby.rb +1 -1
- data/test/filters/test_maruku.rb +1 -1
- data/test/filters/test_mustache.rb +2 -2
- data/test/filters/test_pandoc.rb +1 -1
- data/test/filters/test_rainpress.rb +2 -2
- data/test/filters/test_rdiscount.rb +2 -2
- data/test/filters/test_rdoc.rb +1 -1
- data/test/filters/test_redcarpet.rb +21 -6
- data/test/filters/test_redcloth.rb +3 -3
- data/test/filters/test_relativize_paths.rb +27 -27
- data/test/filters/test_rubypants.rb +1 -1
- data/test/filters/test_sass.rb +8 -8
- data/test/filters/test_slim.rb +4 -4
- data/test/filters/test_typogruby.rb +1 -1
- data/test/filters/test_uglify_js.rb +2 -2
- data/test/filters/test_xsl.rb +2 -2
- data/test/filters/test_yui_compressor.rb +3 -3
- data/test/helper.rb +6 -1
- metadata +12 -6
|
@@ -22,7 +22,7 @@ module Nanoc::CLI
|
|
|
22
22
|
def site
|
|
23
23
|
# Load site if possible
|
|
24
24
|
@site ||= nil
|
|
25
|
-
if
|
|
25
|
+
if self.is_in_site_dir? && @site.nil?
|
|
26
26
|
@site = Nanoc::Site.new('.')
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -36,13 +36,10 @@ module Nanoc::CLI
|
|
|
36
36
|
self.new(opts, args, cmd).call
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
# @see Nanoc::CLI.debug?
|
|
44
|
-
def debug?
|
|
45
|
-
Nanoc::CLI.debug?
|
|
39
|
+
# @return [Boolean] true if the current working directory is a nanoc site
|
|
40
|
+
# directory, false otherwise
|
|
41
|
+
def is_in_site_dir?
|
|
42
|
+
Nanoc::Site.cwd_is_nanoc_site?
|
|
46
43
|
end
|
|
47
44
|
|
|
48
45
|
# Asserts that the current working directory contains a site
|
|
@@ -51,15 +48,31 @@ module Nanoc::CLI
|
|
|
51
48
|
#
|
|
52
49
|
# @return [void]
|
|
53
50
|
def require_site
|
|
54
|
-
print "Loading site data… "
|
|
55
51
|
if site.nil?
|
|
56
|
-
puts "error"
|
|
57
52
|
raise ::Nanoc::Errors::GenericTrivial, "The current working directory does not seem to be a nanoc site."
|
|
58
|
-
else
|
|
59
|
-
puts "done"
|
|
60
53
|
end
|
|
61
54
|
end
|
|
62
55
|
|
|
56
|
+
# Asserts that the current workign directory contains a site (just like
|
|
57
|
+
# {#require_site}) and loads the site into memory.
|
|
58
|
+
#
|
|
59
|
+
# @return [void]
|
|
60
|
+
def load_site
|
|
61
|
+
self.require_site
|
|
62
|
+
print "Loading site data… "
|
|
63
|
+
self.site.load
|
|
64
|
+
puts "done"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
protected
|
|
68
|
+
|
|
69
|
+
# @return [Boolean] true if debug output is enabled, false if not
|
|
70
|
+
#
|
|
71
|
+
# @see Nanoc::CLI.debug?
|
|
72
|
+
def debug?
|
|
73
|
+
Nanoc::CLI.debug?
|
|
74
|
+
end
|
|
75
|
+
|
|
63
76
|
# Sets the data source's VCS to the VCS with the given name. Does nothing
|
|
64
77
|
# when the site's data source does not support VCSes (i.e. does not
|
|
65
78
|
# implement #vcs=).
|
|
@@ -8,12 +8,13 @@ Start the autocompiler web server. Unless overridden with commandline options
|
|
|
8
8
|
or configuration entries, the web server will run on port 3000 and listen on all
|
|
9
9
|
IP addresses. Running the autocompiler requires the `mime/types` and `rack` gems.
|
|
10
10
|
|
|
11
|
-
To specify the host and/or
|
|
12
|
-
|
|
11
|
+
To specify the host, port, and/or handler options in config.yaml, you can add
|
|
12
|
+
any of the following:
|
|
13
13
|
|
|
14
14
|
autocompile:
|
|
15
15
|
host: '10.0.2.0' # override the default host
|
|
16
16
|
port: 4000 # override the default port
|
|
17
|
+
handler: thin # override the default handler
|
|
17
18
|
|
|
18
19
|
EOS
|
|
19
20
|
|
|
@@ -39,7 +40,8 @@ module Nanoc::CLI::Commands
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
# Guess which handler we should use
|
|
42
|
-
|
|
43
|
+
handler_option = options[:handler] || autocompile_config[:handler]
|
|
44
|
+
unless handler = Rack::Handler.get(handler_option)
|
|
43
45
|
begin
|
|
44
46
|
handler = Rack::Handler::Mongrel
|
|
45
47
|
rescue LoadError => e
|
|
@@ -19,15 +19,23 @@ module Nanoc::CLI::Commands
|
|
|
19
19
|
self.require_site
|
|
20
20
|
|
|
21
21
|
runner = Nanoc::Extra::Checking::Runner.new(site)
|
|
22
|
+
|
|
22
23
|
if options[:list]
|
|
23
24
|
runner.list_checks
|
|
24
|
-
|
|
25
|
+
return
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
success = if options[:all]
|
|
25
29
|
runner.run_all
|
|
26
30
|
elsif options[:deploy]
|
|
27
31
|
runner.run_for_deploy
|
|
28
32
|
else
|
|
29
33
|
runner.run_specific(arguments)
|
|
30
34
|
end
|
|
35
|
+
|
|
36
|
+
unless success
|
|
37
|
+
raise Nanoc::Errors::GenericTrivial, 'One or more checks failed'
|
|
38
|
+
end
|
|
31
39
|
end
|
|
32
40
|
|
|
33
41
|
protected
|
|
@@ -285,14 +285,14 @@ EOS
|
|
|
285
285
|
<div id="sidebar">
|
|
286
286
|
<h2>Documentation</h2>
|
|
287
287
|
<ul>
|
|
288
|
-
<li><a href="http://nanoc.
|
|
289
|
-
<li><a href="http://nanoc.
|
|
288
|
+
<li><a href="http://nanoc.ws/docs/">Documentation</a></li>
|
|
289
|
+
<li><a href="http://nanoc.ws/docs/tutorial/">Getting Started</a></li>
|
|
290
290
|
</ul>
|
|
291
291
|
<h2>Community</h2>
|
|
292
292
|
<ul>
|
|
293
293
|
<li><a href="http://groups.google.com/group/nanoc/">Discussion Group</a></li>
|
|
294
294
|
<li><a href="irc://chat.freenode.net/#nanoc">IRC Channel</a></li>
|
|
295
|
-
<li><a href="http://
|
|
295
|
+
<li><a href="http://github.com/nanoc/nanoc/wiki/">Wiki</a></li>
|
|
296
296
|
</ul>
|
|
297
297
|
</div>
|
|
298
298
|
</body>
|
|
@@ -344,8 +344,8 @@ EOS
|
|
|
344
344
|
FileUtils.mkdir_p('output')
|
|
345
345
|
|
|
346
346
|
# Create config
|
|
347
|
-
File.open('
|
|
348
|
-
Nanoc::NotificationCenter.post(:file_created, '
|
|
347
|
+
File.open('nanoc.yaml', 'w') { |io| io.write(DEFAULT_CONFIG) }
|
|
348
|
+
Nanoc::NotificationCenter.post(:file_created, 'nanoc.yaml')
|
|
349
349
|
|
|
350
350
|
# Create rules
|
|
351
351
|
File.open('Rules', 'w') do |io|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
usage 'shell'
|
|
4
|
+
summary 'open a shell on the nanoc environment'
|
|
5
|
+
aliases 'console'
|
|
6
|
+
description <<-EOS
|
|
7
|
+
Open an IRB shell on a context that contains @items, @layouts, @config and @site.
|
|
8
|
+
EOS
|
|
9
|
+
|
|
10
|
+
module Nanoc::CLI::Commands
|
|
11
|
+
|
|
12
|
+
class Shell < ::Nanoc::CLI::CommandRunner
|
|
13
|
+
|
|
14
|
+
def run
|
|
15
|
+
require 'pry'
|
|
16
|
+
|
|
17
|
+
self.require_site
|
|
18
|
+
|
|
19
|
+
Nanoc::Context.new(env).pry
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
protected
|
|
23
|
+
|
|
24
|
+
def env
|
|
25
|
+
{
|
|
26
|
+
:site => self.site,
|
|
27
|
+
:items => self.site.items,
|
|
28
|
+
:layouts => self.site.layouts,
|
|
29
|
+
:config => self.site.config
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
runner Nanoc::CLI::Commands::Shell
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
usage 'sync'
|
|
2
|
+
summary 'sync data sources'
|
|
3
|
+
description <<-EOS
|
|
4
|
+
Sync data source data. This command is useful for updating local item caches
|
|
5
|
+
for data sources which rely on slow external APIs.
|
|
6
|
+
EOS
|
|
7
|
+
|
|
8
|
+
module Nanoc::CLI::Commands
|
|
9
|
+
|
|
10
|
+
class Sync < ::Nanoc::CLI::CommandRunner
|
|
11
|
+
|
|
12
|
+
def run
|
|
13
|
+
# Check arguments
|
|
14
|
+
if arguments.size != 0
|
|
15
|
+
raise Nanoc::Errors::GenericTrivial, "usage: #{command.usage}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Make sure we are in a nanoc site directory
|
|
19
|
+
self.require_site
|
|
20
|
+
|
|
21
|
+
# Update all syncable data sources
|
|
22
|
+
self.site.data_sources.each do |data_source|
|
|
23
|
+
unless data_source.method(:sync).owner == Nanoc::DataSource
|
|
24
|
+
puts "Syncing #{data_source.config[:type]} data source: #{data_source.items_root}"
|
|
25
|
+
data_source.sync
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
runner Nanoc::CLI::Commands::Sync
|
|
@@ -208,6 +208,7 @@ module Nanoc::CLI
|
|
|
208
208
|
'maruku' => 'maruku',
|
|
209
209
|
'mime/types' => 'mime-types',
|
|
210
210
|
'nokogiri' => 'nokogiri',
|
|
211
|
+
'pry' => 'pry',
|
|
211
212
|
'rack' => 'rack',
|
|
212
213
|
'rack/cache' => 'rack-cache',
|
|
213
214
|
'rainpress' => 'rainpress',
|
|
@@ -236,7 +237,11 @@ module Nanoc::CLI
|
|
|
236
237
|
|
|
237
238
|
# Build message
|
|
238
239
|
if gem_name
|
|
239
|
-
|
|
240
|
+
if self.using_bundler?
|
|
241
|
+
"Make sure the gem is added to Gemfile and run `bundle up`."
|
|
242
|
+
else
|
|
243
|
+
"Install the '#{gem_name}' gem using `gem install #{gem_name}`."
|
|
244
|
+
end
|
|
240
245
|
end
|
|
241
246
|
when RuntimeError
|
|
242
247
|
if error.message =~ /^can't modify frozen/
|
|
@@ -249,6 +254,10 @@ module Nanoc::CLI
|
|
|
249
254
|
end
|
|
250
255
|
end
|
|
251
256
|
|
|
257
|
+
def using_bundler?
|
|
258
|
+
defined?(Bundler) && Bundler::SharedHelpers.in_bundle?
|
|
259
|
+
end
|
|
260
|
+
|
|
252
261
|
def write_section_header(stream, title, params={})
|
|
253
262
|
stream.puts
|
|
254
263
|
if params[:verbose]
|
|
@@ -298,7 +307,7 @@ module Nanoc::CLI
|
|
|
298
307
|
def write_issue_link(stream, params={})
|
|
299
308
|
stream.puts
|
|
300
309
|
stream.puts "If you believe this is a bug in nanoc, please do report it at"
|
|
301
|
-
stream.puts "-> https://github.com/
|
|
310
|
+
stream.puts "-> https://github.com/nanoc/nanoc/issues/new <-"
|
|
302
311
|
stream.puts
|
|
303
312
|
stream.puts "A detailed crash log has been written to ./crash.log."
|
|
304
313
|
end
|
|
@@ -6,8 +6,11 @@ module Nanoc::Extra::Checking::Checks
|
|
|
6
6
|
|
|
7
7
|
def run
|
|
8
8
|
require 'set'
|
|
9
|
+
|
|
9
10
|
item_rep_paths = Set.new(@site.items.collect { |i| i.reps }.flatten.collect { |r| r.raw_path })
|
|
11
|
+
|
|
10
12
|
self.output_filenames.each do |f|
|
|
13
|
+
next if self.pruner.filename_excluded?(f)
|
|
11
14
|
if !item_rep_paths.include?(f)
|
|
12
15
|
self.add_issue(
|
|
13
16
|
"file without matching item",
|
|
@@ -16,8 +19,13 @@ module Nanoc::Extra::Checking::Checks
|
|
|
16
19
|
end
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
protected
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
def pruner
|
|
25
|
+
exclude_config = @site.config.fetch(:prune, {}).fetch(:exclude, [])
|
|
26
|
+
@pruner ||= Nanoc::Extra::Pruner.new(@site, :exclude => exclude_config)
|
|
27
|
+
end
|
|
22
28
|
|
|
29
|
+
end
|
|
23
30
|
|
|
31
|
+
end
|
data/lib/nanoc/extra/pruner.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Nanoc::Extra
|
|
|
6
6
|
# that are not managed by nanoc.
|
|
7
7
|
class Pruner
|
|
8
8
|
|
|
9
|
-
# @return [Nanoc::Site] The site this pruner belongs to
|
|
9
|
+
# @return [Nanoc::Site] The site this pruner belongs to
|
|
10
10
|
attr_reader :site
|
|
11
11
|
|
|
12
12
|
# @param [Nanoc::Site] site The site for which a pruner is created
|
|
@@ -34,12 +34,12 @@ module Nanoc::Extra
|
|
|
34
34
|
end.flatten.compact.select { |f| File.file?(f) }
|
|
35
35
|
|
|
36
36
|
# Get present files and dirs
|
|
37
|
-
|
|
37
|
+
present_files = []
|
|
38
|
+
present_dirs = []
|
|
38
39
|
Find.find(self.site.config[:output_dir] + '/') do |f|
|
|
39
|
-
|
|
40
|
+
present_files << f if File.file?(f)
|
|
41
|
+
present_dirs << f if File.directory?(f)
|
|
40
42
|
end
|
|
41
|
-
present_files = present_files_and_dirs.select { |f| File.file?(f) }
|
|
42
|
-
present_dirs = present_files_and_dirs.select { |f| File.directory?(f) }
|
|
43
43
|
|
|
44
44
|
# Remove stray files
|
|
45
45
|
stray_files = (present_files - compiled_files)
|
|
@@ -49,20 +49,23 @@ module Nanoc::Extra
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
# Remove empty directories
|
|
52
|
-
present_dirs.
|
|
52
|
+
present_dirs.reverse_each do |dir|
|
|
53
53
|
next if Dir.foreach(dir) { |n| break true if n !~ /\A\.\.?\z/ }
|
|
54
54
|
next if filename_excluded?(dir)
|
|
55
55
|
self.delete_dir(dir)
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
# @param [String] filename The filename to check
|
|
60
|
+
#
|
|
61
|
+
# @return [Boolean] true if the given file is excluded, false otherwise
|
|
62
|
+
def filename_excluded?(filename)
|
|
63
|
+
pathname = Pathname.new(filename)
|
|
64
|
+
@exclude.any? { |e| pathname.include_component?(e) }
|
|
64
65
|
end
|
|
65
66
|
|
|
67
|
+
protected
|
|
68
|
+
|
|
66
69
|
def delete_file(file)
|
|
67
70
|
if @dry_run
|
|
68
71
|
puts file
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
require 'systemu'
|
|
4
|
-
|
|
5
3
|
module Nanoc::Filters
|
|
6
4
|
|
|
7
5
|
# @since 3.2.0
|
|
8
6
|
class AsciiDoc < Nanoc::Filter
|
|
9
7
|
|
|
8
|
+
requires 'systemu'
|
|
9
|
+
|
|
10
10
|
# Runs the content through [AsciiDoc](http://www.methods.co.nz/asciidoc/).
|
|
11
11
|
# This method takes no options.
|
|
12
12
|
#
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
require 'nokogiri'
|
|
4
|
-
require 'stringio'
|
|
5
|
-
require 'open3'
|
|
6
|
-
|
|
7
3
|
module Nanoc::Filters
|
|
8
4
|
class ColorizeSyntax < Nanoc::Filter
|
|
9
5
|
|
|
6
|
+
requires 'nokogiri', 'stringio', 'open3'
|
|
7
|
+
|
|
10
8
|
# The default colorizer to use for a language if the colorizer for that
|
|
11
9
|
# language is not overridden.
|
|
12
10
|
DEFAULT_COLORIZER = :coderay
|