nanoc3 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 (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
data/README.md DELETED
@@ -1,108 +0,0 @@
1
- # nanoc 3
2
-
3
- nanoc is a simple but very flexible static site generator written in Ruby.
4
- It operates on local files, and therefore does not run on the server. nanoc
5
- “compiles” the local source files into HTML (usually), by evaluating eRuby,
6
- Markdown, etc.
7
-
8
- Note: This documentation looks best with Yardoc, not RDoc.
9
-
10
- ## Resources
11
-
12
- The [nanoc web site](http://nanoc.stoneship.org) contains a few useful
13
- resources to help you get started with nanoc. If you need further assistance,
14
- the following places will help you out:
15
-
16
- * The [discussion group](http://groups.google.com/group/nanoc)
17
- * The [IRC channel](irc://chat.freenode.net/#nanoc)
18
-
19
- ## Source Code Documentation
20
-
21
- The source code is located in `lib/nanoc3` and is structured in a few
22
- directories:
23
-
24
- * `base` contains the bare essentials necessary for nanoc to function
25
- * `source_data` contains raw, uncompiled content that will be compiled
26
- * `result_data` contains the compiled content
27
- * `compilation` contains the compilation functionality
28
- * `cli` contains the commandline interface
29
- * `data_sources` contains the standard data sources ({Nanoc3::DataSource}
30
- subclasses), such as the filesystem data source
31
- * `extra` contains stuff that is not needed by nanoc itself, but which may
32
- be used by helpers, data sources, filters or VCSes.
33
- * `filters` contains the standard filters ({Nanoc3::Filter} subclasses)
34
- such as ERB, Markdown, Haml, …
35
- * `helpers` contains helpers, which provide functionality some sites
36
- may find useful, such as the blogging and tagging helpers
37
- * `tasks` contains rake tasks that perform a variety of functions such as
38
- validating HTML and CSS, uploading compiled files, …
39
-
40
- The namespaces (modules) are organised like this:
41
-
42
- * {Nanoc3} is the namespace for everything nanoc-related (obviously). The
43
- classes in `lib/nanoc3/base` are part of this module (not `Nanoc3::Base`)
44
- * {Nanoc3::CLI} containing everything related to the commandline tool.
45
- * {Nanoc3::DataSources} contains the data sources
46
- * {Nanoc3::Helpers} contains the helpers
47
- * {Nanoc3::Extra} contains useful stuff not needed by nanoc itself
48
- * {Nanoc3::Filters} contains the (textual) filters
49
-
50
- The central class in nanoc is {Nanoc3::Site}, so you should start there if
51
- you want to explore nanoc from a technical perspective.
52
-
53
- ## Dependencies
54
-
55
- nanoc has few dependencies. It is possible to use nanoc programmatically
56
- without any dependencies at all, but if you want to use nanoc in a proper way,
57
- you’ll likely need some dependencies:
58
-
59
- * The **commandline frontend** depends on `cli`.
60
- * The **autocompiler** depends on `mime-types` and `rack`.
61
- * Filters and helpers likely have dependencies on their own too.
62
-
63
- If you’re developing for nanoc, such as writing custom filters or helpers, you
64
- may be interested in the development dependencies:
65
-
66
- * For **documentation generation** you’ll need `yard`.
67
- * For **packaging** you’ll need `rubygems` (1.3 or newer).
68
- * For **testing** you’ll need `mocha` and `minitest`.
69
-
70
- ## Contributors
71
-
72
- (In alphabetical order)
73
-
74
- * Ben Armston
75
- * Colin Barrett
76
- * Bil Bas
77
- * Dmitry Bilunov
78
- * Devon Luke Buchanan
79
- * Stefan Bühler
80
- * Brian Candler
81
- * Michal Cichra
82
- * Zaiste de Grengolada
83
- * Vincent Driessen
84
- * Chris Eppstein
85
- * Jeff Forcier
86
- * Felix Hanley
87
- * Justin Hileman
88
- * Starr Horne
89
- * Tuomas Kareinen
90
- * Matt Keveney
91
- * Nikhil Marathe
92
- * Daniel Mendler
93
- * Ale Muñoz
94
- * Nicky Peeters
95
- * Christian Plessl
96
- * Šime Ramov
97
- * Xavier Shay
98
- * Arnau Siches
99
- * “Soryu”
100
- * Eric Sunshine
101
- * Dennis Sutch
102
- * Matthias Vallentin
103
- * Ruben Verborgh
104
- * Toon Willems
105
-
106
- ## Contact
107
-
108
- You can reach me at <denis.defreyne@stoneship.org>.
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # Set up env
4
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/lib'))
5
- require './test/gem_loader.rb'
6
-
7
- # Load nanoc
8
- require 'nanoc3'
9
-
10
- # Load tasks
11
- Dir.glob('tasks/**/*.rake').each { |r| Rake.application.add_import r }
12
-
13
- # Set default task
14
- task :default => :test
data/bin/nanoc3 DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- # Add lib to load path
5
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
6
-
7
- # Load nanoc
8
- require 'nanoc3'
9
- require 'nanoc3/cli'
10
-
11
- # Run base
12
- Nanoc3::CLI.run(ARGV)
@@ -1,10 +0,0 @@
1
- <%= superb %>
2
- <script type="text/javascript">
3
- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
4
- document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
5
- </script>
6
- <script type="text/javascript">
7
- try {
8
- var pageTracker = _gat._getTracker("UA-15639968-1");
9
- pageTracker._trackPageview();
10
- } catch(err) {}</script>
@@ -1,28 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # The current nanoc version.
6
- VERSION = '3.2.4'
7
-
8
- end
9
-
10
- # Load general requirements
11
- require 'digest'
12
- require 'enumerator'
13
- require 'fileutils'
14
- require 'forwardable'
15
- require 'pathname'
16
- require 'pstore'
17
- require 'set'
18
- require 'tempfile'
19
- require 'thread'
20
- require 'time'
21
- require 'yaml'
22
-
23
- # Load nanoc
24
- require 'nanoc3/base'
25
- require 'nanoc3/extra'
26
- require 'nanoc3/data_sources'
27
- require 'nanoc3/filters'
28
- require 'nanoc3/helpers'
@@ -1,49 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- require 'nanoc3/base/core_ext'
6
- require 'nanoc3/base/ordered_hash'
7
-
8
- # Load helper classes
9
- autoload 'Context', 'nanoc3/base/context'
10
- autoload 'DirectedGraph', 'nanoc3/base/directed_graph'
11
- autoload 'Errors', 'nanoc3/base/errors'
12
- autoload 'Memoization', 'nanoc3/base/memoization'
13
- autoload 'NotificationCenter', 'nanoc3/base/notification_center'
14
- autoload 'PluginRegistry', 'nanoc3/base/plugin_registry'
15
- autoload 'Store', 'nanoc3/base/store'
16
-
17
- # Load source data classes
18
- autoload 'CodeSnippet', 'nanoc3/base/source_data/code_snippet'
19
- autoload 'Configuration', 'nanoc3/base/source_data/configuration'
20
- autoload 'DataSource', 'nanoc3/base/source_data/data_source'
21
- autoload 'Item', 'nanoc3/base/source_data/item'
22
- autoload 'Layout', 'nanoc3/base/source_data/layout'
23
- autoload 'Site', 'nanoc3/base/source_data/site'
24
-
25
- # Load result data classes
26
- autoload 'ItemRep', 'nanoc3/base/result_data/item_rep'
27
-
28
- # Load compilation classes
29
- autoload 'ChecksumStore', 'nanoc3/base/compilation/checksum_store'
30
- autoload 'CompiledContentCache', 'nanoc3/base/compilation/compiled_content_cache'
31
- autoload 'Compiler', 'nanoc3/base/compilation/compiler'
32
- autoload 'CompilerDSL', 'nanoc3/base/compilation/compiler_dsl'
33
- autoload 'DependencyTracker', 'nanoc3/base/compilation/dependency_tracker'
34
- autoload 'Filter', 'nanoc3/base/compilation/filter'
35
- autoload 'ItemRepProxy', 'nanoc3/base/compilation/item_rep_proxy'
36
- autoload 'ItemRepRecorderProxy', 'nanoc3/base/compilation/item_rep_recorder_proxy'
37
- autoload 'OutdatednessChecker', 'nanoc3/base/compilation/outdatedness_checker'
38
- autoload 'OutdatednessReasons', 'nanoc3/base/compilation/outdatedness_reasons'
39
- autoload 'Rule', 'nanoc3/base/compilation/rule'
40
- autoload 'RuleContext', 'nanoc3/base/compilation/rule_context'
41
- autoload 'RuleMemoryCalculator', 'nanoc3/base/compilation/rule_memory_calculator'
42
- autoload 'RuleMemoryStore', 'nanoc3/base/compilation/rule_memory_store'
43
- autoload 'RulesCollection', 'nanoc3/base/compilation/rules_collection'
44
-
45
- # Deprecated; use PluginRepository instead
46
- # TODO [in nanoc 4.0] remove me
47
- autoload 'Plugin', 'nanoc3/base/plugin_registry'
48
-
49
- end
@@ -1,57 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # Stores checksums for objects in order to be able to detect whether a file
6
- # has changed since the last site compilation.
7
- #
8
- # @api private
9
- class ChecksumStore < ::Nanoc3::Store
10
-
11
- # @option params [Nanoc3::Site] site The site where this checksum store
12
- # belongs to
13
- def initialize(params={})
14
- super('tmp/checksums', 1)
15
-
16
- @site = params[:site] if params.has_key?(:site)
17
-
18
- @checksums = {}
19
- end
20
-
21
- # Returns the old checksum for the given object. This makes sense for
22
- # items, layouts and code snippets.
23
- #
24
- # @param [#reference] obj The object for which to fetch the checksum
25
- #
26
- # @return [String] The checksum for the given object
27
- def [](obj)
28
- @checksums[obj.reference]
29
- end
30
-
31
- # Sets the checksum for the given object.
32
- #
33
- # @param [#reference] obj The object for which to set the checksum
34
- #
35
- # @param [String] checksum The checksum
36
- def []=(obj, checksum)
37
- @checksums[obj.reference] = checksum
38
- end
39
-
40
- # @see Nanoc3::Store#unload
41
- def unload
42
- @checksums = {}
43
- end
44
-
45
- protected
46
-
47
- def data
48
- @checksums
49
- end
50
-
51
- def data=(new_data)
52
- @checksums = new_data
53
- end
54
-
55
- end
56
-
57
- end
@@ -1,62 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # Represents a cache than can be used to store already compiled content,
6
- # to prevent it from being needlessly recompiled.
7
- #
8
- # @api private
9
- class CompiledContentCache < ::Nanoc3::Store
10
-
11
- def initialize
12
- super('tmp/compiled_content', 1)
13
-
14
- @cache = {}
15
- end
16
-
17
- # Returns the cached compiled content for the given item
18
- # representation. This cached compiled content is a hash where the keys
19
- # are the snapshot names and the values the compiled content at the
20
- # given snapshot.
21
- #
22
- # @param [Nanoc3::ItemRep] rep The item rep to fetch the content for
23
- #
24
- # @return [Hash<Symbol,String>] A hash containing the cached compiled
25
- # content for the given item representation
26
- def [](rep)
27
- item_cache = @cache[rep.item.identifier] || {}
28
- item_cache[rep.name]
29
- end
30
-
31
- # Sets the compiled content for the given representation.
32
- #
33
- # @param [Nanoc3::ItemRep] rep The item representation for which to set
34
- # the compiled content
35
- #
36
- # @param [Hash<Symbol,String>] content A hash containing the compiled
37
- # content of the given representation
38
- #
39
- # @return [void]
40
- def []=(rep, content)
41
- @cache[rep.item.identifier] ||= {}
42
- @cache[rep.item.identifier][rep.name] = content
43
- end
44
-
45
- # @see Nanoc3::Store#unload
46
- def unload
47
- @cache = {}
48
- end
49
-
50
- protected
51
-
52
- def data
53
- @cache
54
- end
55
-
56
- def data=(new_data)
57
- @cache = new_data
58
- end
59
-
60
- end
61
-
62
- end
@@ -1,455 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # Responsible for compiling a site’s item representations.
6
- #
7
- # The compilation process makes use of notifications (see
8
- # {Nanoc3::NotificationCenter}) to track dependencies between items,
9
- # layouts, etc. The following notifications are used:
10
- #
11
- # * `compilation_started` — indicates that the compiler has started
12
- # compiling this item representation. Has one argument: the item
13
- # representation itself. Only one item can be compiled at a given moment;
14
- # therefore, it is not possible to get two consecutive
15
- # `compilation_started` notifications without also getting a
16
- # `compilation_ended` notification in between them.
17
- #
18
- # * `compilation_ended` — indicates that the compiler has finished compiling
19
- # this item representation (either successfully or with failure). Has one
20
- # argument: the item representation itself.
21
- #
22
- # * `visit_started` — indicates that the compiler requires content or
23
- # attributes from the item representation that will be visited. Has one
24
- # argument: the visited item identifier. This notification is used to
25
- # track dependencies of items on other items; a `visit_started` event
26
- # followed by another `visit_started` event indicates that the item
27
- # corresponding to the former event will depend on the item from the
28
- # latter event.
29
- #
30
- # * `visit_ended` — indicates that the compiler has finished visiting the
31
- # item representation and that the requested attributes or content have
32
- # been fetched (either successfully or with failure)
33
- #
34
- # * `processing_started` — indicates that the compiler has started
35
- # processing the specified object, which can be an item representation
36
- # (when it is compiled) or a layout (when it is used to lay out an item
37
- # representation or when it is used as a partial)
38
- #
39
- # * `processing_ended` — indicates that the compiler has finished processing
40
- # the specified object.
41
- class Compiler
42
-
43
- extend Nanoc3::Memoization
44
-
45
- # @group Accessors
46
-
47
- # @return [Nanoc3::Site] The site this compiler belongs to
48
- attr_reader :site
49
-
50
- # The compilation stack. When the compiler begins compiling a rep or a
51
- # layout, it will be placed on the stack; when it is done compiling the
52
- # rep or layout, it will be removed from the stack.
53
- #
54
- # @return [Array] The compilation stack
55
- attr_reader :stack
56
-
57
- # @group Public instance methods
58
-
59
- # Creates a new compiler fo the given site
60
- #
61
- # @param [Nanoc3::Site] site The site this compiler belongs to
62
- def initialize(site)
63
- @site = site
64
-
65
- @stack = []
66
- end
67
-
68
- # Compiles the site and writes out the compiled item representations.
69
- #
70
- # Previous versions of nanoc (< 3.2) allowed passing items to compile, and
71
- # had a “force” option to make the compiler recompile all pages, even
72
- # when not outdated. These arguments and options are, as of nanoc 3.2, no
73
- # longer used, and will simply be ignored when passed to {#run}.
74
- #
75
- # @overload run
76
- # @return [void]
77
- def run(*args)
78
- # Create output directory if necessary
79
- FileUtils.mkdir_p(@site.config[:output_dir])
80
-
81
- # Compile reps
82
- load
83
- @site.freeze
84
- dependency_tracker.start
85
- compile_reps(reps)
86
- dependency_tracker.stop
87
- store
88
- ensure
89
- # Cleanup
90
- FileUtils.rm_rf(Nanoc3::Filter::TMP_BINARY_ITEMS_DIR)
91
- end
92
-
93
- # @group Private instance methods
94
-
95
- # @return [Nanoc3::RulesCollection] The collection of rules to be used
96
- # for compiling this site
97
- def rules_collection
98
- Nanoc3::RulesCollection.new(self)
99
- end
100
- memoize :rules_collection
101
-
102
- # Load the helper data that is used for compiling the site.
103
- #
104
- # @api private
105
- #
106
- # @return [void]
107
- def load
108
- return if @loaded || @loading
109
- @loading = true
110
-
111
- # Load site if necessary
112
- site.load
113
-
114
- # Preprocess
115
- rules_collection.load
116
- preprocess
117
- site.setup_child_parent_links
118
- build_reps
119
- route_reps
120
-
121
- # Load auxiliary stores
122
- stores.each { |s| s.load }
123
-
124
- # Determine which reps need to be recompiled
125
- forget_dependencies_if_outdated(items)
126
-
127
- @loaded = true
128
- rescue => e
129
- unload
130
- raise e
131
- ensure
132
- @loading = false
133
- end
134
-
135
- # Undoes the effects of {#load}. Used when {#load} raises an exception.
136
- #
137
- # @api private
138
- #
139
- # @return [void]
140
- def unload
141
- return if @unloading
142
- @unloading = true
143
-
144
- stores.each { |s| s.unload }
145
-
146
- @stack = []
147
-
148
- items.each { |item| item.reps.clear }
149
- site.teardown_child_parent_links
150
- rules_collection.unload
151
-
152
- site.unload
153
-
154
- @loaded = false
155
- @unloading = false
156
- end
157
-
158
- # Store the modified helper data used for compiling the site.
159
- #
160
- # @api private
161
- #
162
- # @return [void]
163
- def store
164
- # Calculate rule memory
165
- (reps + layouts).each do |obj|
166
- rule_memory_store[obj] = rule_memory_calculator[obj]
167
- end
168
-
169
- # Calculate checksums
170
- self.objects.each do |obj|
171
- checksum_store[obj] = obj.checksum
172
- end
173
-
174
- # Store
175
- stores.each { |s| s.store }
176
- end
177
-
178
- # Returns the dependency tracker for this site, creating it first if it
179
- # does not yet exist.
180
- #
181
- # @api private
182
- #
183
- # @return [Nanoc3::DependencyTracker] The dependency tracker for this site
184
- def dependency_tracker
185
- dt = Nanoc3::DependencyTracker.new(@site.items + @site.layouts)
186
- dt.compiler = self
187
- dt
188
- end
189
- memoize :dependency_tracker
190
-
191
- # Runs the preprocessor.
192
- #
193
- # @api private
194
- def preprocess
195
- return if rules_collection.preprocessor.nil?
196
- preprocessor_context.instance_eval(&rules_collection.preprocessor)
197
- end
198
-
199
- # Returns all objects managed by the site (items, layouts, code snippets,
200
- # site configuration and the rules).
201
- #
202
- # @api private
203
- def objects
204
- site.items + site.layouts + site.code_snippets +
205
- [ site.config, rules_collection ]
206
- end
207
-
208
- # Creates the representations of all items as defined by the compilation
209
- # rules.
210
- #
211
- # @api private
212
- def build_reps
213
- items.each do |item|
214
- # Find matching rules
215
- matching_rules = rules_collection.item_compilation_rules_for(item)
216
- raise Nanoc3::Errors::NoMatchingCompilationRuleFound.new(item) if matching_rules.empty?
217
-
218
- # Create reps
219
- rep_names = matching_rules.map { |r| r.rep_name }.uniq
220
- rep_names.each do |rep_name|
221
- item.reps << ItemRep.new(item, rep_name)
222
- end
223
- end
224
- end
225
-
226
- # Determines the paths of all item representations.
227
- #
228
- # @api private
229
- def route_reps
230
- reps.each do |rep|
231
- # Find matching rules
232
- rules = rules_collection.routing_rules_for(rep)
233
- raise Nanoc3::Errors::NoMatchingRoutingRuleFound.new(rep) if rules[:last].nil?
234
-
235
- rules.each_pair do |snapshot, rule|
236
- # Get basic path by applying matching rule
237
- basic_path = rule.apply_to(rep, :compiler => self)
238
- next if basic_path.nil?
239
- if basic_path !~ %r{^/}
240
- raise RuntimeError, "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash.".make_compatible_with_env
241
- end
242
-
243
- # Get raw path by prepending output directory
244
- rep.raw_paths[snapshot] = @site.config[:output_dir] + basic_path
245
-
246
- # Get normal path by stripping index filename
247
- rep.paths[snapshot] = basic_path
248
- @site.config[:index_filenames].each do |index_filename|
249
- if rep.paths[snapshot][-index_filename.length..-1] == index_filename
250
- # Strip and stop
251
- rep.paths[snapshot] = rep.paths[snapshot][0..-index_filename.length-1]
252
- break
253
- end
254
- end
255
- end
256
- end
257
- end
258
-
259
- # @param [Nanoc3::ItemRep] rep The item representation for which the
260
- # assigns should be fetched
261
- #
262
- # @return [Hash] The assigns that should be used in the next filter/layout
263
- # operation
264
- #
265
- # @api private
266
- def assigns_for(rep)
267
- if rep.binary?
268
- content_or_filename_assigns = { :filename => rep.temporary_filenames[:last] }
269
- else
270
- content_or_filename_assigns = { :content => rep.content[:last] }
271
- end
272
-
273
- content_or_filename_assigns.merge({
274
- :item => rep.item,
275
- :item_rep => rep,
276
- :items => site.items,
277
- :layouts => site.layouts,
278
- :config => site.config,
279
- :site => site
280
- })
281
- end
282
-
283
- # @return [Nanoc3::OutdatednessChecker] The outdatedness checker
284
- def outdatedness_checker
285
- Nanoc3::OutdatednessChecker.new(
286
- :site => @site,
287
- :checksum_store => checksum_store,
288
- :dependency_tracker => dependency_tracker)
289
- end
290
- memoize :outdatedness_checker
291
-
292
- private
293
-
294
- # @return [Array<Nanoc3::Item>] The site’s items
295
- def items
296
- @site.items
297
- end
298
- memoize :items
299
-
300
- # @return [Array<Nanoc3::ItemRep>] The site’s item representations
301
- def reps
302
- items.map { |i| i.reps }.flatten
303
- end
304
- memoize :reps
305
-
306
- # @return [Array<Nanoc3::Layout>] The site’s layouts
307
- def layouts
308
- @site.layouts
309
- end
310
- memoize :layouts
311
-
312
- # Compiles the given representations.
313
- #
314
- # @param [Array] reps The item representations to compile.
315
- #
316
- # @return [void]
317
- def compile_reps(reps)
318
- content_dependency_graph = Nanoc3::DirectedGraph.new(reps)
319
-
320
- # Listen to processing start/stop
321
- Nanoc3::NotificationCenter.on(:processing_started, self) { |obj| @stack.push(obj) }
322
- Nanoc3::NotificationCenter.on(:processing_ended, self) { |obj| @stack.pop }
323
-
324
- # Attempt to compile all active reps
325
- loop do
326
- # Find rep to compile
327
- break if content_dependency_graph.roots.empty?
328
- rep = content_dependency_graph.roots.each { |e| break e }
329
- @stack = []
330
-
331
- begin
332
- compile_rep(rep)
333
- content_dependency_graph.delete_vertex(rep)
334
- rescue Nanoc3::Errors::UnmetDependency => e
335
- content_dependency_graph.add_edge(e.rep, rep)
336
- unless content_dependency_graph.vertices.include?(e.rep)
337
- content_dependency_graph.add_vertex(e.rep)
338
- end
339
- end
340
- end
341
-
342
- # Check whether everything was compiled
343
- if !content_dependency_graph.vertices.empty?
344
- raise Nanoc3::Errors::RecursiveCompilation.new(content_dependency_graph.vertices)
345
- end
346
- ensure
347
- Nanoc3::NotificationCenter.remove(:processing_started, self)
348
- Nanoc3::NotificationCenter.remove(:processing_ended, self)
349
- end
350
-
351
- # Compiles the given item representation.
352
- #
353
- # This method should not be called directly; please use
354
- # {Nanoc3::Compiler#run} instead, and pass this item representation's item
355
- # as its first argument.
356
- #
357
- # @param [Nanoc3::ItemRep] rep The rep that is to be compiled
358
- #
359
- # @return [void]
360
- def compile_rep(rep)
361
- Nanoc3::NotificationCenter.post(:compilation_started, rep)
362
- Nanoc3::NotificationCenter.post(:processing_started, rep)
363
- Nanoc3::NotificationCenter.post(:visit_started, rep.item)
364
-
365
- # Calculate rule memory if we haven’t yet done do
366
- rules_collection.new_rule_memory_for_rep(rep)
367
-
368
- if !outdatedness_checker.outdated?(rep) && compiled_content_cache[rep]
369
- # Reuse content
370
- Nanoc3::NotificationCenter.post(:cached_content_used, rep)
371
- rep.content = compiled_content_cache[rep]
372
- else
373
- # Recalculate content
374
- rep.snapshot(:raw)
375
- rep.snapshot(:pre, :final => false)
376
- rules_collection.compilation_rule_for(rep).apply_to(rep, :compiler => self)
377
- rep.snapshot(:post) if rep.has_snapshot?(:post)
378
- rep.snapshot(:last)
379
- end
380
-
381
- rep.compiled = true
382
- compiled_content_cache[rep] = rep.content
383
- rescue => e
384
- rep.forget_progress
385
- Nanoc3::NotificationCenter.post(:compilation_failed, rep)
386
- raise e
387
- ensure
388
- Nanoc3::NotificationCenter.post(:visit_ended, rep.item)
389
- Nanoc3::NotificationCenter.post(:processing_ended, rep)
390
- Nanoc3::NotificationCenter.post(:compilation_ended, rep)
391
- end
392
-
393
- # Clears the list of dependencies for items that will be recompiled.
394
- #
395
- # @param [Array<Nanoc3::Item>] items The list of items for which to forget
396
- # the dependencies
397
- #
398
- # @return [void]
399
- def forget_dependencies_if_outdated(items)
400
- items.each do |i|
401
- if i.reps.any? { |r| outdatedness_checker.outdated?(r) }
402
- dependency_tracker.forget_dependencies_for(i)
403
- end
404
- end
405
- end
406
-
407
- # Returns a preprocessor context, creating one if none exists yet.
408
- def preprocessor_context
409
- Nanoc3::Context.new({
410
- :site => @site,
411
- :config => @site.config,
412
- :items => @site.items,
413
- :layouts => @site.layouts
414
- })
415
- end
416
- memoize :preprocessor_context
417
-
418
- # @return [CompiledContentCache] The compiled content cache
419
- def compiled_content_cache
420
- Nanoc3::CompiledContentCache.new
421
- end
422
- memoize :compiled_content_cache
423
-
424
- # @return [ChecksumStore] The checksum store
425
- def checksum_store
426
- Nanoc3::ChecksumStore.new(:site => @site)
427
- end
428
- memoize :checksum_store
429
-
430
- # @return [RuleMemoryStore] The rule memory store
431
- def rule_memory_store
432
- Nanoc3::RuleMemoryStore.new(:site => @site)
433
- end
434
- memoize :rule_memory_store
435
-
436
- # @return [RuleMemoryCalculator] The rule memory calculator
437
- def rule_memory_calculator
438
- Nanoc3::RuleMemoryCalculator.new(:rules_collection => rules_collection)
439
- end
440
- memoize :rule_memory_calculator
441
-
442
- # Returns all stores that can load/store data that can be used for
443
- # compilation.
444
- def stores
445
- [
446
- checksum_store,
447
- compiled_content_cache,
448
- dependency_tracker,
449
- rule_memory_store
450
- ]
451
- end
452
-
453
- end
454
-
455
- end