Sha256: 9d0f25d06265c9743702b895071102d359801b96da62b2da0d1c7a6e8080d09d

Contents?: true

Size: 623 Bytes

Versions: 13

Compression:

Stored size: 623 Bytes

Contents

require_relative 'in_memory_repository'
require_relative '../entities/preset'

module Inferno
  module Repositories
    # Repository that deals with persistence for the `Preset` entity.
    class Presets < InMemoryRepository
      def insert_from_file(path)
        preset_hash = JSON.parse(File.read(path))
        preset_hash.deep_symbolize_keys!
        preset_hash[:id] ||= SecureRandom.uuid
        preset = Entities::Preset.new(preset_hash)

        insert(preset)
      end

      def presets_for_suite(suite_id)
        all.select { |preset| preset.test_suite_id.to_s == suite_id.to_s }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
inferno_core-0.3.5 lib/inferno/repositories/presets.rb
inferno_core-0.3.4 lib/inferno/repositories/presets.rb
inferno_core-0.3.3 lib/inferno/repositories/presets.rb
inferno_core-0.3.2 lib/inferno/repositories/presets.rb
inferno_core-0.3.1 lib/inferno/repositories/presets.rb
inferno_core-0.3.0 lib/inferno/repositories/presets.rb
inferno_core-0.3.0.rc1 lib/inferno/repositories/presets.rb
inferno_core-0.2.0 lib/inferno/repositories/presets.rb
inferno_core-0.2.0.rc4 lib/inferno/repositories/presets.rb
inferno_core-0.2.0.rc3 lib/inferno/repositories/presets.rb
inferno_core-0.2.0.rc2 lib/inferno/repositories/presets.rb
inferno_core-0.2.0.rc1 lib/inferno/repositories/presets.rb
inferno_core-0.1.4.pre lib/inferno/repositories/presets.rb