nanoc3 3.2.4 → 3.3.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.
Files changed (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,119 +0,0 @@
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
- run do |opts, args, cmd|
11
- Nanoc3::CLI::Commands::Debug.call(opts, args, cmd)
12
- end
13
-
14
- module Nanoc3::CLI::Commands
15
-
16
- class Debug < ::Nanoc3::CLI::Command
17
-
18
- def run
19
- # Make sure we are in a nanoc site directory
20
- print "Loading site data... "
21
- self.require_site
22
- puts "done"
23
- puts
24
-
25
- # Get data
26
- items = self.site.items
27
- reps = items.map { |i| i.reps }.flatten
28
- layouts = self.site.layouts
29
-
30
- # Get dependency tracker
31
- compiler = self.site.compiler
32
- compiler.load
33
- dependency_tracker = compiler.dependency_tracker
34
-
35
- # Print item dependencies
36
- puts '=== Item dependencies ======================================================='
37
- puts
38
- items.sort_by { |i| i.identifier }.each do |item|
39
- puts "item #{item.identifier} depends on:"
40
- predecessors = dependency_tracker.objects_causing_outdatedness_of(item).sort_by { |i| i ? i.identifier : '' }
41
- predecessors.each do |pred|
42
- if pred
43
- puts " [ #{format '%6s', pred.type} ] #{pred.identifier}"
44
- else
45
- puts " ( removed item )"
46
- end
47
- end
48
- puts " (nothing)" if predecessors.empty?
49
- puts
50
- end
51
-
52
- # Print representation paths
53
- puts '=== Representation paths ===================================================='
54
- puts
55
- items.sort_by { |i| i.identifier }.each do |item|
56
- item.reps.sort_by { |r| r.name.to_s }.each do |rep|
57
- puts "item #{item.identifier}, rep #{rep.name}:"
58
- if rep.raw_paths.empty?
59
- puts " (not written)"
60
- end
61
- length = rep.raw_paths.keys.map { |s| s.to_s.length }.max
62
- rep.raw_paths.each do |snapshot_name, raw_path|
63
- puts " [ %-#{length}s ] %s" % [ snapshot_name, raw_path ]
64
- end
65
- end
66
- puts
67
- end
68
-
69
- # Print representation outdatedness
70
- puts '=== Representation outdatedness ============================================='
71
- puts
72
- items.sort_by { |i| i.identifier }.each do |item|
73
- item.reps.sort_by { |r| r.name.to_s }.each do |rep|
74
- puts "item #{item.identifier}, rep #{rep.name}:"
75
- outdatedness_reason = compiler.outdatedness_checker.outdatedness_reason_for(rep)
76
- if outdatedness_reason
77
- puts " is outdated: #{outdatedness_reason.message}"
78
- else
79
- puts " is not outdated"
80
- end
81
- end
82
- puts
83
- end
84
-
85
- # Print layout dependencies
86
- puts '=== Layout dependencies ====================================================='
87
- puts
88
- layouts.sort_by { |l| l.identifier }.each do |layout|
89
- puts "layout #{layout.identifier} depends on:"
90
- predecessors = dependency_tracker.objects_causing_outdatedness_of(layout).sort_by { |i| i ? i.identifier : '' }
91
- predecessors.each do |pred|
92
- if pred
93
- puts " [ #{format '%6s', pred.type} ] #{pred.identifier}"
94
- else
95
- puts " ( removed item )"
96
- end
97
- end
98
- puts " (nothing)" if predecessors.empty?
99
- puts
100
- end
101
-
102
- # Print layouts
103
- puts '=== Layouts'
104
- puts
105
- layouts.sort_by { |l| l.identifier }.each do |layout|
106
- puts "layout #{layout.identifier}:"
107
- outdatedness_reason = compiler.outdatedness_checker.outdatedness_reason_for(layout)
108
- if outdatedness_reason
109
- puts " is outdated: #{outdatedness_reason.message}"
110
- else
111
- puts " is not outdated"
112
- end
113
- puts
114
- end
115
- end
116
-
117
- end
118
-
119
- end
@@ -1,98 +0,0 @@
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
- run do |opts, args, cmd|
11
- Nanoc3::CLI::Commands::Info.call(opts, args, cmd)
12
- end
13
-
14
- module Nanoc3::CLI::Commands
15
-
16
- class Info < ::Nanoc3::CLI::Command
17
-
18
- def run
19
- # Check arguments
20
- if arguments.size != 0
21
- $stderr.puts "usage: #{command.usage}"
22
- exit 1
23
- end
24
-
25
- # Get list of plugins (before and after)
26
- plugins_before = Nanoc3::Plugin.all
27
- self.site.code_snippets if self.site
28
- plugins_after = Nanoc3::Plugin.all
29
-
30
- # Divide list of plugins into builtin and custom
31
- plugins_builtin = plugins_before
32
- plugins_custom = plugins_after - plugins_before
33
-
34
- # Find max identifiers length
35
- plugin_with_longest_identifiers = plugins_after.inject do |longest, current|
36
- longest[:identifiers].join(', ').size > current[:identifiers].join(', ').size ? longest : current
37
- end
38
- max_identifiers_length = plugin_with_longest_identifiers[:identifiers].join(', ').size
39
-
40
- PLUGIN_CLASS_ORDER.each do |superclass|
41
- plugins_with_this_superclass = {
42
- :builtin => plugins_builtin.select { |p| p[:superclass] == superclass },
43
- :custom => plugins_custom.select { |p| p[:superclass] == superclass }
44
- }
45
-
46
- # Print kind
47
- kind = name_for_plugin_class(superclass)
48
- puts "#{kind}:"
49
- puts
50
-
51
- # Print plugins organised by subtype
52
- [ :builtin, :custom ].each do |type|
53
- # Find relevant plugins
54
- relevant_plugins = plugins_with_this_superclass[type]
55
-
56
- # Print type
57
- puts " #{type}:"
58
- if relevant_plugins.empty?
59
- puts " (none)"
60
- next
61
- end
62
-
63
- # Print plugins
64
- relevant_plugins.sort_by { |k| k[:identifiers].join(', ') }.each do |plugin|
65
- # Display
66
- puts sprintf(
67
- " %-#{max_identifiers_length}s (%s)",
68
- plugin[:identifiers].join(', '),
69
- plugin[:class].to_s.sub(/^::/, '')
70
- )
71
- end
72
- end
73
-
74
- puts
75
- end
76
- end
77
-
78
- private
79
-
80
- PLUGIN_CLASS_ORDER = [
81
- Nanoc3::Filter,
82
- Nanoc3::Extra::VCS,
83
- Nanoc3::DataSource
84
- ]
85
-
86
- PLUGIN_CLASSES = {
87
- Nanoc3::Filter => 'Filters',
88
- Nanoc3::DataSource => 'Data Sources',
89
- Nanoc3::Extra::VCS => 'VCSes'
90
- }
91
-
92
- def name_for_plugin_class(klass)
93
- PLUGIN_CLASSES[klass]
94
- end
95
-
96
- end
97
-
98
- end
@@ -1,37 +0,0 @@
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
- Nanoc3::CLI::Logger.instance.color = true
8
- end
9
-
10
- opt :d, :debug, 'enable debugging' do
11
- Nanoc3::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
- Nanoc3::CLI::Logger.instance.color = false
21
- end
22
-
23
- opt :V, :verbose, 'make nanoc output more detailed' do
24
- Nanoc3::CLI::Logger.instance.level = :low
25
- end
26
-
27
- opt :v, :version, 'show version information and quit' do
28
- gem_info = defined?(Gem) ? "with RubyGems #{Gem::VERSION}" : "without RubyGems"
29
- engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
30
- puts "nanoc #{Nanoc3::VERSION} (c) 2007-2012 Denis Defreyne."
31
- puts "Running #{engine} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} #{gem_info}"
32
- exit 0
33
- end
34
-
35
- opt :w, :warn, 'enable warnings' do
36
- $-w = true
37
- end
@@ -1,72 +0,0 @@
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
- run do |opts, args, cmd|
19
- Nanoc3::CLI::Commands::Update.call(opts, args, cmd)
20
- end
21
-
22
- module Nanoc3::CLI::Commands
23
-
24
- class Update < ::Nanoc3::CLI::Command
25
-
26
- def run
27
- # Check arguments
28
- if arguments.size != 0
29
- $stderr.puts "usage: #{command.usage}"
30
- exit 1
31
- end
32
-
33
- # Make sure we are in a nanoc site directory
34
- self.require_site
35
-
36
- # Set VCS if possible
37
- self.set_vcs(options[:vcs])
38
-
39
- # Check for -y switch
40
- unless options.has_key?(:yes)
41
- $stderr.puts '*************'
42
- $stderr.puts '** WARNING **'
43
- $stderr.puts '*************'
44
- $stderr.puts
45
- $stderr.puts 'Are you absolutely sure you want to update the ' +
46
- 'content for this site? Updating the site content ' +
47
- 'will change the structure of existing data. This ' +
48
- 'operation is destructive and cannot be reverted. ' +
49
- 'Please do not interrupt this operation; doing so can ' +
50
- 'result in data loss. As always, consider making a ' +
51
- 'backup copy.'
52
- $stderr.puts
53
- $stderr.puts 'If this nanoc site is versioned using a VCS ' +
54
- 'supported by nanoc, consider using the --vcs option ' +
55
- 'to have nanoc perform add/delete/move operations ' +
56
- 'using the specified VCS. To get a list of VCSes ' +
57
- 'supported by nanoc, issue the "info" command.'
58
- $stderr.puts
59
- $stderr.puts 'To continue, use the -y/--yes option, like "nanoc3 ' +
60
- 'update -y".'
61
- exit 1
62
- end
63
-
64
- # Update
65
- self.site.data_sources.each do |data_source|
66
- data_source.update
67
- end
68
- end
69
-
70
- end
71
-
72
- end
@@ -1,84 +0,0 @@
1
- # encoding: utf-8
2
-
3
- usage 'view [options]'
4
- summary 'start the web server that serves static files'
5
- description <<-EOS
6
- Start the static web server. Unless specified, the web server will run on port 3000 and listen on all IP addresses. Running this static web server requires 'adsf' (not 'asdf'!).
7
- EOS
8
-
9
- required :H, :handler, 'specify the handler to use (webrick/mongrel/...)'
10
- required :o, :host, 'specify the host to listen on (default: 0.0.0.0)'
11
- required :p, :port, 'specify the port to listen on (default: 3000)'
12
-
13
- run do |opts, args, cmd|
14
- Nanoc3::CLI::Commands::View.call(opts, args, cmd)
15
- end
16
-
17
- module Nanoc3::CLI::Commands
18
-
19
- class View < ::Nanoc3::CLI::Command
20
-
21
- def run
22
- load_adsf
23
- require 'rack'
24
-
25
- # Make sure we are in a nanoc site directory
26
- self.require_site
27
-
28
- # Set options
29
- options_for_rack = {
30
- :Port => (options[:port] || 3000).to_i,
31
- :Host => (options[:host] || '0.0.0.0')
32
- }
33
-
34
- # Guess which handler we should use
35
- unless handler = Rack::Handler.get(options[:handler])
36
- begin
37
- handler = Rack::Handler::Mongrel
38
- rescue LoadError => e
39
- handler = Rack::Handler::WEBrick
40
- end
41
- end
42
-
43
- # Build app
44
- site = self.site
45
- app = Rack::Builder.new do
46
- use Rack::CommonLogger
47
- use Rack::ShowExceptions
48
- use Rack::Lint
49
- use Rack::Head
50
- use Adsf::Rack::IndexFileFinder, :root => site.config[:output_dir]
51
- run Rack::File.new(site.config[:output_dir])
52
- end.to_app
53
-
54
- # Run autocompiler
55
- handler.run(app, options_for_rack)
56
- end
57
-
58
- protected
59
-
60
- def load_adsf
61
- # Load adsf
62
- begin
63
- require 'adsf'
64
- return
65
- rescue LoadError
66
- $stderr.puts "Could not find the required 'adsf' gem, " \
67
- "which is necessary for the view command."
68
- end
69
-
70
- # Check asdf
71
- begin
72
- require 'asdf'
73
- $stderr.puts "You appear to have 'asdf' installed, " \
74
- "but not 'adsf'. Please install 'adsf' (check the spelling)!"
75
- rescue LoadError
76
- end
77
-
78
- # Done
79
- exit 1
80
- end
81
-
82
- end
83
-
84
- end
@@ -1,125 +0,0 @@
1
- # encoding: utf-8
2
-
3
- usage 'watch [options]'
4
- summary 'start the watcher'
5
- description <<-EOS
6
- Start the watcher. When a change is detected, the site will be recompiled.
7
- EOS
8
-
9
- run do |opts, args, cmd|
10
- Nanoc3::CLI::Commands::Watch.call(opts, args, cmd)
11
- end
12
-
13
- module Nanoc3::CLI::Commands
14
-
15
- class Watch < ::Nanoc3::CLI::Command
16
-
17
- def run
18
- require 'fssm'
19
- require 'pathname'
20
-
21
- watcher_config = self.site.config[:watcher] || {}
22
-
23
- @notifier = Notifier.new
24
-
25
- # Define rebuilder
26
- rebuilder = lambda do |base, relative|
27
- # Determine filename
28
- if base.nil? || relative.nil?
29
- filename = nil
30
- else
31
- filename = ::Pathname.new(File.join([ base, relative ])).relative_path_from(::Pathname.new(Dir.getwd)).to_s
32
- end
33
-
34
- # Notify
35
- if filename
36
- print "Change detected to #{filename}; recompiling… ".make_compatible_with_env
37
- else
38
- print "Watcher started; compiling the entire site… ".make_compatible_with_env
39
- end
40
-
41
- # Recompile
42
- start = Time.now
43
- site = Nanoc3::Site.new('.')
44
- begin
45
- site.compile
46
-
47
- # TODO include icon (--image misc/success-icon.png)
48
- notify_on_compilation_success = watcher_config.fetch(:notify_on_compilation_success) { true }
49
- if notify_on_compilation_success
50
- @notifier.notify('Compilation complete')
51
- end
52
-
53
- time_spent = ((Time.now - start)*1000.0).round
54
- puts "done in #{format '%is %ims', *(time_spent.divmod(1000))}"
55
- rescue Exception => e
56
- # TODO include icon (--image misc/error-icon.png)
57
- notify_on_compilation_failure = watcher_config.fetch(:notify_on_compilation_failure) { true }
58
- if notify_on_compilation_failure
59
- @notifier.notify('Compilation failed')
60
- end
61
-
62
- puts
63
- Nanoc3::CLI::ErrorHandler.print_error(e)
64
- puts
65
- end
66
- end
67
-
68
- # Rebuild once
69
- rebuilder.call(nil, nil)
70
-
71
- # Get directories to watch
72
- dirs_to_watch = watcher_config[:dirs_to_watch] || %w( content layouts lib )
73
- files_to_watch = watcher_config[:files_to_watch] || %w( config.yaml Rules rules Rules.rb rules.rb' )
74
- files_to_watch.delete_if { |f| !File.file?(f) }
75
-
76
- # Watch
77
- puts "Watching for changes…".make_compatible_with_env
78
- watcher = lambda do |*args|
79
- update(&rebuilder)
80
- delete(&rebuilder)
81
- create(&rebuilder)
82
- end
83
- monitor = FSSM::Monitor.new
84
- dirs_to_watch.each { |dir| monitor.path(dir, '**/*', &watcher) }
85
- files_to_watch.each { |filename| monitor.file(filename, &watcher) }
86
- monitor.run
87
- end
88
-
89
- # Allows sending user notifications in a cross-platform way.
90
- class Notifier
91
-
92
- # A list of commandline tool names that can be used to send notifications
93
- TOOLS = %w( growlnotify notify-send )
94
-
95
- # The tool to use for discovering binaries' locations
96
- FIND_BINARY_COMMAND = RUBY_PLATFORM =~ /mingw|mswin/ ? "where" : "which"
97
-
98
- # Send a notification. If no notifier is found, no notification will be
99
- # created.
100
- #
101
- # @param [String] message The message to include in the notification
102
- def notify(message)
103
- return if tool.nil?
104
- send(tool.tr('-', '_'), message)
105
- end
106
-
107
- private
108
-
109
- def tool
110
- @tool ||= TOOLS.find { |t| !`#{FIND_BINARY_COMMAND} #{t}`.empty? }
111
- end
112
-
113
- def growlnotify(message)
114
- system('growlnotify', '-m', message)
115
- end
116
-
117
- def notify_send(message)
118
- system('notify-send', message)
119
- end
120
-
121
- end
122
-
123
- end
124
-
125
- end