Add Rake task for creating a list of Job icon URLs
This commit is contained in:
parent
67146e3ab3
commit
4ee65aecd3
2 changed files with 38 additions and 1 deletions
|
|
@ -32,7 +32,11 @@ namespace :granblue do
|
|||
Rake::Task['granblue:export:summon'].invoke('square')
|
||||
Rake::Task['granblue:export:summon'].reenable
|
||||
|
||||
puts 'Exported 9 files'
|
||||
# Run job tasks
|
||||
Rake::Task['granblue:export:job'].invoke
|
||||
Rake::Task['granblue:export:job'].reenable
|
||||
|
||||
puts 'Exported 10 files'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
33
lib/tasks/export_job.rake
Normal file
33
lib/tasks/export_job.rake
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
namespace :granblue do
|
||||
namespace :export do
|
||||
def build_job_icon_url(id)
|
||||
# Set up URL
|
||||
base_url = 'https://prd-game-a-granbluefantasy.akamaized.net/assets_en/img/sp/ui/icon/job'
|
||||
extension = '.png'
|
||||
|
||||
"#{base_url}/#{id}#{extension}"
|
||||
end
|
||||
|
||||
desc 'Exports a list of weapon URLs for a given size'
|
||||
task :job do |_t, _args|
|
||||
# Include weapon model
|
||||
Dir.glob("#{Rails.root}/app/models/job.rb").each { |file| require file }
|
||||
|
||||
# Set up filepath
|
||||
dir = "#{Rails.root}/export/"
|
||||
filename = "#{dir}/job-icon.txt"
|
||||
FileUtils.mkdir(dir) unless Dir.exist?(dir)
|
||||
|
||||
# Write to file
|
||||
File.open(filename, 'w') do |f|
|
||||
Job.all.each do |w|
|
||||
f.write("#{build_job_icon_url(w.granblue_id.to_s)} \n")
|
||||
end
|
||||
end
|
||||
|
||||
# CLI output
|
||||
count = `wc -l #{filename}`.split.first.to_i
|
||||
puts "Wrote #{count} job URLs for icon size"
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue