<commit_before>require 'rubygems'
require 'mysql2'

class Resource
        class << self
                attr_accessor :database
        end
                
        def self.fetch(query, options = {})
                items = []
                
                query += " ORDER BY #{options[:order_by]}" if options[:order_by]
                query += " LIMIT #{options[:limit]}" if options[:limit]
                
                puts query if options[:debug]
                
                Resource.database.query(query).each do |row|
                        item = self.new
                        
                        row.each do |key, value|
                                item.send("#{key}=", value) if item.respond_to?("#{key}=")
                        end
                        
                        items << item
                end  
                
                items
        end
end<commit_msg>Added self.query and self.escape wrapper methods.<commit_after>require 'rubygems'
require 'mysql2'

class Resource
        class << self
                attr_accessor :database
        end
                
        def self.fetch(query, options = {})
                items = []
                
                query += " ORDER BY #{options[:order_by]}" if options[:order_by]
                query += " LIMIT #{options[:limit]}" if options[:limit]
                
                puts query if options[:debug]
                
                Resource.database.query(query).each do |row|
                        item = self.new
                        
                        row.each do |key, value|
                                item.send("#{key}=", value) if item.respond_to?("#{key}=")
                        end
                        
                        items << item
                end  
                
                items
        end
        
        def self.query(query)
                result = Resource.database.query(query)
                result.count < 1 ? [] : result.to_a
        end
        
        def self.escape(string)
                Resource.database.escape(string)
        end
end
{'fraction_non_alphanumeric': 0.08997668997668998, 'fraction_numerical': 0.0013986013986013986, 'mean_word_length': 0.9160714285714285, 'pattern_counts': {'":': 0, '<': 12, '<?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': '2830083', 'n_tokens_mistral': 507, 'n_tokens_neox': 478, 'n_words': 116}