Module: I18n::Tasks::References
- Included in:
- BaseTask
- Defined in:
- lib/i18n/tasks/references.rb
Instance Method Summary collapse
-
#process_references(usages, data_refs = merge_reference_trees(data_forest.select_keys { |_, node| node.reference? })) ⇒ Object
Given a raw usage tree and a tree of reference keys in the data, return 3 trees: 1.
Instance Method Details
#process_references(usages, data_refs = merge_reference_trees(data_forest.select_keys { |_, node| node.reference? })) ⇒ Object
Given a raw usage tree and a tree of reference keys in the data, return 3 trees:
-
Raw references – a subset of the usages tree with keys that are reference key usages.
-
Resolved references – all the used references in their fully resolved form.
-
Reference keys – all the used reference keys.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/i18n/tasks/references.rb', line 9 def process_references(usages, data_refs = merge_reference_trees(data_forest.select_keys { |_, node| node.reference? })) fail ArgumentError, 'usages must be a Data::Tree::Instance' unless usages.is_a?(Data::Tree::Siblings) fail ArgumentError, 'all_references must be a Data::Tree::Instance' unless data_refs.is_a?(Data::Tree::Siblings) raw_refs = empty_forest resolved_refs = empty_forest refs = empty_forest data_refs.key_to_node.each do |ref_key_part, ref_node| usages.each do |usage_node| next unless usage_node.key == ref_key_part if ref_node.leaf? process_leaf!(ref_node, usage_node, raw_refs, resolved_refs, refs) else process_non_leaf!(ref_node, usage_node, raw_refs, resolved_refs, refs) end end end [raw_refs, resolved_refs, refs] end |