Class: RuboCop::CachedData

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cached_data.rb

Overview

Converts RuboCop objects to and from the serialization format JSON.

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ CachedData

Returns a new instance of CachedData.



8
9
10
# File 'lib/rubocop/cached_data.rb', line 8

def initialize(filename)
  @filename = filename
end

Instance Method Details

#from_json(text) ⇒ Object



12
13
14
# File 'lib/rubocop/cached_data.rb', line 12

def from_json(text)
  deserialize_offenses(JSON.parse(text))
end

#to_json(offenses) ⇒ Object



16
17
18
# File 'lib/rubocop/cached_data.rb', line 16

def to_json(offenses)
  JSON.dump(offenses.map { |o| serialize_offense(o) })
end