nanoc 4.0.2 → 4.1.0a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +17 -0
  3. data/Gemfile +50 -46
  4. data/Gemfile.lock +365 -0
  5. data/Guardfile +3 -0
  6. data/NEWS.md +21 -0
  7. data/README.md +1 -1
  8. data/lib/nanoc/base.rb +3 -15
  9. data/lib/nanoc/base/checksummer.rb +3 -14
  10. data/lib/nanoc/base/compilation/compiler.rb +112 -283
  11. data/lib/nanoc/base/compilation/compiler_dsl.rb +29 -37
  12. data/lib/nanoc/base/compilation/dependency_tracker.rb +25 -170
  13. data/lib/nanoc/base/compilation/filter.rb +3 -4
  14. data/lib/nanoc/base/compilation/item_rep_repo.rb +33 -0
  15. data/lib/nanoc/base/compilation/outdatedness_checker.rb +39 -53
  16. data/lib/nanoc/base/compilation/rule.rb +13 -24
  17. data/lib/nanoc/base/compilation/rule_context.rb +29 -15
  18. data/lib/nanoc/base/entities.rb +10 -0
  19. data/lib/nanoc/base/{source_data → entities}/code_snippet.rb +1 -4
  20. data/lib/nanoc/base/{source_data → entities}/configuration.rb +1 -1
  21. data/lib/nanoc/base/entities/content.rb +8 -9
  22. data/lib/nanoc/base/{identifiable_collection.rb → entities/identifiable_collection.rb} +0 -0
  23. data/lib/nanoc/base/entities/identifier.rb +11 -2
  24. data/lib/nanoc/base/{source_data → entities}/item.rb +0 -18
  25. data/lib/nanoc/base/{result_data → entities}/item_rep.rb +15 -13
  26. data/lib/nanoc/base/entities/rule_memory.rb +54 -0
  27. data/lib/nanoc/base/entities/rule_memory_action.rb +19 -0
  28. data/lib/nanoc/base/entities/rule_memory_actions.rb +3 -0
  29. data/lib/nanoc/base/entities/rule_memory_actions/filter.rb +22 -0
  30. data/lib/nanoc/base/entities/rule_memory_actions/layout.rb +22 -0
  31. data/lib/nanoc/base/entities/rule_memory_actions/snapshot.rb +26 -0
  32. data/lib/nanoc/base/entities/rules_collection.rb +120 -0
  33. data/lib/nanoc/base/{source_data → entities}/site.rb +11 -10
  34. data/lib/nanoc/base/repos.rb +2 -0
  35. data/lib/nanoc/base/repos/checksum_store.rb +3 -9
  36. data/lib/nanoc/base/repos/compiled_content_cache.rb +0 -5
  37. data/lib/nanoc/base/{source_data → repos}/data_source.rb +3 -6
  38. data/lib/nanoc/base/repos/dependency_store.rb +118 -0
  39. data/lib/nanoc/base/repos/rule_memory_store.rb +1 -5
  40. data/lib/nanoc/base/repos/site_loader.rb +0 -28
  41. data/lib/nanoc/base/repos/store.rb +0 -12
  42. data/lib/nanoc/base/services.rb +8 -0
  43. data/lib/nanoc/base/services/compiler_loader.rb +49 -0
  44. data/lib/nanoc/base/services/executor.rb +4 -4
  45. data/lib/nanoc/base/services/item_rep_builder.rb +30 -0
  46. data/lib/nanoc/base/services/item_rep_router.rb +55 -0
  47. data/lib/nanoc/base/services/item_rep_selector.rb +39 -0
  48. data/lib/nanoc/base/services/item_rep_writer.rb +2 -0
  49. data/lib/nanoc/base/services/postprocessor.rb +26 -0
  50. data/lib/nanoc/base/services/preprocessor.rb +26 -0
  51. data/lib/nanoc/base/services/recording_executor.rb +36 -22
  52. data/lib/nanoc/base/services/rule_memory_calculator.rb +84 -0
  53. data/lib/nanoc/base/services/rules_loader.rb +29 -0
  54. data/lib/nanoc/base/views.rb +6 -0
  55. data/lib/nanoc/base/views/config_view.rb +8 -2
  56. data/lib/nanoc/base/views/identifiable_collection_view.rb +5 -4
  57. data/lib/nanoc/base/views/item_rep_collection_view.rb +7 -6
  58. data/lib/nanoc/base/views/item_rep_view.rb +13 -12
  59. data/lib/nanoc/base/views/item_view.rb +18 -12
  60. data/lib/nanoc/base/views/layout_view.rb +1 -1
  61. data/lib/nanoc/base/views/mixins/document_view_mixin.rb +2 -1
  62. data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +1 -1
  63. data/lib/nanoc/base/views/mutable_item_collection_view.rb +4 -7
  64. data/lib/nanoc/base/views/post_compile_item_collection_view.rb +8 -0
  65. data/lib/nanoc/base/views/post_compile_item_view.rb +7 -0
  66. data/lib/nanoc/base/views/site_view.rb +3 -2
  67. data/lib/nanoc/base/views/view.rb +12 -0
  68. data/lib/nanoc/base/views/view_context.rb +12 -0
  69. data/lib/nanoc/cli/commands/compile.rb +13 -15
  70. data/lib/nanoc/cli/commands/create-site.rb +15 -0
  71. data/lib/nanoc/cli/commands/prune.rb +1 -1
  72. data/lib/nanoc/cli/commands/shell.rb +3 -3
  73. data/lib/nanoc/cli/commands/show-data.rb +5 -5
  74. data/lib/nanoc/cli/commands/show-rules.rb +2 -1
  75. data/lib/nanoc/cli/error_handler.rb +28 -30
  76. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +1 -1
  77. data/lib/nanoc/data_sources/filesystem.rb +1 -1
  78. data/lib/nanoc/extra/checking/check.rb +8 -7
  79. data/lib/nanoc/extra/checking/checks/external_links.rb +14 -1
  80. data/lib/nanoc/extra/checking/runner.rb +1 -1
  81. data/lib/nanoc/extra/deployer.rb +3 -3
  82. data/lib/nanoc/extra/piper.rb +5 -5
  83. data/lib/nanoc/extra/pruner.rb +8 -7
  84. data/lib/nanoc/filters/relativize_paths.rb +48 -32
  85. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +0 -1
  86. data/lib/nanoc/helpers/blogging.rb +15 -7
  87. data/lib/nanoc/helpers/capturing.rb +56 -13
  88. data/lib/nanoc/helpers/link_to.rb +2 -2
  89. data/lib/nanoc/helpers/tagging.rb +5 -10
  90. data/lib/nanoc/helpers/text.rb +9 -11
  91. data/lib/nanoc/version.rb +1 -1
  92. data/nanoc-4.0.2.gem +0 -0
  93. data/tags +1175 -0
  94. data/test/base/test_compiler.rb +48 -98
  95. data/test/base/test_compiler_dsl.rb +113 -39
  96. data/test/base/test_dependency_tracker.rb +80 -79
  97. data/test/base/test_outdatedness_checker.rb +39 -26
  98. data/test/base/test_site.rb +0 -97
  99. data/test/cli/commands/test_compile.rb +2 -3
  100. data/test/extra/checking/checks/test_external_links.rb +25 -0
  101. data/test/extra/deployers/test_fog.rb +12 -6
  102. data/test/filters/test_erb.rb +1 -1
  103. data/test/filters/test_erubis.rb +1 -1
  104. data/test/filters/test_haml.rb +1 -1
  105. data/test/filters/test_less.rb +4 -4
  106. data/test/filters/test_sass.rb +1 -0
  107. data/test/filters/test_xsl.rb +7 -8
  108. data/test/helper.rb +0 -2
  109. data/test/helpers/test_blogging.rb +26 -23
  110. data/test/helpers/test_capturing.rb +131 -12
  111. data/test/helpers/test_filtering.rb +6 -6
  112. data/test/helpers/test_link_to.rb +1 -1
  113. data/test/helpers/test_rendering.rb +16 -24
  114. data/test/helpers/test_tagging.rb +13 -10
  115. data/test/helpers/test_xml_sitemap.rb +25 -21
  116. metadata +36 -14
  117. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +0 -35
  118. data/lib/nanoc/base/compilation/rules_collection.rb +0 -245
  119. data/test/base/test_rule_context.rb +0 -78
