nanoc 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. data/.gemtest +0 -0
  2. data/ChangeLog +3 -0
  3. data/Gemfile +32 -0
  4. data/LICENSE +19 -0
  5. data/NEWS.md +470 -0
  6. data/README.md +114 -0
  7. data/Rakefile +14 -0
  8. data/bin/nanoc +7 -27
  9. data/bin/nanoc3 +3 -0
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
  11. data/lib/nanoc.rb +41 -0
  12. data/lib/nanoc/base.rb +49 -0
  13. data/lib/nanoc/base/compilation/checksum_store.rb +57 -0
  14. data/lib/nanoc/base/compilation/compiled_content_cache.rb +62 -0
  15. data/lib/nanoc/base/compilation/compiler.rb +458 -0
  16. data/lib/nanoc/base/compilation/compiler_dsl.rb +214 -0
  17. data/lib/nanoc/base/compilation/dependency_tracker.rb +200 -0
  18. data/lib/nanoc/base/compilation/filter.rb +165 -0
  19. data/lib/nanoc/base/compilation/item_rep_proxy.rb +103 -0
  20. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +102 -0
  21. data/lib/nanoc/base/compilation/outdatedness_checker.rb +223 -0
  22. data/lib/nanoc/base/compilation/outdatedness_reasons.rb +46 -0
  23. data/lib/nanoc/base/compilation/rule.rb +73 -0
  24. data/lib/nanoc/base/compilation/rule_context.rb +84 -0
  25. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +40 -0
  26. data/lib/nanoc/base/compilation/rule_memory_store.rb +53 -0
  27. data/lib/nanoc/base/compilation/rules_collection.rb +243 -0
  28. data/lib/nanoc/base/context.rb +47 -0
  29. data/lib/nanoc/base/core_ext.rb +6 -0
  30. data/lib/nanoc/base/core_ext/array.rb +62 -0
  31. data/lib/nanoc/base/core_ext/hash.rb +63 -0
  32. data/lib/nanoc/base/core_ext/pathname.rb +26 -0
  33. data/lib/nanoc/base/core_ext/string.rb +46 -0
  34. data/lib/nanoc/base/directed_graph.rb +275 -0
  35. data/lib/nanoc/base/errors.rb +211 -0
  36. data/lib/nanoc/base/memoization.rb +67 -0
  37. data/lib/nanoc/base/notification_center.rb +84 -0
  38. data/lib/nanoc/base/ordered_hash.rb +200 -0
  39. data/lib/nanoc/base/plugin_registry.rb +181 -0
  40. data/lib/nanoc/base/result_data/item_rep.rb +492 -0
  41. data/lib/nanoc/base/source_data/code_snippet.rb +58 -0
  42. data/lib/nanoc/base/source_data/configuration.rb +24 -0
  43. data/lib/nanoc/base/source_data/data_source.rb +234 -0
  44. data/lib/nanoc/base/source_data/item.rb +301 -0
  45. data/lib/nanoc/base/source_data/layout.rb +130 -0
  46. data/lib/nanoc/base/source_data/site.rb +361 -0
  47. data/lib/nanoc/base/store.rb +135 -0
  48. data/lib/nanoc/cli.rb +137 -0
  49. data/lib/nanoc/cli/command_runner.rb +104 -0
  50. data/lib/nanoc/cli/commands/autocompile.rb +58 -0
  51. data/lib/nanoc/cli/commands/compile.rb +297 -0
  52. data/lib/nanoc/cli/commands/create_item.rb +60 -0
  53. data/lib/nanoc/cli/commands/create_layout.rb +73 -0
  54. data/lib/nanoc/cli/commands/create_site.rb +411 -0
  55. data/lib/nanoc/cli/commands/debug.rb +117 -0
  56. data/lib/nanoc/cli/commands/deploy.rb +79 -0
  57. data/lib/nanoc/cli/commands/info.rb +98 -0
  58. data/lib/nanoc/cli/commands/nanoc.rb +38 -0
  59. data/lib/nanoc/cli/commands/prune.rb +50 -0
  60. data/lib/nanoc/cli/commands/update.rb +70 -0
  61. data/lib/nanoc/cli/commands/view.rb +82 -0
  62. data/lib/nanoc/cli/commands/watch.rb +124 -0
  63. data/lib/nanoc/cli/error_handler.rb +199 -0
  64. data/lib/nanoc/cli/logger.rb +92 -0
  65. data/lib/nanoc/data_sources.rb +29 -0
  66. data/lib/nanoc/data_sources/deprecated/delicious.rb +42 -0
  67. data/lib/nanoc/data_sources/deprecated/last_fm.rb +87 -0
  68. data/lib/nanoc/data_sources/deprecated/twitter.rb +38 -0
  69. data/lib/nanoc/data_sources/filesystem.rb +299 -0
  70. data/lib/nanoc/data_sources/filesystem_unified.rb +121 -0
  71. data/lib/nanoc/data_sources/filesystem_verbose.rb +91 -0
  72. data/lib/nanoc/extra.rb +24 -0
  73. data/lib/nanoc/extra/auto_compiler.rb +103 -0
  74. data/lib/nanoc/extra/chick.rb +125 -0
  75. data/lib/nanoc/extra/core_ext.rb +6 -0
  76. data/lib/nanoc/extra/core_ext/enumerable.rb +33 -0
  77. data/lib/nanoc/extra/core_ext/pathname.rb +30 -0
  78. data/lib/nanoc/extra/core_ext/time.rb +19 -0
  79. data/lib/nanoc/extra/deployer.rb +47 -0
  80. data/lib/nanoc/extra/deployers.rb +15 -0
  81. data/lib/nanoc/extra/deployers/fog.rb +98 -0
  82. data/lib/nanoc/extra/deployers/rsync.rb +70 -0
  83. data/lib/nanoc/extra/file_proxy.rb +40 -0
  84. data/lib/nanoc/extra/pruner.rb +86 -0
  85. data/lib/nanoc/extra/validators.rb +12 -0
  86. data/lib/nanoc/extra/validators/links.rb +268 -0
  87. data/lib/nanoc/extra/validators/w3c.rb +95 -0
  88. data/lib/nanoc/extra/vcs.rb +66 -0
  89. data/lib/nanoc/extra/vcses.rb +17 -0
  90. data/lib/nanoc/extra/vcses/bazaar.rb +25 -0
  91. data/lib/nanoc/extra/vcses/dummy.rb +24 -0
  92. data/lib/nanoc/extra/vcses/git.rb +25 -0
  93. data/lib/nanoc/extra/vcses/mercurial.rb +25 -0
  94. data/lib/nanoc/extra/vcses/subversion.rb +25 -0
  95. data/lib/nanoc/filters.rb +59 -0
  96. data/lib/nanoc/filters/asciidoc.rb +38 -0
  97. data/lib/nanoc/filters/bluecloth.rb +19 -0
  98. data/lib/nanoc/filters/coderay.rb +21 -0
  99. data/lib/nanoc/filters/coffeescript.rb +20 -0
  100. data/lib/nanoc/filters/colorize_syntax.rb +298 -0
  101. data/lib/nanoc/filters/erb.rb +38 -0
  102. data/lib/nanoc/filters/erubis.rb +34 -0
  103. data/lib/nanoc/filters/haml.rb +27 -0
  104. data/lib/nanoc/filters/kramdown.rb +20 -0
  105. data/lib/nanoc/filters/less.rb +53 -0
  106. data/lib/nanoc/filters/markaby.rb +20 -0
  107. data/lib/nanoc/filters/maruku.rb +20 -0
  108. data/lib/nanoc/filters/mustache.rb +24 -0
  109. data/lib/nanoc/filters/rainpress.rb +19 -0
  110. data/lib/nanoc/filters/rdiscount.rb +22 -0
  111. data/lib/nanoc/filters/rdoc.rb +33 -0
  112. data/lib/nanoc/filters/redcarpet.rb +62 -0
  113. data/lib/nanoc/filters/redcloth.rb +47 -0
  114. data/lib/nanoc/filters/relativize_paths.rb +94 -0
  115. data/lib/nanoc/filters/rubypants.rb +20 -0
  116. data/lib/nanoc/filters/sass.rb +74 -0
  117. data/lib/nanoc/filters/slim.rb +25 -0
  118. data/lib/nanoc/filters/typogruby.rb +23 -0
  119. data/lib/nanoc/filters/uglify_js.rb +42 -0
  120. data/lib/nanoc/filters/xsl.rb +46 -0
  121. data/lib/nanoc/filters/yui_compressor.rb +23 -0
  122. data/lib/nanoc/helpers.rb +16 -0
  123. data/lib/nanoc/helpers/blogging.rb +319 -0
  124. data/lib/nanoc/helpers/breadcrumbs.rb +40 -0
  125. data/lib/nanoc/helpers/capturing.rb +138 -0
  126. data/lib/nanoc/helpers/filtering.rb +50 -0
  127. data/lib/nanoc/helpers/html_escape.rb +55 -0
  128. data/lib/nanoc/helpers/link_to.rb +151 -0
  129. data/lib/nanoc/helpers/rendering.rb +140 -0
  130. data/lib/nanoc/helpers/tagging.rb +71 -0
  131. data/lib/nanoc/helpers/text.rb +44 -0
  132. data/lib/nanoc/helpers/xml_sitemap.rb +76 -0
  133. data/lib/nanoc/tasks.rb +10 -0
  134. data/lib/nanoc/tasks/clean.rake +16 -0
  135. data/lib/nanoc/tasks/clean.rb +29 -0
  136. data/lib/nanoc/tasks/deploy/rsync.rake +16 -0
  137. data/lib/nanoc/tasks/validate.rake +92 -0
  138. data/nanoc.gemspec +49 -0
  139. data/tasks/doc.rake +16 -0
  140. data/tasks/test.rake +46 -0
  141. data/test/base/core_ext/array_spec.rb +73 -0
  142. data/test/base/core_ext/hash_spec.rb +98 -0
  143. data/test/base/core_ext/pathname_spec.rb +27 -0
  144. data/test/base/core_ext/string_spec.rb +37 -0
  145. data/test/base/test_checksum_store.rb +35 -0
  146. data/test/base/test_code_snippet.rb +31 -0
  147. data/test/base/test_compiler.rb +403 -0
  148. data/test/base/test_compiler_dsl.rb +161 -0
  149. data/test/base/test_context.rb +31 -0
  150. data/test/base/test_data_source.rb +46 -0
  151. data/test/base/test_dependency_tracker.rb +262 -0
  152. data/test/base/test_directed_graph.rb +288 -0
  153. data/test/base/test_filter.rb +83 -0
  154. data/test/base/test_item.rb +179 -0
  155. data/test/base/test_item_rep.rb +579 -0
  156. data/test/base/test_layout.rb +59 -0
  157. data/test/base/test_memoization.rb +90 -0
  158. data/test/base/test_notification_center.rb +34 -0
  159. data/test/base/test_outdatedness_checker.rb +394 -0
  160. data/test/base/test_plugin.rb +30 -0
  161. data/test/base/test_rule.rb +19 -0
  162. data/test/base/test_rule_context.rb +65 -0
  163. data/test/base/test_site.rb +190 -0
  164. data/test/cli/commands/test_compile.rb +33 -0
  165. data/test/cli/commands/test_create_item.rb +14 -0
  166. data/test/cli/commands/test_create_layout.rb +28 -0
  167. data/test/cli/commands/test_create_site.rb +24 -0
  168. data/test/cli/commands/test_deploy.rb +74 -0
  169. data/test/cli/commands/test_help.rb +12 -0
  170. data/test/cli/commands/test_info.rb +11 -0
  171. data/test/cli/commands/test_prune.rb +98 -0
  172. data/test/cli/commands/test_update.rb +10 -0
  173. data/test/cli/test_cli.rb +102 -0
  174. data/test/cli/test_error_handler.rb +29 -0
  175. data/test/cli/test_logger.rb +10 -0
  176. data/test/data_sources/test_filesystem.rb +433 -0
  177. data/test/data_sources/test_filesystem_unified.rb +536 -0
  178. data/test/data_sources/test_filesystem_verbose.rb +357 -0
  179. data/test/extra/core_ext/test_enumerable.rb +30 -0
  180. data/test/extra/core_ext/test_pathname.rb +17 -0
  181. data/test/extra/core_ext/test_time.rb +15 -0
  182. data/test/extra/deployers/test_fog.rb +67 -0
  183. data/test/extra/deployers/test_rsync.rb +100 -0
  184. data/test/extra/test_auto_compiler.rb +417 -0
  185. data/test/extra/test_file_proxy.rb +19 -0
  186. data/test/extra/test_vcs.rb +22 -0
  187. data/test/extra/validators/test_links.rb +62 -0
  188. data/test/extra/validators/test_w3c.rb +47 -0
  189. data/test/filters/test_asciidoc.rb +22 -0
  190. data/test/filters/test_bluecloth.rb +18 -0
  191. data/test/filters/test_coderay.rb +44 -0
  192. data/test/filters/test_coffeescript.rb +18 -0
  193. data/test/filters/test_colorize_syntax.rb +379 -0
  194. data/test/filters/test_erb.rb +105 -0
  195. data/test/filters/test_erubis.rb +78 -0
  196. data/test/filters/test_haml.rb +96 -0
  197. data/test/filters/test_kramdown.rb +18 -0
  198. data/test/filters/test_less.rb +113 -0
  199. data/test/filters/test_markaby.rb +24 -0
  200. data/test/filters/test_maruku.rb +18 -0
  201. data/test/filters/test_mustache.rb +25 -0
  202. data/test/filters/test_rainpress.rb +29 -0
  203. data/test/filters/test_rdiscount.rb +31 -0
  204. data/test/filters/test_rdoc.rb +18 -0
  205. data/test/filters/test_redcarpet.rb +73 -0
  206. data/test/filters/test_redcloth.rb +33 -0
  207. data/test/filters/test_relativize_paths.rb +533 -0
  208. data/test/filters/test_rubypants.rb +18 -0
  209. data/test/filters/test_sass.rb +229 -0
  210. data/test/filters/test_slim.rb +35 -0
  211. data/test/filters/test_typogruby.rb +21 -0
  212. data/test/filters/test_uglify_js.rb +30 -0
  213. data/test/filters/test_xsl.rb +105 -0
  214. data/test/filters/test_yui_compressor.rb +44 -0
  215. data/test/gem_loader.rb +11 -0
  216. data/test/helper.rb +207 -0
  217. data/test/helpers/test_blogging.rb +754 -0
  218. data/test/helpers/test_breadcrumbs.rb +81 -0
  219. data/test/helpers/test_capturing.rb +41 -0
  220. data/test/helpers/test_filtering.rb +106 -0
  221. data/test/helpers/test_html_escape.rb +32 -0
  222. data/test/helpers/test_link_to.rb +249 -0
  223. data/test/helpers/test_rendering.rb +89 -0
  224. data/test/helpers/test_tagging.rb +87 -0
  225. data/test/helpers/test_text.rb +24 -0
  226. data/test/helpers/test_xml_sitemap.rb +103 -0
  227. data/test/tasks/test_clean.rb +67 -0
  228. metadata +327 -15
  229. data/bin/nanoc-select +0 -86
  230. 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