Repository navigation
Expand file tree
/
Copy pathtypo
More file actions
executable file
·93 lines (73 loc) · 2.15 KB
/
Copy pathtypo
File metadata and controls
executable file
·93 lines (73 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env ruby
require 'rubygems'
require 'rails-installer'
class Sqlite < RailsInstaller::Database
# The name of the sqlite database file
def self.db_file(installer)
File.join(installer.install_directory,'db','database.sqlite')
end
def self.yml(installer)
%q{
login: &login
adapter: sqlite3
database: db/database.sqlite
development:
<<: *login
production:
<<: *login
test:
database: ":memory"
<<: *login
}
end
end
class TypoInstaller < RailsInstaller
application_name 'typo'
support_location 'the Typo mailing list'
def pre_migrate_database
old_schema_version = get_schema_version
new_schema_version = File.read(File.join(source_directory,'db','schema_version')).to_i
return unless old_schema_version > 0
# Are we downgrading?
if old_schema_version > new_schema_version
message "Downgrading schema from #{old_schema_version} to #{new_schema_version}"
in_directory install_directory do
unless system("rake -s db:migrate VERSION=#{new_schema_version}")
raise InstallFailed, "Downgrade migrating from #{old_schema_version} to #{new_schema_version} failed."
end
end
end
end
# Migrate the database
def migrate
message "Migrating #{@@app_name.capitalize}'s database to newest release"
in_directory install_directory do
unless system("rake -s db:migrate")
raise InstallFailed, "Migration failed"
end
end
end
def install_post_hook
sweep_cache
end
# Sweep the cache
def sweep_cache
in_directory install_directory do
message "Cleaning out #{@@app_name.capitalize}'s cache"
status = system_silently("rake -s sweep_cache")
end
end
end
class SweepCache < RailsInstaller::Command
help "Sweep Typo's cache"
def self.command(installer, *args)
installer.sweep_cache
end
end
# Installer program
directory = ARGV[1]
typo = TypoInstaller.new(directory)
typo.message_proc = Proc.new do |msg|
STDERR.puts " #{msg}"
end
typo.execute_command(*ARGV)