@@ -0,0 +1,29 @@
1
+ module Nanoc::Int
2
+ # @api private
3
+ class RulesLoader
4
+ def initialize(config, rules_collection)
5
+ @dsl = Nanoc::Int::CompilerDSL.new(rules_collection, config)
6
+ end
7
+
8
+ def load
9
+ # Find rules file
10
+ rules_filenames = ['Rules', 'rules', 'Rules.rb', 'rules.rb']
11
+ rules_filename = rules_filenames.find { |f| File.file?(f) }
12
+ raise Nanoc::Int::Errors::NoRulesFileFound.new if rules_filename.nil?
13
+
14
+ parse(rules_filename)
15
+ end
16
+
17
+ def parse(rules_filename)
18
+ rules_filename = File.absolute_path(rules_filename)
19
+
20
+ # Get rule data
21
+ data = File.read(rules_filename)
22
+
23
+ old_rules_filename = @dsl.rules_filename
24
+ @dsl.rules_filename = rules_filename
25
+ @dsl.instance_eval(data, rules_filename)
26
+ @dsl.rules_filename = old_rules_filename
27
+ end
28
+ end
29
+ end
@@ -1,6 +1,9 @@
1
1
  require_relative 'views/mixins/document_view_mixin'
2
2
  require_relative 'views/mixins/mutable_document_view_mixin'
