Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download missing input data in resources rake tasks.
- Loading branch information
Showing
6 changed files
with
114 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# encoding: UTF-8 | ||
|
||
# Copyright 2012 Twitter, Inc | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
require 'cldr/download' | ||
|
||
module TwitterCldr | ||
module Resources | ||
|
||
CLDR_URL = 'http://unicode.org/Public/cldr/21/core.zip' | ||
|
||
class << self | ||
|
||
def download_if_necessary(path, url) | ||
if File.file?(path) | ||
puts "Using '#{path}'." | ||
else | ||
puts "Downloading '#{url}' to '#{path}'." | ||
FileUtils.mkdir_p(File.dirname(path)) | ||
system("curl #{url} -o #{path}") | ||
end | ||
|
||
path | ||
end | ||
|
||
def download_cldr_if_necessary(path, url = CLDR_URL) | ||
if File.directory?(path) | ||
puts "Using CLDR data from '#{path}'." | ||
else | ||
puts "Downloading CLDR data from '#{url}' to '#{path}'." | ||
Cldr.download(url, path) | ||
end | ||
|
||
path | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters