<commit_before>module RailsBlocks
	module Path
		def gem_path
			@gem_path ||= File.expand_path '..', File.dirname(__FILE__)
		end

		def stylesheets_path
			File.join assets_path, 'stylesheets'
		end

		def fonts_path
			File.join assets_path, 'fonts'
		end

		def javascripts_path
			File.join assets_path, 'javascripts'
		end

		def assets_path
			@assets_path ||= File.join gem_path, 'assets'
		end
		
		def blocks_dir
			Rails.root.join RailsBlocks.config.blocks_dir
		end
		
		def block_template(b_name, options = {})
			options[:levels].reverse.each do |level|
				next unless RailsBlocks.tree[level][b_name]
				return RailsBlocks.tree[level][b_name][mod(options)] if RailsBlocks.tree[level][b_name][mod(options)]
				return RailsBlocks.tree[level][b_name]['']
			end
			return nil
		end
		
		def element_template(b_name, e_name, options = {})
			options[:levels].reverse.each do |level|
				next unless RailsBlocks.tree[level][b_name]
				return RailsBlocks.tree[level][b_name]["_#{e_name}"] if RailsBlocks.tree[level][b_name]["_#{e_name}"]
			end
			return nil
			
			block_dir = get_block_dir b_name, options[:levels]
			return nil if block_dir.nil?
			
			path = mod_path(block_dir, RailsBlocks.config.element_separator + e_name, options)
			return path if path

			return path if File.exists? path = File.join(block_dir, RailsBlocks.config.element_separator + e_name + RailsBlocks.config.template_engine)
		end
		
		private
			
			def mod(options)
				return '' unless options[:mods]
				mod_class(*options[:mods].first)
			end
			
			def mod_path(dir, name, options)<commit_msg>added check for empty mods hash<commit_after>module RailsBlocks
	module Path
		def gem_path
			@gem_path ||= File.expand_path '..', File.dirname(__FILE__)
		end

		def stylesheets_path
			File.join assets_path, 'stylesheets'
		end

		def fonts_path
			File.join assets_path, 'fonts'
		end

		def javascripts_path
			File.join assets_path, 'javascripts'
		end

		def assets_path
			@assets_path ||= File.join gem_path, 'assets'
		end
		
		def blocks_dir
			Rails.root.join RailsBlocks.config.blocks_dir
		end
		
		def block_template(b_name, options = {})
			options[:levels].reverse.each do |level|
				next unless RailsBlocks.tree[level][b_name]
				return RailsBlocks.tree[level][b_name][mod(options)] if RailsBlocks.tree[level][b_name][mod(options)]
				return RailsBlocks.tree[level][b_name]['']
			end
			return nil
		end
		
		def element_template(b_name, e_name, options = {})
			options[:levels].reverse.each do |level|
				next unless RailsBlocks.tree[level][b_name]
				return RailsBlocks.tree[level][b_name]["_#{e_name}"] if RailsBlocks.tree[level][b_name]["_#{e_name}"]
			end
			return nil
			
			block_dir = get_block_dir b_name, options[:levels]
			return nil if block_dir.nil?
			
			path = mod_path(block_dir, RailsBlocks.config.element_separator + e_name, options)
			return path if path

			return path if File.exists? path = File.join(block_dir, RailsBlocks.config.element_separator + e_name + RailsBlocks.config.template_engine)
		end
		
		private
			
			def mod(options)
				return '' unless options[:mods] && !options[:mods].empty?
				mod_class(*options[:mods].first)
			end
			
			def mod_path(dir, name, options)
{'fraction_non_alphanumeric': 0.11028500619578686, 'fraction_numerical': 0.0, 'mean_word_length': 4.021772939346812, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5290927', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1060, 'n_words': 235}