Sha256: a9818eaf495b72f8826c674b66ce9d8723009766acf41cda7dbde3d355288127

Contents?: true

Size: 1014 Bytes

Versions: 82

Compression:

Stored size: 1014 Bytes

Contents

# encoding: UTF-8

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

module TwitterCldr
  module Collation

    # Builds a fractional collation elements Trie from the file containing a fractional collation elements table.
    #
    module TrieLoader

      DUMPS_DIR = File.join(TwitterCldr::RESOURCES_DIR, 'collation', 'tries')

      DEFAULT_TRIE_LOCALE = :default

      class << self

        def load_default_trie
          load_trie
        end

        def load_tailored_trie(locale, fallback)
          trie = load_trie(locale)
          trie.fallback = fallback
          trie
        end

        def dump_path(locale)
          File.join(DUMPS_DIR, "#{locale}.dump")
        end

        private

        def load_trie(locale = DEFAULT_TRIE_LOCALE)
          load_dump(locale) do |dump|
            Marshal.load(dump)
          end
        end

        def load_dump(locale, &block)
          File.open(dump_path(locale), 'r', &block)
        end

      end

    end

  end
end

Version data entries

82 entries across 82 versions & 3 rubygems

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