Class: AnalyticsOps::Plan::DuplicateKeyDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/analytics_ops/plan.rb

Overview

Detects duplicate JSON object keys before ordinary JSON parsing can discard them.

Constant Summary collapse

NUMBER =
/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ DuplicateKeyDetector

Returns a new instance of DuplicateKeyDetector.



56
57
58
59
# File 'lib/analytics_ops/plan.rb', line 56

def initialize(source)
  @source = source
  @index = 0
end

Instance Method Details

#callObject

Raises:



61
62
63
64
65
# File 'lib/analytics_ops/plan.rb', line 61

def call
  value
  whitespace
  raise InvalidPlanError, "Unexpected data after plan JSON" unless @index == @source.bytesize
end