3
3
 
4
+ require_relative 'views/view'
5
+ require_relative 'views/view_context'
6
+
4
7
  require_relative 'views/config_view'
5
8
  require_relative 'views/identifiable_collection_view'
6
9
  require_relative 'views/item_view'
@@ -16,3 +19,6 @@ require_relative 'views/mutable_item_collection_view'
16
19
  require_relative 'views/mutable_layout_view'
17
20
  require_relative 'views/mutable_layout_collection_view'
18
21
  require_relative 'views/site_view'
22
+
23
+ require_relative 'views/post_compile_item_view'
24
+ require_relative 'views/post_compile_item_collection_view'
@@ -1,10 +1,11 @@
1
1
  module Nanoc
2
- class ConfigView
2
+ class ConfigView < ::Nanoc::View
3
3
  # @api private
4
4
  NONE = Object.new
5
5
 
6
6
  # @api private
7
- def initialize(config)
7
+ def initialize(config, context)
8
+ super(context)
8
9
  @config = config
9
10
  end
10
11
 
@@ -35,5 +36,10 @@ module Nanoc
35
36
  def [](key)
36
37
  @config[key]
37
38
  end
39
+
40
+ # @see Hash#each
41
+ def each(&block)
42
+ @config.each(&block)
43
+ end
38
44
  end
39
45
  end
@@ -1,9 +1,10 @@
1
1
  module Nanoc
2
- class IdentifiableCollectionView
2
+ class IdentifiableCollectionView < ::Nanoc::View
3
3
  include Enumerable
4
4
 
5
5
  # @api private
6
- def initialize(objects)
6
+ def initialize(objects, context)
7
+ super(context)
7
8
  @objects = objects
8
9
  end
9
10
 
@@ -27,7 +28,7 @@ module Nanoc
27
28
  #
28
29
  # @return [self]
29
30
  def each
30
- @objects.each { |i| yield view_class.new(i) }
31
+ @objects.each { |i| yield view_class.new(i, @context) }
31
32
  self
32
33
  end
33
34
 
@@ -70,7 +71,7 @@ module Nanoc
70
71
  # @return [#identifier] if an object was found
71
72
  def [](arg)
72
73
  res = @objects[arg]
73
- res && view_class.new(res)
74
+ res && view_class.new(res, @context)
74
75
  end
75
76
  end
76
77
  end
@@ -1,5 +1,5 @@
1
1
  module Nanoc
2
- class ItemRepCollectionView
2
+ class ItemRepCollectionView < ::Nanoc::View
3
3
  include Enumerable
4
4
 
5
5
  class NoSuchItemRepError < ::Nanoc::Error
@@ -9,7 +9,8 @@ module Nanoc
9
9
  end
10
10
 
11
11
  # @api private
12
- def initialize(item_reps)
12
+ def initialize(item_reps, context)
13
+ super(context)
13
14
  @item_reps = item_reps
14
15
  end
15
16
 
@@ -19,7 +20,7 @@ module Nanoc
19
20
  end
20
21
 
21
22
  def to_ary
22
- @item_reps.map { |ir| Nanoc::ItemRepView.new(ir) }
23
+ @item_reps.map { |ir| Nanoc::ItemRepView.new(ir, @context) }
23
24
  end
24
25
 
25
26
  # Calls the given block once for each item rep, passing that item rep as a parameter.
@@ -30,7 +31,7 @@ module Nanoc
30
31
  #
31
32
  # @return [self]
32
33
  def each
33
- @item_reps.each { |ir| yield Nanoc::ItemRepView.new(ir) }
34
+ @item_reps.each { |ir| yield Nanoc::ItemRepView.new(ir, @context) }
34
35
  self
35
36
  end
36
37
 
