<commit_before>namespace :instant_authlogic do
	desc "Install controllers, models, views, migration and routes for instant_authlogic plugin"
	task :install do

		src_dir = File.join(File.dirname(__FILE__), "..", "installed_files")
		rails_dir = Rails.root

		# Create directories, if necessary
		puts "Creating directories..."
		[ 'app/controllers', 'app/models', 'app/views', 'db/migrate', 'config' ].each do |dir|
			FileUtils.makedirs(File.join(rails_dir, dir))
		end

		# Install new controllers
		puts "Installing controllers..."
		FileUtils.copy(File.join(src_dir, "controllers", "users_controller.rb"), "#{rails_dir}/app/controllers/")
		FileUtils.copy(File.join(src_dir, "controllers", "user_sessions_controller.rb"), "#{rails_dir}/app/controllers/")

		# Install new models
		puts "Installing models..."
		FileUtils.copy(File.join(src_dir, "models", "user.rb"), "#{rails_dir}/app/models/")
		FileUtils.copy(File.join(src_dir, "models", "user_session.rb"), "#{rails_dir}/app/models/")

		# Install new views
		puts "Installing views..."
		FileUtils.cp_r(File.join(src_dir, "views", "users/"), "#{rails_dir}/app/views/")
		FileUtils.cp_r(File.join(src_dir, "views", "user_sessions/"), "#{rails_dir}/app/views/")

		# Install create_users migration, and timestamp it to order migrations correctly
		puts "Installing migration..."
		timestamp = Time.now.strftime('%Y%m%d%H%M%S')
		FileUtils.copy(File.join(src_dir, "migrate", "create_users.rb"), "#{rails_dir}/db/migrate/#{timestamp}_create_users.rb")

		# Optionally overwrite application_controller.rb and routes.rb
		overwrite_application_controller = ask("Overwrite app/controllers/application_controller.rb? [y/n] ")
		if overwrite_application_controller == 'y'
			FileUtils.copy(File.join(src_dir, "controllers", "application_controller.rb"), "#{rails_dir}/app/controllers/")
		else
			# Output the file
			puts "Copy the following lines into app/controllers/application_controller.rb:"
      puts
			puts `cat #{File.join(src_dir, "controllers", "application_controller.rb")}`
      puts
		end

		overwrite_routes = ask("Overwrite config/routes.rb? [y/n] ")
		if overwrite_routes == 'y'
			FileUtils.copy(File.join(src_dir, "config", "routes.rb"), "#{rails_dir}/config/")
		else
			# Output the file
			puts "Copy the following lines into config/routes.rb:"<commit_msg>Named migration using Time.now.utc instead of Time.now in install task in rake file<commit_after>namespace :instant_authlogic do
	desc "Install controllers, models, views, migration and routes for instant_authlogic plugin"
	task :install do

		src_dir = File.join(File.dirname(__FILE__), "..", "installed_files")
		rails_dir = Rails.root

		# Create directories, if necessary
		puts "Creating directories..."
		[ 'app/controllers', 'app/models', 'app/views', 'db/migrate', 'config' ].each do |dir|
			FileUtils.makedirs(File.join(rails_dir, dir))
		end

		# Install new controllers
		puts "Installing controllers..."
		FileUtils.copy(File.join(src_dir, "controllers", "users_controller.rb"), "#{rails_dir}/app/controllers/")
		FileUtils.copy(File.join(src_dir, "controllers", "user_sessions_controller.rb"), "#{rails_dir}/app/controllers/")

		# Install new models
		puts "Installing models..."
		FileUtils.copy(File.join(src_dir, "models", "user.rb"), "#{rails_dir}/app/models/")
		FileUtils.copy(File.join(src_dir, "models", "user_session.rb"), "#{rails_dir}/app/models/")

		# Install new views
		puts "Installing views..."
		FileUtils.cp_r(File.join(src_dir, "views", "users/"), "#{rails_dir}/app/views/")
		FileUtils.cp_r(File.join(src_dir, "views", "user_sessions/"), "#{rails_dir}/app/views/")

		# Install create_users migration, and timestamp it to order migrations correctly
		puts "Installing migration..."
		timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')
		FileUtils.copy(File.join(src_dir, "migrate", "create_users.rb"), "#{rails_dir}/db/migrate/#{timestamp}_create_users.rb")

		# Optionally overwrite application_controller.rb and routes.rb
		overwrite_application_controller = ask("Overwrite app/controllers/application_controller.rb? [y/n] ")
		if overwrite_application_controller == 'y'
			FileUtils.copy(File.join(src_dir, "controllers", "application_controller.rb"), "#{rails_dir}/app/controllers/")
		else
			# Output the file
			puts "Copy the following lines into app/controllers/application_controller.rb:"
      puts
			puts `cat #{File.join(src_dir, "controllers", "application_controller.rb")}`
      puts
		end

		overwrite_routes = ask("Overwrite config/routes.rb? [y/n] ")
		if overwrite_routes == 'y'
			FileUtils.copy(File.join(src_dir, "config", "routes.rb"), "#{rails_dir}/config/")
		else
			# Output the file
			puts "Copy the following lines into config/routes.rb:"
{'fraction_non_alphanumeric': 0.15498310810810811, 'fraction_numerical': 0.0, 'mean_word_length': 5.080872913992298, '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': '2468783', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1569, 'n_words': 327}