Sha256: cc4528bc7db659065f5933865303e10e2411a9ed234095accc7d80b6be64b318

Contents?: true

Size: 1.43 KB

Versions: 29

Compression:

Stored size: 1.43 KB

Contents

# encoding: UTF-8

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

require 'open-uri'

module TwitterCldr
  module Resources
    module Requirements

      # This requirement makes use of the JarClassLoader package (https://github.com/kamranzafar/JCL)
      # to load ICU in an isolated environment to keep different versions of the
      # library separate. If ICU versions are not kept separate, the one that's
      # first on the classpath wins, which can be surprising if you're not
      # expecting it. Oh, and it can break all the tests.
      class IcuRequirement
        POM_FILE = File.join(TwitterCldr::VENDOR_DIR, 'maven', 'pom.xml').freeze

        attr_reader :version

        def initialize(version)
          @version = version
        end

        def prepare
          pom.add_dependency('com.ibm.icu', 'icu4j', version)
          pom.add_dependency('org.xeustechnologies', 'jcl-core', '2.7')

          pom.install
          pom.require_jar('org.xeustechnologies', 'jcl-core')

          java_import 'org.xeustechnologies.jcl.JarClassLoader'
          class_loader.add(pom.get('com.ibm.icu', 'icu4j').path)
        end

        def get_class(name)
          class_loader.load_class(name).ruby_class
        end

        private

        def class_loader
          @class_loader ||= JarClassLoader.new
        end

        def pom
          @pom ||= PomManager.new(POM_FILE)
        end
      end

    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
twitter_cldr-6.13.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.12.1 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.12.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.11.5 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.11.4 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.11.3 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.11.2 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.11.1 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.11.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.10.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.9.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.8.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.7.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.6.2 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.6.1 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.6.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.5.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.4.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.3.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb
twitter_cldr-6.2.0 lib/twitter_cldr/resources/requirements/icu_requirement.rb