Sha256: 778293076c482fc8470a280cbed4b6d673637d558951d334077ab3afca1e0a05

Contents?: true

Size: 1.26 KB

Versions: 212

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/gems_registry'
require 'eac_ruby_utils/patches/object/if_respond'
require 'eac_ruby_utils/patches/object/to_pathname'

module EacRubyUtils
  module Rspec
    class SetupManager
      GEMS_REGISTRY_SUFFIX = 'Rspec::Setup'

      class << self
        def create(app_root_path, rspec_config = nil)
          if rspec_config
            new(app_root_path, rspec_config)
          else
            ::RSpec.configure { |new_rspec_config| new(app_root_path, new_rspec_config) }
          end
        end
      end

      attr_reader :app_root_path, :rspec_config

      def initialize(app_root_path, rspec_config)
        @app_root_path = app_root_path.to_pathname
        @rspec_config = rspec_config
        include_registry
      end

      # @return [EacRubyUtils::GemsRegistry]
      def gems_registry
        @gems_registry ||= ::EacRubyUtils::GemsRegistry.new(GEMS_REGISTRY_SUFFIX)
      end

      protected

      def include_registry
        gems_registry.registered.each do |gem|
          include_gem_registered(gem.registered_module)
        end
      end

      # @param gem [EacRubyUtils::GemsRegistry::Gem]
      def include_gem_registered(registered_module)
        extend(registered_module)
      end
    end
  end
end

Version data entries

212 entries across 212 versions & 4 rubygems

Version Path
eac_tools-0.52.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.51.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.50.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_ruby_utils-0.110.1 lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.49.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_ruby_utils-0.110.0 lib/eac_ruby_utils/rspec/setup_manager.rb
eac_ruby_utils-0.109.1 lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.48.1 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.48.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.47.2 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_ruby_utils-0.109.0 lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.47.1 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_ruby_utils-0.108.0 lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.47.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.46.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.45.2 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.45.1 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.45.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb
eac_ruby_utils-0.107.1 lib/eac_ruby_utils/rspec/setup_manager.rb
eac_tools-0.44.0 sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb