Sha256: d243ddcc790566e182de9cfa2847f335d5c9acc3c3e77328e202d7db6e55aa00

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# 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/23.1/core.zip'
    ICU4J_URL = 'http://download.icu-project.org/files/icu4j/51.2/icu4j-51_2.jar'

    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

      def download_icu4j_if_necessary(path, url = ICU4J_URL)
        download_if_necessary(path, url)
        path
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twitter_cldr-2.4.3 lib/twitter_cldr/resources/download.rb
twitter_cldr-3.0.0.beta1 lib/twitter_cldr/resources/download.rb
twitter_cldr-2.4.2 lib/twitter_cldr/resources/download.rb
twitter_cldr-2.4.1 lib/twitter_cldr/resources/download.rb