nanoc 4.11.12 → 4.11.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- module OutdatednessRules
6
- class ContentModified < Nanoc::Core::OutdatednessRule
7
- affects_props :raw_content, :compiled_content
8
-
9
- def apply(obj, outdatedness_checker)
10
- obj = obj.item if obj.is_a?(Nanoc::Core::ItemRep)
11
-
12
- ch_old = outdatedness_checker.checksum_store.content_checksum_for(obj)
13
- ch_new = outdatedness_checker.checksums.content_checksum_for(obj)
14
- if ch_old != ch_new
15
- Nanoc::Core::OutdatednessReasons::ContentModified
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- module OutdatednessRules
6
- class ItemCollectionExtended < Nanoc::Core::OutdatednessRule
7
- affects_props :raw_content
8
-
9
- contract Nanoc::Core::ItemCollection, C::Named['Nanoc::Int::OutdatednessChecker'] => C::Maybe[Nanoc::Core::OutdatednessReasons::Generic]
10
- def apply(_obj, outdatedness_checker)
11
- new_items = outdatedness_checker.dependency_store.new_items
12
-
13
- if new_items.any?
14
- Nanoc::Core::OutdatednessReasons::ItemCollectionExtended.new(new_items)
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- module OutdatednessRules
6
- class LayoutCollectionExtended < Nanoc::Core::OutdatednessRule
7
- affects_props :raw_content
8
-
9
- contract Nanoc::Core::LayoutCollection, C::Named['Nanoc::Int::OutdatednessChecker'] => C::Maybe[Nanoc::Core::OutdatednessReasons::Generic]
10
- def apply(_obj, outdatedness_checker)
11
- new_layouts = outdatedness_checker.dependency_store.new_layouts
12
-
13
- if new_layouts.any?
14
- Nanoc::Core::OutdatednessReasons::LayoutCollectionExtended.new(new_layouts)
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- module OutdatednessRules
6
- class NotWritten < Nanoc::Core::OutdatednessRule
7
- affects_props :raw_content, :attributes, :compiled_content, :path
8
-
9
- def apply(obj, _outdatedness_checker)
10
- if obj.raw_paths.values.flatten.compact.any? { |fn| !File.file?(fn) }
11
- Nanoc::Core::OutdatednessReasons::NotWritten
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- module OutdatednessRules
6
- class RulesModified < Nanoc::Core::OutdatednessRule
7
- affects_props :compiled_content, :path
8
-
9
- def apply(obj, outdatedness_checker)
10
- # Check rules of obj itself
11
- if rules_modified?(obj, outdatedness_checker)
12
- return Nanoc::Core::OutdatednessReasons::RulesModified
13
- end
14
-
15
- # Check rules of layouts used by obj
16
- layouts = layouts_touched_by(obj, outdatedness_checker)
17
- if layouts.any? { |layout| rules_modified?(layout, outdatedness_checker) }
18
- return Nanoc::Core::OutdatednessReasons::RulesModified
19
- end
20
-
21
- nil
22
- end
23
-
24
- private
25
-
26
- def rules_modified?(obj, outdatedness_checker)
27
- seq_old = outdatedness_checker.action_sequence_store[obj]
28
- seq_new = outdatedness_checker.action_sequence_for(obj).serialize
29
-
30
- !seq_old.eql?(seq_new)
31
- end
32
-
33
- def layouts_touched_by(obj, outdatedness_checker)
34
- actions = outdatedness_checker.action_sequence_store[obj]
35
- layout_actions = actions.select { |a| a.first == :layout }
36
-
37
- layout_actions.map do |layout_action|
38
- layout_pattern = layout_action[1]
39
- outdatedness_checker.site.layouts[layout_pattern]
40
- end.compact
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- module OutdatednessRules
6
- class UsesAlwaysOutdatedFilter < Nanoc::Core::OutdatednessRule
7
- affects_props :raw_content, :attributes, :path
8
-
9
- def apply(obj, outdatedness_checker)
10
- seq = outdatedness_checker.action_sequence_for(obj)
11
- if any_always_outdated?(seq)
12
- Nanoc::Core::OutdatednessReasons::UsesAlwaysOutdatedFilter
13
- end
14
- end
15
-
16
- def any_always_outdated?(seq)
17
- seq
18
- .select { |a| a.is_a?(Nanoc::Core::ProcessingActions::Filter) }
19
- .map { |a| Nanoc::Filter.named(a.filter_name) }
20
- .compact
21
- .any?(&:always_outdated?)
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,123 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- # Responsible for finding and deleting files in the site’s output directory
5
- # that are not managed by Nanoc.
6
- #
7
- # @api private
8
- class Pruner
9
- include Nanoc::Core::ContractsSupport
10
-
11
- contract Nanoc::Core::Configuration, Nanoc::Core::ItemRepRepo, C::KeywordArgs[dry_run: C::Optional[C::Bool], exclude: C::Optional[C::IterOf[String]]] => C::Any
12
- def initialize(config, reps, dry_run: false, exclude: [])
13
- @config = config
14
- @reps = reps
15
- @dry_run = dry_run
16
- @exclude = Set.new(exclude)
17
- end
18
-
19
- def run
20
- return unless File.directory?(@config.output_dir)
21
-
22
- compiled_files = @reps.flat_map { |r| r.raw_paths.values.flatten }.compact
23
- present_files, present_dirs = files_and_dirs_in(@config.output_dir + '/')
24
-
25
- remove_stray_files(present_files, compiled_files)
26
- remove_empty_directories(present_dirs)
27
- end
28
-
29
- contract String => C::Bool
30
- def filename_excluded?(filename)
31
- pathname = Pathname.new(strip_output_dir(filename))
32
- @exclude.any? { |e| pathname_components(pathname).include?(e) }
33
- end
34
-
35
- contract String => String
36
- def strip_output_dir(filename)
37
- if filename.start_with?(@config.output_dir)
38
- filename[@config.output_dir.size..-1]
39
- else
40
- filename
41
- end
42
- end
43
-
44
- contract Pathname => C::ArrayOf[String]
45
- def pathname_components(pathname)
46
- components = []
47
- tmp = pathname
48
- loop do
49
- old = tmp
50
- components << File.basename(tmp)
51
- tmp = File.dirname(tmp)
52
- break if old == tmp
53
- end
54
- components.reverse
55
- end
56
-
57
- contract C::ArrayOf[String], C::ArrayOf[String] => self
58
- # @api private
59
- def remove_stray_files(present_files, compiled_files)
60
- (present_files - compiled_files).each do |f|
61
- delete_file(f) unless filename_excluded?(f)
62
- end
63
- self
64
- end
65
-
66
- contract C::ArrayOf[String] => self
67
- # @api private
68
- def remove_empty_directories(present_dirs)
69
- present_dirs.reverse_each do |dir|
70
- next if Dir.foreach(dir) { |n| break true if n !~ /\A\.\.?\z/ }
71
- next if filename_excluded?(dir)
72
-
73
- delete_dir(dir)
74
- end
75
- self
76
- end
77
-
78
- contract String => C::ArrayOf[C::ArrayOf[String]]
79
- # @api private
80
- def files_and_dirs_in(dir)
81
- present_files = []
82
- present_dirs = []
83
-
84
- expanded_dir = File.expand_path(dir)
85
-
86
- Find.find(dir) do |f|
87
- case File.ftype(f)
88
- when 'file'
89
- unless filename_excluded?(f)
90
- present_files << f
91
- end
92
- when 'directory'
93
- if filename_excluded?(f)
94
- Find.prune
95
- elsif expanded_dir != File.expand_path(f)
96
- present_dirs << f
97
- end
98
- end
99
- end
100
-
101
- [present_files, present_dirs]
102
- end
103
-
104
- protected
105
-
106
- def delete_file(file)
107
- log_delete_and_run(file) { FileUtils.rm(file) }
108
- end
109
-
110
- def delete_dir(dir)
111
- log_delete_and_run(dir) { Dir.rmdir(dir) }
112
- end
113
-
114
- def log_delete_and_run(thing)
115
- if @dry_run
116
- puts thing
117
- else
118
- Nanoc::CLI::Logger.instance.file(:high, :delete, thing)
119
- yield
120
- end
121
- end
122
- end
123
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'views/mixins/document_view_mixin'
4
- require_relative 'views/mixins/mutable_document_view_mixin'
5
-
6
- require_relative 'views/view'
7
-
8
- require_relative 'views/basic_item_rep_view'
9
- require_relative 'views/basic_item_rep_collection_view'
10
- require_relative 'views/basic_item_view'
11
-
12
- require_relative 'views/compilation_item_rep_view'
13
- require_relative 'views/compilation_item_rep_collection_view'
14
- require_relative 'views/compilation_item_view'
15
-
16
- require_relative 'views/config_view'
17
- require_relative 'views/identifiable_collection_view'
18
- require_relative 'views/item_collection_with_reps_view'
19
- require_relative 'views/item_collection_without_reps_view'
20
- require_relative 'views/layout_view'
21
- require_relative 'views/layout_collection_view'
22
-
23
- require_relative 'views/mutable_config_view'
24
- require_relative 'views/mutable_identifiable_collection_view'
25
- require_relative 'views/mutable_item_view'
26
- require_relative 'views/mutable_item_collection_view'
27
- require_relative 'views/mutable_layout_view'
28
- require_relative 'views/mutable_layout_collection_view'
29
-
30
- require_relative 'views/post_compile_item_view'
31
- require_relative 'views/post_compile_item_collection_view'
32
- require_relative 'views/post_compile_item_rep_view'
33
- require_relative 'views/post_compile_item_rep_collection_view'
34
-
35
- # TODO: Move this, once the load order is improved (i.e. the checksummer is
36
- # loded after the views are).
37
- Nanoc::Core::Checksummer.define_behavior(
38
- Nanoc::View,
39
- Nanoc::Core::Checksummer::UnwrapUpdateBehavior,
40
- )
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class BasicItemRepCollectionView < ::Nanoc::View
5
- include Enumerable
6
-
7
- class NoSuchItemRepError < ::Nanoc::Error
8
- def initialize(rep_name)
9
- super("No rep named #{rep_name.inspect} was found.")
10
- end
11
- end
12
-
13
- # @api private
14
- def initialize(item_reps, context)
15
- super(context)
16
- @item_reps = item_reps
17
- end
18
-
19
- # @api private
20
- def _unwrap
21
- @item_reps
22
- end
23
-
24
- # @api private
25
- def view_class
26
- Nanoc::BasicItemRepView
27
- end
28
-
29
- def to_ary
30
- @item_reps.map { |ir| view_class.new(ir, @context) }
31
- end
32
-
33
- # Calls the given block once for each item rep, passing that item rep as a parameter.
34
- #
35
- # @yieldparam [Object] item rep view
36
- #
37
- # @yieldreturn [void]
38
- #
39
- # @return [self]
40
- def each
41
- @item_reps.each { |ir| yield view_class.new(ir, @context) }
42
- self
43
- end
44
-
45
- # @return [Integer]
46
- def size
47
- @item_reps.size
48
- end
49
-
50
- # Return the item rep with the given name, or nil if no item rep exists.
51
- #
52
- # @param [Symbol] rep_name
53
- #
54
- # @return [nil] if no item rep with the given name was found
55
- #
56
- # @return [Nanoc::BasicItemRepView] if an item rep with the given name was found
57
- def [](rep_name)
58
- case rep_name
59
- when Symbol
60
- res = @item_reps.find { |ir| ir.name == rep_name }
61
- res && view_class.new(res, @context)
62
- when Integer
63
- raise ArgumentError, "expected BasicItemRepCollectionView#[] to be called with a symbol (you likely want `.reps[:default]` rather than `.reps[#{rep_name}]`)"
64
- else
65
- raise ArgumentError, 'expected BasicItemRepCollectionView#[] to be called with a symbol'
66
- end
67
- end
68
-
69
- # Return the item rep with the given name, or raises an exception if there
70
- # is no rep with the given name.
71
- #
72
- # @param [Symbol] rep_name
73
- #
74
- # @return [Nanoc::BasicItemRepView]
75
- #
76
- # @raise if no rep was found
77
- def fetch(rep_name)
78
- res = @item_reps.find { |ir| ir.name == rep_name }
79
- if res
80
- view_class.new(res, @context)
81
- else
82
- raise NoSuchItemRepError.new(rep_name)
83
- end
84
- end
85
- end
86
- end
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- class BasicItemRepView < ::Nanoc::View
5
- # @api private
6
- def initialize(item_rep, context)
7
- super(context)
8
- @item_rep = item_rep
9
- end
10
-
11
- # @abstract
12
- def item_view_class
13
- Nanoc::BasicItemView
14
- end
15
-
16
- # @api private
17
- def _unwrap
18
- @item_rep
19
- end
20
-
21
- # @see Object#==
22
- def ==(other)
23
- other.respond_to?(:item) && other.respond_to?(:name) && item == other.item && name == other.name
24
- end
25
-
26
- # @see Object#eql?
27
- def eql?(other)
28
- other.is_a?(self.class) &&
29
- item.eql?(other.item) &&
30
- name.eql?(other.name)
31
- end
32
-
33
- # @see Object#hash
34
- def hash
35
- self.class.hash ^ item.identifier.hash ^ name.hash
36
- end
37
-
38
- # @return [Symbol]
39
- def name
40
- @item_rep.name
41
- end
42
-
43
- def snapshot?(name)
44
- @context.dependency_tracker.bounce(_unwrap.item, compiled_content: true)
45
- @item_rep.snapshot?(name)
46
- end
47
-
48
- # Returns the item rep’s path, as used when being linked to. It starts
49
- # with a slash and it is relative to the output directory. It does not
50
- # include the path to the output directory. It will not include the
51
- # filename if the filename is an index filename.
52
- #
53
- # @param [Symbol] snapshot The snapshot for which the path should be
54
- # returned.
55
- #
56
- # @return [String] The item rep’s path.
57
- def path(snapshot: :last)
58
- @context.dependency_tracker.bounce(_unwrap.item, path: true)
59
- @item_rep.path(snapshot: snapshot)
60
- end
61
-
62
- # Returns the item that this item rep belongs to.
63
- #
64
- # @return [Nanoc::CompilationItemView]
65
- def item
66
- item_view_class.new(@item_rep.item, @context)
67
- end
68
-
69
- # @api private
70
- def binary?
71
- snapshot_def = _unwrap.snapshot_defs.find { |sd| sd.name == :last }
72
- raise Nanoc::Int::Errors::NoSuchSnapshot.new(_unwrap, :last) if snapshot_def.nil?
73
-
74
- snapshot_def.binary?
75
- end
76
-
77
- def inspect
78
- "<#{self.class} item.identifier=#{item.identifier} name=#{name}>"
79
- end
80
- end
81
- end