forked from constantine-nikolaou/openid_active_record_store
/
install.rb
53 lines (41 loc) · 939 Bytes
/
install.rb
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
# Install hook code here
require 'ftools'
# keep everything in this scope
class InstallOpenIdActiveRecordStore
def initialize
show_banner
check_system_consistency
copy_migration_files
end
def here
File.dirname(__FILE__)
end
def sources
Dir.glob(File.join([here, 'migrations', '*.*']))
end
def target
File.join([here, '..', '..', '..', 'db', 'migrate'])
end
def validate_file_existence(file)
abort "File not found: #{target}" unless File.exist? file
end
def show_banner
puts '
** Copying migrations to your application
'
end
def check_system_consistency
validate_file_existence(target)
sources.each { |file| validate_file_existence(file) }
end
def copy_migration_files
sources.each do |file|
File.copy(file, target)
puts "
Source : #{file}
Target : #{target}
"
end
end
end
InstallOpenIdActiveRecordStore.new