forked from flyerhzm/chinese_regions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.rb
22 lines (18 loc) · 1003 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
# Install hook code here
require 'fileutils'
puts "** Installing chinese_regions Plugin"
puts "** Installing chinese_regions models"
model_src_path = File.join(RAILS_ROOT, '/vendor/plugins/chinese_regions/generators/models/')
model_dest_path = File.join(RAILS_ROOT, '/app/models/')
['region.rb', 'city.rb', 'district.rb'].each do |file|
FileUtils.cp(File.join(model_src_path, file), File.join(model_dest_path, file))
end
puts "** Installing chinese_regions migrations"
migration_src_path = File.join(RAILS_ROOT, '/vendor/plugins/chinese_regions/generators/migrations/')
migration_dest_path = File.join(RAILS_ROOT, '/db/migrate/')
FileUtils.mkdir(migration_dest_path) unless File.exists?(migration_dest_path)
['create_regions.rb', 'create_cities.rb', 'create_districts.rb'].each do |file|
FileUtils.cp(File.join(migration_src_path, file), File.join(migration_dest_path, Time.new.getutc.strftime("%Y%m%d%H%M%S") + "_" + file))
sleep 1
end
puts "** Successfully installed chinese_regions Plugin"