nanoc 4.11.0 → 4.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +6 -0
  3. data/lib/nanoc.rb +4 -7
  4. data/lib/nanoc/base.rb +3 -3
  5. data/lib/nanoc/base/assertions.rb +1 -1
  6. data/lib/nanoc/base/entities.rb +2 -20
  7. data/lib/nanoc/base/entities/action_sequence.rb +60 -64
  8. data/lib/nanoc/base/entities/checksum_collection.rb +23 -21
  9. data/lib/nanoc/base/entities/dependency.rb +24 -22
  10. data/lib/nanoc/base/entities/outdatedness_reasons.rb +74 -72
  11. data/lib/nanoc/base/entities/outdatedness_status.rb +19 -17
  12. data/lib/nanoc/base/entities/props.rb +119 -117
  13. data/lib/nanoc/base/entities/site.rb +46 -50
  14. data/lib/nanoc/base/errors.rb +183 -198
  15. data/lib/nanoc/base/repos.rb +4 -2
  16. data/lib/nanoc/base/repos/action_sequence_store.rb +44 -42
  17. data/lib/nanoc/base/repos/aggregate_data_source.rb +24 -22
  18. data/lib/nanoc/base/repos/checksum_store.rb +51 -49
  19. data/lib/nanoc/base/repos/compiled_content_cache.rb +47 -45
  20. data/lib/nanoc/base/repos/compiled_content_store.rb +76 -0
  21. data/lib/nanoc/base/repos/config_loader.rb +74 -72
  22. data/lib/nanoc/base/repos/dependency_store.rb +174 -172
  23. data/lib/nanoc/base/repos/in_mem_data_source.rb +17 -15
  24. data/lib/nanoc/base/repos/item_rep_repo.rb +26 -24
  25. data/lib/nanoc/base/repos/outdatedness_store.rb +50 -48
  26. data/lib/nanoc/base/repos/prefixed_data_source.rb +21 -19
  27. data/lib/nanoc/base/repos/site_loader.rb +75 -73
  28. data/lib/nanoc/base/repos/store.rb +93 -91
  29. data/lib/nanoc/base/services.rb +7 -3
  30. data/lib/nanoc/base/services/action_provider.rb +23 -21
  31. data/lib/nanoc/base/services/action_sequence_builder.rb +42 -34
  32. data/lib/nanoc/base/services/compilation_context.rb +49 -47
  33. data/lib/nanoc/base/services/compiler.rb +177 -170
  34. data/lib/nanoc/base/services/compiler/phases.rb +8 -1
  35. data/lib/nanoc/base/services/compiler/phases/abstract.rb +44 -38
  36. data/lib/nanoc/base/services/compiler/phases/cache.rb +34 -28
  37. data/lib/nanoc/base/services/compiler/phases/mark_done.rb +17 -11
  38. data/lib/nanoc/base/services/compiler/phases/notify.rb +21 -0
  39. data/lib/nanoc/base/services/compiler/phases/recalculate.rb +37 -31
  40. data/lib/nanoc/base/services/compiler/phases/resume.rb +47 -48
  41. data/lib/nanoc/base/services/compiler/phases/write.rb +65 -59
  42. data/lib/nanoc/base/services/compiler/stage.rb +27 -8
  43. data/lib/nanoc/base/services/compiler/stages.rb +7 -1
  44. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +25 -19
  45. data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +34 -28
  46. data/lib/nanoc/base/services/compiler/stages/cleanup.rb +33 -27
  47. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +79 -69
  48. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +46 -40
  49. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +15 -9
  50. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +28 -22
  51. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +16 -10
  52. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +25 -19
  53. data/lib/nanoc/base/services/compiler/stages/prune.rb +23 -17
  54. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +15 -9
  55. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +26 -20
  56. data/lib/nanoc/base/services/compiler_loader.rb +26 -24
  57. data/lib/nanoc/base/services/dependency_tracker.rb +47 -45
  58. data/lib/nanoc/base/services/executor.rb +16 -15
  59. data/lib/nanoc/base/services/filter.rb +37 -5
  60. data/lib/nanoc/base/services/instrumentor.rb +12 -10
  61. data/lib/nanoc/base/services/item_rep_builder.rb +21 -19
  62. data/lib/nanoc/base/services/item_rep_router.rb +72 -70
  63. data/lib/nanoc/base/services/item_rep_selector.rb +48 -46
  64. data/lib/nanoc/base/services/item_rep_writer.rb +58 -53
  65. data/lib/nanoc/base/services/outdatedness_checker.rb +181 -179
  66. data/lib/nanoc/base/services/outdatedness_rule.rb +23 -21
  67. data/lib/nanoc/base/services/outdatedness_rules.rb +5 -3
  68. data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +28 -24
  69. data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +20 -16
  70. data/lib/nanoc/base/services/outdatedness_rules/content_modified.rb +13 -9
  71. data/lib/nanoc/base/services/outdatedness_rules/item_collection_extended.rb +12 -8
  72. data/lib/nanoc/base/services/outdatedness_rules/layout_collection_extended.rb +12 -8
  73. data/lib/nanoc/base/services/outdatedness_rules/not_written.rb +10 -6
  74. data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +39 -35
  75. data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +19 -15
  76. data/lib/nanoc/base/services/pruner.rb +2 -2
  77. data/lib/nanoc/base/views.rb +7 -0
  78. data/lib/nanoc/base/views/basic_item_view.rb +1 -1
  79. data/lib/nanoc/base/views/compilation_item_rep_view.rb +2 -2
  80. data/lib/nanoc/base/views/identifiable_collection_view.rb +2 -2
  81. data/lib/nanoc/base/views/mixins/document_view_mixin.rb +1 -1
  82. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +5 -5
  83. data/lib/nanoc/base/views/mutable_item_collection_view.rb +3 -3
  84. data/lib/nanoc/base/views/mutable_layout_collection_view.rb +2 -2
  85. data/lib/nanoc/base/views/view_context_for_compilation.rb +6 -6
  86. data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +2 -2
  87. data/lib/nanoc/base/views/view_context_for_shell.rb +2 -2
  88. data/lib/nanoc/checking/check.rb +1 -1
  89. data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +24 -7
  90. data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +79 -15
  91. data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +4 -7
  92. data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +15 -24
  93. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +22 -18
  94. data/lib/nanoc/cli/commands/create-site.rb +2 -7
  95. data/lib/nanoc/cli/commands/shell.rb +1 -1
  96. data/lib/nanoc/cli/commands/show-data.rb +9 -9
  97. data/lib/nanoc/cli/logger.rb +1 -1
  98. data/lib/nanoc/data_sources/filesystem.rb +8 -8
  99. data/lib/nanoc/filters/erb.rb +1 -1
  100. data/lib/nanoc/filters/erubi.rb +1 -1
  101. data/lib/nanoc/filters/erubis.rb +1 -1
  102. data/lib/nanoc/filters/haml.rb +1 -1
  103. data/lib/nanoc/filters/sass.rb +1 -1
  104. data/lib/nanoc/filters/slim.rb +1 -1
  105. data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
  106. data/lib/nanoc/helpers/capturing.rb +9 -8
  107. data/lib/nanoc/helpers/filtering.rb +2 -2
  108. data/lib/nanoc/helpers/rendering.rb +1 -1
  109. data/lib/nanoc/rule_dsl.rb +10 -0
  110. data/lib/nanoc/rule_dsl/action_provider.rb +3 -3
  111. data/lib/nanoc/rule_dsl/action_recorder.rb +3 -3
  112. data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +7 -7
  113. data/lib/nanoc/rule_dsl/compilation_rule.rb +2 -2
  114. data/lib/nanoc/rule_dsl/compilation_rule_context.rb +9 -9
  115. data/lib/nanoc/rule_dsl/compiler_dsl.rb +4 -4
  116. data/lib/nanoc/rule_dsl/routing_rule.rb +3 -3
  117. data/lib/nanoc/rule_dsl/rule.rb +5 -5
  118. data/lib/nanoc/rule_dsl/rule_context.rb +3 -3
  119. data/lib/nanoc/rule_dsl/rules_collection.rb +4 -4
  120. data/lib/nanoc/spec.rb +15 -15
  121. data/lib/nanoc/version.rb +1 -1
  122. metadata +10 -111
  123. data/lib/nanoc/base/contracts_support.rb +0 -130
  124. data/lib/nanoc/base/core_ext.rb +0 -5
  125. data/lib/nanoc/base/core_ext/array.rb +0 -50
  126. data/lib/nanoc/base/core_ext/hash.rb +0 -54
  127. data/lib/nanoc/base/core_ext/string.rb +0 -16
  128. data/lib/nanoc/base/entities/code_snippet.rb +0 -53
  129. data/lib/nanoc/base/entities/configuration-schema.json +0 -122
  130. data/lib/nanoc/base/entities/configuration.rb +0 -206
  131. data/lib/nanoc/base/entities/content.rb +0 -112
  132. data/lib/nanoc/base/entities/context.rb +0 -70
  133. data/lib/nanoc/base/entities/directed_graph.rb +0 -195
  134. data/lib/nanoc/base/entities/document.rb +0 -125
  135. data/lib/nanoc/base/entities/identifiable_collection.rb +0 -141
  136. data/lib/nanoc/base/entities/identifier.rb +0 -222
  137. data/lib/nanoc/base/entities/item.rb +0 -10
  138. data/lib/nanoc/base/entities/item_collection.rb +0 -14
  139. data/lib/nanoc/base/entities/item_rep.rb +0 -91
  140. data/lib/nanoc/base/entities/layout.rb +0 -10
  141. data/lib/nanoc/base/entities/layout_collection.rb +0 -14
  142. data/lib/nanoc/base/entities/lazy_value.rb +0 -43
  143. data/lib/nanoc/base/entities/pattern.rb +0 -85
  144. data/lib/nanoc/base/entities/processing_action.rb +0 -21
  145. data/lib/nanoc/base/entities/processing_actions.rb +0 -5
  146. data/lib/nanoc/base/entities/processing_actions/filter.rb +0 -36
  147. data/lib/nanoc/base/entities/processing_actions/layout.rb +0 -36
  148. data/lib/nanoc/base/entities/processing_actions/snapshot.rb +0 -46
  149. data/lib/nanoc/base/entities/snapshot_def.rb +0 -22
  150. data/lib/nanoc/base/repos/data_source.rb +0 -168
  151. data/lib/nanoc/base/repos/snapshot_repo.rb +0 -67
  152. data/lib/nanoc/base/services/checksummer.rb +0 -274
  153. data/lib/nanoc/base/services/notification_center.rb +0 -87
  154. data/lib/nanoc/base/services/temp_filename_factory.rb +0 -52
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Int
4
- # @api private
5
- class Layout < ::Nanoc::Int::Document
6
- def reference
7
- "layout:#{identifier}"
8
- end
9
- end
10
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Int
4
- # @api private
5
- class LayoutCollection < IdentifiableCollection
6
- def initialize(config, objects = [])
7
- initialize_basic(config, objects, 'layouts')
8
- end
9
-
10
- def reference
11
- 'layouts'
12
- end
13
- end
14
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Int
4
- # Holds a value that might be generated lazily.
5
- #
6
- # @api private
7
- class LazyValue
8
- include Nanoc::Int::ContractsSupport
9
-
10
- # @param [Object, Proc] value_or_proc A value or a proc to generate the value
11
- def initialize(value_or_proc)
12
- @value = { raw: value_or_proc }
13
- end
14
-
15
- # @return [Object] The value, generated when needed
16
- def value
17
- if @value.key?(:raw)
18
- value = @value.delete(:raw)
19
- @value[:final] = value.respond_to?(:call) ? value.call : value
20
- @value.__nanoc_freeze_recursively if frozen?
21
- end
22
- @value[:final]
23
- end
24
-
25
- contract C::Func[C::Any => C::Any] => self
26
- # Returns a new lazy value that will apply the given transformation when the value is requested.
27
- #
28
- # @yield resolved value
29
- #
30
- # @return [Nanoc::Int::LazyValue]
31
- def map
32
- Nanoc::Int::LazyValue.new(-> { yield(value) })
33
- end
34
-
35
- contract C::None => self
36
- # @return [void]
37
- def freeze
38
- super
39
- @value.__nanoc_freeze_recursively unless @value[:raw]
40
- self
41
- end
42
- end
43
- end
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Int
4
- # @api private
5
- class Pattern
6
- include Nanoc::Int::ContractsSupport
7
-
8
- contract C::Any => self
9
- def self.from(obj)
10
- case obj
11
- when Nanoc::Int::StringPattern, Nanoc::Int::RegexpPattern
12
- obj
13
- when String
14
- Nanoc::Int::StringPattern.new(obj)
15
- when Regexp
16
- Nanoc::Int::RegexpPattern.new(obj)
17
- when Symbol
18
- Nanoc::Int::StringPattern.new(obj.to_s)
19
- else
20
- raise ArgumentError, "Do not know how to convert `#{obj.inspect}` into a Nanoc::Pattern"
21
- end
22
- end
23
-
24
- def initialize(_obj)
25
- raise NotImplementedError
26
- end
27
-
28
- def match?(_identifier)
29
- raise NotImplementedError
30
- end
31
-
32
- def captures(_identifier)
33
- raise NotImplementedError
34
- end
35
- end
36
-
37
- # @api private
38
- class StringPattern < Pattern
39
- MATCH_OPTS = File::FNM_PATHNAME | File::FNM_EXTGLOB
40
-
41
- contract String => C::Any
42
- def initialize(string)
43
- @string = string
44
- end
45
-
46
- contract C::Or[Nanoc::Identifier, String] => C::Bool
47
- def match?(identifier)
48
- File.fnmatch(@string, identifier.to_s, MATCH_OPTS)
49
- end
50
-
51
- contract C::Or[Nanoc::Identifier, String] => nil
52
- def captures(_identifier)
53
- nil
54
- end
55
-
56
- contract C::None => String
57
- def to_s
58
- @string
59
- end
60
- end
61
-
62
- # @api private
63
- class RegexpPattern < Pattern
64
- contract Regexp => C::Any
65
- def initialize(regexp)
66
- @regexp = regexp
67
- end
68
-
69
- contract C::Or[Nanoc::Identifier, String] => C::Bool
70
- def match?(identifier)
71
- (identifier.to_s =~ @regexp) != nil
72
- end
73
-
74
- contract C::Or[Nanoc::Identifier, String] => C::Maybe[C::ArrayOf[String]]
75
- def captures(identifier)
76
- matches = @regexp.match(identifier.to_s)
77
- matches&.captures
78
- end
79
-
80
- contract C::None => String
81
- def to_s
82
- @regexp.to_s
83
- end
84
- end
85
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Int
4
- class ProcessingAction
5
- def serialize
6
- raise NotImplementedError.new('Nanoc::ProcessingAction subclasses must implement #serialize and #to_s')
7
- end
8
-
9
- def to_s
10
- raise NotImplementedError.new('Nanoc::ProcessingAction subclasses must implement #serialize and #to_s')
11
- end
12
-
13
- def inspect
14
- format(
15
- '<%s %s>',
16
- self.class.to_s,
17
- serialize[1..-1].map(&:inspect).join(', '),
18
- )
19
- end
20
- end
21
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'processing_actions/filter'
4
- require_relative 'processing_actions/layout'
5
- require_relative 'processing_actions/snapshot'
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Int::ProcessingActions
4
- class Filter < Nanoc::Int::ProcessingAction
5
- # filter :foo
6
- # filter :foo, params
7
-
8
- attr_reader :filter_name
9
- attr_reader :params
10
-
11
- def initialize(filter_name, params)
12
- @filter_name = filter_name
13
- @params = params
14
- end
15
-
16
- def serialize
17
- [:filter, @filter_name, Nanoc::Int::Checksummer.calc(@params)]
18
- end
19
-
20
- def to_s
21
- "filter #{@filter_name.inspect}, #{@params.inspect}"
22
- end
23
-
24
- def hash
25
- self.class.hash ^ filter_name.hash ^ params.hash
26
- end
27
-
28
- def ==(other)
29
- self.class == other.class && filter_name == other.filter_name && params == other.params
30
- end
31
-
32
- def eql?(other)
33
- self == other
34
- end
35
- end
36
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Int::ProcessingActions
4
- class Layout < Nanoc::Int::ProcessingAction
5
- # layout '/foo.erb'
6
- # layout '/foo.erb', params
7
-
8
- attr_reader :layout_identifier
9
- attr_reader :params
10
-
11
- def initialize(layout_identifier, params)
12
- @layout_identifier = layout_identifier
13
- @params = params
14
- end
15
-
16
- def serialize
17
- [:layout, @layout_identifier, Nanoc::Int::Checksummer.calc(@params)]
18
- end
19
-
20
- def to_s
21
- "layout #{@layout_identifier.inspect}, #{@params.inspect}"
22
- end
23
-
24
- def hash
25
- self.class.hash ^ layout_identifier.hash ^ params.hash
26
- end
27
-
28
- def ==(other)
29
- self.class == other.class && layout_identifier == other.layout_identifier && params == other.params
30
- end
31
-
32
- def eql?(other)
33
- self == other
34
- end
35
- end
36
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Int::ProcessingActions
4
- class Snapshot < Nanoc::Int::ProcessingAction
5
- # snapshot :before_layout
6
- # snapshot :before_layout, path: '/about.md'
7
-
8
- include Nanoc::Int::ContractsSupport
9
-
10
- attr_reader :snapshot_names
11
- attr_reader :paths
12
-
13
- contract C::IterOf[Symbol], C::IterOf[String] => C::Any
14
- def initialize(snapshot_names, paths)
15
- @snapshot_names = snapshot_names
16
- @paths = paths
17
- end
18
-
19
- contract C::None => Array
20
- def serialize
21
- [:snapshot, @snapshot_names, true, @paths]
22
- end
23
-
24
- contract C::KeywordArgs[snapshot_names: C::Optional[C::IterOf[Symbol]], paths: C::Optional[C::IterOf[String]]] => self
25
- def update(snapshot_names: [], paths: [])
26
- self.class.new(@snapshot_names + snapshot_names.to_a, @paths + paths.to_a)
27
- end
28
-
29
- contract C::None => String
30
- def to_s
31
- "snapshot #{@snapshot_names.inspect}, paths: #{@paths.inspect}"
32
- end
33
-
34
- def hash
35
- self.class.hash ^ snapshot_names.hash ^ paths.hash
36
- end
37
-
38
- def ==(other)
39
- self.class == other.class && snapshot_names == other.snapshot_names && paths == other.paths
40
- end
41
-
42
- def eql?(other)
43
- self == other
44
- end
45
- end
46
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class SnapshotDef
6
- include Nanoc::Int::ContractsSupport
7
-
8
- attr_reader :name
9
- attr_reader :binary
10
-
11
- contract Symbol, C::KeywordArgs[binary: C::Optional[C::Bool]] => C::Any
12
- def initialize(name, binary:)
13
- @name = name
14
- @binary = binary
15
- end
16
-
17
- def binary?
18
- @binary
19
- end
20
- end
21
- end
22
- end
@@ -1,168 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- # Responsible for loading site data. It is the (abstract) superclass for all
5
- # data sources. Subclasses must at least implement the data reading methods
6
- # ({#items} and {#layouts}).
7
- #
8
- # Apart from the methods for loading and storing data, there are the {#up}
9
- # and {#down} methods for bringing up and tearing down the connection to the
10
- # data source. These should be overridden in subclasses. The {#loading}
11
- # method wraps {#up} and {#down}. {#loading} is a convenience method for the
12
- # more low-level methods {#use} and {#unuse}, which respectively increment
13
- # and decrement the reference count; when the reference count goes from 0 to
14
- # 1, the data source will be loaded ({#up} will be called) and when the
15
- # reference count goes from 1 to 0, the data source will be unloaded
16
- # ({#down} will be called).
17
- #
18
- # @abstract Subclasses should at least implement {#items} and {#layouts}.
19
- class DataSource
20
- # @return [String] The root path where items returned by this data source
21
- # should be mounted.
22
- attr_reader :items_root
23
-
24
- # @return [String] The root path where layouts returned by this data
25
- # source should be mounted.
26
- attr_reader :layouts_root
27
-
28
- # @return [Hash] The configuration for this data source. For example,
29
- # online data sources could contain authentication details.
30
- attr_reader :config
31
-
32
- extend DDPlugin::Plugin
33
-
34
- def initialize(site_config, items_root, layouts_root, config)
35
- @site_config = site_config
36
- @items_root = items_root
37
- @layouts_root = layouts_root
38
- @config = config || {}
39
-
40
- @references = 0
41
- end
42
-
43
- # Marks the data source as used by the caller.
44
- #
45
- # Calling this method increases the internal reference count. When the
46
- # data source is used for the first time (first {#use} call), the data
47
- # source will be loaded ({#up} will be called).
48
- #
49
- # @return [void]
50
- def use
51
- up if @references.zero?
52
- @references += 1
53
- end
54
-
55
- # Marks the data source as unused by the caller.
56
- #
57
- # Calling this method decreases the internal reference count. When the
58
- # reference count reaches zero, i.e. when the data source is not used any
59
- # more, the data source will be unloaded ({#down} will be called).
60
- #
61
- # @return [void]
62
- def unuse
63
- @references -= 1
64
- down if @references.zero?
65
- end
66
-
67
- # Brings up the connection to the data. Depending on the way data is
68
- # stored, this may not be necessary. This is the ideal place to connect to
69
- # the database, for example.
70
- #
71
- # Subclasses may override this method, but are not required to do so; the
72
- # default implementation simply does nothing.
73
- #
74
- # @return [void]
75
- def up; end
76
-
77
- # Brings down the connection to the data. This method should undo the
78
- # effects of the {#up} method. For example, a database connection
79
- # established in {#up} should be closed in this method.
80
- #
81
- # Subclasses may override this method, but are not required to do so; the
82
- # default implementation simply does nothing.
83
- #
84
- # @return [void]
85
- def down; end
86
-
87
- # Returns the collection of items (represented by {Nanoc::Int::Item}) in
88
- # this site. The default implementation simply returns an empty array.
89
- #
90
- # Subclasses should not prepend `items_root` to the item's identifiers, as
91
- # this will be done automatically.
92
- #
93
- # Subclasses may override this method, but are not required to do so; the
94
- # default implementation simply does nothing.
95
- #
96
- # @return [Enumerable] The collection of items
97
- def items
98
- []
99
- end
100
-
101
- # @api private
102
- def item_changes
103
- warn "Caution: Data source #{self.class.identifier.inspect} does not implement #item_changes; live compilation will not pick up changes in this data source."
104
- Enumerator.new { |_y| sleep }
105
- end
106
-
107
- # @api private
108
- def layout_changes
109
- warn "Caution: Data source #{self.class.identifier.inspect} does not implement #layout_changes; live compilation will not pick up changes in this data source."
110
- Enumerator.new { |_y| sleep }
111
- end
112
-
113
- # Returns the collection of layouts (represented by {Nanoc::Int::Layout}) in
114
- # this site. The default implementation simply returns an empty array.
115
- #
116
- # Subclasses should prepend `layout_root` to the layout's identifiers,
117
- # since this is not done automatically.
118
- #
119
- # Subclasses may override this method, but are not required to do so; the
120
- # default implementation simply does nothing.
121
- #
122
- # @return [Enumerable] The collection of layouts
123
- def layouts
124
- []
125
- end
126
-
127
- # Creates a new in-memory item instance. This is intended for use within
128
- # the {#items} method.
129
- #
130
- # @param [String, Proc] content The uncompiled item content
131
- # (if it is a textual item) or the path to the filename containing the
132
- # content (if it is a binary item).
133
- #
134
- # @param [Hash, Proc] attributes A hash containing this item's attributes.
135
- #
136
- # @param [String] identifier This item's identifier.
137
- #
138
- # @param [Boolean] binary Whether or not this item is binary
139
- #
140
- # @param [String, nil] checksum_data
141
- #
142
- # @param [String, nil] content_checksum_data
143
- #
144
- # @param [String, nil] attributes_checksum_data
145
- def new_item(content, attributes, identifier, binary: false, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil)
146
- content = Nanoc::Int::Content.create(content, binary: binary)
147
- Nanoc::Int::Item.new(content, attributes, identifier, checksum_data: checksum_data, content_checksum_data: content_checksum_data, attributes_checksum_data: attributes_checksum_data)
148
- end
149
-
150
- # Creates a new in-memory layout instance. This is intended for use within
151
- # the {#layouts} method.
152
- #
153
- # @param [String] raw_content The raw content of this layout.
154
- #
155
- # @param [Hash] attributes A hash containing this layout's attributes.
156
- #
157
- # @param [String] identifier This layout's identifier.
158
- #
159
- # @param [String, nil] checksum_data
160
- #
161
- # @param [String, nil] content_checksum_data
162
- #
163
- # @param [String, nil] attributes_checksum_data
164
- def new_layout(raw_content, attributes, identifier, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil)
165
- Nanoc::Int::Layout.new(raw_content, attributes, identifier, checksum_data: checksum_data, content_checksum_data: content_checksum_data, attributes_checksum_data: attributes_checksum_data)
166
- end
167
- end
168
- end