<commit_before>require 'test/unit'	#	<-- needed but not added by rails generator
require 'rubygems'
require 'active_support'
require 'active_support/test_case'
require 'active_record'
require File.dirname(__FILE__) + '/../init'

ActiveRecord::Base.establish_connection(
	:adapter => "sqlite3", 
	:database => ":memory:")

def build_full_database_structure
	here = File.dirname(__FILE__)
	require 'rails_generator'
	require 'rails_generator/scripts/generate'
	Dir.glob(here + "/../db/migrate/*rb").each do |fn|
		File.delete(fn)
	end
	File.delete('my_log_file') if File.exists?('my_log_file')

	Dir.mkdir(here + "/../db") unless
		File.exists?(here + "/../db")
	Dir.mkdir(here + "/../db/migrate/") unless
		File.exists?(here + "/../db/migrate/")
	require 'ftools'
	File.copy(here + "/001_create_trackables.rb",
		here + "/../db/migrate/")

	Rails::Generator::Base.append_sources(
		Rails::Generator::PathSource.new(
			:trackable, here + "/../generators/"
	) )	#	needed to find generators
	Rails::Generator::Scripts::Generate.new.run(
		['track_migration'],{
		:destination => '.'	#	File.dirname(__FILE__)
	})
	sleep 1	#	otherwise end up with dup date error
	Rails::Generator::Scripts::Generate.new.run(
		['trackable_migration','Book'],{
		:destination => '.'	#	File.dirname(__FILE__)
	})<commit_msg>Using FileUtils.copy rather that ftools' File.copy<commit_after>require 'test/unit'	#	<-- needed but not added by rails generator
require 'rubygems'
require 'active_support'
require 'active_support/test_case'
require 'active_record'
require File.dirname(__FILE__) + '/../init'

ActiveRecord::Base.establish_connection(
	:adapter => "sqlite3", 
	:database => ":memory:")

def build_full_database_structure
	here = File.dirname(__FILE__)
	require 'rails_generator'
	require 'rails_generator/scripts/generate'
	Dir.glob(here + "/../db/migrate/*rb").each do |fn|
		File.delete(fn)
	end
	File.delete('my_log_file') if File.exists?('my_log_file')

	Dir.mkdir(here + "/../db") unless
		File.exists?(here + "/../db")
	Dir.mkdir(here + "/../db/migrate/") unless
		File.exists?(here + "/../db/migrate/")
#	require 'ftools'
	FileUtils.copy(here + "/001_create_trackables.rb",
		here + "/../db/migrate/")

	Rails::Generator::Base.append_sources(
		Rails::Generator::PathSource.new(
			:trackable, here + "/../generators/"
	) )	#	needed to find generators
	Rails::Generator::Scripts::Generate.new.run(
		['track_migration'],{
		:destination => '.'	#	File.dirname(__FILE__)
	})
	sleep 1	#	otherwise end up with dup date error
	Rails::Generator::Scripts::Generate.new.run(
		['trackable_migration','Book'],{
		:destination => '.'	#	File.dirname(__FILE__)
	})
{'fraction_non_alphanumeric': 0.18009837306091564, 'fraction_numerical': 0.0037835792659856224, 'mean_word_length': 4.747826086956522, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 11, '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': '2087998', 'n_tokens_mistral': 961, 'n_tokens_neox': 918, 'n_words': 173}