@@ -50,7 +51,7 @@ module Nanoc
50
51
  case rep_name
51
52
  when Symbol
52
53
  res = @item_reps.find { |ir| ir.name == rep_name }
53
- res && Nanoc::ItemRepView.new(res)
54
+ res && Nanoc::ItemRepView.new(res, @context)
54
55
  when Fixnum
55
56
  raise ArgumentError, "expected ItemRepCollectionView#[] to be called with a symbol (you likely want `.reps[:default]` rather than `.reps[#{rep_name}]`)"
56
57
  else
@@ -69,7 +70,7 @@ module Nanoc
69
70
  def fetch(rep_name)
70
71
  res = @item_reps.find { |ir| ir.name == rep_name }
71
72
  if res
72
- Nanoc::ItemRepView.new(res)
73
+ Nanoc::ItemRepView.new(res, @context)
73
74
  else
74
75
  raise NoSuchItemRepError.new(rep_name)
75
76
  end
@@ -1,7 +1,8 @@
1
1
  module Nanoc
2
- class ItemRepView
2
+ class ItemRepView < ::Nanoc::View
3
3
  # @api private
4
- def initialize(item_rep)
4
+ def initialize(item_rep, context)
5
+ super(context)
5
6
  @item_rep = item_rep
6
7
  end
7
8
 
@@ -28,17 +29,17 @@ module Nanoc
28
29
 
29
30
  # Returns the compiled content.
30
31
  #
31
- # @option params [String] :snapshot The name of the snapshot from which to
32
+ # @param [String] snapshot The name of the snapshot from which to
32
33
  # fetch the compiled content. By default, the returned compiled content
33
34
  # will be the content compiled right before the first layout call (if
34
35
  # any).
35
36
  #
36
37
  # @return [String] The content at the given snapshot.
37
- def compiled_content(params = {})
38
+ def compiled_content(snapshot: nil)
38
39
  Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
39
40
  Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap.item)
40
41
 
41
- @item_rep.compiled_content(params)
42
+ @item_rep.compiled_content(snapshot: snapshot)
42
43
  end
43
44
 
44
45
  # Returns the item rep’s path, as used when being linked to. It starts
@@ -46,30 +47,30 @@ module Nanoc
46
47
  # include the path to the output directory. It will not include the
47
48
  # filename if the filename is an index filename.
48
49
  #
49
- # @option params [Symbol] :snapshot (:last) The snapshot for which the
50
- # path should be returned.
50
+ # @param [Symbol] snapshot The snapshot for which the path should be
51
+ # returned.
51
52
  #
52
53
  # @return [String] The item rep’s path.
53
- def path(params = {})
54
+ def path(snapshot: :last)
54
55
  Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
55
56
  Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap.item)
56
57
 
57
- @item_rep.path(params)
58
+ @item_rep.path(snapshot: snapshot)
58
59
  end
59
60
 
60
61
  # Returns the item that this item rep belongs to.
61
62
  #
62
63
  # @return [Nanoc::ItemView]
63
64
  def item
64
- Nanoc::ItemView.new(@item_rep.item)
65
+ Nanoc::ItemView.new(@item_rep.item, @context)
65
66
  end
66
67
 
67
68
  # @api private
68
- def raw_path(params = {})
69
+ def raw_path(snapshot: :last)
69
70
  Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
70
71
  Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap.item)
71
72
 
72
- @item_rep.raw_path(params)
73
+ @item_rep.raw_path(snapshot: snapshot)
73
74
  end
74
75
 
75
76
  # @api private
@@ -1,21 +1,21 @@
1
1
  module Nanoc
2
- class ItemView
2
+ class ItemView < ::Nanoc::View
3
3
  include Nanoc::DocumentViewMixin
4
4
 
5
5
  # Returns the compiled content.
6
6
  #
7
- # @option params [String] :rep (:default) The name of the representation
7
+ # @param [String] rep The name of the representation
8
8
  # from which the compiled content should be fetched. By default, the
9
9
  # compiled content will be fetched from the default representation.
10
10
  #
11
- # @option params [String] :snapshot The name of the snapshot from which to
11
+ # @param [String] snapshot The name of the snapshot from which to
12
12
  # fetch the compiled content. By default, the returned compiled content
13
13
  # will be the content compiled right before the first layout call (if
14
14
  # any).
15
15
  #
16
16
  # @return [String] The content of the given rep at the given snapshot.
