lib/nanoc/base/compilation/rule.rb in nanoc-3.8.0 vs lib/nanoc/base/compilation/rule.rb in nanoc-4.0.0a1

- old
+ new

@@ -1,9 +1,11 @@ # encoding: utf-8 -module Nanoc +module Nanoc::Int # Contains the processing information for a item. + # + # @api private class Rule # @return [Regexp] The regex that determines which items this rule can be # applied to. This rule can be applied to items with a identifier # matching this regex. attr_reader :identifier_regex @@ -40,34 +42,34 @@ @snapshot_name = params[:snapshot_name] @block = block end - # @param [Nanoc::Item] item The item to check + # @param [Nanoc::Int::Item] item The item to check # # @return [Boolean] true if this rule can be applied to the given item # rep, false otherwise def applicable_to?(item) item.identifier =~ @identifier_regex end # Applies this rule to the given item rep. # - # @param [Nanoc::ItemRep] rep The item representation where this rule + # @param [Nanoc::Int::ItemRep] rep The item representation where this rule # should be applied to # - # @option params [Nanoc::Compiler] :compiler The compiler + # @option params [Nanoc::Int::Compiler] :compiler The compiler # # @raise [ArgumentError] if no compiler is passed # # @return [void] def apply_to(rep, params = {}) compiler = params.fetch(:compiler) do raise ArgumentError, 'Required :compiler option is missing' end - rep = Nanoc::ItemRepProxy.new(rep, compiler) unless rep.proxy? - context = Nanoc::RuleContext.new(rep: rep, compiler: compiler) + rep = Nanoc::Int::ItemRepProxy.new(rep, compiler) unless rep.proxy? + context = Nanoc::Int::RuleContext.new(rep: rep, compiler: compiler) context.instance_exec(matches(rep.item.identifier), &@block) end protected @@ -76,10 +78,10 @@ # # @param [String] identifier Identifier to capture groups for # # @return [nil, Array] Captured groups, if any def matches(identifier) - matches = @identifier_regex.match(identifier) + matches = @identifier_regex.match(identifier.to_s) matches && matches.captures end end end