Sha256: dc9f630e8f3f4f2a2132cfb06b721b4bd1c45fe93e8fe89e9a57b58a56a5d8a2

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'watchdocs/rails/recordings/recorder'
require 'watchdocs/rails/recordings/exporter'

module Watchdocs
  module Rails
    module Recordings
      attr_reader :store

      class << self
        def record(new_call, from_specs)
          Recorder.new(
            from_specs: from_specs
          ).call(new_call)
        end

        def clear!(from_specs: true)
          set_store(from_specs)
          clear_recordings
        end

        def export(recordings = nil, from_specs: true)
          recordings ||= current_recordings
          set_store(from_specs)
          send_recordings(recordings) && clear!(from_specs)
        end

        private

        def current_recordings
          store.read
        end

        def clear_recordings
          store.delete!
        end

        def export_recorings(recordings)
          Exporter.export(recordings)
        end

        def set_store(from_specs)
          @store = if from_specs
                     Rails::Buffer::MemoryBuffer
                   else
                     Rails::Buffer::FileBuffer
                   end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watchdocs-rails-0.3.0 lib/watchdocs/rails/recordings.rb