<commit_before>require 'stringex_lite'
require 'safe_yaml'

SafeYAML::OPTIONS[:default_mode] = :safe

module Striker
	class Page


		attr_reader :meta, :content, :title, :name, :template

		def initialize(page)
			@page = File.join Settings::PAGES_DIR, page
			@meta = YAML.load_file(@page)
			@title = @meta['title']
			@content = extract_content.post_match
			@name = @meta['title'].to_url
			@template = @meta['template']

			@meta['images'] = self.image.all
			@meta['thumbnail'] = self.image.thumbnail
		end
		
		def image
			Media::Image.new(self)
		end

		private
		def extract_content
			File.open(@page, 'r').read.match(/^(?<headers>---\s*\n.*?\n?)^(---\s*$\n?)/m)
		end

	end
end<commit_msg>base_dir instance variable in page class<commit_after>require 'stringex_lite'
require 'safe_yaml'

SafeYAML::OPTIONS[:default_mode] = :safe

module Striker
	class Page


		attr_reader :meta, :content, :title, :name, :template, :base_dir

		def initialize(page)
			@base_dir = File.basename page, File.extname(page)
			@page = File.join Settings::PAGES_DIR, page
			@meta = YAML.load_file(@page)
			@title = @meta['title']
			@content = extract_content.post_match
			@name = @meta['title'].to_url
			@template = @meta['template']

			@meta['images'] = self.image.all
			# @meta['thumbnail'] = self.image.thumbnail
			self.image.thumbnail
		end
		
		def image
			Media::Image.new(self)
		end

		private
		def extract_content
			File.open(@page, 'r').read.match(/^(?<headers>---\s*\n.*?\n?)^(---\s*$\n?)/m)
		end

	end
end
{'fraction_non_alphanumeric': 0.17105263157894737, 'fraction_numerical': 0.0, 'mean_word_length': 3.938311688311688, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1505432', 'n_tokens_mistral': 642, 'n_tokens_neox': 553, 'n_words': 108}