Sha256: f9d8a851f66a9761ef045f2145b4748dd09ae6513feedb4bab0e0c74f3829673

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Resources

    CLDR_URL = 'http://unicode.org/Public/cldr/26/core.zip'
    ICU4J_URL = 'http://download.icu-project.org/files/icu4j/54.1/icu4j-54_1.jar'

    # Use these instead to update collation and tailoring data
    # 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
          begin
            require 'zip'
          rescue LoadError
            raise StandardError.new("Unable to require 'zip'. Please switch to at least Ruby 1.9, then rebundle and try again.")
          end

          require 'cldr/download'

          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

8 entries across 8 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/resources/download.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/resources/download.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/lib/twitter_cldr/resources/download.rb
twitter_cldr-3.2.1 lib/twitter_cldr/resources/download.rb
twitter_cldr-3.2.0 lib/twitter_cldr/resources/download.rb
twitter_cldr-3.1.2 lib/twitter_cldr/resources/download.rb
twitter_cldr-3.1.1 lib/twitter_cldr/resources/download.rb
twitter_cldr-3.1.0 lib/twitter_cldr/resources/download.rb