Sha256: 2c59697d73ca7ea6df456cab3e41d6d7ba27c46950eb2c6eb8441387d709a9c9

Contents?: true

Size: 833 Bytes

Versions: 11

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

module Coverband
  module Adapters
    ###
    # FilesStore store a merged coverage file to local disk
    # Generally this is for testing and development
    # Not recommended for production deployment
    ###
    class FileStore < Base
      def initialize(path, _opts = {})
        super()
        @path = path

        config_dir = File.dirname(@path)
        Dir.mkdir config_dir unless File.exist?(config_dir)
      end

      def clear!
        File.delete(path) if File.exist?(path)
      end

      private

      attr_accessor :path

      def save_coverage(report)
        File.open(path, 'w') { |f| f.write(report.to_json) }
      end

      def get_report
        if File.exist?(path)
          JSON.parse(File.read(path))
        else
          {}
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
coverband-4.1.0.beta lib/coverband/adapters/file_store.rb
coverband-4.2.0.beta lib/coverband/adapters/file_store.rb
coverband-4.2.0.alpha lib/coverband/adapters/file_store.rb
coverband-4.1.0.alpha lib/coverband/adapters/file_store.rb
coverband-4.0.1 lib/coverband/adapters/file_store.rb
coverband-4.0.1.beta lib/coverband/adapters/file_store.rb
coverband-4.0.1.alpha lib/coverband/adapters/file_store.rb
coverband-4.0.0 lib/coverband/adapters/file_store.rb
coverband-4.0.0.alpha lib/coverband/adapters/file_store.rb
coverband-3.0.1 lib/coverband/adapters/file_store.rb
coverband-3.0.1.alpha lib/coverband/adapters/file_store.rb