<commit_before>require 'itamae'

module Itamae
  class Recipe
    attr_reader :path
    attr_reader :runner
    attr_reader :dependencies
    attr_reader :delayed_actions

    def initialize(runner, path)
      @runner = runner
      @path = path
      @dependencies = RecipeDependencies.new
      @delayed_actions = []

      load_dependencies
    end

    def node
      @runner.node
    end

    def run(options = {})
      Logger.info "Recipe: #{@path}"

      @dependencies.each do |resource|
        case resource
        when Resource::Base
          resource.run(nil, dry_run: options[:dry_run])
        when Recipe
          resource.run(options)
        end
      end

      @delayed_actions.uniq.each do |action, resource|
        resource.run(action, dry_run: options[:dry_run])
      end

      Logger.info "< Finished. (#{@path})"
    end

    private

    def load_dependencies
      instance_eval(File.read(@path), @path, 1)
    end

    def method_missing(method, name, &block)
      klass = Resource.get_resource_class(method)
      resource = klass.new(self, name, &block)
      @dependencies << resource
    rescue NameError
      super
    end

    def include_recipe(target)
      target = ::File.expand_path(target, File.dirname(@path))
      recipe = Recipe.new(@runner, target)
      @dependencies << recipe
    end
  end
end

<commit_msg>If a file to be included doesn't exist, raise an error.<commit_after>require 'itamae'

module Itamae
  class Recipe
    NotFoundError = Class.new(StandardError)

    attr_reader :path
    attr_reader :runner
    attr_reader :dependencies
    attr_reader :delayed_actions

    def initialize(runner, path)
      @runner = runner
      @path = path
      @dependencies = RecipeDependencies.new
      @delayed_actions = []

      load_dependencies
    end

    def node
      @runner.node
    end

    def run(options = {})
      Logger.info "Recipe: #{@path}"

      @dependencies.each do |resource|
        case resource
        when Resource::Base
          resource.run(nil, dry_run: options[:dry_run])
        when Recipe
          resource.run(options)
        end
      end

      @delayed_actions.uniq.each do |action, resource|
        resource.run(action, dry_run: options[:dry_run])
      end

      Logger.info "< Finished. (#{@path})"
    end

    private

    def load_dependencies
      instance_eval(File.read(@path), @path, 1)
    end

    def method_missing(method, name, &block)
      klass = Resource.get_resource_class(method)
      resource = klass.new(self, name, &block)
      @dependencies << resource
    rescue NameError
      super
    end

    def include_recipe(target)
      target = ::File.expand_path(target, File.dirname(@path))
      unless File.exist?(target)
        raise NotFoundError, "File not found. (#{target})"
      end
      recipe = Recipe.new(@runner, target)
      @dependencies << recipe
    end
  end
end


{'fraction_non_alphanumeric': 0.09595613433858807, 'fraction_numerical': 0.0006854009595613434, 'mean_word_length': 2.4422169811320753, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5284222', 'n_tokens_mistral': 899, 'n_tokens_neox': 861, 'n_words': 217}