Sha256: e040b746eb525507c0e3dcba091dcb69fe3069a9561456207f876aaab637d0f1

Contents?: true

Size: 706 Bytes

Versions: 9

Compression:

Stored size: 706 Bytes

Contents

# encoding: UTF-8

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

require 'nokogiri'

module TwitterCldr
  module Resources

    class CldrDataBuilder
      DEEP_MERGER = proc do |key, v1, v2|
        Hash === v1 && Hash === v2 ? v1.merge(v2, &DEEP_MERGER) : (v2 || v1)
      end

      attr_reader :cldr_locale

      def initialize(cldr_locale)
        @cldr_locale = cldr_locale
      end

      def merge_each_ancestor
        cldr_locale.ancestors.inject({}) do |result, ancestor_locale|
          deep_merge(yield(ancestor_locale), result)
        end
      end

      private

      def deep_merge(h1, h2)
        h1.merge(h2, &DEEP_MERGER)
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
twitter_cldr-6.12.1 lib/twitter_cldr/resources/cldr_data_builder.rb
twitter_cldr-6.12.0 lib/twitter_cldr/resources/cldr_data_builder.rb
twitter_cldr-6.11.5 lib/twitter_cldr/resources/cldr_data_builder.rb
twitter_cldr-6.11.4 lib/twitter_cldr/resources/cldr_data_builder.rb
twitter_cldr-6.11.3 lib/twitter_cldr/resources/cldr_data_builder.rb
twitter_cldr-6.11.2 lib/twitter_cldr/resources/cldr_data_builder.rb
twitter_cldr-6.11.1 lib/twitter_cldr/resources/cldr_data_builder.rb
twitter_cldr-6.11.0 lib/twitter_cldr/resources/cldr_data_builder.rb
twitter_cldr-6.10.0 lib/twitter_cldr/resources/cldr_data_builder.rb