Removed superfluous 'tracks' directory at the root of the repository.

Testing commits to github.
This commit is contained in:
bsag 2008-05-20 21:28:26 +01:00
parent 6a42901514
commit 4cbf5a34d3
2269 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,17 @@
desc ' Create YAML test fixtures from data in an existing database.
Defaults to development database. Set RAILS_ENV to override (taken from Rails Recipes book).'
task :extract_fixtures => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_info", "sessions", "users"]
ActiveRecord::Base.establish_connection
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
i = "000"
File.open("#{RAILS_ROOT}/db/exported_fixtures/#{table_name}.yml", 'w' ) do |file|
data = ActiveRecord::Base.connection.select_all(sql % table_name)
file.write data.inject({}) { |hash, record|
hash["#{table_name}_#{i.succ!}"] = record
hash
}.to_yaml
end
end
end

34
lib/tasks/gems.rake Normal file
View file

@ -0,0 +1,34 @@
desc "Copy third-party gems into ./lib"
task :freeze_other_gems do
# TODO Get this list from parsing environment.rb
libraries = %w(redcloth)
require 'rubygems'
require 'find'
libraries.each do |library|
library_gem = Gem.cache.search(library).sort_by { |g| g.version }.last
puts "Freezing #{library} for #{library_gem.version}..."
# TODO Add dependencies to list of libraries to freeze
#library_gem.dependencies.each { |g| libraries << g }
folder_for_library = "#{library_gem.name}-#{library_gem.version}"
system "cd vendor; gem unpack -v '#{library_gem.version}' #{library_gem.name};"
# Copy files recursively to ./lib
folder_for_library_with_lib = "vendor/#{folder_for_library}/lib/"
Find.find(folder_for_library_with_lib) do |original_file|
destination_file = "./lib/" + original_file.gsub(folder_for_library_with_lib, '')
if File.directory?(original_file)
if !File.exist?(destination_file)
Dir.mkdir destination_file
end
else
File.copy original_file, destination_file
end
end
system "rm -r vendor/#{folder_for_library}"
end
end

View file

@ -0,0 +1,8 @@
desc "Load exported fixtures (in db/exported_fixtures) into the current environment's database"
task :load_exported_fixtures => :environment do
require 'active_record/fixtures'
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
Dir.glob(File.join(RAILS_ROOT, 'db', 'exported_fixtures', '*.{yml,csv}')).each do |fixture_file|
Fixtures.create_fixtures('db/exported_fixtures', File.basename(fixture_file, '.*'))
end
end

View file

@ -0,0 +1,50 @@
namespace :query_trace do
desc "Enables the query_trace plugin. Must restart server to take effect."
task :on => :environment do
unless File.exist?("#{RAILS_ROOT}/vendor/query_trace.tar.gz")
Dir.chdir("#{RAILS_ROOT}/vendor") do
url = "https://terralien.devguard.com/svn/projects/plugins/query_trace"
puts "Loading query_trace from #{url}..."
system "svn co #{url} query_trace"
system "tar zcf query_trace.tar.gz --exclude=.svn query_trace"
FileUtils.rm_rf("query_trace")
end
end
Dir.chdir("#{RAILS_ROOT}/vendor/plugins") do
system "tar zxf ../query_trace.tar.gz query_trace"
end
puts "QueryTrace plugin enabled. Must restart server to take effect."
end
desc "Disables the query_trace plugin. Must restart server to take effect."
task :off => :environment do
FileUtils.rm_rf("#{RAILS_ROOT}/vendor/plugins/query_trace")
puts "QueryTrace plugin disabled. Must restart server to take effect."
end
end
namespace :query_analyzer do
desc "Enables the query_analyzer plugin. Must restart server to take effect."
task :on => :environment do
unless File.exist?("#{RAILS_ROOT}/vendor/query_analyzer.tar.gz")
Dir.chdir("#{RAILS_ROOT}/vendor") do
url = "http://svn.nfectio.us/plugins/query_analyzer"
puts "Loading query_analyzer from #{url}..."
system "svn co #{url} query_analyzer"
system "tar zcf query_analyzer.tar.gz --exclude=.svn query_analyzer"
FileUtils.rm_rf("query_analyzer")
end
end
Dir.chdir("#{RAILS_ROOT}/vendor/plugins") do
system "tar zxf ../query_analyzer.tar.gz query_analyzer"
end
puts "QueryAnalyzer plugin enabled. Must restart server to take effect."
end
desc "Disables the query_analyzer plugin. Must restart server to take effect."
task :off => :environment do
FileUtils.rm_rf("#{RAILS_ROOT}/vendor/plugins/query_analyzer")
puts "QueryAnalyzer plugin disabled. Must restart server to take effect."
end
end

