<commit_before>module Nanoc
  class Compiler

    PAGE_DEFAULTS = {
      :filters    => [],
      :extension  => 'html',
      :order      => 0,
      :layout     => 'default'
    }

    def initialize
      Nanoc::Application.ensure_in_site
      Nanoc::Configuration.reload

      @global_page = PAGE_DEFAULTS.merge(YAML.load_file_and_clean('meta.yaml'))
    end

    def run
      # Require all Ruby source files in lib/
      Dir['lib/*.rb'].each { |f| require f }

      # Compile all pages
      pages = compile_pages(uncompiled_pages)

      # Put pages in their layouts
      pages.each do |page|
        # Prepare layout content
        context = page.merge({ :page => page, :pages => pages }) # fallback for nanoc 1.0
        content = layout_for_page(page).eruby(context)

        # Write page with layout
        FileManager.create_file(path_for_page(page)) { content }
      end
    end

    private

    # Returns a list of uncompiled pages
    def uncompiled_pages
      # Get all meta files
      pages = meta_files.collect do |filename|
        # Read the meta file
        page = @global_page.merge(YAML.load_file_and_clean(filename))
        page[:path] = filename.sub(/^content/, '').sub('meta.yaml', '')

        # Get the content filename<commit_msg>removing ability to access properties of @page directly using instance variables (use @page[:foo] instead of @foo) (was deprecated, now removed)<commit_after>module Nanoc
  class Compiler

    PAGE_DEFAULTS = {
      :filters    => [],
      :extension  => 'html',
      :order      => 0,
      :layout     => 'default'
    }

    def initialize
      Nanoc::Application.ensure_in_site
      Nanoc::Configuration.reload

      @global_page = PAGE_DEFAULTS.merge(YAML.load_file_and_clean('meta.yaml'))
    end

    def run
      # Require all Ruby source files in lib/
      Dir['lib/*.rb'].each { |f| require f }

      # Compile all pages
      pages = compile_pages(uncompiled_pages)

      # Put pages in their layouts
      pages.each do |page|
        # Prepare layout content
        context = { :page => page, :pages => pages }
        content = layout_for_page(page).eruby(context)

        # Write page with layout
        FileManager.create_file(path_for_page(page)) { content }
      end
    end

    private

    # Returns a list of uncompiled pages
    def uncompiled_pages
      # Get all meta files
      pages = meta_files.collect do |filename|
        # Read the meta file
        page = @global_page.merge(YAML.load_file_and_clean(filename))
        page[:path] = filename.sub(/^content/, '').sub('meta.yaml', '')

        # Get the content filename
{'fraction_non_alphanumeric': 0.10378787878787879, 'fraction_numerical': 0.0015151515151515152, 'mean_word_length': 2.407741935483871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1596693', 'n_tokens_mistral': 806, 'n_tokens_neox': 763, 'n_words': 209}