Sha256: 5150d6b40c022d80577c73eb3160282e41d3cb5754caa02f11b43070a00ef969

Contents?: true

Size: 634 Bytes

Versions: 5

Compression:

Stored size: 634 Bytes

Contents

require "fileutils"

module Rubycritic

  class SmellyPathnamesSerializer
    def initialize(file_name)
      @file_name = file_name
    end

    def load
      Marshal.load(File.read(@file_name))
    end

    def dump(smelly_pathnames)
      create_file_directory
      # HACK It's not possible to Marshal procs or lambdas.
      smelly_pathnames.default = []
      File.open(@file_name, "w+") do |file|
        Marshal.dump(smelly_pathnames, file)
      end
    end

    private

    def create_file_directory
      FileUtils.mkdir_p(file_directory)
    end

    def file_directory
      File.dirname(@file_name)
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubycritic-0.0.6 lib/rubycritic/smelly_pathnames_serializer.rb
rubycritic-0.0.5 lib/rubycritic/smelly_pathnames_serializer.rb
rubycritic-0.0.4 lib/rubycritic/smelly_pathnames_serializer.rb
rubycritic-0.0.3 lib/rubycritic/smelly_pathnames_serializer.rb
rubycritic-0.0.2 lib/rubycritic/smelly_pathnames_serializer.rb