Sha256: 267615af3b40976b03165a126458bc9357d91e4ecab8be1be61c01b3eee44479
Contents?: true
Size: 1.26 KB
Versions: 12
Compression:
Stored size: 1.26 KB
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 require 'open-uri' require 'fileutils' module TwitterCldr module Resources module Requirements class UnicodeRequirement UNICODE_URL = "ftp://ftp.unicode.org/Public/%{version}".freeze attr_reader :version, :files def initialize(version, files) @version = version @files = files end def prepare files.each do |file| unless File.file?(source_path_for(file)) STDOUT.write("Downloading #{file} from unicode v#{version}... ") download(file) puts 'done' end puts "Using #{file} from unicode v#{version}" end end def source_path_for(file) File.join(TwitterCldr::VENDOR_DIR, "unicode_v#{version}", file) end def url UNICODE_URL end private def download(file) source_path = source_path_for(file) FileUtils.mkdir_p(File.dirname(source_path)) remote_url = File.join(url % { version: version }, file) File.open(source_path, 'wb') { |file| file << URI.open(remote_url).read } end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems