Class: TwitterCldr::Resources::Requirements::CldrRequirement

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

Constant Summary collapse

CLDR_URL =
"ftp://unicode.org/Public/cldr/%{version}/core.zip".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ CldrRequirement

Returns a new instance of CldrRequirement.



22
23
24
# File 'lib/twitter_cldr/resources/requirements/cldr_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/cldr_requirement.rb', line 20

def version
  @version
end

Instance Method Details

#alt?(node) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/twitter_cldr/resources/requirements/cldr_requirement.rb', line 45

def alt?(node)
  !node.attribute('alt').nil?
end

#build_data(locale, &block) ⇒ Object



56
57
58
# File 'lib/twitter_cldr/resources/requirements/cldr_requirement.rb', line 56

def build_data(locale, &block)
  CldrDataBuilder.new(locale_for(locale)).merge_each_ancestor(&block)
end

#common_pathObject



41
42
43
# File 'lib/twitter_cldr/resources/requirements/cldr_requirement.rb', line 41

def common_path
  File.join(source_path, 'common')
end

#docset(path, root_locale) ⇒ Object



60
61
62
# File 'lib/twitter_cldr/resources/requirements/cldr_requirement.rb', line 60

def docset(path, root_locale)
  CldrDocumentSet.new(path, locale_for(root_locale), self)
end

#draft?(node) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
# File 'lib/twitter_cldr/resources/requirements/cldr_requirement.rb', line 49

def draft?(node)
  draft = node.attribute('draft')
  draft && (
    draft.value == 'unconfirmed' || draft.value == 'provisional'
  )
end

#dtdObject



64
65
66
# File 'lib/twitter_cldr/resources/requirements/cldr_requirement.rb', line 64

def dtd
  @dtd ||= CldrDTD.new(self)
end

#prepareObject



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

def prepare
  # download and unzip if source directory doesn't exist
  unless File.directory?(source_path)
    STDOUT.write("Downloading cldr v#{version}... ")
    download
    puts 'done'
  end

  puts "Using cldr v#{version} from #{source_path}"
end

#source_pathObject



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

def source_path
  @source_path ||= File.join(TwitterCldr::VENDOR_DIR, "cldr_v#{version}")
end