nanoc 3.2.4 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/ChangeLog +3 -0
- data/Gemfile +32 -0
- data/LICENSE +19 -0
- data/NEWS.md +470 -0
- data/README.md +114 -0
- data/Rakefile +14 -0
- data/bin/nanoc +7 -27
- data/bin/nanoc3 +3 -0
- data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
- data/lib/nanoc.rb +41 -0
- data/lib/nanoc/base.rb +49 -0
- data/lib/nanoc/base/compilation/checksum_store.rb +57 -0
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +62 -0
- data/lib/nanoc/base/compilation/compiler.rb +458 -0
- data/lib/nanoc/base/compilation/compiler_dsl.rb +214 -0
- data/lib/nanoc/base/compilation/dependency_tracker.rb +200 -0
- data/lib/nanoc/base/compilation/filter.rb +165 -0
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +103 -0
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +102 -0
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +223 -0
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +46 -0
- data/lib/nanoc/base/compilation/rule.rb +73 -0
- data/lib/nanoc/base/compilation/rule_context.rb +84 -0
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +40 -0
- data/lib/nanoc/base/compilation/rule_memory_store.rb +53 -0
- data/lib/nanoc/base/compilation/rules_collection.rb +243 -0
- data/lib/nanoc/base/context.rb +47 -0
- data/lib/nanoc/base/core_ext.rb +6 -0
- data/lib/nanoc/base/core_ext/array.rb +62 -0
- data/lib/nanoc/base/core_ext/hash.rb +63 -0
- data/lib/nanoc/base/core_ext/pathname.rb +26 -0
- data/lib/nanoc/base/core_ext/string.rb +46 -0
- data/lib/nanoc/base/directed_graph.rb +275 -0
- data/lib/nanoc/base/errors.rb +211 -0
- data/lib/nanoc/base/memoization.rb +67 -0
- data/lib/nanoc/base/notification_center.rb +84 -0
- data/lib/nanoc/base/ordered_hash.rb +200 -0
- data/lib/nanoc/base/plugin_registry.rb +181 -0
- data/lib/nanoc/base/result_data/item_rep.rb +492 -0
- data/lib/nanoc/base/source_data/code_snippet.rb +58 -0
- data/lib/nanoc/base/source_data/configuration.rb +24 -0
- data/lib/nanoc/base/source_data/data_source.rb +234 -0
- data/lib/nanoc/base/source_data/item.rb +301 -0
- data/lib/nanoc/base/source_data/layout.rb +130 -0
- data/lib/nanoc/base/source_data/site.rb +361 -0
- data/lib/nanoc/base/store.rb +135 -0
- data/lib/nanoc/cli.rb +137 -0
- data/lib/nanoc/cli/command_runner.rb +104 -0
- data/lib/nanoc/cli/commands/autocompile.rb +58 -0
- data/lib/nanoc/cli/commands/compile.rb +297 -0
- data/lib/nanoc/cli/commands/create_item.rb +60 -0
- data/lib/nanoc/cli/commands/create_layout.rb +73 -0
- data/lib/nanoc/cli/commands/create_site.rb +411 -0
- data/lib/nanoc/cli/commands/debug.rb +117 -0
- data/lib/nanoc/cli/commands/deploy.rb +79 -0
- data/lib/nanoc/cli/commands/info.rb +98 -0
- data/lib/nanoc/cli/commands/nanoc.rb +38 -0
- data/lib/nanoc/cli/commands/prune.rb +50 -0
- data/lib/nanoc/cli/commands/update.rb +70 -0
- data/lib/nanoc/cli/commands/view.rb +82 -0
- data/lib/nanoc/cli/commands/watch.rb +124 -0
- data/lib/nanoc/cli/error_handler.rb +199 -0
- data/lib/nanoc/cli/logger.rb +92 -0
- data/lib/nanoc/data_sources.rb +29 -0
- data/lib/nanoc/data_sources/deprecated/delicious.rb +42 -0
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +87 -0
- data/lib/nanoc/data_sources/deprecated/twitter.rb +38 -0
- data/lib/nanoc/data_sources/filesystem.rb +299 -0
- data/lib/nanoc/data_sources/filesystem_unified.rb +121 -0
- data/lib/nanoc/data_sources/filesystem_verbose.rb +91 -0
- data/lib/nanoc/extra.rb +24 -0
- data/lib/nanoc/extra/auto_compiler.rb +103 -0
- data/lib/nanoc/extra/chick.rb +125 -0
- data/lib/nanoc/extra/core_ext.rb +6 -0
- data/lib/nanoc/extra/core_ext/enumerable.rb +33 -0
- data/lib/nanoc/extra/core_ext/pathname.rb +30 -0
- data/lib/nanoc/extra/core_ext/time.rb +19 -0
- data/lib/nanoc/extra/deployer.rb +47 -0
- data/lib/nanoc/extra/deployers.rb +15 -0
- data/lib/nanoc/extra/deployers/fog.rb +98 -0
- data/lib/nanoc/extra/deployers/rsync.rb +70 -0
- data/lib/nanoc/extra/file_proxy.rb +40 -0
- data/lib/nanoc/extra/pruner.rb +86 -0
- data/lib/nanoc/extra/validators.rb +12 -0
- data/lib/nanoc/extra/validators/links.rb +268 -0
- data/lib/nanoc/extra/validators/w3c.rb +95 -0
- data/lib/nanoc/extra/vcs.rb +66 -0
- data/lib/nanoc/extra/vcses.rb +17 -0
- data/lib/nanoc/extra/vcses/bazaar.rb +25 -0
- data/lib/nanoc/extra/vcses/dummy.rb +24 -0
- data/lib/nanoc/extra/vcses/git.rb +25 -0
- data/lib/nanoc/extra/vcses/mercurial.rb +25 -0
- data/lib/nanoc/extra/vcses/subversion.rb +25 -0
- data/lib/nanoc/filters.rb +59 -0
- data/lib/nanoc/filters/asciidoc.rb +38 -0
- data/lib/nanoc/filters/bluecloth.rb +19 -0
- data/lib/nanoc/filters/coderay.rb +21 -0
- data/lib/nanoc/filters/coffeescript.rb +20 -0
- data/lib/nanoc/filters/colorize_syntax.rb +298 -0
- data/lib/nanoc/filters/erb.rb +38 -0
- data/lib/nanoc/filters/erubis.rb +34 -0
- data/lib/nanoc/filters/haml.rb +27 -0
- data/lib/nanoc/filters/kramdown.rb +20 -0
- data/lib/nanoc/filters/less.rb +53 -0
- data/lib/nanoc/filters/markaby.rb +20 -0
- data/lib/nanoc/filters/maruku.rb +20 -0
- data/lib/nanoc/filters/mustache.rb +24 -0
- data/lib/nanoc/filters/rainpress.rb +19 -0
- data/lib/nanoc/filters/rdiscount.rb +22 -0
- data/lib/nanoc/filters/rdoc.rb +33 -0
- data/lib/nanoc/filters/redcarpet.rb +62 -0
- data/lib/nanoc/filters/redcloth.rb +47 -0
- data/lib/nanoc/filters/relativize_paths.rb +94 -0
- data/lib/nanoc/filters/rubypants.rb +20 -0
- data/lib/nanoc/filters/sass.rb +74 -0
- data/lib/nanoc/filters/slim.rb +25 -0
- data/lib/nanoc/filters/typogruby.rb +23 -0
- data/lib/nanoc/filters/uglify_js.rb +42 -0
- data/lib/nanoc/filters/xsl.rb +46 -0
- data/lib/nanoc/filters/yui_compressor.rb +23 -0
- data/lib/nanoc/helpers.rb +16 -0
- data/lib/nanoc/helpers/blogging.rb +319 -0
- data/lib/nanoc/helpers/breadcrumbs.rb +40 -0
- data/lib/nanoc/helpers/capturing.rb +138 -0
- data/lib/nanoc/helpers/filtering.rb +50 -0
- data/lib/nanoc/helpers/html_escape.rb +55 -0
- data/lib/nanoc/helpers/link_to.rb +151 -0
- data/lib/nanoc/helpers/rendering.rb +140 -0
- data/lib/nanoc/helpers/tagging.rb +71 -0
- data/lib/nanoc/helpers/text.rb +44 -0
- data/lib/nanoc/helpers/xml_sitemap.rb +76 -0
- data/lib/nanoc/tasks.rb +10 -0
- data/lib/nanoc/tasks/clean.rake +16 -0
- data/lib/nanoc/tasks/clean.rb +29 -0
- data/lib/nanoc/tasks/deploy/rsync.rake +16 -0
- data/lib/nanoc/tasks/validate.rake +92 -0
- data/nanoc.gemspec +49 -0
- data/tasks/doc.rake +16 -0
- data/tasks/test.rake +46 -0
- data/test/base/core_ext/array_spec.rb +73 -0
- data/test/base/core_ext/hash_spec.rb +98 -0
- data/test/base/core_ext/pathname_spec.rb +27 -0
- data/test/base/core_ext/string_spec.rb +37 -0
- data/test/base/test_checksum_store.rb +35 -0
- data/test/base/test_code_snippet.rb +31 -0
- data/test/base/test_compiler.rb +403 -0
- data/test/base/test_compiler_dsl.rb +161 -0
- data/test/base/test_context.rb +31 -0
- data/test/base/test_data_source.rb +46 -0
- data/test/base/test_dependency_tracker.rb +262 -0
- data/test/base/test_directed_graph.rb +288 -0
- data/test/base/test_filter.rb +83 -0
- data/test/base/test_item.rb +179 -0
- data/test/base/test_item_rep.rb +579 -0
- data/test/base/test_layout.rb +59 -0
- data/test/base/test_memoization.rb +90 -0
- data/test/base/test_notification_center.rb +34 -0
- data/test/base/test_outdatedness_checker.rb +394 -0
- data/test/base/test_plugin.rb +30 -0
- data/test/base/test_rule.rb +19 -0
- data/test/base/test_rule_context.rb +65 -0
- data/test/base/test_site.rb +190 -0
- data/test/cli/commands/test_compile.rb +33 -0
- data/test/cli/commands/test_create_item.rb +14 -0
- data/test/cli/commands/test_create_layout.rb +28 -0
- data/test/cli/commands/test_create_site.rb +24 -0
- data/test/cli/commands/test_deploy.rb +74 -0
- data/test/cli/commands/test_help.rb +12 -0
- data/test/cli/commands/test_info.rb +11 -0
- data/test/cli/commands/test_prune.rb +98 -0
- data/test/cli/commands/test_update.rb +10 -0
- data/test/cli/test_cli.rb +102 -0
- data/test/cli/test_error_handler.rb +29 -0
- data/test/cli/test_logger.rb +10 -0
- data/test/data_sources/test_filesystem.rb +433 -0
- data/test/data_sources/test_filesystem_unified.rb +536 -0
- data/test/data_sources/test_filesystem_verbose.rb +357 -0
- data/test/extra/core_ext/test_enumerable.rb +30 -0
- data/test/extra/core_ext/test_pathname.rb +17 -0
- data/test/extra/core_ext/test_time.rb +15 -0
- data/test/extra/deployers/test_fog.rb +67 -0
- data/test/extra/deployers/test_rsync.rb +100 -0
- data/test/extra/test_auto_compiler.rb +417 -0
- data/test/extra/test_file_proxy.rb +19 -0
- data/test/extra/test_vcs.rb +22 -0
- data/test/extra/validators/test_links.rb +62 -0
- data/test/extra/validators/test_w3c.rb +47 -0
- data/test/filters/test_asciidoc.rb +22 -0
- data/test/filters/test_bluecloth.rb +18 -0
- data/test/filters/test_coderay.rb +44 -0
- data/test/filters/test_coffeescript.rb +18 -0
- data/test/filters/test_colorize_syntax.rb +379 -0
- data/test/filters/test_erb.rb +105 -0
- data/test/filters/test_erubis.rb +78 -0
- data/test/filters/test_haml.rb +96 -0
- data/test/filters/test_kramdown.rb +18 -0
- data/test/filters/test_less.rb +113 -0
- data/test/filters/test_markaby.rb +24 -0
- data/test/filters/test_maruku.rb +18 -0
- data/test/filters/test_mustache.rb +25 -0
- data/test/filters/test_rainpress.rb +29 -0
- data/test/filters/test_rdiscount.rb +31 -0
- data/test/filters/test_rdoc.rb +18 -0
- data/test/filters/test_redcarpet.rb +73 -0
- data/test/filters/test_redcloth.rb +33 -0
- data/test/filters/test_relativize_paths.rb +533 -0
- data/test/filters/test_rubypants.rb +18 -0
- data/test/filters/test_sass.rb +229 -0
- data/test/filters/test_slim.rb +35 -0
- data/test/filters/test_typogruby.rb +21 -0
- data/test/filters/test_uglify_js.rb +30 -0
- data/test/filters/test_xsl.rb +105 -0
- data/test/filters/test_yui_compressor.rb +44 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +207 -0
- data/test/helpers/test_blogging.rb +754 -0
- data/test/helpers/test_breadcrumbs.rb +81 -0
- data/test/helpers/test_capturing.rb +41 -0
- data/test/helpers/test_filtering.rb +106 -0
- data/test/helpers/test_html_escape.rb +32 -0
- data/test/helpers/test_link_to.rb +249 -0
- data/test/helpers/test_rendering.rb +89 -0
- data/test/helpers/test_tagging.rb +87 -0
- data/test/helpers/test_text.rb +24 -0
- data/test/helpers/test_xml_sitemap.rb +103 -0
- data/test/tasks/test_clean.rb +67 -0
- metadata +327 -15
- data/bin/nanoc-select +0 -86
- data/lib/nanoc-select.rb +0 -11
@@ -0,0 +1,117 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
usage 'debug'
|
4
|
+
summary 'show debug information for this site'
|
5
|
+
description <<-EOS
|
6
|
+
Show information about all items, item representations and layouts in the
|
7
|
+
current site.
|
8
|
+
EOS
|
9
|
+
|
10
|
+
module Nanoc::CLI::Commands
|
11
|
+
|
12
|
+
class Debug < ::Nanoc::CLI::CommandRunner
|
13
|
+
|
14
|
+
def run
|
15
|
+
# Make sure we are in a nanoc site directory
|
16
|
+
print "Loading site data... "
|
17
|
+
self.require_site
|
18
|
+
puts "done"
|
19
|
+
puts
|
20
|
+
|
21
|
+
# Get data
|
22
|
+
items = self.site.items
|
23
|
+
reps = items.map { |i| i.reps }.flatten
|
24
|
+
layouts = self.site.layouts
|
25
|
+
|
26
|
+
# Get dependency tracker
|
27
|
+
compiler = self.site.compiler
|
28
|
+
compiler.load
|
29
|
+
dependency_tracker = compiler.dependency_tracker
|
30
|
+
|
31
|
+
# Print item dependencies
|
32
|
+
puts '=== Item dependencies ======================================================='
|
33
|
+
puts
|
34
|
+
items.sort_by { |i| i.identifier }.each do |item|
|
35
|
+
puts "item #{item.identifier} depends on:"
|
36
|
+
predecessors = dependency_tracker.objects_causing_outdatedness_of(item).sort_by { |i| i ? i.identifier : '' }
|
37
|
+
predecessors.each do |pred|
|
38
|
+
if pred
|
39
|
+
puts " [ #{format '%6s', pred.type} ] #{pred.identifier}"
|
40
|
+
else
|
41
|
+
puts " ( removed item )"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
puts " (nothing)" if predecessors.empty?
|
45
|
+
puts
|
46
|
+
end
|
47
|
+
|
48
|
+
# Print representation paths
|
49
|
+
puts '=== Representation paths ===================================================='
|
50
|
+
puts
|
51
|
+
items.sort_by { |i| i.identifier }.each do |item|
|
52
|
+
item.reps.sort_by { |r| r.name.to_s }.each do |rep|
|
53
|
+
puts "item #{item.identifier}, rep #{rep.name}:"
|
54
|
+
if rep.raw_paths.empty?
|
55
|
+
puts " (not written)"
|
56
|
+
end
|
57
|
+
length = rep.raw_paths.keys.map { |s| s.to_s.length }.max
|
58
|
+
rep.raw_paths.each do |snapshot_name, raw_path|
|
59
|
+
puts " [ %-#{length}s ] %s" % [ snapshot_name, raw_path ]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
puts
|
63
|
+
end
|
64
|
+
|
65
|
+
# Print representation outdatedness
|
66
|
+
puts '=== Representation outdatedness ============================================='
|
67
|
+
puts
|
68
|
+
items.sort_by { |i| i.identifier }.each do |item|
|
69
|
+
item.reps.sort_by { |r| r.name.to_s }.each do |rep|
|
70
|
+
puts "item #{item.identifier}, rep #{rep.name}:"
|
71
|
+
outdatedness_reason = compiler.outdatedness_checker.outdatedness_reason_for(rep)
|
72
|
+
if outdatedness_reason
|
73
|
+
puts " is outdated: #{outdatedness_reason.message}"
|
74
|
+
else
|
75
|
+
puts " is not outdated"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
puts
|
79
|
+
end
|
80
|
+
|
81
|
+
# Print layout dependencies
|
82
|
+
puts '=== Layout dependencies ====================================================='
|
83
|
+
puts
|
84
|
+
layouts.sort_by { |l| l.identifier }.each do |layout|
|
85
|
+
puts "layout #{layout.identifier} depends on:"
|
86
|
+
predecessors = dependency_tracker.objects_causing_outdatedness_of(layout).sort_by { |i| i ? i.identifier : '' }
|
87
|
+
predecessors.each do |pred|
|
88
|
+
if pred
|
89
|
+
puts " [ #{format '%6s', pred.type} ] #{pred.identifier}"
|
90
|
+
else
|
91
|
+
puts " ( removed item )"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
puts " (nothing)" if predecessors.empty?
|
95
|
+
puts
|
96
|
+
end
|
97
|
+
|
98
|
+
# Print layouts
|
99
|
+
puts '=== Layouts'
|
100
|
+
puts
|
101
|
+
layouts.sort_by { |l| l.identifier }.each do |layout|
|
102
|
+
puts "layout #{layout.identifier}:"
|
103
|
+
outdatedness_reason = compiler.outdatedness_checker.outdatedness_reason_for(layout)
|
104
|
+
if outdatedness_reason
|
105
|
+
puts " is outdated: #{outdatedness_reason.message}"
|
106
|
+
else
|
107
|
+
puts " is not outdated"
|
108
|
+
end
|
109
|
+
puts
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
runner Nanoc::CLI::Commands::Debug
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Find all
|
4
|
+
registry = Nanoc::PluginRegistry.instance
|
5
|
+
deployer_class = Nanoc::Extra::Deployer
|
6
|
+
deployers = registry.find_all(deployer_class)
|
7
|
+
deployer_names = deployers.keys.sort_by { |k| k.to_s }
|
8
|
+
|
9
|
+
usage 'deploy [options]'
|
10
|
+
summary 'deploy the compiled site'
|
11
|
+
description <<-EOS
|
12
|
+
Deploys the compiled site. The compiled site contents in the output directory will be uploaded to the destination, which is specified using the -t/--target option.
|
13
|
+
|
14
|
+
Available deployers: #{deployer_names.join(', ')}
|
15
|
+
|
16
|
+
EOS
|
17
|
+
|
18
|
+
option :t, :target, 'specify the location to deploy to', :argument => :required
|
19
|
+
flag :l, :list, 'list available locations to deploy to'
|
20
|
+
option :n, :'dry-run', 'show what would be deployed'
|
21
|
+
|
22
|
+
module Nanoc::CLI::Commands
|
23
|
+
|
24
|
+
class Deploy < ::Nanoc::CLI::CommandRunner
|
25
|
+
|
26
|
+
def run
|
27
|
+
require_site
|
28
|
+
|
29
|
+
# Get config
|
30
|
+
deploy_configs = site.config.fetch(:deploy) do
|
31
|
+
$stderr.puts "The site configuration has no deploy configuration."
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
|
35
|
+
# List
|
36
|
+
if options[:list]
|
37
|
+
puts "Available deployment configurations:"
|
38
|
+
deploy_configs.keys.each do |name|
|
39
|
+
puts " #{name}"
|
40
|
+
end
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get target
|
45
|
+
target = options.fetch(:target) do
|
46
|
+
$stderr.puts "The deploy command requires a --target option."
|
47
|
+
exit 1
|
48
|
+
end
|
49
|
+
target = target.to_sym
|
50
|
+
config = deploy_configs.fetch(target) do
|
51
|
+
$stderr.puts "The site configuration has no deploy configuration for #{target}."
|
52
|
+
exit 1
|
53
|
+
end
|
54
|
+
|
55
|
+
# Get deployer
|
56
|
+
name = config.fetch(:kind) do
|
57
|
+
$stderr.puts "The specified deploy target does not have a kind."
|
58
|
+
$stderr.puts "(expected one of #{KIND_MAPPING.keys.join(', ')})"
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
deployer_class = Nanoc::Extra::Deployer.named(name) do
|
62
|
+
$stderr.puts "The specified deploy target has an unrecognised kind (#{kind})."
|
63
|
+
$stderr.puts "(expected one of #{KIND_MAPPING.keys.join(', ')})"
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
|
67
|
+
# Run
|
68
|
+
deployer = deployer_class.new(
|
69
|
+
site.config[:output_dir],
|
70
|
+
config,
|
71
|
+
:dry_run => options[:'dry-run'])
|
72
|
+
deployer.run
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
runner Nanoc::CLI::Commands::Deploy
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
summary 'show info about available plugins'
|
4
|
+
usage 'info [options]'
|
5
|
+
description <<-EOS
|
6
|
+
Show a list of available plugins, including filters, data sources and VCSes.
|
7
|
+
If the current directory contains a nanoc web site, the plugins defined in this site will be shown as well.
|
8
|
+
EOS
|
9
|
+
|
10
|
+
module Nanoc::CLI::Commands
|
11
|
+
|
12
|
+
class Info < ::Nanoc::CLI::CommandRunner
|
13
|
+
|
14
|
+
def run
|
15
|
+
# Check arguments
|
16
|
+
if arguments.size != 0
|
17
|
+
$stderr.puts "usage: #{command.usage}"
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get list of plugins (before and after)
|
22
|
+
plugins_before = Nanoc::Plugin.all
|
23
|
+
self.site.code_snippets if self.site
|
24
|
+
plugins_after = Nanoc::Plugin.all
|
25
|
+
|
26
|
+
# Divide list of plugins into builtin and custom
|
27
|
+
plugins_builtin = plugins_before
|
28
|
+
plugins_custom = plugins_after - plugins_before
|
29
|
+
|
30
|
+
# Find max identifiers length
|
31
|
+
plugin_with_longest_identifiers = plugins_after.inject do |longest, current|
|
32
|
+
longest[:identifiers].join(', ').size > current[:identifiers].join(', ').size ? longest : current
|
33
|
+
end
|
34
|
+
max_identifiers_length = plugin_with_longest_identifiers[:identifiers].join(', ').size
|
35
|
+
|
36
|
+
PLUGIN_CLASS_ORDER.each do |superclass|
|
37
|
+
plugins_with_this_superclass = {
|
38
|
+
:builtin => plugins_builtin.select { |p| p[:superclass] == superclass },
|
39
|
+
:custom => plugins_custom.select { |p| p[:superclass] == superclass }
|
40
|
+
}
|
41
|
+
|
42
|
+
# Print kind
|
43
|
+
kind = name_for_plugin_class(superclass)
|
44
|
+
puts "#{kind}:"
|
45
|
+
puts
|
46
|
+
|
47
|
+
# Print plugins organised by subtype
|
48
|
+
[ :builtin, :custom ].each do |type|
|
49
|
+
# Find relevant plugins
|
50
|
+
relevant_plugins = plugins_with_this_superclass[type]
|
51
|
+
|
52
|
+
# Print type
|
53
|
+
puts " #{type}:"
|
54
|
+
if relevant_plugins.empty?
|
55
|
+
puts " (none)"
|
56
|
+
next
|
57
|
+
end
|
58
|
+
|
59
|
+
# Print plugins
|
60
|
+
relevant_plugins.sort_by { |k| k[:identifiers].join(', ') }.each do |plugin|
|
61
|
+
# Display
|
62
|
+
puts sprintf(
|
63
|
+
" %-#{max_identifiers_length}s (%s)",
|
64
|
+
plugin[:identifiers].join(', '),
|
65
|
+
plugin[:class].to_s.sub(/^::/, '')
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
puts
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
PLUGIN_CLASS_ORDER = [
|
77
|
+
Nanoc::Filter,
|
78
|
+
Nanoc::Extra::VCS,
|
79
|
+
Nanoc::DataSource,
|
80
|
+
Nanoc::Extra::Deployer
|
81
|
+
]
|
82
|
+
|
83
|
+
PLUGIN_CLASSES = {
|
84
|
+
Nanoc::Filter => 'Filters',
|
85
|
+
Nanoc::DataSource => 'Data Sources',
|
86
|
+
Nanoc::Extra::VCS => 'VCSes',
|
87
|
+
Nanoc::Extra::Deployer => 'Deployers'
|
88
|
+
}
|
89
|
+
|
90
|
+
def name_for_plugin_class(klass)
|
91
|
+
PLUGIN_CLASSES[klass]
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
runner Nanoc::CLI::Commands::Info
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
usage 'nanoc command [options] [arguments]'
|
4
|
+
summary 'nanoc, a static site compiler written in Ruby'
|
5
|
+
|
6
|
+
opt :l, :color, 'enable color' do
|
7
|
+
Nanoc::CLI::Logger.instance.color = true
|
8
|
+
end
|
9
|
+
|
10
|
+
opt :d, :debug, 'enable debugging' do
|
11
|
+
Nanoc::CLI.debug = true
|
12
|
+
end
|
13
|
+
|
14
|
+
opt :h, :help, 'show the help message and quit' do |value, cmd|
|
15
|
+
puts cmd.help
|
16
|
+
exit 0
|
17
|
+
end
|
18
|
+
|
19
|
+
opt :C, :'no-color', 'disable color' do
|
20
|
+
Nanoc::CLI::Logger.instance.color = false
|
21
|
+
end
|
22
|
+
|
23
|
+
opt :V, :verbose, 'make nanoc output more detailed' do
|
24
|
+
Nanoc::CLI::Logger.instance.level = :low
|
25
|
+
end
|
26
|
+
|
27
|
+
opt :v, :version, 'show version information and quit' do
|
28
|
+
puts Nanoc.version_information
|
29
|
+
exit 0
|
30
|
+
end
|
31
|
+
|
32
|
+
opt :w, :warn, 'enable warnings' do
|
33
|
+
$-w = true
|
34
|
+
end
|
35
|
+
|
36
|
+
run do |opts, args, cmd|
|
37
|
+
cmd.command_named('compile').run([])
|
38
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
usage 'prune'
|
4
|
+
summary 'removes files not managed by nanoc from the output directory'
|
5
|
+
description <<-EOS
|
6
|
+
Find all files in the output directory that do not correspond to an item
|
7
|
+
managed by nanoc and remove them. Since this is a hazardous operation, an
|
8
|
+
additional --yes flag is needed as confirmation.
|
9
|
+
|
10
|
+
Also see the auto_prune site configuration option in config.yaml, which will
|
11
|
+
automatically prune after compilation.
|
12
|
+
EOS
|
13
|
+
|
14
|
+
flag :y, :yes, 'confirm deletion'
|
15
|
+
flag :n, :'dry-run', 'print files to be deleted instead of actually deleting them'
|
16
|
+
|
17
|
+
module Nanoc::CLI::Commands
|
18
|
+
|
19
|
+
class Prune < ::Nanoc::CLI::CommandRunner
|
20
|
+
|
21
|
+
def run
|
22
|
+
require_site
|
23
|
+
|
24
|
+
if options.has_key?(:yes)
|
25
|
+
Nanoc::Extra::Pruner.new(self.site, :exclude => self.prune_config_exclude).run
|
26
|
+
elsif options.has_key?(:'dry-run')
|
27
|
+
Nanoc::Extra::Pruner.new(self.site, :exclude => self.prune_config_exclude, :dry_run => true).run
|
28
|
+
else
|
29
|
+
$stderr.puts "WARNING: Since the prune command is a destructive command, it requires an additional --yes flag in order to work."
|
30
|
+
$stderr.puts
|
31
|
+
$stderr.puts "Please ensure that the output directory does not contain any files (such as images or stylesheets) that are necessary but are not managed by nanoc. If you want to get a list of all files that would be removed, pass --dry-run."
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
def prune_config
|
39
|
+
self.site.config[:prune] || {}
|
40
|
+
end
|
41
|
+
|
42
|
+
def prune_config_exclude
|
43
|
+
self.prune_config[:exclude] || {}
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
runner Nanoc::CLI::Commands::Prune
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
usage 'update [options]'
|
4
|
+
summary 'update the data stored by the data source to a newer version'
|
5
|
+
description <<-EOS
|
6
|
+
Update the data stored by the data source to a newer format. The format in
|
7
|
+
which data is stored can change between releases, and even though backward
|
8
|
+
compatibility is usually preserved, it is often a good idea to store the site
|
9
|
+
data in a newer format so newer features can be taken advantage of.
|
10
|
+
|
11
|
+
This command will change data, and it is therefore recommended to make a
|
12
|
+
backup in case something goes wrong.
|
13
|
+
EOS
|
14
|
+
|
15
|
+
required :c, :vcs, 'select the VCS to use'
|
16
|
+
flag :y, :yes, 'update the data without warning'
|
17
|
+
|
18
|
+
module Nanoc::CLI::Commands
|
19
|
+
|
20
|
+
class Update < ::Nanoc::CLI::CommandRunner
|
21
|
+
|
22
|
+
def run
|
23
|
+
# Check arguments
|
24
|
+
if arguments.size != 0
|
25
|
+
$stderr.puts "usage: #{command.usage}"
|
26
|
+
exit 1
|
27
|
+
end
|
28
|
+
|
29
|
+
# Make sure we are in a nanoc site directory
|
30
|
+
self.require_site
|
31
|
+
|
32
|
+
# Set VCS if possible
|
33
|
+
self.set_vcs(options[:vcs])
|
34
|
+
|
35
|
+
# Check for -y switch
|
36
|
+
unless options.has_key?(:yes)
|
37
|
+
$stderr.puts '*************'
|
38
|
+
$stderr.puts '** WARNING **'
|
39
|
+
$stderr.puts '*************'
|
40
|
+
$stderr.puts
|
41
|
+
$stderr.puts 'Are you absolutely sure you want to update the ' +
|
42
|
+
'content for this site? Updating the site content ' +
|
43
|
+
'will change the structure of existing data. This ' +
|
44
|
+
'operation is destructive and cannot be reverted. ' +
|
45
|
+
'Please do not interrupt this operation; doing so can ' +
|
46
|
+
'result in data loss. As always, consider making a ' +
|
47
|
+
'backup copy.'
|
48
|
+
$stderr.puts
|
49
|
+
$stderr.puts 'If this nanoc site is versioned using a VCS ' +
|
50
|
+
'supported by nanoc, consider using the --vcs option ' +
|
51
|
+
'to have nanoc perform add/delete/move operations ' +
|
52
|
+
'using the specified VCS. To get a list of VCSes ' +
|
53
|
+
'supported by nanoc, issue the "info" command.'
|
54
|
+
$stderr.puts
|
55
|
+
$stderr.puts 'To continue, use the -y/--yes option, like "nanoc ' +
|
56
|
+
'update -y".'
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
|
60
|
+
# Update
|
61
|
+
self.site.data_sources.each do |data_source|
|
62
|
+
data_source.update
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
runner Nanoc::CLI::Commands::Update
|