nanoc 4.11.12 → 4.11.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +7 -1
  3. data/bin/nanoc +1 -1
  4. data/lib/nanoc.rb +2 -27
  5. data/lib/nanoc/base.rb +3 -6
  6. data/lib/nanoc/base/errors.rb +6 -104
  7. data/lib/nanoc/checking/check.rb +4 -4
  8. data/lib/nanoc/checking/checks/external_links.rb +1 -1
  9. data/lib/nanoc/checking/checks/stale.rb +1 -1
  10. data/lib/nanoc/checking/runner.rb +2 -2
  11. data/lib/nanoc/data_sources/filesystem/tools.rb +4 -4
  12. data/lib/nanoc/extra.rb +1 -1
  13. data/lib/nanoc/helpers/blogging.rb +8 -8
  14. data/lib/nanoc/helpers/capturing.rb +1 -1
  15. data/lib/nanoc/helpers/link_to.rb +1 -1
  16. data/lib/nanoc/orig_cli.rb +20 -0
  17. data/lib/nanoc/{cli → orig_cli}/commands/check.rb +3 -3
  18. data/lib/nanoc/{cli → orig_cli}/commands/deploy.rb +8 -8
  19. data/lib/nanoc/{cli → orig_cli}/commands/show-rules.rb +3 -3
  20. data/lib/nanoc/rule_dsl/action_provider.rb +5 -5
  21. data/lib/nanoc/rule_dsl/action_recorder.rb +4 -4
  22. data/lib/nanoc/rule_dsl/compilation_rule_context.rb +1 -1
  23. data/lib/nanoc/rule_dsl/compiler_dsl.rb +1 -1
  24. data/lib/nanoc/rule_dsl/rule_context.rb +6 -6
  25. data/lib/nanoc/version.rb +1 -1
  26. metadata +13 -152
  27. data/lib/nanoc/base/error.rb +0 -7
  28. data/lib/nanoc/base/feature.rb +0 -104
  29. data/lib/nanoc/base/repos.rb +0 -4
  30. data/lib/nanoc/base/repos/config_loader.rb +0 -95
  31. data/lib/nanoc/base/repos/site_loader.rb +0 -102
  32. data/lib/nanoc/base/services.rb +0 -23
  33. data/lib/nanoc/base/services/compiler.rb +0 -214
  34. data/lib/nanoc/base/services/compiler/phases.rb +0 -19
  35. data/lib/nanoc/base/services/compiler/phases/abstract.rb +0 -50
  36. data/lib/nanoc/base/services/compiler/phases/cache.rb +0 -45
  37. data/lib/nanoc/base/services/compiler/phases/mark_done.rb +0 -25
  38. data/lib/nanoc/base/services/compiler/phases/notify.rb +0 -21
  39. data/lib/nanoc/base/services/compiler/phases/recalculate.rb +0 -51
  40. data/lib/nanoc/base/services/compiler/phases/resume.rb +0 -54
  41. data/lib/nanoc/base/services/compiler/phases/write.rb +0 -86
  42. data/lib/nanoc/base/services/compiler/stages.rb +0 -23
  43. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +0 -38
  44. data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +0 -44
  45. data/lib/nanoc/base/services/compiler/stages/cleanup.rb +0 -45
  46. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +0 -98
  47. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +0 -51
  48. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +0 -22
  49. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +0 -37
  50. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +0 -23
  51. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +0 -34
  52. data/lib/nanoc/base/services/compiler/stages/prune.rb +0 -32
  53. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +0 -22
  54. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +0 -34
  55. data/lib/nanoc/base/services/compiler_loader.rb +0 -48
  56. data/lib/nanoc/base/services/executor.rb +0 -134
  57. data/lib/nanoc/base/services/filter.rb +0 -267
  58. data/lib/nanoc/base/services/item_rep_builder.rb +0 -54
  59. data/lib/nanoc/base/services/item_rep_selector.rb +0 -69
  60. data/lib/nanoc/base/services/item_rep_writer.rb +0 -86
  61. data/lib/nanoc/base/services/outdatedness_checker.rb +0 -222
  62. data/lib/nanoc/base/services/outdatedness_rules.rb +0 -18
  63. data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +0 -41
  64. data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +0 -31
  65. data/lib/nanoc/base/services/outdatedness_rules/content_modified.rb +0 -21
  66. data/lib/nanoc/base/services/outdatedness_rules/item_collection_extended.rb +0 -20
  67. data/lib/nanoc/base/services/outdatedness_rules/layout_collection_extended.rb +0 -20
  68. data/lib/nanoc/base/services/outdatedness_rules/not_written.rb +0 -17
  69. data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +0 -45
  70. data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +0 -26
  71. data/lib/nanoc/base/services/pruner.rb +0 -123
  72. data/lib/nanoc/base/views.rb +0 -40
  73. data/lib/nanoc/base/views/basic_item_rep_collection_view.rb +0 -86
  74. data/lib/nanoc/base/views/basic_item_rep_view.rb +0 -81
  75. data/lib/nanoc/base/views/basic_item_view.rb +0 -52
  76. data/lib/nanoc/base/views/compilation_item_rep_collection_view.rb +0 -10
  77. data/lib/nanoc/base/views/compilation_item_rep_view.rb +0 -49
  78. data/lib/nanoc/base/views/compilation_item_view.rb +0 -45
  79. data/lib/nanoc/base/views/config_view.rb +0 -68
  80. data/lib/nanoc/base/views/identifiable_collection_view.rb +0 -109
  81. data/lib/nanoc/base/views/item_collection_with_reps_view.rb +0 -10
  82. data/lib/nanoc/base/views/item_collection_without_reps_view.rb +0 -10
  83. data/lib/nanoc/base/views/layout_collection_view.rb +0 -10
  84. data/lib/nanoc/base/views/layout_view.rb +0 -7
  85. data/lib/nanoc/base/views/mixins/document_view_mixin.rb +0 -88
  86. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +0 -58
  87. data/lib/nanoc/base/views/mutable_config_view.rb +0 -14
  88. data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +0 -17
  89. data/lib/nanoc/base/views/mutable_item_collection_view.rb +0 -32
  90. data/lib/nanoc/base/views/mutable_item_view.rb +0 -7
  91. data/lib/nanoc/base/views/mutable_layout_collection_view.rb +0 -24
  92. data/lib/nanoc/base/views/mutable_layout_view.rb +0 -7
  93. data/lib/nanoc/base/views/post_compile_item_collection_view.rb +0 -10
  94. data/lib/nanoc/base/views/post_compile_item_rep_collection_view.rb +0 -10
  95. data/lib/nanoc/base/views/post_compile_item_rep_view.rb +0 -31
  96. data/lib/nanoc/base/views/post_compile_item_view.rb +0 -18
  97. data/lib/nanoc/base/views/view.rb +0 -41
  98. data/lib/nanoc/cli.rb +0 -241
  99. data/lib/nanoc/cli/ansi_string_colorizer.rb +0 -28
  100. data/lib/nanoc/cli/cleaning_stream.rb +0 -160
  101. data/lib/nanoc/cli/command_runner.rb +0 -72
  102. data/lib/nanoc/cli/commands/compile.rb +0 -57
  103. data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +0 -58
  104. data/lib/nanoc/cli/commands/compile_listeners/aggregate.rb +0 -50
  105. data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +0 -100
  106. data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +0 -101
  107. data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +0 -76
  108. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +0 -170
  109. data/lib/nanoc/cli/commands/create-site.rb +0 -257
  110. data/lib/nanoc/cli/commands/nanoc.rb +0 -42
  111. data/lib/nanoc/cli/commands/prune.rb +0 -49
  112. data/lib/nanoc/cli/commands/shell.rb +0 -57
  113. data/lib/nanoc/cli/commands/show-data.rb +0 -185
  114. data/lib/nanoc/cli/commands/show-plugins.rb +0 -89
  115. data/lib/nanoc/cli/commands/view.rb +0 -68
  116. data/lib/nanoc/cli/error_handler.rb +0 -365
  117. data/lib/nanoc/cli/logger.rb +0 -75
  118. data/lib/nanoc/cli/stack_trace_writer.rb +0 -50
  119. data/lib/nanoc/cli/stream_cleaners.rb +0 -10
  120. data/lib/nanoc/cli/stream_cleaners/abstract.rb +0 -21
  121. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +0 -13
  122. data/lib/nanoc/cli/stream_cleaners/utf8.rb +0 -17
  123. data/lib/nanoc/cli/transform.rb +0 -16
  124. data/lib/nanoc/spec.rb +0 -240
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class BasicItemView < ::Nanoc::View
5
- include Nanoc::DocumentViewMixin
6
-
7
- # Returns the children of this item. For items with identifiers that have
8
- # extensions, returns an empty collection.
9
- #
10
- # @return [Enumerable<Nanoc::CompilationItemView>]
11
- def children
12
- unless _unwrap.identifier.legacy?
13
- raise Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(_unwrap.identifier)
14
- end
15
-
16
- children_pattern = Nanoc::Core::Pattern.from(_unwrap.identifier.to_s + '*/')
17
- children = @context.items.select { |i| children_pattern.match?(i.identifier) }
18
-
19
- children.map { |i| self.class.new(i, @context) }.freeze
20
- end
21
-
22
- # Returns the parent of this item, if one exists. For items with identifiers
23
- # that have extensions, returns nil.
24
- #
25
- # @return [Nanoc::CompilationItemView] if the item has a parent
26
- #
27
- # @return [nil] if the item has no parent
28
- def parent
29
- unless _unwrap.identifier.legacy?
30
- raise Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(_unwrap.identifier)
31
- end
32
-
33
- parent_identifier = '/' + _unwrap.identifier.components[0..-2].join('/') + '/'
34
- parent_identifier = '/' if parent_identifier == '//'
35
-
36
- parent = @context.items[parent_identifier]
37
-
38
- parent && self.class.new(parent, @context)
39
- end
40
-
41
- # @return [Boolean] True if the item is binary, false otherwise
42
- def binary?
43
- _unwrap.content.binary?
44
- end
45
-
46
- # @return [String, nil] The path to the file containing the uncompiled content of this item.
47
- def raw_filename
48
- @context.dependency_tracker.bounce(_unwrap, raw_content: true)
49
- _unwrap.content.filename
50
- end
51
- end
52
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class CompilationItemRepCollectionView < ::Nanoc::BasicItemRepCollectionView
5
- # @api private
6
- def view_class
7
- Nanoc::CompilationItemRepView
8
- end
9
- end
10
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class CompilationItemRepView < ::Nanoc::BasicItemRepView
5
- # @abstract
6
- def item_view_class
7
- Nanoc::CompilationItemView
8
- end
9
-
10
- # Returns the item rep’s raw path. It includes the path to the output
11
- # directory and the full filename.
12
- #
13
- # @param [Symbol] snapshot The snapshot for which the path should be
14
- # returned.
15
- #
16
- # @return [String] The item rep’s raw path.
17
- def raw_path(snapshot: :last)
18
- @context.dependency_tracker.bounce(_unwrap.item, compiled_content: true)
19
-
20
- res = @item_rep.raw_path(snapshot: snapshot)
21
-
22
- unless @item_rep.compiled?
23
- Fiber.yield(Nanoc::Int::Errors::UnmetDependency.new(@item_rep, snapshot))
24
- end
25
-
26
- # Wait for file to exist
27
- if res
28
- start = Time.now
29
- sleep 0.05 until File.file?(res) || Time.now - start > 1.0
30
- raise Nanoc::Int::Errors::InternalInconsistency, "File did not apear in time: #{res}" unless File.file?(res)
31
- end
32
-
33
- res
34
- end
35
-
36
- # Returns the compiled content.
37
- #
38
- # @param [String] snapshot The name of the snapshot from which to
39
- # fetch the compiled content. By default, the returned compiled content
40
- # will be the content compiled right before the first layout call (if
41
- # any).
42
- #
43
- # @return [String] The content at the given snapshot.
44
- def compiled_content(snapshot: nil)
45
- @context.dependency_tracker.bounce(_unwrap.item, compiled_content: true)
46
- @context.compiled_content_store.compiled_content(rep: _unwrap, snapshot: snapshot)
47
- end
48
- end
49
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class CompilationItemView < ::Nanoc::BasicItemView
5
- # Returns the compiled content.
6
- #
7
- # @param [String] rep The name of the representation
8
- # from which the compiled content should be fetched. By default, the
9
- # compiled content will be fetched from the default representation.
10
- #
11
- # @param [String] snapshot The name of the snapshot from which to
12
- # fetch the compiled content. By default, the returned compiled content
13
- # will be the content compiled right before the first layout call (if
14
- # any).
15
- #
16
- # @return [String] The content of the given rep at the given snapshot.
17
- def compiled_content(rep: :default, snapshot: nil)
18
- reps.fetch(rep).compiled_content(snapshot: snapshot)
19
- end
20
-
21
- # Returns the item path, as used when being linked to. It starts
22
- # with a slash and it is relative to the output directory. It does not
23
- # include the path to the output directory. It will not include the
24
- # filename if the filename is an index filename.
25
- #
26
- # @param [String] rep The name of the representation
27
- # from which the path should be fetched. By default, the path will be
28
- # fetched from the default representation.
29
- #
30
- # @param [Symbol] snapshot The snapshot for which the
31
- # path should be returned.
32
- #
33
- # @return [String] The item’s path.
34
- def path(rep: :default, snapshot: :last)
35
- reps.fetch(rep).path(snapshot: snapshot)
36
- end
37
-
38
- # Returns the representations of this item.
39
- #
40
- # @return [Nanoc::BasicItemRepCollectionView]
41
- def reps
42
- Nanoc::CompilationItemRepCollectionView.new(@context.reps[_unwrap], @context)
43
- end
44
- end
45
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class ConfigView < ::Nanoc::View
5
- # @api private
6
- NONE = Object.new.freeze
7
-
8
- # @api private
9
- def initialize(config, context)
10
- super(context)
11
- @config = config
12
- end
13
-
14
- # @api private
15
- def _unwrap
16
- @config
17
- end
18
-
19
- # @api private
20
- def output_dir
21
- @config.output_dir
22
- end
23
-
24
- # @see Hash#fetch
25
- def fetch(key, fallback = NONE, &_block)
26
- @context.dependency_tracker.bounce(_unwrap, attributes: [key])
27
- @config.fetch(key) do
28
- if !fallback.equal?(NONE)
29
- fallback
30
- elsif block_given?
31
- yield(key)
32
- else
33
- raise KeyError, "key not found: #{key.inspect}"
34
- end
35
- end
36
- end
37
-
38
- # @see Hash#key?
39
- def key?(key)
40
- @context.dependency_tracker.bounce(_unwrap, attributes: [key])
41
- @config.key?(key)
42
- end
43
-
44
- # @see Hash#[]
45
- def [](key)
46
- @context.dependency_tracker.bounce(_unwrap, attributes: [key])
47
- @config[key]
48
- end
49
-
50
- # @see Hash#each
51
- def each(&block)
52
- @context.dependency_tracker.bounce(_unwrap, attributes: true)
53
- @config.each(&block)
54
- end
55
-
56
- # @see Configuration#env_name
57
- def env_name
58
- @context.dependency_tracker.bounce(_unwrap, attributes: true)
59
- @config.env_name
60
- end
61
-
62
- # @see Hash#dig
63
- def dig(*keys)
64
- @context.dependency_tracker.bounce(_unwrap, attributes: keys.take(1))
65
- @config.dig(*keys)
66
- end
67
- end
68
- end
@@ -1,109 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class IdentifiableCollectionView < ::Nanoc::View
5
- include Enumerable
6
-
7
- NOTHING = Object.new
8
-
9
- # @api private
10
- def initialize(objects, context)
11
- super(context)
12
- @objects = objects
13
- end
14
-
15
- # @api private
16
- def _unwrap
17
- @objects
18
- end
19
-
20
- # @abstract
21
- #
22
- # @api private
23
- def view_class
24
- raise NotImplementedError
25
- end
26
-
27
- # Calls the given block once for each object, passing that object as a parameter.
28
- #
29
- # @yieldparam [#identifier] object
30
- #
31
- # @yieldreturn [void]
32
- #
33
- # @return [self]
34
- def each
35
- @context.dependency_tracker.bounce(_unwrap, raw_content: true)
36
- @objects.each { |i| yield view_class.new(i, @context) }
37
- self
38
- end
39
-
40
- # @return [Integer]
41
- def size
42
- @context.dependency_tracker.bounce(_unwrap, raw_content: true)
43
- @objects.size
44
- end
45
-
46
- # Finds all objects whose identifier matches the given argument.
47
- #
48
- # @param [String, Regex] arg
49
- #
50
- # @return [Enumerable]
51
- def find_all(arg = NOTHING, &block)
52
- if NOTHING.equal?(arg)
53
- @context.dependency_tracker.bounce(_unwrap, raw_content: true)
54
- return @objects.map { |i| view_class.new(i, @context) }.select(&block)
55
- end
56
-
57
- prop_attribute =
58
- case arg
59
- when String, Nanoc::Core::Identifier
60
- [arg.to_s]
61
- when Regexp
62
- [arg]
63
- else
64
- true
65
- end
66
-
67
- @context.dependency_tracker.bounce(_unwrap, raw_content: prop_attribute)
68
- @objects.find_all(arg).map { |i| view_class.new(i, @context) }
69
- end
70
-
71
- # @overload [](string)
72
- #
73
- # Finds the object whose identifier matches the given string.
74
- #
75
- # If the glob syntax is enabled, the string can be a glob, in which case
76
- # this method finds the first object that matches the given glob.
77
- #
78
- # @param [String] string
79
- #
80
- # @return [nil] if no object matches the string
81
- #
82
- # @return [#identifier] if an object was found
83
- #
84
- # @overload [](regex)
85
- #
86
- # Finds the object whose identifier matches the given regular expression.
87
- #
88
- # @param [Regex] regex
89
- #
90
- # @return [nil] if no object matches the regex
91
- #
92
- # @return [#identifier] if an object was found
93
- def [](arg)
94
- prop_attribute =
95
- case arg
96
- when String, Nanoc::Core::Identifier
97
- [arg.to_s]
98
- when Regexp
99
- [arg]
100
- else
101
- true
102
- end
103
-
104
- @context.dependency_tracker.bounce(_unwrap, raw_content: prop_attribute)
105
- res = @objects[arg]
106
- res && view_class.new(res, @context)
107
- end
108
- end
109
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class ItemCollectionWithRepsView < ::Nanoc::IdentifiableCollectionView
5
- # @api private
6
- def view_class
7
- Nanoc::CompilationItemView
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class ItemCollectionWithoutRepsView < ::Nanoc::IdentifiableCollectionView
5
- # @api private
6
- def view_class
7
- Nanoc::BasicItemView
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class LayoutCollectionView < ::Nanoc::IdentifiableCollectionView
5
- # @api private
6
- def view_class
7
- Nanoc::LayoutView
8
- end
9
- end
10
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class LayoutView < ::Nanoc::View
5
- include Nanoc::DocumentViewMixin
6
- end
7
- end
@@ -1,88 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module DocumentViewMixin
5
- # @api private
6
- NONE = Object.new.freeze
7
-
8
- # @api private
9
- def initialize(document, context)
10
- super(context)
11
- @document = document
12
- end
13
-
14
- # @api private
15
- def _unwrap
16
- @document
17
- end
18
-
19
- # @see Object#==
20
- def ==(other)
21
- other.respond_to?(:identifier) && identifier == other.identifier
22
- end
23
-
24
- # @see Object#eql?
25
- def eql?(other)
26
- other.is_a?(self.class) && identifier.eql?(other.identifier)
27
- end
28
-
29
- # @see Object#hash
30
- def hash
31
- self.class.hash ^ identifier.hash
32
- end
33
-
34
- # @return [Nanoc::Core::Identifier]
35
- def identifier
36
- _unwrap.identifier
37
- end
38
-
39
- # @see Hash#[]
40
- def [](key)
41
- @context.dependency_tracker.bounce(_unwrap, attributes: [key])
42
- _unwrap.attributes[key]
43
- end
44
-
45
- # @return [Hash]
46
- def attributes
47
- # TODO: Refine dependencies
48
- @context.dependency_tracker.bounce(_unwrap, attributes: true)
49
- _unwrap.attributes
50
- end
51
-
52
- # @see Hash#fetch
53
- def fetch(key, fallback = NONE, &_block)
54
- @context.dependency_tracker.bounce(_unwrap, attributes: [key])
55
-
56
- if _unwrap.attributes.key?(key)
57
- _unwrap.attributes[key]
58
- elsif !fallback.equal?(NONE)
59
- fallback
60
- elsif block_given?
61
- yield(key)
62
- else
63
- raise KeyError, "key not found: #{key.inspect}"
64
- end
65
- end
66
-
67
- # @see Hash#key?
68
- def key?(key)
69
- @context.dependency_tracker.bounce(_unwrap, attributes: [key])
70
- _unwrap.attributes.key?(key)
71
- end
72
-
73
- # @api private
74
- def reference
75
- _unwrap.reference
76
- end
77
-
78
- # @api private
79
- def raw_content
80
- @context.dependency_tracker.bounce(_unwrap, raw_content: true)
81
- _unwrap.content.string
82
- end
83
-
84
- def inspect
85
- "<#{self.class} identifier=#{_unwrap.identifier}>"
86
- end
87
- end
88
- end