<commit_before>module RailsBlocks
	module Names
		def element_classes(b_name, e_name, options = {})
			base_class = element_class b_name, e_name
			classes(base_class, options)
		end
		
		def block_classes(b_name, options = {})
			base_class = block_class b_name
			classes(base_class, options)
		end
		
		def mix_classes(mixes, context_block)
			mixes = [mixes] unless mixes.is_a? Array
			mixes.map do |mix|
				if mix[:e]
					raise RailsBlocks::BadMixError if context_block.nil?
					element_classes(context_block, mix[:e].to_s, mix)
				else
					raise RailsBlocks::BadMixError if mix[:b].nil?
					block_classes(mix[:b].to_s, mix)
				end
			end
		end
		
		private
			def classes(base_class, options = {})
				classes = [base_class]
				classes |= mods_classes(base_class, options[:mods]) unless options[:mods].nil?
				classes |= mix_classes(options[:mix], options[:parent_block]) if options[:mix]
				classes |= Array(options[:class]) if options[:class]
				classes << RailsBlocks.config.js_class if options[:js]
				classes
			end
			
			def mods_classes(base_class, mods)
				mods.map do |key, value|
					next('') unless value
					mod = mod_class(key, value)
					base_class + RailsBlocks.config.modifier_separator + mod
				end
			end
			
			def mod_class(key, value)
				value == true ? key.to_s : key.to_s + '_' + value.to_s
			end
			
			def block_class(b_name)
				RailsBlocks.config.prefix + b_name.to_s
			end
			
			def element_class(b_name, e_name)
				block_class(b_name) + RailsBlocks.config.element_separator + e_name.to_s
			end
	end
end<commit_msg>added ability to add block to mix<commit_after>module RailsBlocks
	module Names
		def element_classes(b_name, e_name, options = {})
			base_class = element_class b_name, e_name
			classes(base_class, options)
		end
		
		def block_classes(b_name, options = {})
			base_class = block_class b_name
			classes(base_class, options)
		end
		
		def mix_classes(mixes, context_block)
			mixes = [mixes] unless mixes.is_a? Array
			mixes.map do |mix|
				if mix[:e]
					raise RailsBlocks::BadMixError if context_block.nil? && !mix[:b]
					if mix[:b]
						element_classes(mix[:b].to_s, mix[:e].to_s, mix)
					else
						element_classes(context_block, mix[:e].to_s, mix)
					end
				else
					raise RailsBlocks::BadMixError if mix[:b].nil?
					block_classes(mix[:b].to_s, mix)
				end
			end
		end
		
		private
			def classes(base_class, options = {})
				classes = [base_class]
				classes |= mods_classes(base_class, options[:mods]) unless options[:mods].nil?
				classes |= mix_classes(options[:mix], options[:parent_block]) if options[:mix]
				classes |= Array(options[:class]) if options[:class]
				classes << RailsBlocks.config.js_class if options[:js]
				classes
			end
			
			def mods_classes(base_class, mods)
				mods.map do |key, value|
					next('') unless value
					mod = mod_class(key, value)
					base_class + RailsBlocks.config.modifier_separator + mod
				end
			end
			
			def mod_class(key, value)
				value == true ? key.to_s : key.to_s + '_' + value.to_s
			end
			
			def block_class(b_name)
				RailsBlocks.config.prefix + b_name.to_s
			end
			
			def element_class(b_name, e_name)
				block_class(b_name) + RailsBlocks.config.element_separator + e_name.to_s
			end
	end
end
{'fraction_non_alphanumeric': 0.10852950168144299, 'fraction_numerical': 0.0, 'mean_word_length': 3.4216216216216218, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2611775', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1123, 'n_words': 255}