17
- def compiled_content(params = {})
18
- reps.fetch(params.fetch(:rep, :default)).compiled_content(params)
17
+ def compiled_content(rep: :default, snapshot: :pre)
18
+ reps.fetch(rep).compiled_content(snapshot: snapshot)
19
19
  end
20
20
 
21
21
  # Returns the item path, as used when being linked to. It starts
@@ -23,16 +23,16 @@ module Nanoc
23
23
  # include the path to the output directory. It will not include the
24
24
  # filename if the filename is an index filename.
25
25
  #
26
- # @option params [String] :rep (:default) The name of the representation
26
+ # @param [String] rep The name of the representation
27
27
  # from which the path should be fetched. By default, the path will be
28
28
  # fetched from the default representation.
29
29
  #
30
- # @option params [Symbol] :snapshot (:last) The snapshot for which the
30
+ # @param [Symbol] snapshot The snapshot for which the
31
31
  # path should be returned.
32
32
  #
33
33
  # @return [String] The item’s path.
34
- def path(params = {})
35
- reps.fetch(params.fetch(:rep, :default)).path(params)
34
+ def path(rep: :default, snapshot: :last)
35
+ reps.fetch(rep).path(snapshot: snapshot)
36
36
  end
37
37
 
38
38
  # Returns the children of this item. For items with identifiers that have
@@ -44,7 +44,10 @@ module Nanoc
44
44
  raise Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(unwrap.identifier)
45
45
  end
46
46
 
47
- unwrap.children.map { |i| Nanoc::ItemView.new(i) }
47
+ children_pattern = Nanoc::Int::Pattern.from(unwrap.identifier.to_s + '*/')
48
+ children = @context.items.select { |i| children_pattern.match?(i.identifier) }
49
+
50
+ children.map { |i| Nanoc::ItemView.new(i, @context) }.freeze
48
51
  end
49
52
 
50
53
  # Returns the parent of this item, if one exists. For items with identifiers
@@ -58,7 +61,10 @@ module Nanoc
58
61
  raise Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(unwrap.identifier)
59
62
  end
60
63
 
61
- unwrap.parent && Nanoc::ItemView.new(unwrap.parent)
64
+ parent_identifier = '/' + unwrap.identifier.components[0..-2].join('/') + '/'
65
+ parent = @context.items[parent_identifier]
66
+
67
+ parent && Nanoc::ItemView.new(parent, @context).freeze
62
68
  end
63
69
 
64
70
  # @return [Boolean] True if the item is binary, false otherwise
@@ -70,7 +76,7 @@ module Nanoc
70
76
  #
71
77
  # @return [Nanoc::ItemRepCollectionView]
72
78
  def reps
73
- Nanoc::ItemRepCollectionView.new(unwrap.reps)
79
+ Nanoc::ItemRepCollectionView.new(@context.reps[unwrap], @context)
74
80
  end
75
81
 
76
82
  # @api private
@@ -1,5 +1,5 @@
1
1
  module Nanoc
2
- class LayoutView
2
+ class LayoutView < ::Nanoc::View
3
3
  include Nanoc::DocumentViewMixin
4
4
  end
5
5
  end
@@ -4,7 +4,8 @@ module Nanoc
4
4
  NONE = Object.new
5
5
 
6
6
  # @api private
7
- def initialize(document)
7
+ def initialize(document, context)
8
+ super(context)
8
9
  @document = document
9
10
  end
10
11
 
@@ -8,7 +8,7 @@ module Nanoc
8
8
  #
9
9
  # @return [self]
10
10
  def delete_if(&_block)
11
- @objects.delete_if { |o| yield(view_class.new(o)) }
11
+ @objects.delete_if { |o| yield(view_class.new(o, @context)) }
12
12
  self
13
13
  end
14
14
  end
@@ -15,17 +15,14 @@ module Nanoc
15
15
  #
16
16
  # @param [Nanoc::Identifier, String] identifier This item's identifier.
17
17
  #
18
- # @param [Hash] params Extra parameters.
18
+ # @param [Boolean] binary Whether or not this item is binary
19
19
  #
20
- # @option params [Boolean] :binary (false) Whether or not this item is
21
- # binary
22
- #
23
- # @option params [String] :filename (nil) Absolute path to the file
20
+ # @param [String] filename Absolute path to the file
24
21
  # containing this content (if any)
25
22
  #
26
23
  # @return [self]
27
- def create(content, attributes, identifier, params = {})
28
- content = Nanoc::Int::Content.create(content, params)
24
+ def create(content, attributes, identifier, binary: false, filename: nil)
25
+ content = Nanoc::Int::Content.create(content, binary: binary, filename: filename)
29
26
  @objects << Nanoc::Int::Item.new(content, attributes, identifier)
