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
@@ -1,102 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # Represents an item representation, but provides an interface that is
6
- # easier to use when writing compilation and routing rules. It is also
7
- # responsible for fetching the necessary information from the compiler, such
8
- # as assigns.
9
- #
10
- # The API provided by item representation proxies allows layout identifiers
11
- # to be given as literals instead of as references to {Nanoc3::Layout}.
12
- class ItemRepProxy
13
-
14
- extend Forwardable
15
-
16
- def_delegators :@item_rep, :item, :name, :binary, :binary?, :compiled_content, :has_snapshot?, :raw_path, :path
17
- def_delegator :@item_rep, :snapshot
18
-
19
- # @param [Nanoc3::ItemRep] item_rep The item representation that this
20
- # proxy should behave like
21
- #
22
- # @param [Nanoc3::Compiler] compiler The compiler that will provide the
23
- # necessary compilation-related functionality.
24
- def initialize(item_rep, compiler)
25
- @item_rep = item_rep
26
- @compiler = compiler
27
- end
28
-
29
- # Runs the item content through the given filter with the given arguments.
30
- # This method will replace the content of the `:last` snapshot with the
31
- # filtered content of the last snapshot.
32
- #
33
- # This method is supposed to be called only in a compilation rule block
34
- # (see {Nanoc3::CompilerDSL#compile}).
35
- #
36
- # @see Nanoc3::ItemRep#filter
37
- #
38
- # @param [Symbol] filter_name The name of the filter to run the item
39
- # representations' content through
40
- #
41
- # @param [Hash] filter_args The filter arguments that should be passed to
42
- # the filter's #run method
43
- #
44
- # @return [void]
45
- def filter(name, args={})
46
- set_assigns
47
- @item_rep.filter(name, args)
48
- end
49
-
50
- # Lays out the item using the given layout. This method will replace the
51
- # content of the `:last` snapshot with the laid out content of the last
52
- # snapshot.
53
- #
54
- # This method is supposed to be called only in a compilation rule block
55
- # (see {Nanoc3::CompilerDSL#compile}).
56
- #
57
- # @see Nanoc3::ItemRep#layout
58
- #
59
- # @param [String] layout_identifier The identifier of the layout to use
60
- #
61
- # @return [void]
62
- def layout(layout_identifier)
63
- set_assigns
64
-
65
- layout = layout_with_identifier(layout_identifier)
66
- filter_name, filter_args = @compiler.rules_collection.filter_for_layout(layout)
67
-
68
- @item_rep.layout(layout, filter_name, filter_args)
69
- end
70
-
71
- # Returns true because this item is already a proxy, and therefore doesn’t
72
- # need to be wrapped anymore.
73
- #
74
- # @api private
75
- #
76
- # @return [true]
77
- #
78
- # @see Nanoc3::ItemRep#is_proxy?
79
- # @see Nanoc3::ItemRepRecorderProxy#is_proxy?
80
- def is_proxy?
81
- true
82
- end
83
-
84
- private
85
-
86
- def set_assigns
87
- @item_rep.assigns = @compiler.assigns_for(@item_rep)
88
- end
89
-
90
- def layouts
91
- @compiler.site.layouts
92
- end
93
-
94
- def layout_with_identifier(layout_identifier)
95
- layout ||= layouts.find { |l| l.identifier == layout_identifier.cleaned_identifier }
96
- raise Nanoc3::Errors::UnknownLayout.new(layout_identifier) if layout.nil?
97
- layout
98
- end
99
-
100
- end
101
-
102
- end
@@ -1,88 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # Represents a fake iem representation that does not actually perform any
6
- # actual filtering, layouting or snapshotting, but instead keeps track of
7
- # what would happen if a real item representation would have been used
8
- # instead. It therefore “records” the actions that happens upon it.
9
- #
10
- # The list of recorded actions is used during compilation to determine
11
- # whether an item representation needs to be recompiled: if the list of
12
- # actions is different from the list of actions from the previous
13
- # compilation run, the item needs to be recompiled; if it is the same, it
14
- # may not need to be recompiled.
15
- #
16
- # @api private
17
- class ItemRepRecorderProxy
18
-
19
- extend Forwardable
20
-
21
- def_delegators :@item_rep, :item, :name, :binary, :binary?, :compiled_content, :has_snapshot?, :raw_path, :path, :assigns, :assigns=
22
-
23
- # @example The compilation rule and the corresponding rule memory
24
- #
25
- # # rule
26
- # compile '/foo/' do
27
- # filter :erb
28
- # filter :myfilter, :arg1 => 'stuff'
29
- # layout 'meh'
30
- # end
31
- #
32
- # # memory
33
- # [
34
- # [ :filter, :erb, {} ],
35
- # [ :filter, :myfilter, { :arg1 => 'stuff' } ],
36
- # [ :layout, 'meh' ]
37
- # ]
38
- #
39
- # @return [Array] The list of recorded actions (“rule memory”)
40
- attr_reader :rule_memory
41
-
42
- # @param [Nanoc3::ItemRep] item_rep The item representation that this
43
- # proxy should behave like
44
- def initialize(item_rep)
45
- @item_rep = item_rep
46
- @rule_memory = []
47
- end
48
-
49
- # @return [void]
50
- #
51
- # @see Nanoc3::ItemRepProxy#filter, Nanoc3::ItemRep#filter
52
- def filter(name, args={})
53
- @rule_memory << [ :filter, name, args ]
54
- end
55
-
56
- # @return [void]
57
- #
58
- # @see Nanoc3::ItemRepProxy#layout, Nanoc3::ItemRep#layout
59
- def layout(layout_identifier)
60
- @rule_memory << [ :layout, layout_identifier ]
61
- end
62
-
63
- # @return [void]
64
- #
65
- # @see Nanoc3::ItemRep#snapshot
66
- def snapshot(snapshot_name, params={})
67
- @rule_memory << [ :snapshot, snapshot_name, params ]
68
- end
69
-
70
- # @return [{}]
71
- def content
72
- {}
73
- end
74
-
75
- # Returns true because this item is already a proxy, and therefore doesn’t
76
- # need to be wrapped anymore.
77
- #
78
- # @return [true]
79
- #
80
- # @see Nanoc3::ItemRep#is_proxy?
81
- # @see Nanoc3::ItemRepProxy#is_proxy?
82
- def is_proxy?
83
- true
84
- end
85
-
86
- end
87
-
88
- end
@@ -1,223 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # Responsible for determining whether an item or a layout is outdated.
6
- #
7
- # @api private
8
- class OutdatednessChecker
9
-
10
- extend Nanoc3::Memoization
11
-
12
- # @option params [Nanoc3::Site] :site (nil) The site this outdatedness
13
- # checker belongs to.
14
- #
15
- # @option params [Nanoc3::ChecksumStore] :checksum_store (nil) The
16
- # checksum store where checksums of items, layouts, … are stored.
17
- #
18
- # @option params [Nanoc3::DependencyTracker] :dependency_tracker (nil) The
19
- # dependency tracker for the given site.
20
- def initialize(params={})
21
- @site = params[:site] or raise ArgumentError,
22
- 'Nanoc3::OutdatednessChecker#initialize needs a :site parameter'
23
- @checksum_store = params[:checksum_store] or raise ArgumentError,
24
- 'Nanoc3::OutdatednessChecker#initialize needs a :checksum_store parameter'
25
- @dependency_tracker = params[:dependency_tracker] or raise ArgumentError,
26
- 'Nanoc3::OutdatednessChecker#initialize needs a :dependency_tracker parameter'
27
-
28
- @basic_outdatedness_reasons = {}
29
- @outdatedness_reasons = {}
30
- @objects_outdated_due_to_dependencies = {}
31
- end
32
-
33
- # Checks whether the given object is outdated and therefore needs to be
34
- # recompiled.
35
- #
36
- # @param [Nanoc3::Item, Nanoc3::ItemRep, Nanoc3::Layout] obj The object
37
- # whose outdatedness should be checked.
38
- #
39
- # @return [Boolean] true if the object is outdated, false otherwise
40
- def outdated?(obj)
41
- !outdatedness_reason_for(obj).nil?
42
- end
43
-
44
- # Calculates the reason why the given object is outdated.
45
- #
46
- # @param [Nanoc3::Item, Nanoc3::ItemRep, Nanoc3::Layout] obj The object
47
- # whose outdatedness reason should be calculated.
48
- #
49
- # @return [Nanoc3::OutdatednessReasons::Generic, nil] The reason why the
50
- # given object is outdated, or nil if the object is not outdated.
51
- def outdatedness_reason_for(obj)
52
- reason = basic_outdatedness_reason_for(obj)
53
- if reason.nil? && outdated_due_to_dependencies?(obj)
54
- reason = Nanoc3::OutdatednessReasons::DependenciesOutdated
55
- end
56
- reason
57
- end
58
- memoize :outdatedness_reason_for
59
-
60
- private
61
-
62
- # Checks whether the given object is outdated and therefore needs to be
63
- # recompiled. This method does not take dependencies into account; use
64
- # {#outdated?} if you want to include dependencies in the outdatedness
65
- # check.
66
- #
67
- # @param [Nanoc3::Item, Nanoc3::ItemRep, Nanoc3::Layout] obj The object
68
- # whose outdatedness should be checked.
69
- #
70
- # @return [Boolean] true if the object is outdated, false otherwise
71
- def basic_outdated?(obj)
72
- !basic_outdatedness_reason_for(obj).nil?
73
- end
74
-
75
- # Calculates the reason why the given object is outdated. This method does
76
- # not take dependencies into account; use {#outdatedness_reason_for?} if
77
- # you want to include dependencies in the outdatedness check.
78
- #
79
- # @param [Nanoc3::Item, Nanoc3::ItemRep, Nanoc3::Layout] obj The object
80
- # whose outdatedness reason should be calculated.
81
- #
82
- # @return [Nanoc3::OutdatednessReasons::Generic, nil] The reason why the
83
- # given object is outdated, or nil if the object is not outdated.
84
- def basic_outdatedness_reason_for(obj)
85
- case obj.type
86
- when :item_rep
87
- # Outdated if rules outdated
88
- return Nanoc3::OutdatednessReasons::RulesModified if
89
- rule_memory_differs_for(obj)
90
-
91
- # Outdated if checksums are missing or different
92
- return Nanoc3::OutdatednessReasons::NotEnoughData if !checksums_available?(obj.item)
93
- return Nanoc3::OutdatednessReasons::SourceModified if !checksums_identical?(obj.item)
94
-
95
- # Outdated if compiled file doesn't exist (yet)
96
- return Nanoc3::OutdatednessReasons::NotWritten if obj.raw_path && !File.file?(obj.raw_path)
97
-
98
- # Outdated if code snippets outdated
99
- return Nanoc3::OutdatednessReasons::CodeSnippetsModified if site.code_snippets.any? do |cs|
100
- object_modified?(cs)
101
- end
102
-
103
- # Outdated if configuration outdated
104
- return Nanoc3::OutdatednessReasons::ConfigurationModified if object_modified?(site.config)
105
-
106
- # Not outdated
107
- return nil
108
- when :item
109
- obj.reps.find { |rep| basic_outdatedness_reason_for(rep) }
110
- when :layout
111
- # Outdated if rules outdated
112
- return Nanoc3::OutdatednessReasons::RulesModified if
113
- rule_memory_differs_for(obj)
114
-
115
- # Outdated if checksums are missing or different
116
- return Nanoc3::OutdatednessReasons::NotEnoughData if !checksums_available?(obj)
117
- return Nanoc3::OutdatednessReasons::SourceModified if !checksums_identical?(obj)
118
-
119
- # Not outdated
120
- return nil
121
- else
122
- raise RuntimeError, "do not know how to check outdatedness of #{obj.inspect}"
123
- end
124
- end
125
- memoize :basic_outdatedness_reason_for
126
-
127
- # Checks whether the given object is outdated due to dependencies.
128
- #
129
- # @param [Nanoc3::Item, Nanoc3::ItemRep, Nanoc3::Layout] obj The object
130
- # whose outdatedness should be checked.
131
- #
132
- # @param [Set] processed The collection of items that has been visited
133
- # during this outdatedness check. This is used to prevent checks for
134
- # items that (indirectly) depend on their own from looping
135
- # indefinitely. It should not be necessary to pass this a custom value.
136
- #
137
- # @return [Boolean] true if the object is outdated, false otherwise
138
- def outdated_due_to_dependencies?(obj, processed=Set.new)
139
- # Convert from rep to item if necessary
140
- obj = obj.item if obj.type == :item_rep
141
-
142
- # Get from cache
143
- if @objects_outdated_due_to_dependencies.has_key?(obj)
144
- return @objects_outdated_due_to_dependencies[obj]
145
- end
146
-
147
- # Check processed
148
- # Don’t return true; the false will be or’ed into a true if there
149
- # really is a dependency that is causing outdatedness.
150
- return false if processed.include?(obj)
151
-
152
- # Calculate
153
- is_outdated = dependency_tracker.objects_causing_outdatedness_of(obj).any? do |other|
154
- other.nil? || basic_outdated?(other) || outdated_due_to_dependencies?(other, processed.merge([obj]))
155
- end
156
-
157
- # Cache
158
- @objects_outdated_due_to_dependencies[obj] = is_outdated
159
-
160
- # Done
161
- is_outdated
162
- end
163
-
164
- # @param [Nanoc3::ItemRep, Nanoc3::Layout] obj The layout or item
165
- # representation to check the rule memory for
166
- #
167
- # @return [Boolean] true if the rule memory for the given item
168
- # represenation has changed, false otherwise
169
- def rule_memory_differs_for(obj)
170
- rules_collection.rule_memory_differs_for(obj)
171
- end
172
- memoize :rule_memory_differs_for
173
-
174
- # @param obj
175
- #
176
- # @return [Boolean] false if either the new or the old checksum for the
177
- # given object is not available, true if both checksums are available
178
- def checksums_available?(obj)
179
- !!checksum_store[obj] && obj.checksum
180
- end
181
- memoize :checksums_available?
182
-
183
- # @param obj
184
- #
185
- # @return [Boolean] false if the old and new checksums for the given
186
- # object differ, true if they are identical
187
- def checksums_identical?(obj)
188
- checksum_store[obj] == obj.checksum
189
- end
190
- memoize :checksums_identical?
191
-
192
- # @param obj
193
- #
194
- # @return [Boolean] true if the old and new checksums for the given object
195
- # are available and identical, false otherwise
196
- def object_modified?(obj)
197
- !checksums_available?(obj) || !checksums_identical?(obj)
198
- end
199
- memoize :object_modified?
200
-
201
- # @return [Nanoc3::ChecksumStore] The checksum store
202
- def checksum_store
203
- @checksum_store
204
- end
205
-
206
- # @return [Nanoc3::RulesCollection] The rules collection
207
- def rules_collection
208
- site.compiler.rules_collection
209
- end
210
-
211
- # @return [Nanoc3::DependencyTracker] The dependency tracker
212
- def dependency_tracker
213
- @dependency_tracker
214
- end
215
-
216
- # @return [Nanoc3::Site] The site
217
- def site
218
- @site
219
- end
220
-
221
- end
222
-
223
- end
@@ -1,46 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3
4
-
5
- # Module that contains all outdatedness reasons.
6
- module OutdatednessReasons
7
-
8
- # A generic outdatedness reason. An outdatedness reason is basically a
9
- # descriptive message that explains why a given object is outdated.
10
- class Generic
11
-
12
- # @return [String] A descriptive message for this outdatedness reason
13
- attr_reader :message
14
-
15
- # @param [String] message The descriptive message for this outdatedness
16
- # reason
17
- def initialize(message)
18
- @message = message
19
- end
20
-
21
- end
22
-
23
- CodeSnippetsModified = Generic.new(
24
- 'The code snippets have been modified since the last time the site was compiled.')
25
-
26
- ConfigurationModified = Generic.new(
27
- 'The site configuration has been modified since the last time the site was compiled.')
28
-
29
- DependenciesOutdated = Generic.new(
30
- 'This item uses content or attributes that have changed since the last time the site was compiled.')
31
-
32
- NotEnoughData = Generic.new(
33
- 'Not enough data is present to correctly determine whether the item is outdated.')
34
-
35
- NotWritten = Generic.new(
36
- 'This item representation has not yet been written to the output directory (but it does have a path).')
37
-
38
- RulesModified = Generic.new(
39
- 'The rules file has been modified since the last time the site was compiled.')
40
-
41
- SourceModified = Generic.new(
42
- 'The source file of this item has been modified since the last time the site was compiled.')
43
-
44
- end
45
-
46
- end