Class: Nokogiri::XML::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb

Instance Method Summary collapse

Instance Method Details

#=~(other) ⇒ Object

Return true if this node is content-equivalent to other, false otherwise



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb', line 368

def =~(other)
  return true if self == other
  return false unless name == other.name

  stype = node_type
  otype = other.node_type
  return false unless stype == otype

  sa = attributes
  oa = other.attributes
  return false unless sa.length == oa.length

  sa = sa.sort.map { |n, a| [n, a.value, a.namespace&.href] }
  oa = oa.sort.map { |n, a| [n, a.value, a.namespace&.href] }
  return false unless sa == oa

  skids = children
  okids = other.children
  return false unless skids.length == okids.length
  return false if stype == TEXT_NODE && (content != other.content)

  sns = namespace
  ons = other.namespace
  return false if !sns ^ !ons
  return false if sns && (sns.href != ons.href)

  skids.to_enum.with_index.all? { |ski, i| ski =~ okids[i] }
end