30
27
  self
31
28
  end
@@ -0,0 +1,8 @@
1
+ module Nanoc
2
+ class PostCompileItemCollectionView < Nanoc::IdentifiableCollectionView
3
+ # @api private
4
+ def view_class
5
+ Nanoc::PostCompileItemView
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Nanoc
2
+ class PostCompileItemView < Nanoc::ItemView
3
+ def modified
4
+ reps.select { |rep| rep.unwrap.modified }
5
+ end
6
+ end
7
+ end
@@ -1,7 +1,8 @@
1
1
  module Nanoc
2
- class SiteView
2
+ class SiteView < ::Nanoc::View
3
3
  # @api private
4
- def initialize(site)
4
+ def initialize(site, context)
5
+ super(context)
5
6
  @site = site
6
7
  end
7
8
 
@@ -0,0 +1,12 @@
1
+ module Nanoc
2
+ class View
3
+ # @api private
4
+ def initialize(context)
5
+ @context = context
6
+ end
7
+
8
+ def _context
9
+ @context
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Nanoc
2
+ # @api private
3
+ class ViewContext
4
+ attr_reader :reps
5
+ attr_reader :items
6
+
7
+ def initialize(reps:, items:)
8
+ @reps = reps
9
+ @items = items
10
+ end
11
+ end
12
+ end
@@ -17,15 +17,13 @@ EOS
17
17
 
18
18
  module Nanoc::CLI::Commands
19
19
  class Compile < ::Nanoc::CLI::CommandRunner
20
- extend Nanoc::Int::Memoization
21
-
22
20
  # Listens to compilation events and reacts to them. This abstract class
23
21
  # does not have a real implementation; subclasses should override {#start}
24
22
  # and set up notifications to listen to.
25
23
  #
26
24
  # @abstract Subclasses must override {#start} and may override {#stop}.
27
25
  class Listener
28
- def initialize(_params = {})
26
+ def initialize(*)
29
27
  end
30
28
 
31
29
  # @param [Nanoc::CLI::CommandRunner] command_runner The command runner for this listener
@@ -147,11 +145,11 @@ module Nanoc::CLI::Commands
147
145
  command_runner.options.fetch(:verbose, false)
148
146
  end
149
147
 
150
- # @option params [Array<Nanoc::Int::ItemRep>] :reps The list of item representations in the site
151
- def initialize(params = {})
148
+ # @param [Enumerable<Nanoc::Int::ItemRep>] reps
149
+ def initialize(reps:)
152
150
  @times = {}
153
151
 
154
- @reps = params.fetch(:reps)
152
+ @reps = reps
155
153
  end
156
154
 
157
155
  # @see Listener#start
@@ -249,7 +247,7 @@ module Nanoc::CLI::Commands
249
247
  !ENV.key?('TRAVIS')
250
248
  end
251
249
 
252
- def initialize(_params = {})
250
+ def initialize(*)
253
251
  @gc_count = 0
254
252
  end
255
253
 
@@ -314,11 +312,10 @@ module Nanoc::CLI::Commands
314
312
 
315
313
  # Prints file actions (created, updated, deleted, identical, skipped)
316
314
  class FileActionPrinter < Listener
317
- # @option params [Array<Nanoc::Int::ItemRep>] :reps The list of item representations in the site
318
- def initialize(params = {})
315
+ def initialize(reps:)
319
316
  @start_times = {}
320
317
 
321
- @reps = params.fetch(:reps)
318
+ @reps = reps
322
319
  end
323
320
 
324
321
  # @see Listener#start
@@ -361,9 +358,11 @@ module Nanoc::CLI::Commands
361
358
  end
362
359
  end
363
360
 
364
- def initialize(options, arguments, command, params = {})
365
- super(options, arguments, command)
366
- @listener_classes = params.fetch(:listener_classes, default_listener_classes)
361
+ attr_accessor :listener_classes
362
+
363
+ def initialize(options, arguments, command)
364
+ super
365
+ @listener_classes = default_listener_classes
367
366
  end
368
367
 
369
368
  def run
@@ -425,9 +424,8 @@ module Nanoc::CLI::Commands
425
424
  end
426
425
 
427
426
  def reps
428
- site.items.map(&:reps).flatten
427
+ site.compiler.reps
429
428
  end
430
- memoize :reps
431
429
 
432
430
  def prune_config
433
431
  site.config[:prune] || {}