-
Notifications
You must be signed in to change notification settings - Fork 4
/
update-data.rb
executable file
·77 lines (57 loc) · 1.9 KB
/
update-data.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'fileutils'
ORIGIN_FOLDER="tmp/data"
ASSETS_FOLDER="app/src/main/assets"
def replace_file(origin, assets)
if File.file?(origin)
filename = File.basename(origin)
destination = "#{assets}/#{filename}"
FileUtils.rm_rf(destination)
FileUtils.cp(origin, destination)
puts "#{destination} updated ✅"
end
end
def replace_dir(origin, assets)
if File.directory?(origin)
dirname = File.basename(origin)
destination = "#{assets}/#{dirname}"
FileUtils.rm_rf(destination)
FileUtils.copy_entry(origin, destination)
puts "#{destination} updated ✅"
end
end
def main
system("git clone https://github.com/cesko-digital/movapp-data.git tmp")
puts "data..."
Dir.glob("#{ORIGIN_FOLDER}/*-dictionary.json") do |filename|
next if filename == '.' or filename == '..'
replace_file(filename, ASSETS_FOLDER)
end
Dir.glob("#{ORIGIN_FOLDER}/*-sounds") do |filename|
next if filename == '.' or filename == '..'
replace_dir(filename, ASSETS_FOLDER)
end
Dir.glob("#{ORIGIN_FOLDER}/*-alphabet.json") do |filename|
next if filename == '.' or filename == '..'
replace_file(filename, ASSETS_FOLDER)
end
Dir.glob("#{ORIGIN_FOLDER}/*-alphabet") do |filename|
next if filename == '.' or filename == '..'
replace_dir(filename, ASSETS_FOLDER)
end
Dir.glob("#{ORIGIN_FOLDER}/stories") do |filename|
next if filename == '.' or filename == '..'
replace_dir(filename, ASSETS_FOLDER)
end
replace_file("#{ORIGIN_FOLDER}/team.v1.json", ASSETS_FOLDER)
puts "data ✅"
puts "images.."
Dir.glob("#{ORIGIN_FOLDER}/images/android") do |filename|
next if filename == '.' or filename == '..'
replace_dir(filename, "#{ASSETS_FOLDER}/images")
end
puts "images ✅"
puts "🧹🧹🧹🧹🧹"
FileUtils.rm_rf("tmp/", :verbose => true)
puts "All ✅"
end
main()