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.



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

def initialize(filename)
  @filename = filename
end

Instance Method Details

#from_json(text) ⇒ Object



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

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

#to_json(offenses) ⇒ Object



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

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