Sha256: 7e8e9808e7538ea240f67726bc0f1ee12d709ad7384f0fdd2346ad1bff534680

Contents?: true

Size: 506 Bytes

Versions: 7

Compression:

Stored size: 506 Bytes

Contents

# frozen_string_literal: true
require 'fileutils'

module RubyCritic
  class Serializer
    def initialize(file)
      @file = file
    end

    def load
      Marshal.load(File.binread(@file))
    end

    def dump(content)
      create_file_directory
      File.open(@file, 'w+') do |file|
        Marshal.dump(content, file)
      end
    end

    private

    def create_file_directory
      FileUtils.mkdir_p(file_directory)
    end

    def file_directory
      File.dirname(@file)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubycritic-3.2.0 lib/rubycritic/serializer.rb
rubycritic-3.1.3 lib/rubycritic/serializer.rb
rubycritic-3.1.2 lib/rubycritic/serializer.rb
rubycritic-3.1.1 lib/rubycritic/serializer.rb
rubycritic-3.1.0 lib/rubycritic/serializer.rb
rubycritic-3.0.0 lib/rubycritic/serializer.rb
rubycritic-2.9.4 lib/rubycritic/serializer.rb