Class: TwitterCldr::Resources::Requirements::IcuRequirement

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/resources/requirements/icu_requirement.rb

Overview

This requirement makes use of the JarClassLoader package (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.

Constant Summary collapse

POM_FILE =
File.join(TwitterCldr::VENDOR_DIR, 'maven', 'pom.xml').freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ IcuRequirement

Returns a new instance of IcuRequirement.



22
23
24
# File 'lib/twitter_cldr/resources/requirements/icu_requirement.rb', line 22

def initialize(version)
  @version = version
end

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.



20
21
22
# File 'lib/twitter_cldr/resources/requirements/icu_requirement.rb', line 20

def version
  @version
end

Instance Method Details

#get_class(name) ⇒ Object



37
38
39
# File 'lib/twitter_cldr/resources/requirements/icu_requirement.rb', line 37

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

#prepareObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/twitter_cldr/resources/requirements/icu_requirement.rb', line 26

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