View file

@ -0,0 +1,25 @@
namespace :tracks do
desc 'Replace the password of USER with a new one.'
task :password => :environment do
Dependencies.load_paths.unshift(File.dirname(__FILE__) + "/..../vendor/gems/highline-1.4.0/lib")
require "highline/import"
user = User.find_by_login(ENV['USER'])
if user.nil?
puts "Sorry, we couldn't find user '#{ENV['USER']}'. To specify a different user, pass USER=username to this task."
exit 0
end
puts "Changing Tracks password for #{ENV['USER']}."
password = ask("New password: ") { |q| q.echo = false }
password_confirmation = ask('Retype new password: ') { |q| q.echo = false }
begin
user.change_password(password, password_confirmation)
rescue ActiveRecord::RecordInvalid
puts "Sorry, we couldn't change #{ENV['USER']}'s password: "
user.errors.each_full { |msg| puts "- #{msg}\n" }
end
end
end

View file

@ -0,0 +1,15 @@
desc "Initialises the installation, copy the *.tmpl files and directories to versions named without the .tmpl extension. It won't overwrite the files and directories if you've already copied them. You need to manually copy database.yml.tmpl -> database.yml and fill in the details before you run this task."
task :setup_tracks => :environment do
# Check the root directory for template files
FileList["*.tmpl"].each do |template_file|
f = File.basename(template_file) # with suffix
f_only = File.basename(template_file,".tmpl") # without suffix
if File.exists?(f_only)
puts f_only + " already exists"
else
cp_r(f, f_only)
puts f_only + " created"
end
end
end

View file

@ -0,0 +1,40 @@
desc "Updates sqlite/sqlite3 databases created under Tracks 1.03 to the format required for Tracks 1.04. After this is done, you should be able to keep up to date with changes in the schema by running rake db:migrate."
task :upgrade_sqlite_db => :environment do
# Change the three lines below appropriately for your setup
old_db = "tracks_103.db"
new_db = "tracks_104.db"
cmd = "sqlite3"
replace_string = "update todos set done='f' where done=0;\nupdate todos set done='t' where done=1;\nupdate contexts set hide='f' where hide=0;\nupdate contexts set hide='t' where hide=1;\nupdate projects set done='f' where done=0;\nupdate projects set done='t' where done=1;\nCREATE TABLE 'schema_info' (\n 'version' INTEGER default NULL\n);\nINSERT INTO \"schema_info\" VALUES(1);\nCOMMIT;"
# cd to the db directory
cd("db") do
# Dump the old db into the temp file and replace the tinyints with booleans
`#{cmd} #{old_db} .dump | sed "s/tinyint(4) NOT NULL default '0'/boolean default 'f'/" > temp.sql`
# Create a second sqldump file for writing
sqldump = File.open("temp2.sql", "w+")
File.open("temp.sql") do |file|
file.each_line do |line|
# If COMMIT is on the line, insert the replace string
# else just write the line back in
# This effectively replaces COMMIT with the replace string
if /COMMIT/ =~ line
sqldump.write replace_string
else
sqldump.write line
end
end
sqldump.close
end
# Read the second dump back in to a new db
system "#{cmd} #{new_db} < temp2.sql"
puts "Created the a new database called #{new_db}."
# Clean up the temp files
rm("temp.sql")
rm("temp2.sql")
puts "Temporary files cleaned up."
end
# rake db:migrate
puts "Now check the database and run 'rake db:migrate' in the root of your Tracks installation."
end