forked from bbc/android-devices
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
23 lines (20 loc) · 865 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'open-uri'
require 'csv'
task :update do
devices = CSV.parse(URI.open('http://storage.googleapis.com/play_public/supported_devices.csv', 'rb:UTF-16LE').read)
File.open('content/devices.csv', 'w') { |f| f.write(devices.inject([]) { |csv, row| csv << CSV.generate_line(row) }.join('').encode('UTF-8')) }
end
# TODO: Move to rake task
# def self.update_devices(url = '')
# csv_url = url.nil? || url.empty? ? 'http://storage.googleapis.com/play_public/supported_devices.csv' : url
# begin
# devices = CSV.parse(open(csv_url).read)
# File.open("#{path}/devices.csv",'w') {|f| f.write(devices.inject([]) { |csv,row| csv << CSV.generate_line(row) }.join('').encode('UTF-8'))}
# return true
# rescue Exception => e
# puts e
# raise 'Unable to update devices'
# end
# end